├── .github └── workflows │ └── build.yml ├── .gitignore ├── Fabric-1.16.5 ├── gradle.properties └── src │ └── main │ ├── java │ └── top │ │ └── gregtao │ │ └── xibaopp │ │ ├── SnowAnimation.java │ │ ├── XibaoPlusPlusConfig.java │ │ ├── XibaoPlusPlusMain.java │ │ ├── XibaoPlusPlusMusic.java │ │ ├── XibaoType.java │ │ ├── mixin │ │ ├── DisconnectedScreenAccessor.java │ │ ├── DisconnectedScreenMixin.java │ │ └── MinecraftClientMixin.java │ │ └── util │ │ └── RenderHelper.java │ └── resources │ ├── fabric.mod.json │ └── xibaopp.mixins.json ├── Fabric-1.17.1 ├── gradle.properties └── src │ └── main │ ├── java │ └── top │ │ └── gregtao │ │ └── xibaopp │ │ ├── SnowAnimation.java │ │ ├── XibaoPlusPlusConfig.java │ │ ├── XibaoPlusPlusMain.java │ │ ├── XibaoPlusPlusMusic.java │ │ ├── XibaoType.java │ │ ├── mixin │ │ ├── DisconnectedScreenAccessor.java │ │ ├── DisconnectedScreenMixin.java │ │ └── MinecraftClientMixin.java │ │ └── util │ │ └── RenderHelper.java │ └── resources │ ├── fabric.mod.json │ └── xibaopp.mixins.json ├── Fabric-1.18.2 ├── gradle.properties └── src │ └── main │ ├── java │ └── top │ │ └── gregtao │ │ └── xibaopp │ │ ├── SnowAnimation.java │ │ ├── XibaoPlusPlusConfig.java │ │ ├── XibaoPlusPlusMain.java │ │ ├── XibaoPlusPlusMusic.java │ │ ├── XibaoType.java │ │ ├── mixin │ │ ├── DisconnectedScreenAccessor.java │ │ ├── DisconnectedScreenMixin.java │ │ └── MinecraftClientMixin.java │ │ └── util │ │ └── RenderHelper.java │ └── resources │ ├── fabric.mod.json │ └── xibaopp.mixins.json ├── Fabric-1.19.3 ├── gradle.properties └── src │ └── main │ ├── java │ └── top │ │ └── gregtao │ │ └── xibaopp │ │ ├── SnowAnimation.java │ │ ├── XibaoPlusPlusConfig.java │ │ ├── XibaoPlusPlusMain.java │ │ ├── XibaoPlusPlusMusic.java │ │ ├── XibaoType.java │ │ ├── mixin │ │ ├── DisconnectedScreenAccessor.java │ │ ├── DisconnectedScreenMixin.java │ │ └── MinecraftClientMixin.java │ │ └── util │ │ └── RenderHelper.java │ └── resources │ ├── fabric.mod.json │ └── xibaopp.mixins.json ├── Fabric-1.19.4 ├── gradle.properties └── src │ └── main │ ├── java │ └── top │ │ └── gregtao │ │ └── xibaopp │ │ ├── SnowAnimation.java │ │ ├── XibaoPlusPlusConfig.java │ │ ├── XibaoPlusPlusMain.java │ │ ├── XibaoPlusPlusMusic.java │ │ ├── XibaoType.java │ │ ├── mixin │ │ ├── DisconnectedScreenAccessor.java │ │ ├── DisconnectedScreenMixin.java │ │ └── MinecraftClientMixin.java │ │ └── util │ │ └── RenderHelper.java │ └── resources │ ├── fabric.mod.json │ └── xibaopp.mixins.json ├── Fabric-1.19 ├── gradle.properties └── src │ └── main │ ├── java │ └── top │ │ └── gregtao │ │ └── xibaopp │ │ ├── SnowAnimation.java │ │ ├── XibaoPlusPlusConfig.java │ │ ├── XibaoPlusPlusMain.java │ │ ├── XibaoPlusPlusMusic.java │ │ ├── XibaoType.java │ │ ├── mixin │ │ ├── DisconnectedScreenAccessor.java │ │ ├── DisconnectedScreenMixin.java │ │ └── MinecraftClientMixin.java │ │ └── util │ │ └── RenderHelper.java │ └── resources │ ├── fabric.mod.json │ └── xibaopp.mixins.json ├── Fabric-1.20.1 ├── gradle.properties └── src │ └── main │ ├── java │ └── top │ │ └── gregtao │ │ └── xibaopp │ │ ├── SnowAnimation.java │ │ ├── XibaoPlusPlusConfig.java │ │ ├── XibaoPlusPlusMain.java │ │ ├── XibaoPlusPlusMusic.java │ │ ├── XibaoType.java │ │ ├── mixin │ │ ├── DisconnectedScreenAccessor.java │ │ ├── DisconnectedScreenMixin.java │ │ └── MinecraftClientMixin.java │ │ └── util │ │ └── RenderHelper.java │ └── resources │ ├── fabric.mod.json │ └── xibaopp.mixins.json ├── Fabric-1.20.4 ├── gradle.properties └── src │ └── main │ ├── java │ └── top │ │ └── gregtao │ │ └── xibaopp │ │ ├── BackgroundWidget.java │ │ ├── SnowAnimation.java │ │ ├── XibaoPlusPlusConfig.java │ │ ├── XibaoPlusPlusMain.java │ │ ├── XibaoPlusPlusMusic.java │ │ ├── XibaoType.java │ │ ├── mixin │ │ ├── DisconnectedScreenAccessor.java │ │ ├── DisconnectedScreenMixin.java │ │ └── MinecraftClientMixin.java │ │ └── util │ │ └── RenderHelper.java │ └── resources │ ├── fabric.mod.json │ └── xibaopp.mixins.json ├── Fabric-1.20.6 ├── gradle.properties └── src │ └── main │ ├── java │ └── top │ │ └── gregtao │ │ └── xibaopp │ │ ├── BackgroundWidget.java │ │ ├── SnowAnimation.java │ │ ├── XibaoPlusPlusConfig.java │ │ ├── XibaoPlusPlusMain.java │ │ ├── XibaoPlusPlusMusic.java │ │ ├── XibaoType.java │ │ ├── mixin │ │ ├── DisconnectedScreenAccessor.java │ │ ├── DisconnectedScreenMixin.java │ │ ├── MinecraftClientMixin.java │ │ └── ScreenMixin.java │ │ └── util │ │ └── RenderHelper.java │ └── resources │ ├── fabric.mod.json │ └── xibaopp.mixins.json ├── Fabric-1.20 ├── gradle.properties └── src │ └── main │ ├── java │ └── top │ │ └── gregtao │ │ └── xibaopp │ │ ├── SnowAnimation.java │ │ ├── XibaoPlusPlusConfig.java │ │ ├── XibaoPlusPlusMain.java │ │ ├── XibaoPlusPlusMusic.java │ │ ├── XibaoType.java │ │ ├── mixin │ │ ├── DisconnectedScreenAccessor.java │ │ ├── DisconnectedScreenMixin.java │ │ └── MinecraftClientMixin.java │ │ └── util │ │ └── RenderHelper.java │ └── resources │ ├── fabric.mod.json │ └── xibaopp.mixins.json ├── Fabric-1.21.1 ├── gradle.properties └── src │ └── main │ ├── java │ └── top │ │ └── gregtao │ │ └── xibaopp │ │ ├── BackgroundWidget.java │ │ ├── SnowAnimation.java │ │ ├── XibaoPlusPlusConfig.java │ │ ├── XibaoPlusPlusMain.java │ │ ├── XibaoPlusPlusMusic.java │ │ ├── XibaoType.java │ │ ├── mixin │ │ ├── DisconnectedScreenAccessor.java │ │ ├── DisconnectedScreenMixin.java │ │ ├── MinecraftClientMixin.java │ │ └── ScreenMixin.java │ │ └── util │ │ └── RenderHelper.java │ └── resources │ ├── fabric.mod.json │ └── xibaopp.mixins.json ├── Fabric-1.21.4 ├── gradle.properties └── src │ └── main │ ├── java │ └── top │ │ └── gregtao │ │ └── xibaopp │ │ ├── BackgroundWidget.java │ │ ├── SnowAnimation.java │ │ ├── XibaoPlusPlusConfig.java │ │ ├── XibaoPlusPlusMain.java │ │ ├── XibaoPlusPlusMusic.java │ │ ├── XibaoType.java │ │ ├── mixin │ │ ├── DisconnectedScreenAccessor.java │ │ ├── DisconnectedScreenMixin.java │ │ ├── MinecraftClientMixin.java │ │ └── ScreenMixin.java │ │ └── util │ │ └── RenderHelper.java │ └── resources │ ├── fabric.mod.json │ └── xibaopp.mixins.json ├── LICENSE ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── logo-1-1.png ├── logo.png ├── resources └── assets │ └── xibaopp │ ├── README.md │ ├── lang │ ├── en_us.json │ ├── lzh.json │ └── zh_cn.json │ ├── sounds.json │ ├── sounds │ ├── chunjiexuqu.ogg │ ├── haoyunlai.ogg │ ├── the_magnificent_seven.ogg │ └── yijianmei.ogg │ └── textures │ ├── beibao.png │ ├── logo.png │ ├── red_snow.png │ ├── white_snow.png │ ├── xibao.png │ └── yellow_snow.png └── settings.gradle /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | on: 3 | push: 4 | branches: [Fabric] 5 | jobs: 6 | build: 7 | runs-on: windows-latest 8 | steps: 9 | - uses: actions/checkout@v4 10 | 11 | - name: Set up Java 12 | uses: actions/setup-java@v3 13 | with: 14 | java-version: '21' 15 | distribution: 'temurin' 16 | 17 | - name: Validate Gradle wrapper 18 | uses: gradle/wrapper-validation-action@v1 19 | 20 | - name: Use Gradle build action 21 | uses: gradle/gradle-build-action@v2 22 | 23 | - name: Execute Gradle build 24 | run: ./gradlew build 25 | 26 | - name: Upload to artifact 27 | uses: actions/upload-artifact@v4 28 | with: 29 | name: xibao-build 30 | path: | 31 | Fabric-*/build/libs/XibaoPlusPlus-*-*-mc*.jar 32 | !Fabric-*/build/libs/XibaoPlusPlus-*-*-mc*-*.jar -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | .idea 3 | build 4 | run 5 | */.gradle 6 | */build 7 | */run -------------------------------------------------------------------------------- /Fabric-1.16.5/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx2G 2 | loom.platform=fabric 3 | 4 | 5 | minecraft_version=1.16.5 6 | yarn_mappings=1.16.5+build.10 7 | loader_version=0.14.9 8 | 9 | mod_version = 0.2.0-release-mc1.16.5 10 | maven_group = top.gregtao.xibaopp 11 | archives_base_name = XibaoPlusPlus-Fabric 12 | 13 | fabric_version=0.42.0+1.16 14 | -------------------------------------------------------------------------------- /Fabric-1.16.5/src/main/java/top/gregtao/xibaopp/SnowAnimation.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.client.MinecraftClient; 4 | import net.minecraft.util.Identifier; 5 | import top.gregtao.xibaopp.util.RenderHelper; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import java.util.Random; 10 | 11 | public class SnowAnimation { 12 | public static SnowAnimation INSTANCE; 13 | private Identifier[] source; 14 | private int lastWidth, lastHeight; 15 | private float amount = 0.1f; 16 | private final Random random; 17 | private final List snows; 18 | 19 | public SnowAnimation(Random random) { 20 | this.random = random; 21 | this.snows = new ArrayList<>(); 22 | } 23 | 24 | public void tick(MinecraftClient client, int width, int height, Identifier[] source) { 25 | this.source = source; 26 | if (width != this.lastWidth || height != this.lastHeight) { 27 | this.snows.clear(); 28 | this.lastWidth = width; 29 | this.lastHeight = height; 30 | } 31 | this.spawnGroup(); 32 | for (Snow snow : this.snows) { 33 | RenderHelper.renderParticle(client, snow.x, height - snow.y, 4, 4, this.source[snow.source % this.source.length]); 34 | snow.move(); 35 | if (snow.y > height) { 36 | snow.removed = true; 37 | } 38 | } 39 | if (this.snows.size() > 500) { 40 | int i = 0; 41 | while (i < this.snows.size() && this.snows.get(i).removed) this.snows.remove(i); 42 | } 43 | } 44 | 45 | public void spawnGroup() { 46 | this.amount += 0.001f; 47 | float realAmount = Math.min(0.4f, this.amount); 48 | if (realAmount < 1) { 49 | if (this.random.nextInt((int) (1 / realAmount)) == 0) this.spawn(); 50 | } else { 51 | for (int i = 1; i <= realAmount; ++i) this.spawn(); 52 | } 53 | if (this.amount >= 0.6f) this.amount = 0.1f; 54 | } 55 | 56 | public int getSourceIndex() { 57 | return this.random.nextInt(this.source.length); 58 | } 59 | 60 | public void spawn() { 61 | int x = random.nextInt(this.lastWidth); 62 | int k = (random.nextInt(4)) * 2 + 1; 63 | this.snows.add(new Snow(x, random.nextInt(2) == 0 ? -k : k, this.getSourceIndex())); 64 | } 65 | 66 | } 67 | class Snow { 68 | public int baseX, x, y, k, source; 69 | public boolean removed = false; 70 | public Snow(int x, int k, int source) { 71 | this.baseX = this.x = x; 72 | this.k = k; 73 | this.source = source; 74 | this.y = 0; 75 | } 76 | public void move() { 77 | this.y++; 78 | this.x = this.baseX + this.y / this.k; 79 | } 80 | } -------------------------------------------------------------------------------- /Fabric-1.16.5/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusConfig.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.FileWriter; 6 | import java.io.IOException; 7 | import java.util.Properties; 8 | import java.util.Random; 9 | 10 | public class XibaoPlusPlusConfig { 11 | private static final File file = new File("xibao_plus_plus.properties"); 12 | 13 | public static boolean shouldPlayMusic = false; 14 | public static boolean tempSnow = false; 15 | public static Random random = new Random(); 16 | 17 | public static boolean playMusic = true; 18 | public static boolean showPicture = true; 19 | public static boolean displaySnow = false; 20 | 21 | public static XibaoType type = XibaoType.XIBAO; 22 | 23 | public static void loadConfig() throws Exception { 24 | if (!file.exists()) { 25 | storeConfig(); 26 | return; 27 | } 28 | Properties properties = new Properties(); 29 | properties.load(new FileInputStream(file)); 30 | playMusic = properties.getOrDefault("playMusic", "true").equals("true"); 31 | showPicture = properties.getOrDefault("showPicture", "true").equals("true"); 32 | displaySnow = properties.getOrDefault("displaySnow", "false").equals("true"); 33 | type = XibaoType.getByString(properties.getProperty("type")); 34 | } 35 | 36 | public static void storeConfig() throws IOException { 37 | Properties properties = new Properties(); 38 | properties.setProperty("playMusic", String.valueOf(playMusic)); 39 | properties.setProperty("showPicture", String.valueOf(showPicture)); 40 | properties.setProperty("displaySnow", String.valueOf(displaySnow)); 41 | properties.setProperty("type", type.type); 42 | properties.store(new FileWriter(file), "Xibao Plus Plus"); 43 | } 44 | 45 | public static void switchAlbum() { 46 | XibaoType[] types = XibaoType.values(); 47 | type = types[(type.ordinal() + 1) % types.length]; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Fabric-1.16.5/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusMain.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.fabricmc.api.ClientModInitializer; 4 | import net.fabricmc.api.EnvType; 5 | import net.fabricmc.api.Environment; 6 | import net.minecraft.util.registry.Registry; 7 | 8 | @Environment(EnvType.CLIENT) 9 | public class XibaoPlusPlusMain implements ClientModInitializer { 10 | @Override 11 | public void onInitializeClient() { 12 | Registry.register(Registry.SOUND_EVENT, XibaoPlusPlusMusic.XIBAO_SOUND_EVENT.getId(), XibaoPlusPlusMusic.XIBAO_SOUND_EVENT); 13 | 14 | try { 15 | XibaoPlusPlusConfig.loadConfig(); 16 | } catch (Exception e) { 17 | throw new RuntimeException(e); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Fabric-1.16.5/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusMusic.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.sound.MusicSound; 4 | import net.minecraft.sound.SoundEvent; 5 | import net.minecraft.util.Identifier; 6 | 7 | public class XibaoPlusPlusMusic { 8 | public static SoundEvent XIBAO_SOUND_EVENT = new SoundEvent(new Identifier("xibaopp", "xibao")); 9 | public static MusicSound XIBAO_MUSIC = new MusicSound(XIBAO_SOUND_EVENT, 0, 0, true); 10 | public static SoundEvent BEIBAO_SOUND_EVENT = new SoundEvent(new Identifier("xibaopp", "beibao")); 11 | public static MusicSound BEIBAO_MUSIC = new MusicSound(BEIBAO_SOUND_EVENT, 0, 0, true); 12 | } 13 | -------------------------------------------------------------------------------- /Fabric-1.16.5/src/main/java/top/gregtao/xibaopp/XibaoType.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.sound.MusicSound; 4 | import net.minecraft.util.Identifier; 5 | 6 | public enum XibaoType { 7 | XIBAO( 8 | XibaoPlusPlusMusic.XIBAO_MUSIC, 9 | new Identifier("xibaopp", "textures/xibao.png"), 10 | new Identifier[] { 11 | new Identifier("xibaopp", "textures/yellow_snow.png"), 12 | new Identifier("xibaopp", "textures/red_snow.png") 13 | }, 14 | "xibao" 15 | ), 16 | BEIBAO( 17 | XibaoPlusPlusMusic.BEIBAO_MUSIC, 18 | new Identifier("xibaopp", "textures/beibao.png"), 19 | new Identifier[] { 20 | new Identifier("xibaopp", "textures/white_snow.png") 21 | }, 22 | "beibao" 23 | ) 24 | ; 25 | public final MusicSound music; 26 | public final Identifier background; 27 | public final Identifier[] snows; 28 | public final String type; 29 | 30 | XibaoType(MusicSound music, Identifier background, Identifier[] snows, String type) { 31 | this.music = music; 32 | this.background = background; 33 | this.snows = snows; 34 | this.type = type; 35 | } 36 | 37 | public static XibaoType getByString(String type) { 38 | for (XibaoType xibaoType : values()) { 39 | if (type.equals(xibaoType.type)) return xibaoType; 40 | } 41 | return XIBAO; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Fabric-1.16.5/src/main/java/top/gregtao/xibaopp/mixin/DisconnectedScreenAccessor.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.gui.screen.DisconnectedScreen; 6 | import net.minecraft.text.Text; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.gen.Accessor; 9 | 10 | @Environment(EnvType.CLIENT) 11 | @Mixin(DisconnectedScreen.class) 12 | public interface DisconnectedScreenAccessor { 13 | 14 | @Accessor("reason") 15 | Text getReason(); 16 | 17 | @Accessor("reasonHeight") 18 | int getReasonHeight(); 19 | } 20 | -------------------------------------------------------------------------------- /Fabric-1.16.5/src/main/java/top/gregtao/xibaopp/mixin/DisconnectedScreenMixin.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.gui.screen.DisconnectedScreen; 6 | import net.minecraft.client.gui.screen.Screen; 7 | import net.minecraft.client.gui.widget.ButtonWidget; 8 | import net.minecraft.client.util.math.MatrixStack; 9 | import net.minecraft.text.Text; 10 | import net.minecraft.text.TranslatableText; 11 | import org.spongepowered.asm.mixin.Mixin; 12 | import org.spongepowered.asm.mixin.injection.At; 13 | import org.spongepowered.asm.mixin.injection.Inject; 14 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 15 | import top.gregtao.xibaopp.SnowAnimation; 16 | import top.gregtao.xibaopp.XibaoPlusPlusConfig; 17 | import top.gregtao.xibaopp.util.RenderHelper; 18 | 19 | @Environment(EnvType.CLIENT) 20 | @Mixin(DisconnectedScreen.class) 21 | public class DisconnectedScreenMixin extends Screen { 22 | 23 | protected DisconnectedScreenMixin(Text title) { 24 | super(title); 25 | } 26 | 27 | @Inject(method = "init", at = @At("TAIL")) 28 | private void initInject(CallbackInfo ci) { 29 | XibaoPlusPlusConfig.shouldPlayMusic = true; 30 | XibaoPlusPlusConfig.tempSnow = false; 31 | this.addButton(new ButtonWidget( 32 | this.width / 2 - 100, this.height - 22, 33 | 66, 20, new TranslatableText("gui.stopMusic"), 34 | button -> XibaoPlusPlusConfig.shouldPlayMusic = !XibaoPlusPlusConfig.shouldPlayMusic)); 35 | this.addButton(new ButtonWidget( 36 | this.width / 2 - 33, this.height - 22, 37 | 66, 20, new TranslatableText("gui.dropSnow"), 38 | button -> { 39 | SnowAnimation.INSTANCE = new SnowAnimation(XibaoPlusPlusConfig.random); 40 | XibaoPlusPlusConfig.tempSnow = !XibaoPlusPlusConfig.tempSnow; 41 | })); 42 | this.addButton(new ButtonWidget( 43 | this.width / 2 + 34, this.height - 22, 44 | 66, 20, new TranslatableText("gui.switchAlbum"), 45 | button -> XibaoPlusPlusConfig.switchAlbum())); 46 | if (XibaoPlusPlusConfig.displaySnow) SnowAnimation.INSTANCE = new SnowAnimation(XibaoPlusPlusConfig.random); 47 | } 48 | 49 | @Inject(method = "render", at = @At(value = "INVOKE", 50 | target = "Lnet/minecraft/client/font/MultilineText;drawCenterWithShadow(Lnet/minecraft/client/util/math/MatrixStack;II)I")) 51 | private void renderInject(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) { 52 | if (this.client == null) return; 53 | if (XibaoPlusPlusConfig.showPicture) { 54 | RenderHelper.renderStretchTexture(this.client, this.width, this.height, 225, 55 | XibaoPlusPlusConfig.type.background); 56 | } 57 | if (XibaoPlusPlusConfig.displaySnow || XibaoPlusPlusConfig.tempSnow) { 58 | SnowAnimation.INSTANCE.tick(this.client, this.width, this.height, XibaoPlusPlusConfig.type.snows); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Fabric-1.16.5/src/main/java/top/gregtao/xibaopp/mixin/MinecraftClientMixin.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.MinecraftClient; 6 | import net.minecraft.client.gui.screen.DisconnectedScreen; 7 | import net.minecraft.sound.MusicSound; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 12 | import top.gregtao.xibaopp.XibaoPlusPlusConfig; 13 | import top.gregtao.xibaopp.XibaoPlusPlusMusic; 14 | 15 | @Environment(EnvType.CLIENT) 16 | @Mixin(MinecraftClient.class) 17 | public class MinecraftClientMixin { 18 | 19 | @Inject(method = "getMusicType", at = @At("TAIL"), cancellable = true) 20 | public void getMusicTypeInject(CallbackInfoReturnable cir) { 21 | if (XibaoPlusPlusConfig.playMusic && XibaoPlusPlusConfig.shouldPlayMusic) { 22 | if (MinecraftClient.getInstance().currentScreen instanceof DisconnectedScreen) { 23 | cir.setReturnValue(XibaoPlusPlusConfig.type.music); 24 | } 25 | } 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Fabric-1.16.5/src/main/java/top/gregtao/xibaopp/util/RenderHelper.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.util; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import net.minecraft.client.MinecraftClient; 5 | import net.minecraft.client.render.*; 6 | import net.minecraft.util.Identifier; 7 | 8 | public class RenderHelper { 9 | public static void renderStretchTexture(MinecraftClient client, int width, int height, int light, Identifier source) { 10 | Tessellator tessellator = Tessellator.getInstance(); 11 | BufferBuilder bufferBuilder = tessellator.getBuffer(); 12 | client.getTextureManager().bindTexture(source); 13 | RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); 14 | bufferBuilder.begin(7, VertexFormats.POSITION_TEXTURE_COLOR); 15 | bufferBuilder.vertex(0.0D, height, 0.0D).texture(0, 1).color(light, light, light, 255).next(); 16 | bufferBuilder.vertex(width, height, 0.0D).texture(1, 1).color(light, light, light, 255).next(); 17 | bufferBuilder.vertex(width, 0.0D, 0.0D).texture(1, 0).color(light, light, light, 255).next(); 18 | bufferBuilder.vertex(0.0D, 0.0D, 0.0D).texture(0, 0).color(light, light, light, 255).next(); 19 | tessellator.draw(); 20 | } 21 | 22 | public static void renderParticle(MinecraftClient client, int x, int y, int width, int height, Identifier source) { 23 | Tessellator tessellator = Tessellator.getInstance(); 24 | BufferBuilder bufferBuilder = tessellator.getBuffer(); 25 | client.getTextureManager().bindTexture(source); 26 | RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); 27 | RenderSystem.enableAlphaTest(); 28 | bufferBuilder.begin(7, VertexFormats.POSITION_TEXTURE_COLOR); 29 | bufferBuilder.vertex(0.0D + x, height + y, 0.0D).texture(0, 1).color(255, 255, 255, 255).next(); 30 | bufferBuilder.vertex(width + x, height + y, 0.0D).texture(1, 1).color(255, 255, 255, 255).next(); 31 | bufferBuilder.vertex(width + x, 0.0D + y, 0.0D).texture(1, 0).color(255, 255, 255, 255).next(); 32 | bufferBuilder.vertex(0.0D + x, 0.0D + y, 0.0D).texture(0, 0).color(255, 255, 255, 255).next(); 33 | tessellator.draw(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Fabric-1.16.5/src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "xibaopp", 4 | "version": "${version}", 5 | 6 | "name": "Xibao", 7 | "description": "Congratulations! You had lost the connection!", 8 | "authors": [ 9 | "GregTao", 10 | "TeaCon(灵感)" 11 | ], 12 | "contact": { 13 | "email": "本模组内容若有侵权请联系gregtaoo@outlook.com删除" 14 | }, 15 | 16 | "license": "GPL v3", 17 | "icon": "assets/xibaopp/textures/logo.png", 18 | 19 | "environment": "*", 20 | "entrypoints": { 21 | "client": [ 22 | "top.gregtao.xibaopp.XibaoPlusPlusMain" 23 | ] 24 | }, 25 | "mixins": [ 26 | "xibaopp.mixins.json" 27 | ], 28 | 29 | "depends": { 30 | "fabricloader": ">=0.13.3", 31 | "fabric": "*", 32 | "minecraft": "1.16.x", 33 | "java": ">=8" 34 | }, 35 | "suggests": { 36 | "another-mod": "*" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Fabric-1.16.5/src/main/resources/xibaopp.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "top.gregtao.xibaopp.mixin", 5 | "compatibilityLevel": "JAVA_8", 6 | "mixins": [ 7 | ], 8 | "client": [ 9 | "DisconnectedScreenAccessor", 10 | "DisconnectedScreenMixin", 11 | "MinecraftClientMixin" 12 | ], 13 | "injectors": { 14 | "defaultRequire": 1 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Fabric-1.17.1/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx2G 2 | loom.platform=fabric 3 | 4 | minecraft_version=1.17.1 5 | yarn_mappings=1.17.1+build.65 6 | loader_version=0.14.9 7 | 8 | mod_version = 0.2.0-release-mc1.17.1 9 | maven_group = top.gregtao.xibaopp 10 | archives_base_name = XibaoPlusPlus-Fabric 11 | 12 | fabric_version=0.46.1+1.17 13 | -------------------------------------------------------------------------------- /Fabric-1.17.1/src/main/java/top/gregtao/xibaopp/SnowAnimation.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.client.MinecraftClient; 4 | import net.minecraft.util.Identifier; 5 | import top.gregtao.xibaopp.util.RenderHelper; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import java.util.Random; 10 | 11 | public class SnowAnimation { 12 | public static SnowAnimation INSTANCE; 13 | private Identifier[] source; 14 | private int lastWidth, lastHeight; 15 | private float amount = 0.1f; 16 | private final Random random; 17 | private final List snows; 18 | 19 | public SnowAnimation(Random random) { 20 | this.random = random; 21 | this.snows = new ArrayList<>(); 22 | } 23 | 24 | public void tick(int width, int height, Identifier[] source) { 25 | this.source = source; 26 | if (width != this.lastWidth || height != this.lastHeight) { 27 | this.snows.clear(); 28 | this.lastWidth = width; 29 | this.lastHeight = height; 30 | } 31 | this.spawnGroup(); 32 | for (Snow snow : this.snows) { 33 | RenderHelper.renderParticle(snow.x, height - snow.y, 4, 4, this.source[snow.source % this.source.length]); 34 | snow.move(); 35 | if (snow.y > height) { 36 | snow.removed = true; 37 | } 38 | } 39 | if (this.snows.size() > 500) { 40 | int i = 0; 41 | while (i < this.snows.size() && this.snows.get(i).removed) this.snows.remove(i); 42 | } 43 | } 44 | 45 | public void spawnGroup() { 46 | this.amount += 0.001f; 47 | float realAmount = Math.min(0.4f, this.amount); 48 | if (realAmount < 1) { 49 | if (this.random.nextInt((int) (1 / realAmount)) == 0) this.spawn(); 50 | } else { 51 | for (int i = 1; i <= realAmount; ++i) this.spawn(); 52 | } 53 | if (this.amount >= 0.6f) this.amount = 0.1f; 54 | } 55 | 56 | public int getSourceIndex() { 57 | return this.random.nextInt(this.source.length); 58 | } 59 | 60 | public void spawn() { 61 | int x = random.nextInt(this.lastWidth); 62 | int k = (random.nextInt(4)) * 2 + 1; 63 | this.snows.add(new Snow(x, random.nextInt(2) == 0 ? -k : k, this.getSourceIndex())); 64 | } 65 | 66 | } 67 | 68 | class Snow { 69 | public int baseX, x, y, k, source; 70 | public boolean removed = false; 71 | public Snow(int x, int k, int source) { 72 | this.baseX = this.x = x; 73 | this.k = k; 74 | this.source = source; 75 | this.y = 0; 76 | } 77 | public void move() { 78 | this.y++; 79 | this.x = this.baseX + this.y / this.k; 80 | } 81 | } -------------------------------------------------------------------------------- /Fabric-1.17.1/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusConfig.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.FileWriter; 6 | import java.io.IOException; 7 | import java.util.Properties; 8 | import java.util.Random; 9 | 10 | public class XibaoPlusPlusConfig { 11 | private static final File file = new File("xibao_plus_plus.properties"); 12 | 13 | public static boolean shouldPlayMusic = false; 14 | public static boolean tempSnow = false; 15 | public static Random random = new Random(); 16 | 17 | public static boolean playMusic = true; 18 | public static boolean showPicture = true; 19 | public static boolean displaySnow = false; 20 | 21 | public static XibaoType type = XibaoType.XIBAO; 22 | 23 | public static void loadConfig() throws Exception { 24 | if (!file.exists()) { 25 | storeConfig(); 26 | return; 27 | } 28 | Properties properties = new Properties(); 29 | properties.load(new FileInputStream(file)); 30 | playMusic = properties.getOrDefault("playMusic", "true").equals("true"); 31 | showPicture = properties.getOrDefault("showPicture", "true").equals("true"); 32 | displaySnow = properties.getOrDefault("displaySnow", "false").equals("true"); 33 | type = XibaoType.getByString(properties.getProperty("type")); 34 | } 35 | 36 | public static void storeConfig() throws IOException { 37 | Properties properties = new Properties(); 38 | properties.setProperty("playMusic", String.valueOf(playMusic)); 39 | properties.setProperty("showPicture", String.valueOf(showPicture)); 40 | properties.setProperty("displaySnow", String.valueOf(displaySnow)); 41 | properties.setProperty("type", type.type); 42 | properties.store(new FileWriter(file), "Xibao Plus Plus"); 43 | } 44 | 45 | public static void switchAlbum() { 46 | XibaoType[] types = XibaoType.values(); 47 | type = types[(type.ordinal() + 1) % types.length]; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Fabric-1.17.1/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusMain.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.fabricmc.api.ClientModInitializer; 4 | import net.fabricmc.api.EnvType; 5 | import net.fabricmc.api.Environment; 6 | import net.minecraft.util.registry.Registry; 7 | 8 | @Environment(EnvType.CLIENT) 9 | public class XibaoPlusPlusMain implements ClientModInitializer { 10 | @Override 11 | public void onInitializeClient() { 12 | Registry.register(Registry.SOUND_EVENT, XibaoPlusPlusMusic.XIBAO_SOUND_EVENT.getId(), XibaoPlusPlusMusic.XIBAO_SOUND_EVENT); 13 | 14 | try { 15 | XibaoPlusPlusConfig.loadConfig(); 16 | } catch (Exception e) { 17 | throw new RuntimeException(e); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Fabric-1.17.1/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusMusic.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.sound.MusicSound; 4 | import net.minecraft.sound.SoundEvent; 5 | import net.minecraft.util.Identifier; 6 | 7 | public class XibaoPlusPlusMusic { 8 | public static SoundEvent XIBAO_SOUND_EVENT = new SoundEvent(new Identifier("xibaopp", "xibao")); 9 | public static MusicSound XIBAO_MUSIC = new MusicSound(XIBAO_SOUND_EVENT, 0, 0, true); 10 | public static SoundEvent BEIBAO_SOUND_EVENT = new SoundEvent(new Identifier("xibaopp", "beibao")); 11 | public static MusicSound BEIBAO_MUSIC = new MusicSound(BEIBAO_SOUND_EVENT, 0, 0, true); 12 | } 13 | -------------------------------------------------------------------------------- /Fabric-1.17.1/src/main/java/top/gregtao/xibaopp/XibaoType.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.sound.MusicSound; 4 | import net.minecraft.util.Identifier; 5 | 6 | public enum XibaoType { 7 | XIBAO( 8 | XibaoPlusPlusMusic.XIBAO_MUSIC, 9 | new Identifier("xibaopp", "textures/xibao.png"), 10 | new Identifier[] { 11 | new Identifier("xibaopp", "textures/yellow_snow.png"), 12 | new Identifier("xibaopp", "textures/red_snow.png") 13 | }, 14 | "xibao" 15 | ), 16 | BEIBAO( 17 | XibaoPlusPlusMusic.BEIBAO_MUSIC, 18 | new Identifier("xibaopp", "textures/beibao.png"), 19 | new Identifier[] { 20 | new Identifier("xibaopp", "textures/white_snow.png") 21 | }, 22 | "beibao" 23 | ) 24 | ; 25 | public final MusicSound music; 26 | public final Identifier background; 27 | public final Identifier[] snows; 28 | public final String type; 29 | 30 | XibaoType(MusicSound music, Identifier background, Identifier[] snows, String type) { 31 | this.music = music; 32 | this.background = background; 33 | this.snows = snows; 34 | this.type = type; 35 | } 36 | 37 | public static XibaoType getByString(String type) { 38 | for (XibaoType xibaoType : values()) { 39 | if (type.equals(xibaoType.type)) return xibaoType; 40 | } 41 | return XIBAO; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Fabric-1.17.1/src/main/java/top/gregtao/xibaopp/mixin/DisconnectedScreenAccessor.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.gui.screen.DisconnectedScreen; 6 | import net.minecraft.text.Text; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.gen.Accessor; 9 | 10 | @Environment(EnvType.CLIENT) 11 | @Mixin(DisconnectedScreen.class) 12 | public interface DisconnectedScreenAccessor { 13 | 14 | @Accessor("reason") 15 | Text getReason(); 16 | 17 | @Accessor("reasonHeight") 18 | int getReasonHeight(); 19 | } 20 | -------------------------------------------------------------------------------- /Fabric-1.17.1/src/main/java/top/gregtao/xibaopp/mixin/DisconnectedScreenMixin.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.gui.screen.DisconnectedScreen; 6 | import net.minecraft.client.gui.screen.Screen; 7 | import net.minecraft.client.gui.widget.ButtonWidget; 8 | import net.minecraft.client.util.math.MatrixStack; 9 | import net.minecraft.text.Text; 10 | import net.minecraft.text.TranslatableText; 11 | import org.spongepowered.asm.mixin.Mixin; 12 | import org.spongepowered.asm.mixin.injection.At; 13 | import org.spongepowered.asm.mixin.injection.Inject; 14 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 15 | import top.gregtao.xibaopp.SnowAnimation; 16 | import top.gregtao.xibaopp.XibaoPlusPlusConfig; 17 | import top.gregtao.xibaopp.util.RenderHelper; 18 | 19 | @Environment(EnvType.CLIENT) 20 | @Mixin(DisconnectedScreen.class) 21 | public class DisconnectedScreenMixin extends Screen { 22 | 23 | protected DisconnectedScreenMixin(Text title) { 24 | super(title); 25 | } 26 | 27 | @Inject(method = "init", at = @At("TAIL")) 28 | private void initInject(CallbackInfo ci) { 29 | XibaoPlusPlusConfig.shouldPlayMusic = true; 30 | XibaoPlusPlusConfig.tempSnow = false; 31 | this.addDrawableChild(new ButtonWidget( 32 | this.width / 2 - 100, this.height - 22, 33 | 66, 20, new TranslatableText("gui.stopMusic"), 34 | button -> XibaoPlusPlusConfig.shouldPlayMusic = !XibaoPlusPlusConfig.shouldPlayMusic)); 35 | this.addDrawableChild(new ButtonWidget( 36 | this.width / 2 - 33, this.height - 22, 37 | 66, 20, new TranslatableText("gui.dropSnow"), 38 | button -> { 39 | SnowAnimation.INSTANCE = new SnowAnimation(XibaoPlusPlusConfig.random); 40 | XibaoPlusPlusConfig.tempSnow = !XibaoPlusPlusConfig.tempSnow; 41 | })); 42 | this.addDrawableChild(new ButtonWidget( 43 | this.width / 2 + 34, this.height - 22, 44 | 66, 20, new TranslatableText("gui.switchAlbum"), 45 | button -> XibaoPlusPlusConfig.switchAlbum())); 46 | if (XibaoPlusPlusConfig.displaySnow) SnowAnimation.INSTANCE = new SnowAnimation(XibaoPlusPlusConfig.random); 47 | } 48 | 49 | @Inject(method = "render", at = @At(value = "INVOKE", 50 | target = "Lnet/minecraft/client/font/MultilineText;drawCenterWithShadow(Lnet/minecraft/client/util/math/MatrixStack;II)I")) 51 | private void renderInject(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) { 52 | if (this.client == null) return; 53 | if (XibaoPlusPlusConfig.showPicture) { 54 | RenderHelper.renderStretchTexture(this.width, this.height, 225, 55 | XibaoPlusPlusConfig.type.background); 56 | } 57 | if (XibaoPlusPlusConfig.displaySnow || XibaoPlusPlusConfig.tempSnow) { 58 | SnowAnimation.INSTANCE.tick(this.width, this.height, XibaoPlusPlusConfig.type.snows); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Fabric-1.17.1/src/main/java/top/gregtao/xibaopp/mixin/MinecraftClientMixin.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.MinecraftClient; 6 | import net.minecraft.client.gui.screen.DisconnectedScreen; 7 | import net.minecraft.sound.MusicSound; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 12 | import top.gregtao.xibaopp.XibaoPlusPlusConfig; 13 | 14 | @Environment(EnvType.CLIENT) 15 | @Mixin(MinecraftClient.class) 16 | public class MinecraftClientMixin { 17 | 18 | @Inject(method = "getMusicType", at = @At("TAIL"), cancellable = true) 19 | public void getMusicTypeInject(CallbackInfoReturnable cir) { 20 | if (XibaoPlusPlusConfig.playMusic && XibaoPlusPlusConfig.shouldPlayMusic) { 21 | if (MinecraftClient.getInstance().currentScreen instanceof DisconnectedScreen) { 22 | cir.setReturnValue(XibaoPlusPlusConfig.type.music); 23 | } 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Fabric-1.17.1/src/main/java/top/gregtao/xibaopp/util/RenderHelper.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.util; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import net.minecraft.client.render.*; 5 | import net.minecraft.util.Identifier; 6 | 7 | public class RenderHelper { 8 | public static void renderStretchTexture(int width, int height, int light, Identifier source) { 9 | Tessellator tessellator = Tessellator.getInstance(); 10 | BufferBuilder bufferBuilder = tessellator.getBuffer(); 11 | RenderSystem.setShader(GameRenderer::getPositionTexColorShader); 12 | RenderSystem.setShaderTexture(0, source); 13 | RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); 14 | bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); 15 | bufferBuilder.vertex(0.0D, height, 0.0D).texture(0, 1).color(light, light, light, 255).next(); 16 | bufferBuilder.vertex(width, height, 0.0D).texture(1, 1).color(light, light, light, 255).next(); 17 | bufferBuilder.vertex(width, 0.0D, 0.0D).texture(1, 0).color(light, light, light, 255).next(); 18 | bufferBuilder.vertex(0.0D, 0.0D, 0.0D).texture(0, 0).color(light, light, light, 255).next(); 19 | tessellator.draw(); 20 | } 21 | 22 | public static void renderParticle(int x, int y, int width, int height, Identifier source) { 23 | Tessellator tessellator = Tessellator.getInstance(); 24 | BufferBuilder bufferBuilder = tessellator.getBuffer(); 25 | RenderSystem.setShader(GameRenderer::getPositionTexColorShader); 26 | RenderSystem.setShaderTexture(0, source); 27 | RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); 28 | bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); 29 | bufferBuilder.vertex(0.0D + x, height + y, 0.0D).texture(0, 1).color(255, 255, 255, 255).next(); 30 | bufferBuilder.vertex(width + x, height + y, 0.0D).texture(1, 1).color(255, 255, 255, 255).next(); 31 | bufferBuilder.vertex(width + x, 0.0D + y, 0.0D).texture(1, 0).color(255, 255, 255, 255).next(); 32 | bufferBuilder.vertex(0.0D + x, 0.0D + y, 0.0D).texture(0, 0).color(255, 255, 255, 255).next(); 33 | tessellator.draw(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Fabric-1.17.1/src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "xibaopp", 4 | "version": "${version}", 5 | 6 | "name": "Xibao", 7 | "description": "Congratulations! You had lost the connection!", 8 | "authors": [ 9 | "GregTao", 10 | "TeaCon(灵感)" 11 | ], 12 | "contact": { 13 | "email": "本模组内容若有侵权请联系gregtaoo@outlook.com删除" 14 | }, 15 | 16 | "license": "GPL v3", 17 | "icon": "assets/xibaopp/textures/logo.png", 18 | 19 | "environment": "*", 20 | "entrypoints": { 21 | "client": [ 22 | "top.gregtao.xibaopp.XibaoPlusPlusMain" 23 | ] 24 | }, 25 | "mixins": [ 26 | "xibaopp.mixins.json" 27 | ], 28 | 29 | "depends": { 30 | "fabricloader": ">=0.13.3", 31 | "fabric": "*", 32 | "minecraft": "1.17.x", 33 | "java": ">=16" 34 | }, 35 | "suggests": { 36 | "another-mod": "*" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Fabric-1.17.1/src/main/resources/xibaopp.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "top.gregtao.xibaopp.mixin", 5 | "compatibilityLevel": "JAVA_16", 6 | "mixins": [ 7 | ], 8 | "client": [ 9 | "DisconnectedScreenAccessor", 10 | "DisconnectedScreenMixin", 11 | "MinecraftClientMixin" 12 | ], 13 | "injectors": { 14 | "defaultRequire": 1 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Fabric-1.18.2/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx2G 2 | loom.platform=fabric 3 | 4 | minecraft_version=1.18.2 5 | yarn_mappings=1.18.2+build.1 6 | loader_version=0.13.3 7 | 8 | mod_version = 0.2.0-release-mc1.18.2 9 | maven_group = top.gregtao.xibaopp 10 | archives_base_name = XibaoPlusPlus-Fabric 11 | 12 | fabric_version=0.50.0+1.18.2 13 | 14 | -------------------------------------------------------------------------------- /Fabric-1.18.2/src/main/java/top/gregtao/xibaopp/SnowAnimation.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.client.MinecraftClient; 4 | import net.minecraft.util.Identifier; 5 | import top.gregtao.xibaopp.util.RenderHelper; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import java.util.Random; 10 | 11 | public class SnowAnimation { 12 | public static SnowAnimation INSTANCE; 13 | private Identifier[] source; 14 | private int lastWidth, lastHeight; 15 | private float amount = 0.1f; 16 | private final Random random; 17 | private final List snows; 18 | 19 | public SnowAnimation(Random random) { 20 | this.random = random; 21 | this.snows = new ArrayList<>(); 22 | } 23 | 24 | public void tick(int width, int height, Identifier[] source) { 25 | this.source = source; 26 | if (width != this.lastWidth || height != this.lastHeight) { 27 | this.snows.clear(); 28 | this.lastWidth = width; 29 | this.lastHeight = height; 30 | } 31 | this.spawnGroup(); 32 | for (Snow snow : this.snows) { 33 | RenderHelper.renderParticle(snow.x, height - snow.y, 4, 4, this.source[snow.source % this.source.length]); 34 | snow.move(); 35 | if (snow.y > height) { 36 | snow.removed = true; 37 | } 38 | } 39 | if (this.snows.size() > 500) { 40 | int i = 0; 41 | while (i < this.snows.size() && this.snows.get(i).removed) this.snows.remove(i); 42 | } 43 | } 44 | 45 | public void spawnGroup() { 46 | this.amount += 0.001f; 47 | float realAmount = Math.min(0.4f, this.amount); 48 | if (realAmount < 1) { 49 | if (this.random.nextInt((int) (1 / realAmount)) == 0) this.spawn(); 50 | } else { 51 | for (int i = 1; i <= realAmount; ++i) this.spawn(); 52 | } 53 | if (this.amount >= 0.6f) this.amount = 0.1f; 54 | } 55 | 56 | public int getSourceIndex() { 57 | return this.random.nextInt(this.source.length); 58 | } 59 | 60 | public void spawn() { 61 | int x = random.nextInt(this.lastWidth); 62 | int k = (random.nextInt(4)) * 2 + 1; 63 | this.snows.add(new Snow(x, random.nextInt(2) == 0 ? -k : k, this.getSourceIndex())); 64 | } 65 | 66 | } 67 | 68 | class Snow { 69 | public int baseX, x, y, k, source; 70 | public boolean removed = false; 71 | public Snow(int x, int k, int source) { 72 | this.baseX = this.x = x; 73 | this.k = k; 74 | this.source = source; 75 | this.y = 0; 76 | } 77 | public void move() { 78 | this.y++; 79 | this.x = this.baseX + this.y / this.k; 80 | } 81 | } -------------------------------------------------------------------------------- /Fabric-1.18.2/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusConfig.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.FileWriter; 6 | import java.io.IOException; 7 | import java.util.Properties; 8 | import java.util.Random; 9 | 10 | public class XibaoPlusPlusConfig { 11 | private static final File file = new File("xibao_plus_plus.properties"); 12 | 13 | public static boolean shouldPlayMusic = false; 14 | public static boolean tempSnow = false; 15 | public static Random random = new Random(); 16 | 17 | public static boolean playMusic = true; 18 | public static boolean showPicture = true; 19 | public static boolean displaySnow = false; 20 | 21 | public static XibaoType type = XibaoType.XIBAO; 22 | 23 | public static void loadConfig() throws Exception { 24 | if (!file.exists()) { 25 | storeConfig(); 26 | return; 27 | } 28 | Properties properties = new Properties(); 29 | properties.load(new FileInputStream(file)); 30 | playMusic = properties.getOrDefault("playMusic", "true").equals("true"); 31 | showPicture = properties.getOrDefault("showPicture", "true").equals("true"); 32 | displaySnow = properties.getOrDefault("displaySnow", "false").equals("true"); 33 | type = XibaoType.getByString(properties.getProperty("type")); 34 | } 35 | 36 | public static void storeConfig() throws IOException { 37 | Properties properties = new Properties(); 38 | properties.setProperty("playMusic", String.valueOf(playMusic)); 39 | properties.setProperty("showPicture", String.valueOf(showPicture)); 40 | properties.setProperty("displaySnow", String.valueOf(displaySnow)); 41 | properties.setProperty("type", type.type); 42 | properties.store(new FileWriter(file), "Xibao Plus Plus"); 43 | } 44 | 45 | public static void switchAlbum() { 46 | XibaoType[] types = XibaoType.values(); 47 | type = types[(type.ordinal() + 1) % types.length]; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Fabric-1.18.2/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusMain.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.fabricmc.api.ClientModInitializer; 4 | import net.fabricmc.api.EnvType; 5 | import net.fabricmc.api.Environment; 6 | import net.minecraft.util.registry.Registry; 7 | 8 | @Environment(EnvType.CLIENT) 9 | public class XibaoPlusPlusMain implements ClientModInitializer { 10 | @Override 11 | public void onInitializeClient() { 12 | Registry.register(Registry.SOUND_EVENT, XibaoPlusPlusMusic.XIBAO_SOUND_EVENT.getId(), XibaoPlusPlusMusic.XIBAO_SOUND_EVENT); 13 | 14 | try { 15 | XibaoPlusPlusConfig.loadConfig(); 16 | } catch (Exception e) { 17 | throw new RuntimeException(e); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Fabric-1.18.2/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusMusic.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.sound.MusicSound; 4 | import net.minecraft.sound.SoundEvent; 5 | import net.minecraft.util.Identifier; 6 | 7 | public class XibaoPlusPlusMusic { 8 | public static SoundEvent XIBAO_SOUND_EVENT = new SoundEvent(new Identifier("xibaopp", "xibao")); 9 | public static MusicSound XIBAO_MUSIC = new MusicSound(XIBAO_SOUND_EVENT, 0, 0, true); 10 | public static SoundEvent BEIBAO_SOUND_EVENT = new SoundEvent(new Identifier("xibaopp", "beibao")); 11 | public static MusicSound BEIBAO_MUSIC = new MusicSound(BEIBAO_SOUND_EVENT, 0, 0, true); 12 | } 13 | -------------------------------------------------------------------------------- /Fabric-1.18.2/src/main/java/top/gregtao/xibaopp/XibaoType.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.sound.MusicSound; 4 | import net.minecraft.util.Identifier; 5 | 6 | public enum XibaoType { 7 | XIBAO( 8 | XibaoPlusPlusMusic.XIBAO_MUSIC, 9 | new Identifier("xibaopp", "textures/xibao.png"), 10 | new Identifier[] { 11 | new Identifier("xibaopp", "textures/yellow_snow.png"), 12 | new Identifier("xibaopp", "textures/red_snow.png") 13 | }, 14 | "xibao" 15 | ), 16 | BEIBAO( 17 | XibaoPlusPlusMusic.BEIBAO_MUSIC, 18 | new Identifier("xibaopp", "textures/beibao.png"), 19 | new Identifier[] { 20 | new Identifier("xibaopp", "textures/white_snow.png") 21 | }, 22 | "beibao" 23 | ) 24 | ; 25 | public final MusicSound music; 26 | public final Identifier background; 27 | public final Identifier[] snows; 28 | public final String type; 29 | 30 | XibaoType(MusicSound music, Identifier background, Identifier[] snows, String type) { 31 | this.music = music; 32 | this.background = background; 33 | this.snows = snows; 34 | this.type = type; 35 | } 36 | 37 | public static XibaoType getByString(String type) { 38 | for (XibaoType xibaoType : values()) { 39 | if (type.equals(xibaoType.type)) return xibaoType; 40 | } 41 | return XIBAO; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Fabric-1.18.2/src/main/java/top/gregtao/xibaopp/mixin/DisconnectedScreenAccessor.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.gui.screen.DisconnectedScreen; 6 | import net.minecraft.text.Text; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.gen.Accessor; 9 | 10 | @Environment(EnvType.CLIENT) 11 | @Mixin(DisconnectedScreen.class) 12 | public interface DisconnectedScreenAccessor { 13 | 14 | @Accessor("reason") 15 | Text getReason(); 16 | 17 | @Accessor("reasonHeight") 18 | int getReasonHeight(); 19 | } 20 | -------------------------------------------------------------------------------- /Fabric-1.18.2/src/main/java/top/gregtao/xibaopp/mixin/DisconnectedScreenMixin.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.gui.screen.DisconnectedScreen; 6 | import net.minecraft.client.gui.screen.Screen; 7 | import net.minecraft.client.gui.widget.ButtonWidget; 8 | import net.minecraft.client.util.math.MatrixStack; 9 | import net.minecraft.text.Text; 10 | import net.minecraft.text.TranslatableText; 11 | import org.spongepowered.asm.mixin.Mixin; 12 | import org.spongepowered.asm.mixin.injection.At; 13 | import org.spongepowered.asm.mixin.injection.Inject; 14 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 15 | import top.gregtao.xibaopp.SnowAnimation; 16 | import top.gregtao.xibaopp.XibaoPlusPlusConfig; 17 | import top.gregtao.xibaopp.util.RenderHelper; 18 | 19 | @Environment(EnvType.CLIENT) 20 | @Mixin(DisconnectedScreen.class) 21 | public class DisconnectedScreenMixin extends Screen { 22 | 23 | protected DisconnectedScreenMixin(Text title) { 24 | super(title); 25 | } 26 | 27 | @Inject(method = "init", at = @At("TAIL")) 28 | private void initInject(CallbackInfo ci) { 29 | XibaoPlusPlusConfig.shouldPlayMusic = true; 30 | XibaoPlusPlusConfig.tempSnow = false; 31 | this.addDrawableChild(new ButtonWidget( 32 | this.width / 2 - 100, this.height - 22, 33 | 66, 20, new TranslatableText("gui.stopMusic"), 34 | button -> XibaoPlusPlusConfig.shouldPlayMusic = !XibaoPlusPlusConfig.shouldPlayMusic)); 35 | this.addDrawableChild(new ButtonWidget( 36 | this.width / 2 - 33, this.height - 22, 37 | 66, 20, new TranslatableText("gui.dropSnow"), 38 | button -> { 39 | SnowAnimation.INSTANCE = new SnowAnimation(XibaoPlusPlusConfig.random); 40 | XibaoPlusPlusConfig.tempSnow = !XibaoPlusPlusConfig.tempSnow; 41 | })); 42 | this.addDrawableChild(new ButtonWidget( 43 | this.width / 2 + 34, this.height - 22, 44 | 66, 20, new TranslatableText("gui.switchAlbum"), 45 | button -> XibaoPlusPlusConfig.switchAlbum())); 46 | if (XibaoPlusPlusConfig.displaySnow) SnowAnimation.INSTANCE = new SnowAnimation(XibaoPlusPlusConfig.random); 47 | } 48 | 49 | @Inject(method = "render", at = @At(value = "INVOKE", 50 | target = "Lnet/minecraft/client/font/MultilineText;drawCenterWithShadow(Lnet/minecraft/client/util/math/MatrixStack;II)I")) 51 | private void renderInject(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) { 52 | if (this.client == null) return; 53 | if (XibaoPlusPlusConfig.showPicture) { 54 | RenderHelper.renderStretchTexture(this.width, this.height, 225, 55 | XibaoPlusPlusConfig.type.background); 56 | } 57 | if (XibaoPlusPlusConfig.displaySnow || XibaoPlusPlusConfig.tempSnow) { 58 | SnowAnimation.INSTANCE.tick(this.width, this.height, XibaoPlusPlusConfig.type.snows); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Fabric-1.18.2/src/main/java/top/gregtao/xibaopp/mixin/MinecraftClientMixin.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.MinecraftClient; 6 | import net.minecraft.client.gui.screen.DisconnectedScreen; 7 | import net.minecraft.sound.MusicSound; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 12 | import top.gregtao.xibaopp.XibaoPlusPlusConfig; 13 | 14 | @Environment(EnvType.CLIENT) 15 | @Mixin(MinecraftClient.class) 16 | public class MinecraftClientMixin { 17 | 18 | @Inject(method = "getMusicType", at = @At("TAIL"), cancellable = true) 19 | public void getMusicTypeInject(CallbackInfoReturnable cir) { 20 | if (XibaoPlusPlusConfig.playMusic && XibaoPlusPlusConfig.shouldPlayMusic) { 21 | if (MinecraftClient.getInstance().currentScreen instanceof DisconnectedScreen) { 22 | cir.setReturnValue(XibaoPlusPlusConfig.type.music); 23 | } 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Fabric-1.18.2/src/main/java/top/gregtao/xibaopp/util/RenderHelper.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.util; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import net.minecraft.client.render.*; 5 | import net.minecraft.util.Identifier; 6 | 7 | public class RenderHelper { 8 | public static void renderStretchTexture(int width, int height, int light, Identifier source) { 9 | Tessellator tessellator = Tessellator.getInstance(); 10 | BufferBuilder bufferBuilder = tessellator.getBuffer(); 11 | RenderSystem.setShader(GameRenderer::getPositionTexColorShader); 12 | RenderSystem.setShaderTexture(0, source); 13 | RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); 14 | bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); 15 | bufferBuilder.vertex(0.0D, height, 0.0D).texture(0, 1).color(light, light, light, 255).next(); 16 | bufferBuilder.vertex(width, height, 0.0D).texture(1, 1).color(light, light, light, 255).next(); 17 | bufferBuilder.vertex(width, 0.0D, 0.0D).texture(1, 0).color(light, light, light, 255).next(); 18 | bufferBuilder.vertex(0.0D, 0.0D, 0.0D).texture(0, 0).color(light, light, light, 255).next(); 19 | tessellator.draw(); 20 | } 21 | 22 | public static void renderParticle(int x, int y, int width, int height, Identifier source) { 23 | Tessellator tessellator = Tessellator.getInstance(); 24 | BufferBuilder bufferBuilder = tessellator.getBuffer(); 25 | RenderSystem.setShader(GameRenderer::getPositionTexColorShader); 26 | RenderSystem.setShaderTexture(0, source); 27 | RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); 28 | bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); 29 | bufferBuilder.vertex(0.0D + x, height + y, 0.0D).texture(0, 1).color(255, 255, 255, 255).next(); 30 | bufferBuilder.vertex(width + x, height + y, 0.0D).texture(1, 1).color(255, 255, 255, 255).next(); 31 | bufferBuilder.vertex(width + x, 0.0D + y, 0.0D).texture(1, 0).color(255, 255, 255, 255).next(); 32 | bufferBuilder.vertex(0.0D + x, 0.0D + y, 0.0D).texture(0, 0).color(255, 255, 255, 255).next(); 33 | tessellator.draw(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Fabric-1.18.2/src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "xibaopp", 4 | "version": "${version}", 5 | 6 | "name": "Xibao", 7 | "description": "Congratulations! You had lost the connection!", 8 | "authors": [ 9 | "GregTao", 10 | "TeaCon(灵感)" 11 | ], 12 | "contact": { 13 | "email": "本模组内容若有侵权请联系gregtaoo@outlook.com删除" 14 | }, 15 | 16 | "license": "GPL v3", 17 | "icon": "assets/xibaopp/textures/logo.png", 18 | 19 | "environment": "*", 20 | "entrypoints": { 21 | "client": [ 22 | "top.gregtao.xibaopp.XibaoPlusPlusMain" 23 | ] 24 | }, 25 | "mixins": [ 26 | "xibaopp.mixins.json" 27 | ], 28 | 29 | "depends": { 30 | "fabricloader": ">=0.13.3", 31 | "fabric": "*", 32 | "minecraft": "1.18.x", 33 | "java": ">=17" 34 | }, 35 | "suggests": { 36 | "another-mod": "*" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Fabric-1.18.2/src/main/resources/xibaopp.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "top.gregtao.xibaopp.mixin", 5 | "compatibilityLevel": "JAVA_17", 6 | "mixins": [ 7 | ], 8 | "client": [ 9 | "DisconnectedScreenAccessor", 10 | "DisconnectedScreenMixin", 11 | "MinecraftClientMixin" 12 | ], 13 | "injectors": { 14 | "defaultRequire": 1 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Fabric-1.19.3/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx2G 2 | loom.platform=fabric 3 | 4 | minecraft_version=1.19.3 5 | yarn_mappings=1.19.3+build.5 6 | loader_version=0.14.12 7 | 8 | mod_version = 0.2.0-release-mc1.19.3 9 | maven_group = top.gregtao.xibaopp 10 | archives_base_name = XibaoPlusPlus-Fabric 11 | 12 | fabric_version=0.72.0+1.19.3 -------------------------------------------------------------------------------- /Fabric-1.19.3/src/main/java/top/gregtao/xibaopp/SnowAnimation.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.util.Identifier; 4 | import top.gregtao.xibaopp.util.RenderHelper; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import java.util.Random; 9 | 10 | public class SnowAnimation { 11 | public static SnowAnimation INSTANCE; 12 | private Identifier[] source; 13 | private int lastWidth, lastHeight; 14 | private float amount = 0.1f; 15 | private final Random random; 16 | private final List snows; 17 | 18 | public SnowAnimation(Random random) { 19 | this.random = random; 20 | this.snows = new ArrayList<>(); 21 | } 22 | 23 | public void tick(int width, int height, Identifier[] source) { 24 | this.source = source; 25 | if (width != this.lastWidth || height != this.lastHeight) { 26 | this.snows.clear(); 27 | this.lastWidth = width; 28 | this.lastHeight = height; 29 | } 30 | this.spawnGroup(); 31 | for (Snow snow : this.snows) { 32 | RenderHelper.renderParticle(snow.x, height - snow.y, 4, 4, this.source[snow.source % this.source.length]); 33 | snow.move(); 34 | if (snow.y > height) { 35 | snow.removed = true; 36 | } 37 | } 38 | if (this.snows.size() > 500) { 39 | int i = 0; 40 | while (i < this.snows.size() && this.snows.get(i).removed) this.snows.remove(i); 41 | } 42 | } 43 | 44 | public void spawnGroup() { 45 | this.amount += 0.001f; 46 | float realAmount = Math.min(0.4f, this.amount); 47 | if (realAmount < 1) { 48 | if (this.random.nextInt((int) (1 / realAmount)) == 0) this.spawn(); 49 | } else { 50 | for (int i = 1; i <= realAmount; ++i) this.spawn(); 51 | } 52 | if (this.amount >= 0.6f) this.amount = 0.1f; 53 | } 54 | 55 | public int getSourceIndex() { 56 | return this.random.nextInt(this.source.length); 57 | } 58 | 59 | public void spawn() { 60 | int x = random.nextInt(this.lastWidth); 61 | int k = (random.nextInt(4)) * 2 + 1; 62 | this.snows.add(new Snow(x, random.nextInt(2) == 0 ? -k : k, this.getSourceIndex())); 63 | } 64 | 65 | } 66 | 67 | class Snow { 68 | public int baseX, x, y, k, source; 69 | public boolean removed = false; 70 | public Snow(int x, int k, int source) { 71 | this.baseX = this.x = x; 72 | this.k = k; 73 | this.source = source; 74 | this.y = 0; 75 | } 76 | public void move() { 77 | this.y++; 78 | this.x = this.baseX + this.y / this.k; 79 | } 80 | } -------------------------------------------------------------------------------- /Fabric-1.19.3/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusConfig.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.FileWriter; 6 | import java.io.IOException; 7 | import java.util.Properties; 8 | import java.util.Random; 9 | 10 | public class XibaoPlusPlusConfig { 11 | private static final File file = new File("xibao_plus_plus.properties"); 12 | 13 | public static boolean shouldPlayMusic = false; 14 | public static boolean tempSnow = false; 15 | public static Random random = new Random(); 16 | 17 | public static boolean playMusic = true; 18 | public static boolean showPicture = true; 19 | public static boolean displaySnow = false; 20 | 21 | public static XibaoType type = XibaoType.XIBAO; 22 | 23 | public static void loadConfig() throws Exception { 24 | if (!file.exists()) { 25 | storeConfig(); 26 | return; 27 | } 28 | Properties properties = new Properties(); 29 | properties.load(new FileInputStream(file)); 30 | playMusic = properties.getOrDefault("playMusic", "true").equals("true"); 31 | showPicture = properties.getOrDefault("showPicture", "true").equals("true"); 32 | displaySnow = properties.getOrDefault("displaySnow", "false").equals("true"); 33 | type = XibaoType.getByString(properties.getProperty("type")); 34 | } 35 | 36 | public static void storeConfig() throws IOException { 37 | Properties properties = new Properties(); 38 | properties.setProperty("playMusic", String.valueOf(playMusic)); 39 | properties.setProperty("showPicture", String.valueOf(showPicture)); 40 | properties.setProperty("displaySnow", String.valueOf(displaySnow)); 41 | properties.setProperty("type", type.type); 42 | properties.store(new FileWriter(file), "Xibao Plus Plus"); 43 | } 44 | 45 | public static void switchAlbum() { 46 | XibaoType[] types = XibaoType.values(); 47 | type = types[(type.ordinal() + 1) % types.length]; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Fabric-1.19.3/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusMain.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.fabricmc.api.ClientModInitializer; 4 | import net.fabricmc.api.EnvType; 5 | import net.fabricmc.api.Environment; 6 | 7 | @Environment(EnvType.CLIENT) 8 | public class XibaoPlusPlusMain implements ClientModInitializer { 9 | @Override 10 | public void onInitializeClient() { 11 | try { 12 | XibaoPlusPlusConfig.loadConfig(); 13 | } catch (Exception e) { 14 | throw new RuntimeException(e); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Fabric-1.19.3/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusMusic.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.registry.Registries; 4 | import net.minecraft.registry.Registry; 5 | import net.minecraft.registry.entry.RegistryEntry; 6 | import net.minecraft.sound.MusicSound; 7 | import net.minecraft.sound.SoundEvent; 8 | import net.minecraft.util.Identifier; 9 | 10 | public class XibaoPlusPlusMusic { 11 | public static RegistryEntry.Reference XIBAO_SOUND_EVENT = registerReference(new Identifier("xibaopp", "xibao")); 12 | public static MusicSound XIBAO_MUSIC = new MusicSound(XIBAO_SOUND_EVENT, 0, 0, true); 13 | public static RegistryEntry.Reference BEIBAO_SOUND_EVENT = registerReference(new Identifier("xibaopp", "beibao")); 14 | public static MusicSound BEIBAO_MUSIC = new MusicSound(BEIBAO_SOUND_EVENT, 0, 0, true); 15 | 16 | private static RegistryEntry.Reference registerReference(Identifier id) { 17 | return registerReference(id, id); 18 | } 19 | private static RegistryEntry.Reference registerReference(Identifier id, Identifier soundId) { 20 | return Registry.registerReference(Registries.SOUND_EVENT, id, SoundEvent.of(soundId)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Fabric-1.19.3/src/main/java/top/gregtao/xibaopp/XibaoType.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.sound.MusicSound; 4 | import net.minecraft.util.Identifier; 5 | 6 | public enum XibaoType { 7 | XIBAO( 8 | XibaoPlusPlusMusic.XIBAO_MUSIC, 9 | new Identifier("xibaopp", "textures/xibao.png"), 10 | new Identifier[] { 11 | new Identifier("xibaopp", "textures/yellow_snow.png"), 12 | new Identifier("xibaopp", "textures/red_snow.png") 13 | }, 14 | "xibao" 15 | ), 16 | BEIBAO( 17 | XibaoPlusPlusMusic.BEIBAO_MUSIC, 18 | new Identifier("xibaopp", "textures/beibao.png"), 19 | new Identifier[] { 20 | new Identifier("xibaopp", "textures/white_snow.png") 21 | }, 22 | "beibao" 23 | ) 24 | ; 25 | public final MusicSound music; 26 | public final Identifier background; 27 | public final Identifier[] snows; 28 | public final String type; 29 | 30 | XibaoType(MusicSound music, Identifier background, Identifier[] snows, String type) { 31 | this.music = music; 32 | this.background = background; 33 | this.snows = snows; 34 | this.type = type; 35 | } 36 | 37 | public static XibaoType getByString(String type) { 38 | for (XibaoType xibaoType : values()) { 39 | if (type.equals(xibaoType.type)) return xibaoType; 40 | } 41 | return XIBAO; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Fabric-1.19.3/src/main/java/top/gregtao/xibaopp/mixin/DisconnectedScreenAccessor.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.gui.screen.DisconnectedScreen; 6 | import net.minecraft.text.Text; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.gen.Accessor; 9 | 10 | @Environment(EnvType.CLIENT) 11 | @Mixin(DisconnectedScreen.class) 12 | public interface DisconnectedScreenAccessor { 13 | 14 | @Accessor("reason") 15 | Text getReason(); 16 | 17 | @Accessor("reasonHeight") 18 | int getReasonHeight(); 19 | } 20 | -------------------------------------------------------------------------------- /Fabric-1.19.3/src/main/java/top/gregtao/xibaopp/mixin/MinecraftClientMixin.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.MinecraftClient; 6 | import net.minecraft.client.gui.screen.DisconnectedScreen; 7 | import net.minecraft.sound.MusicSound; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 12 | import top.gregtao.xibaopp.XibaoPlusPlusConfig; 13 | 14 | @Environment(EnvType.CLIENT) 15 | @Mixin(MinecraftClient.class) 16 | public class MinecraftClientMixin { 17 | 18 | @Inject(method = "getMusicType", at = @At("TAIL"), cancellable = true) 19 | public void getMusicTypeInject(CallbackInfoReturnable cir) { 20 | if (XibaoPlusPlusConfig.playMusic && XibaoPlusPlusConfig.shouldPlayMusic) { 21 | if (MinecraftClient.getInstance().currentScreen instanceof DisconnectedScreen) { 22 | cir.setReturnValue(XibaoPlusPlusConfig.type.music); 23 | } 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Fabric-1.19.3/src/main/java/top/gregtao/xibaopp/util/RenderHelper.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.util; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import net.minecraft.client.render.*; 5 | import net.minecraft.util.Identifier; 6 | 7 | public class RenderHelper { 8 | public static void renderStretchTexture(int width, int height, int light, Identifier source) { 9 | Tessellator tessellator = Tessellator.getInstance(); 10 | BufferBuilder bufferBuilder = tessellator.getBuffer(); 11 | RenderSystem.setShader(GameRenderer::getPositionTexColorProgram); 12 | RenderSystem.setShaderTexture(0, source); 13 | RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); 14 | bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); 15 | bufferBuilder.vertex(0.0D, height, 0.0D).texture(0, 1).color(light, light, light, 255).next(); 16 | bufferBuilder.vertex(width, height, 0.0D).texture(1, 1).color(light, light, light, 255).next(); 17 | bufferBuilder.vertex(width, 0.0D, 0.0D).texture(1, 0).color(light, light, light, 255).next(); 18 | bufferBuilder.vertex(0.0D, 0.0D, 0.0D).texture(0, 0).color(light, light, light, 255).next(); 19 | tessellator.draw(); 20 | } 21 | 22 | public static void renderParticle(int x, int y, int width, int height, Identifier source) { 23 | Tessellator tessellator = Tessellator.getInstance(); 24 | BufferBuilder bufferBuilder = tessellator.getBuffer(); 25 | RenderSystem.setShader(GameRenderer::getPositionTexColorProgram); 26 | RenderSystem.setShaderTexture(0, source); 27 | RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); 28 | bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); 29 | bufferBuilder.vertex(0.0D + x, height + y, 0.0D).texture(0, 1).color(255, 255, 255, 255).next(); 30 | bufferBuilder.vertex(width + x, height + y, 0.0D).texture(1, 1).color(255, 255, 255, 255).next(); 31 | bufferBuilder.vertex(width + x, 0.0D + y, 0.0D).texture(1, 0).color(255, 255, 255, 255).next(); 32 | bufferBuilder.vertex(0.0D + x, 0.0D + y, 0.0D).texture(0, 0).color(255, 255, 255, 255).next(); 33 | tessellator.draw(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Fabric-1.19.3/src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "xibaopp", 4 | "version": "${version}", 5 | 6 | "name": "Xibao", 7 | "description": "Congratulations! You had lost the connection!", 8 | "authors": [ 9 | "GregTao", 10 | "TeaCon(灵感)" 11 | ], 12 | "contact": { 13 | "email": "本模组内容若有侵权请联系gregtaoo@outlook.com删除" 14 | }, 15 | 16 | "license": "GPL v3", 17 | "icon": "assets/xibaopp/textures/logo.png", 18 | 19 | "environment": "*", 20 | "entrypoints": { 21 | "client": [ 22 | "top.gregtao.xibaopp.XibaoPlusPlusMain" 23 | ] 24 | }, 25 | "mixins": [ 26 | "xibaopp.mixins.json" 27 | ], 28 | 29 | "depends": { 30 | "fabricloader": ">=0.14.6", 31 | "fabric": "*", 32 | "minecraft": "1.19.3", 33 | "java": ">=17" 34 | }, 35 | "suggests": { 36 | "another-mod": "*" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Fabric-1.19.3/src/main/resources/xibaopp.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "top.gregtao.xibaopp.mixin", 5 | "compatibilityLevel": "JAVA_17", 6 | "mixins": [ 7 | ], 8 | "client": [ 9 | "DisconnectedScreenAccessor", 10 | "DisconnectedScreenMixin", 11 | "MinecraftClientMixin" 12 | ], 13 | "injectors": { 14 | "defaultRequire": 1 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Fabric-1.19.4/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx2G 2 | loom.platform=fabric 3 | 4 | minecraft_version=1.19.4 5 | yarn_mappings=1.19.4+build.2 6 | loader_version=0.14.12 7 | 8 | mod_version = 0.2.0-release-mc1.19.4 9 | maven_group = top.gregtao.xibaopp 10 | archives_base_name = XibaoPlusPlus-Fabric 11 | 12 | fabric_version=0.86.0+1.19.4 -------------------------------------------------------------------------------- /Fabric-1.19.4/src/main/java/top/gregtao/xibaopp/SnowAnimation.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.util.Identifier; 4 | import top.gregtao.xibaopp.util.RenderHelper; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import java.util.Random; 9 | 10 | public class SnowAnimation { 11 | public static SnowAnimation INSTANCE; 12 | private Identifier[] source; 13 | private int lastWidth, lastHeight; 14 | private float amount = 0.1f; 15 | private final Random random; 16 | private final List snows; 17 | 18 | public SnowAnimation(Random random) { 19 | this.random = random; 20 | this.snows = new ArrayList<>(); 21 | } 22 | 23 | public void tick(int width, int height, Identifier[] source) { 24 | this.source = source; 25 | if (width != this.lastWidth || height != this.lastHeight) { 26 | this.snows.clear(); 27 | this.lastWidth = width; 28 | this.lastHeight = height; 29 | } 30 | this.spawnGroup(); 31 | for (Snow snow : this.snows) { 32 | RenderHelper.renderParticle(snow.x, height - snow.y, 4, 4, this.source[snow.source % this.source.length]); 33 | snow.move(); 34 | if (snow.y > height) { 35 | snow.removed = true; 36 | } 37 | } 38 | if (this.snows.size() > 500) { 39 | int i = 0; 40 | while (i < this.snows.size() && this.snows.get(i).removed) this.snows.remove(i); 41 | } 42 | } 43 | 44 | public void spawnGroup() { 45 | this.amount += 0.001f; 46 | float realAmount = Math.min(0.4f, this.amount); 47 | if (realAmount < 1) { 48 | if (this.random.nextInt((int) (1 / realAmount)) == 0) this.spawn(); 49 | } else { 50 | for (int i = 1; i <= realAmount; ++i) this.spawn(); 51 | } 52 | if (this.amount >= 0.6f) this.amount = 0.1f; 53 | } 54 | 55 | public int getSourceIndex() { 56 | return this.random.nextInt(this.source.length); 57 | } 58 | 59 | public void spawn() { 60 | int x = random.nextInt(this.lastWidth); 61 | int k = (random.nextInt(4)) * 2 + 1; 62 | this.snows.add(new Snow(x, random.nextInt(2) == 0 ? -k : k, this.getSourceIndex())); 63 | } 64 | 65 | } 66 | 67 | class Snow { 68 | public int baseX, x, y, k, source; 69 | public boolean removed = false; 70 | public Snow(int x, int k, int source) { 71 | this.baseX = this.x = x; 72 | this.k = k; 73 | this.source = source; 74 | this.y = 0; 75 | } 76 | public void move() { 77 | this.y++; 78 | this.x = this.baseX + this.y / this.k; 79 | } 80 | } -------------------------------------------------------------------------------- /Fabric-1.19.4/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusConfig.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.FileWriter; 6 | import java.io.IOException; 7 | import java.util.Properties; 8 | import java.util.Random; 9 | 10 | public class XibaoPlusPlusConfig { 11 | private static final File file = new File("xibao_plus_plus.properties"); 12 | 13 | public static boolean shouldPlayMusic = false; 14 | public static boolean tempSnow = false; 15 | public static Random random = new Random(); 16 | 17 | public static boolean playMusic = true; 18 | public static boolean showPicture = true; 19 | public static boolean displaySnow = false; 20 | 21 | public static XibaoType type = XibaoType.XIBAO; 22 | 23 | public static void loadConfig() throws Exception { 24 | if (!file.exists()) { 25 | storeConfig(); 26 | return; 27 | } 28 | Properties properties = new Properties(); 29 | properties.load(new FileInputStream(file)); 30 | playMusic = properties.getOrDefault("playMusic", "true").equals("true"); 31 | showPicture = properties.getOrDefault("showPicture", "true").equals("true"); 32 | displaySnow = properties.getOrDefault("displaySnow", "false").equals("true"); 33 | type = XibaoType.getByString(properties.getProperty("type")); 34 | } 35 | 36 | public static void storeConfig() throws IOException { 37 | Properties properties = new Properties(); 38 | properties.setProperty("playMusic", String.valueOf(playMusic)); 39 | properties.setProperty("showPicture", String.valueOf(showPicture)); 40 | properties.setProperty("displaySnow", String.valueOf(displaySnow)); 41 | properties.setProperty("type", type.type); 42 | properties.store(new FileWriter(file), "Xibao Plus Plus"); 43 | } 44 | 45 | public static void switchAlbum() { 46 | XibaoType[] types = XibaoType.values(); 47 | type = types[(type.ordinal() + 1) % types.length]; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Fabric-1.19.4/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusMain.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.fabricmc.api.ClientModInitializer; 4 | import net.fabricmc.api.EnvType; 5 | import net.fabricmc.api.Environment; 6 | 7 | @Environment(EnvType.CLIENT) 8 | public class XibaoPlusPlusMain implements ClientModInitializer { 9 | @Override 10 | public void onInitializeClient() { 11 | try { 12 | XibaoPlusPlusConfig.loadConfig(); 13 | } catch (Exception e) { 14 | throw new RuntimeException(e); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Fabric-1.19.4/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusMusic.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.registry.Registries; 4 | import net.minecraft.registry.Registry; 5 | import net.minecraft.registry.entry.RegistryEntry; 6 | import net.minecraft.sound.MusicSound; 7 | import net.minecraft.sound.SoundEvent; 8 | import net.minecraft.util.Identifier; 9 | 10 | public class XibaoPlusPlusMusic { 11 | public static RegistryEntry.Reference XIBAO_SOUND_EVENT = registerReference(new Identifier("xibaopp", "xibao")); 12 | public static MusicSound XIBAO_MUSIC = new MusicSound(XIBAO_SOUND_EVENT, 0, 0, true); 13 | public static RegistryEntry.Reference BEIBAO_SOUND_EVENT = registerReference(new Identifier("xibaopp", "beibao")); 14 | public static MusicSound BEIBAO_MUSIC = new MusicSound(BEIBAO_SOUND_EVENT, 0, 0, true); 15 | 16 | private static RegistryEntry.Reference registerReference(Identifier id) { 17 | return registerReference(id, id); 18 | } 19 | private static RegistryEntry.Reference registerReference(Identifier id, Identifier soundId) { 20 | return Registry.registerReference(Registries.SOUND_EVENT, id, SoundEvent.of(soundId)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Fabric-1.19.4/src/main/java/top/gregtao/xibaopp/XibaoType.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.sound.MusicSound; 4 | import net.minecraft.util.Identifier; 5 | 6 | public enum XibaoType { 7 | XIBAO( 8 | XibaoPlusPlusMusic.XIBAO_MUSIC, 9 | new Identifier("xibaopp", "textures/xibao.png"), 10 | new Identifier[] { 11 | new Identifier("xibaopp", "textures/yellow_snow.png"), 12 | new Identifier("xibaopp", "textures/red_snow.png") 13 | }, 14 | "xibao" 15 | ), 16 | BEIBAO( 17 | XibaoPlusPlusMusic.BEIBAO_MUSIC, 18 | new Identifier("xibaopp", "textures/beibao.png"), 19 | new Identifier[] { 20 | new Identifier("xibaopp", "textures/white_snow.png") 21 | }, 22 | "beibao" 23 | ) 24 | ; 25 | public final MusicSound music; 26 | public final Identifier background; 27 | public final Identifier[] snows; 28 | public final String type; 29 | 30 | XibaoType(MusicSound music, Identifier background, Identifier[] snows, String type) { 31 | this.music = music; 32 | this.background = background; 33 | this.snows = snows; 34 | this.type = type; 35 | } 36 | 37 | public static XibaoType getByString(String type) { 38 | for (XibaoType xibaoType : values()) { 39 | if (type.equals(xibaoType.type)) return xibaoType; 40 | } 41 | return XIBAO; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Fabric-1.19.4/src/main/java/top/gregtao/xibaopp/mixin/DisconnectedScreenAccessor.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.gui.screen.DisconnectedScreen; 6 | import net.minecraft.text.Text; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.gen.Accessor; 9 | 10 | @Environment(EnvType.CLIENT) 11 | @Mixin(DisconnectedScreen.class) 12 | public interface DisconnectedScreenAccessor { 13 | 14 | @Accessor("reason") 15 | Text getReason(); 16 | 17 | @Accessor("reasonHeight") 18 | int getReasonHeight(); 19 | } 20 | -------------------------------------------------------------------------------- /Fabric-1.19.4/src/main/java/top/gregtao/xibaopp/mixin/MinecraftClientMixin.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.MinecraftClient; 6 | import net.minecraft.client.gui.screen.DisconnectedScreen; 7 | import net.minecraft.sound.MusicSound; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 12 | import top.gregtao.xibaopp.XibaoPlusPlusConfig; 13 | 14 | @Environment(EnvType.CLIENT) 15 | @Mixin(MinecraftClient.class) 16 | public class MinecraftClientMixin { 17 | 18 | @Inject(method = "getMusicType", at = @At("TAIL"), cancellable = true) 19 | public void getMusicTypeInject(CallbackInfoReturnable cir) { 20 | if (XibaoPlusPlusConfig.playMusic && XibaoPlusPlusConfig.shouldPlayMusic) { 21 | if (MinecraftClient.getInstance().currentScreen instanceof DisconnectedScreen) { 22 | cir.setReturnValue(XibaoPlusPlusConfig.type.music); 23 | } 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Fabric-1.19.4/src/main/java/top/gregtao/xibaopp/util/RenderHelper.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.util; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import net.minecraft.client.render.*; 5 | import net.minecraft.util.Identifier; 6 | 7 | public class RenderHelper { 8 | public static void renderStretchTexture(int width, int height, int light, Identifier source) { 9 | Tessellator tessellator = Tessellator.getInstance(); 10 | BufferBuilder bufferBuilder = tessellator.getBuffer(); 11 | RenderSystem.setShader(GameRenderer::getPositionTexColorProgram); 12 | RenderSystem.setShaderTexture(0, source); 13 | RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); 14 | bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); 15 | bufferBuilder.vertex(0.0D, height, 0.0D).texture(0, 1).color(light, light, light, 255).next(); 16 | bufferBuilder.vertex(width, height, 0.0D).texture(1, 1).color(light, light, light, 255).next(); 17 | bufferBuilder.vertex(width, 0.0D, 0.0D).texture(1, 0).color(light, light, light, 255).next(); 18 | bufferBuilder.vertex(0.0D, 0.0D, 0.0D).texture(0, 0).color(light, light, light, 255).next(); 19 | tessellator.draw(); 20 | } 21 | 22 | public static void renderParticle(int x, int y, int width, int height, Identifier source) { 23 | Tessellator tessellator = Tessellator.getInstance(); 24 | BufferBuilder bufferBuilder = tessellator.getBuffer(); 25 | RenderSystem.setShader(GameRenderer::getPositionTexColorProgram); 26 | RenderSystem.setShaderTexture(0, source); 27 | RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); 28 | bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); 29 | bufferBuilder.vertex(0.0D + x, height + y, 0.0D).texture(0, 1).color(255, 255, 255, 255).next(); 30 | bufferBuilder.vertex(width + x, height + y, 0.0D).texture(1, 1).color(255, 255, 255, 255).next(); 31 | bufferBuilder.vertex(width + x, 0.0D + y, 0.0D).texture(1, 0).color(255, 255, 255, 255).next(); 32 | bufferBuilder.vertex(0.0D + x, 0.0D + y, 0.0D).texture(0, 0).color(255, 255, 255, 255).next(); 33 | tessellator.draw(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Fabric-1.19.4/src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "xibaopp", 4 | "version": "${version}", 5 | 6 | "name": "Xibao", 7 | "description": "Congratulations! You had lost the connection!", 8 | "authors": [ 9 | "GregTao", 10 | "TeaCon(灵感)" 11 | ], 12 | "contact": { 13 | "email": "本模组内容若有侵权请联系gregtaoo@outlook.com删除" 14 | }, 15 | 16 | "license": "GPL v3", 17 | "icon": "assets/xibaopp/textures/logo.png", 18 | 19 | "environment": "*", 20 | "entrypoints": { 21 | "client": [ 22 | "top.gregtao.xibaopp.XibaoPlusPlusMain" 23 | ] 24 | }, 25 | "mixins": [ 26 | "xibaopp.mixins.json" 27 | ], 28 | 29 | "depends": { 30 | "fabricloader": ">=0.14.6", 31 | "fabric": "*", 32 | "minecraft": "1.19.4", 33 | "java": ">=17" 34 | }, 35 | "suggests": { 36 | "another-mod": "*" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Fabric-1.19.4/src/main/resources/xibaopp.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "top.gregtao.xibaopp.mixin", 5 | "compatibilityLevel": "JAVA_17", 6 | "mixins": [ 7 | ], 8 | "client": [ 9 | "DisconnectedScreenAccessor", 10 | "DisconnectedScreenMixin", 11 | "MinecraftClientMixin" 12 | ], 13 | "injectors": { 14 | "defaultRequire": 1 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Fabric-1.19/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx2G 2 | loom.platform=fabric 3 | 4 | minecraft_version=1.19 5 | yarn_mappings=1.19+build.1 6 | loader_version=0.14.6 7 | 8 | mod_version = 0.2.0-release-mc1.19 9 | maven_group = top.gregtao.xibaopp 10 | archives_base_name = XibaoPlusPlus-Fabric 11 | 12 | fabric_version=0.55.1+1.19 13 | -------------------------------------------------------------------------------- /Fabric-1.19/src/main/java/top/gregtao/xibaopp/SnowAnimation.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.util.Identifier; 4 | import top.gregtao.xibaopp.util.RenderHelper; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import java.util.Random; 9 | 10 | public class SnowAnimation { 11 | public static SnowAnimation INSTANCE; 12 | private Identifier[] source; 13 | private int lastWidth, lastHeight; 14 | private float amount = 0.1f; 15 | private final Random random; 16 | private final List snows; 17 | 18 | public SnowAnimation(Random random) { 19 | this.random = random; 20 | this.snows = new ArrayList<>(); 21 | } 22 | 23 | public void tick(int width, int height, Identifier[] source) { 24 | this.source = source; 25 | if (width != this.lastWidth || height != this.lastHeight) { 26 | this.snows.clear(); 27 | this.lastWidth = width; 28 | this.lastHeight = height; 29 | } 30 | this.spawnGroup(); 31 | for (Snow snow : this.snows) { 32 | RenderHelper.renderParticle(snow.x, height - snow.y, 4, 4, this.source[snow.source % this.source.length]); 33 | snow.move(); 34 | if (snow.y > height) { 35 | snow.removed = true; 36 | } 37 | } 38 | if (this.snows.size() > 500) { 39 | int i = 0; 40 | while (i < this.snows.size() && this.snows.get(i).removed) this.snows.remove(i); 41 | } 42 | } 43 | 44 | public void spawnGroup() { 45 | this.amount += 0.001f; 46 | float realAmount = Math.min(0.4f, this.amount); 47 | if (realAmount < 1) { 48 | if (this.random.nextInt((int) (1 / realAmount)) == 0) this.spawn(); 49 | } else { 50 | for (int i = 1; i <= realAmount; ++i) this.spawn(); 51 | } 52 | if (this.amount >= 0.6f) this.amount = 0.1f; 53 | } 54 | 55 | public int getSourceIndex() { 56 | return this.random.nextInt(this.source.length); 57 | } 58 | 59 | public void spawn() { 60 | int x = random.nextInt(this.lastWidth); 61 | int k = (random.nextInt(4)) * 2 + 1; 62 | this.snows.add(new Snow(x, random.nextInt(2) == 0 ? -k : k, this.getSourceIndex())); 63 | } 64 | 65 | } 66 | 67 | class Snow { 68 | public int baseX, x, y, k, source; 69 | public boolean removed = false; 70 | public Snow(int x, int k, int source) { 71 | this.baseX = this.x = x; 72 | this.k = k; 73 | this.source = source; 74 | this.y = 0; 75 | } 76 | public void move() { 77 | this.y++; 78 | this.x = this.baseX + this.y / this.k; 79 | } 80 | } -------------------------------------------------------------------------------- /Fabric-1.19/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusConfig.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.FileWriter; 6 | import java.io.IOException; 7 | import java.util.Properties; 8 | import java.util.Random; 9 | 10 | public class XibaoPlusPlusConfig { 11 | private static final File file = new File("xibao_plus_plus.properties"); 12 | 13 | public static boolean shouldPlayMusic = false; 14 | public static boolean tempSnow = false; 15 | public static Random random = new Random(); 16 | 17 | public static boolean playMusic = true; 18 | public static boolean showPicture = true; 19 | public static boolean displaySnow = false; 20 | 21 | public static XibaoType type = XibaoType.XIBAO; 22 | 23 | public static void loadConfig() throws Exception { 24 | if (!file.exists()) { 25 | storeConfig(); 26 | return; 27 | } 28 | Properties properties = new Properties(); 29 | properties.load(new FileInputStream(file)); 30 | playMusic = properties.getOrDefault("playMusic", "true").equals("true"); 31 | showPicture = properties.getOrDefault("showPicture", "true").equals("true"); 32 | displaySnow = properties.getOrDefault("displaySnow", "false").equals("true"); 33 | type = XibaoType.getByString(properties.getProperty("type")); 34 | } 35 | 36 | public static void storeConfig() throws IOException { 37 | Properties properties = new Properties(); 38 | properties.setProperty("playMusic", String.valueOf(playMusic)); 39 | properties.setProperty("showPicture", String.valueOf(showPicture)); 40 | properties.setProperty("displaySnow", String.valueOf(displaySnow)); 41 | properties.setProperty("type", type.type); 42 | properties.store(new FileWriter(file), "Xibao Plus Plus"); 43 | } 44 | 45 | public static void switchAlbum() { 46 | XibaoType[] types = XibaoType.values(); 47 | type = types[(type.ordinal() + 1) % types.length]; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Fabric-1.19/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusMain.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.fabricmc.api.ClientModInitializer; 4 | import net.fabricmc.api.EnvType; 5 | import net.fabricmc.api.Environment; 6 | import net.minecraft.util.registry.Registry; 7 | 8 | @Environment(EnvType.CLIENT) 9 | public class XibaoPlusPlusMain implements ClientModInitializer { 10 | @Override 11 | public void onInitializeClient() { 12 | Registry.register(Registry.SOUND_EVENT, XibaoPlusPlusMusic.XIBAO_SOUND_EVENT.getId(), XibaoPlusPlusMusic.XIBAO_SOUND_EVENT); 13 | 14 | try { 15 | XibaoPlusPlusConfig.loadConfig(); 16 | } catch (Exception e) { 17 | throw new RuntimeException(e); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Fabric-1.19/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusMusic.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.sound.MusicSound; 4 | import net.minecraft.sound.SoundEvent; 5 | import net.minecraft.util.Identifier; 6 | 7 | public class XibaoPlusPlusMusic { 8 | public static SoundEvent XIBAO_SOUND_EVENT = new SoundEvent(new Identifier("xibaopp", "xibao")); 9 | public static MusicSound XIBAO_MUSIC = new MusicSound(XIBAO_SOUND_EVENT, 0, 0, true); 10 | public static SoundEvent BEIBAO_SOUND_EVENT = new SoundEvent(new Identifier("xibaopp", "beibao")); 11 | public static MusicSound BEIBAO_MUSIC = new MusicSound(BEIBAO_SOUND_EVENT, 0, 0, true); 12 | } 13 | -------------------------------------------------------------------------------- /Fabric-1.19/src/main/java/top/gregtao/xibaopp/XibaoType.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.sound.MusicSound; 4 | import net.minecraft.util.Identifier; 5 | 6 | public enum XibaoType { 7 | XIBAO( 8 | XibaoPlusPlusMusic.XIBAO_MUSIC, 9 | new Identifier("xibaopp", "textures/xibao.png"), 10 | new Identifier[] { 11 | new Identifier("xibaopp", "textures/yellow_snow.png"), 12 | new Identifier("xibaopp", "textures/red_snow.png") 13 | }, 14 | "xibao" 15 | ), 16 | BEIBAO( 17 | XibaoPlusPlusMusic.BEIBAO_MUSIC, 18 | new Identifier("xibaopp", "textures/beibao.png"), 19 | new Identifier[] { 20 | new Identifier("xibaopp", "textures/white_snow.png") 21 | }, 22 | "beibao" 23 | ) 24 | ; 25 | public final MusicSound music; 26 | public final Identifier background; 27 | public final Identifier[] snows; 28 | public final String type; 29 | 30 | XibaoType(MusicSound music, Identifier background, Identifier[] snows, String type) { 31 | this.music = music; 32 | this.background = background; 33 | this.snows = snows; 34 | this.type = type; 35 | } 36 | 37 | public static XibaoType getByString(String type) { 38 | for (XibaoType xibaoType : values()) { 39 | if (type.equals(xibaoType.type)) return xibaoType; 40 | } 41 | return XIBAO; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Fabric-1.19/src/main/java/top/gregtao/xibaopp/mixin/DisconnectedScreenAccessor.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.gui.screen.DisconnectedScreen; 6 | import net.minecraft.text.Text; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.gen.Accessor; 9 | 10 | @Environment(EnvType.CLIENT) 11 | @Mixin(DisconnectedScreen.class) 12 | public interface DisconnectedScreenAccessor { 13 | 14 | @Accessor("reason") 15 | Text getReason(); 16 | 17 | @Accessor("reasonHeight") 18 | int getReasonHeight(); 19 | } 20 | -------------------------------------------------------------------------------- /Fabric-1.19/src/main/java/top/gregtao/xibaopp/mixin/DisconnectedScreenMixin.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.gui.screen.DisconnectedScreen; 6 | import net.minecraft.client.gui.screen.Screen; 7 | import net.minecraft.client.gui.widget.ButtonWidget; 8 | import net.minecraft.client.util.math.MatrixStack; 9 | import net.minecraft.text.MutableText; 10 | import net.minecraft.text.Text; 11 | import net.minecraft.text.TranslatableTextContent; 12 | import org.spongepowered.asm.mixin.Mixin; 13 | import org.spongepowered.asm.mixin.injection.At; 14 | import org.spongepowered.asm.mixin.injection.Inject; 15 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 16 | import top.gregtao.xibaopp.SnowAnimation; 17 | import top.gregtao.xibaopp.XibaoPlusPlusConfig; 18 | import top.gregtao.xibaopp.util.RenderHelper; 19 | 20 | @Environment(EnvType.CLIENT) 21 | @Mixin(DisconnectedScreen.class) 22 | public class DisconnectedScreenMixin extends Screen { 23 | 24 | protected DisconnectedScreenMixin(Text title) { 25 | super(title); 26 | } 27 | 28 | @Inject(method = "init", at = @At("TAIL")) 29 | private void initInject(CallbackInfo ci) { 30 | XibaoPlusPlusConfig.shouldPlayMusic = true; 31 | XibaoPlusPlusConfig.tempSnow = false; 32 | this.addDrawableChild(new ButtonWidget( 33 | this.width / 2 - 100, this.height - 22, 34 | 66, 20, Text.translatable("gui.stopMusic"), 35 | button -> XibaoPlusPlusConfig.shouldPlayMusic = !XibaoPlusPlusConfig.shouldPlayMusic)); 36 | this.addDrawableChild(new ButtonWidget( 37 | this.width / 2 - 33, this.height - 22, 38 | 66, 20, Text.translatable("gui.dropSnow"), 39 | button -> { 40 | SnowAnimation.INSTANCE = new SnowAnimation(XibaoPlusPlusConfig.random); 41 | XibaoPlusPlusConfig.tempSnow = !XibaoPlusPlusConfig.tempSnow; 42 | })); 43 | this.addDrawableChild(new ButtonWidget( 44 | this.width / 2 + 34, this.height - 22, 45 | 66, 20, Text.translatable("gui.switchAlbum"), 46 | button -> XibaoPlusPlusConfig.switchAlbum())); 47 | if (XibaoPlusPlusConfig.displaySnow) SnowAnimation.INSTANCE = new SnowAnimation(XibaoPlusPlusConfig.random); 48 | } 49 | 50 | @Inject(method = "render", at = @At(value = "INVOKE", 51 | target = "Lnet/minecraft/client/font/MultilineText;drawCenterWithShadow(Lnet/minecraft/client/util/math/MatrixStack;II)I")) 52 | private void renderInject(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) { 53 | if (this.client == null) return; 54 | if (XibaoPlusPlusConfig.showPicture) { 55 | RenderHelper.renderStretchTexture(this.width, this.height, 225, 56 | XibaoPlusPlusConfig.type.background); 57 | } 58 | if (XibaoPlusPlusConfig.displaySnow || XibaoPlusPlusConfig.tempSnow) { 59 | SnowAnimation.INSTANCE.tick(this.width, this.height, XibaoPlusPlusConfig.type.snows); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Fabric-1.19/src/main/java/top/gregtao/xibaopp/mixin/MinecraftClientMixin.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.MinecraftClient; 6 | import net.minecraft.client.gui.screen.DisconnectedScreen; 7 | import net.minecraft.sound.MusicSound; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 12 | import top.gregtao.xibaopp.XibaoPlusPlusConfig; 13 | 14 | @Environment(EnvType.CLIENT) 15 | @Mixin(MinecraftClient.class) 16 | public class MinecraftClientMixin { 17 | 18 | @Inject(method = "getMusicType", at = @At("TAIL"), cancellable = true) 19 | public void getMusicTypeInject(CallbackInfoReturnable cir) { 20 | if (XibaoPlusPlusConfig.playMusic && XibaoPlusPlusConfig.shouldPlayMusic) { 21 | if (MinecraftClient.getInstance().currentScreen instanceof DisconnectedScreen) { 22 | cir.setReturnValue(XibaoPlusPlusConfig.type.music); 23 | } 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Fabric-1.19/src/main/java/top/gregtao/xibaopp/util/RenderHelper.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.util; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import net.minecraft.client.render.*; 5 | import net.minecraft.util.Identifier; 6 | 7 | public class RenderHelper { 8 | public static void renderStretchTexture(int width, int height, int light, Identifier source) { 9 | Tessellator tessellator = Tessellator.getInstance(); 10 | BufferBuilder bufferBuilder = tessellator.getBuffer(); 11 | RenderSystem.setShader(GameRenderer::getPositionTexColorShader); 12 | RenderSystem.setShaderTexture(0, source); 13 | RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); 14 | bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); 15 | bufferBuilder.vertex(0.0D, height, 0.0D).texture(0, 1).color(light, light, light, 255).next(); 16 | bufferBuilder.vertex(width, height, 0.0D).texture(1, 1).color(light, light, light, 255).next(); 17 | bufferBuilder.vertex(width, 0.0D, 0.0D).texture(1, 0).color(light, light, light, 255).next(); 18 | bufferBuilder.vertex(0.0D, 0.0D, 0.0D).texture(0, 0).color(light, light, light, 255).next(); 19 | tessellator.draw(); 20 | } 21 | 22 | public static void renderParticle(int x, int y, int width, int height, Identifier source) { 23 | Tessellator tessellator = Tessellator.getInstance(); 24 | BufferBuilder bufferBuilder = tessellator.getBuffer(); 25 | RenderSystem.setShader(GameRenderer::getPositionTexColorShader); 26 | RenderSystem.setShaderTexture(0, source); 27 | RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); 28 | bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); 29 | bufferBuilder.vertex(0.0D + x, height + y, 0.0D).texture(0, 1).color(255, 255, 255, 255).next(); 30 | bufferBuilder.vertex(width + x, height + y, 0.0D).texture(1, 1).color(255, 255, 255, 255).next(); 31 | bufferBuilder.vertex(width + x, 0.0D + y, 0.0D).texture(1, 0).color(255, 255, 255, 255).next(); 32 | bufferBuilder.vertex(0.0D + x, 0.0D + y, 0.0D).texture(0, 0).color(255, 255, 255, 255).next(); 33 | tessellator.draw(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Fabric-1.19/src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "xibaopp", 4 | "version": "${version}", 5 | 6 | "name": "Xibao", 7 | "description": "Congratulations! You had lost the connection!", 8 | "authors": [ 9 | "GregTao", 10 | "TeaCon(灵感)" 11 | ], 12 | "contact": { 13 | "email": "本模组内容若有侵权请联系gregtaoo@outlook.com删除" 14 | }, 15 | 16 | "license": "GPL v3", 17 | "icon": "assets/xibaopp/textures/logo.png", 18 | 19 | "environment": "*", 20 | "entrypoints": { 21 | "client": [ 22 | "top.gregtao.xibaopp.XibaoPlusPlusMain" 23 | ] 24 | }, 25 | "mixins": [ 26 | "xibaopp.mixins.json" 27 | ], 28 | 29 | "depends": { 30 | "fabricloader": ">=0.14.6", 31 | "fabric": "*", 32 | "minecraft": "1.19.x", 33 | "java": ">=17" 34 | }, 35 | "suggests": { 36 | "another-mod": "*" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Fabric-1.19/src/main/resources/xibaopp.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "top.gregtao.xibaopp.mixin", 5 | "compatibilityLevel": "JAVA_17", 6 | "mixins": [ 7 | ], 8 | "client": [ 9 | "DisconnectedScreenAccessor", 10 | "DisconnectedScreenMixin", 11 | "MinecraftClientMixin" 12 | ], 13 | "injectors": { 14 | "defaultRequire": 1 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Fabric-1.20.1/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx2G 2 | loom.platform=fabric 3 | 4 | minecraft_version=1.20.1 5 | yarn_mappings=1.20.1+build.10 6 | loader_version=0.14.12 7 | 8 | mod_version = 0.2.0-release-mc1.20.1 9 | maven_group = top.gregtao.xibaopp 10 | archives_base_name = XibaoPlusPlus-Fabric 11 | 12 | fabric_version=0.86.0+1.20.1 -------------------------------------------------------------------------------- /Fabric-1.20.1/src/main/java/top/gregtao/xibaopp/SnowAnimation.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.util.Identifier; 4 | import top.gregtao.xibaopp.util.RenderHelper; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import java.util.Random; 9 | 10 | public class SnowAnimation { 11 | public static SnowAnimation INSTANCE; 12 | private Identifier[] source; 13 | private int lastWidth, lastHeight; 14 | private float amount = 0.1f; 15 | private final Random random; 16 | private final List snows; 17 | 18 | public SnowAnimation(Random random) { 19 | this.random = random; 20 | this.snows = new ArrayList<>(); 21 | } 22 | 23 | public void tick(int width, int height, Identifier[] source) { 24 | this.source = source; 25 | if (width != this.lastWidth || height != this.lastHeight) { 26 | this.snows.clear(); 27 | this.lastWidth = width; 28 | this.lastHeight = height; 29 | } 30 | this.spawnGroup(); 31 | for (Snow snow : this.snows) { 32 | RenderHelper.renderParticle(snow.x, height - snow.y, 4, 4, this.source[snow.source % this.source.length]); 33 | snow.move(); 34 | if (snow.y > height) { 35 | snow.removed = true; 36 | } 37 | } 38 | if (this.snows.size() > 500) { 39 | int i = 0; 40 | while (i < this.snows.size() && this.snows.get(i).removed) this.snows.remove(i); 41 | } 42 | } 43 | 44 | public void spawnGroup() { 45 | this.amount += 0.001f; 46 | float realAmount = Math.min(0.4f, this.amount); 47 | if (realAmount < 1) { 48 | if (this.random.nextInt((int) (1 / realAmount)) == 0) this.spawn(); 49 | } else { 50 | for (int i = 1; i <= realAmount; ++i) this.spawn(); 51 | } 52 | if (this.amount >= 0.6f) this.amount = 0.1f; 53 | } 54 | 55 | public int getSourceIndex() { 56 | return this.random.nextInt(this.source.length); 57 | } 58 | 59 | public void spawn() { 60 | int x = random.nextInt(this.lastWidth); 61 | int k = (random.nextInt(4)) * 2 + 1; 62 | this.snows.add(new Snow(x, random.nextInt(2) == 0 ? -k : k, this.getSourceIndex())); 63 | } 64 | 65 | } 66 | 67 | class Snow { 68 | public int baseX, x, y, k, source; 69 | public boolean removed = false; 70 | public Snow(int x, int k, int source) { 71 | this.baseX = this.x = x; 72 | this.k = k; 73 | this.source = source; 74 | this.y = 0; 75 | } 76 | public void move() { 77 | this.y++; 78 | this.x = this.baseX + this.y / this.k; 79 | } 80 | } -------------------------------------------------------------------------------- /Fabric-1.20.1/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusConfig.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.FileWriter; 6 | import java.io.IOException; 7 | import java.util.Properties; 8 | import java.util.Random; 9 | 10 | public class XibaoPlusPlusConfig { 11 | private static final File file = new File("xibao_plus_plus.properties"); 12 | 13 | public static boolean shouldPlayMusic = false; 14 | public static boolean tempSnow = false; 15 | public static Random random = new Random(); 16 | 17 | public static boolean playMusic = true; 18 | public static boolean showPicture = true; 19 | public static boolean displaySnow = false; 20 | 21 | public static XibaoType type = XibaoType.XIBAO; 22 | 23 | public static void loadConfig() throws Exception { 24 | if (!file.exists()) { 25 | storeConfig(); 26 | return; 27 | } 28 | Properties properties = new Properties(); 29 | properties.load(new FileInputStream(file)); 30 | playMusic = properties.getOrDefault("playMusic", "true").equals("true"); 31 | showPicture = properties.getOrDefault("showPicture", "true").equals("true"); 32 | displaySnow = properties.getOrDefault("displaySnow", "false").equals("true"); 33 | type = XibaoType.getByString(properties.getProperty("type")); 34 | } 35 | 36 | public static void storeConfig() throws IOException { 37 | Properties properties = new Properties(); 38 | properties.setProperty("playMusic", String.valueOf(playMusic)); 39 | properties.setProperty("showPicture", String.valueOf(showPicture)); 40 | properties.setProperty("displaySnow", String.valueOf(displaySnow)); 41 | properties.setProperty("type", type.type); 42 | properties.store(new FileWriter(file), "Xibao Plus Plus"); 43 | } 44 | 45 | public static void switchAlbum() { 46 | XibaoType[] types = XibaoType.values(); 47 | type = types[(type.ordinal() + 1) % types.length]; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Fabric-1.20.1/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusMain.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.fabricmc.api.ClientModInitializer; 4 | import net.fabricmc.api.EnvType; 5 | import net.fabricmc.api.Environment; 6 | 7 | @Environment(EnvType.CLIENT) 8 | public class XibaoPlusPlusMain implements ClientModInitializer { 9 | @Override 10 | public void onInitializeClient() { 11 | try { 12 | XibaoPlusPlusConfig.loadConfig(); 13 | } catch (Exception e) { 14 | throw new RuntimeException(e); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Fabric-1.20.1/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusMusic.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.registry.Registries; 4 | import net.minecraft.registry.Registry; 5 | import net.minecraft.registry.entry.RegistryEntry; 6 | import net.minecraft.sound.MusicSound; 7 | import net.minecraft.sound.SoundEvent; 8 | import net.minecraft.util.Identifier; 9 | 10 | public class XibaoPlusPlusMusic { 11 | public static RegistryEntry.Reference XIBAO_SOUND_EVENT = registerReference(new Identifier("xibaopp", "xibao")); 12 | public static MusicSound XIBAO_MUSIC = new MusicSound(XIBAO_SOUND_EVENT, 0, 0, true); 13 | public static RegistryEntry.Reference BEIBAO_SOUND_EVENT = registerReference(new Identifier("xibaopp", "beibao")); 14 | public static MusicSound BEIBAO_MUSIC = new MusicSound(BEIBAO_SOUND_EVENT, 0, 0, true); 15 | 16 | private static RegistryEntry.Reference registerReference(Identifier id) { 17 | return registerReference(id, id); 18 | } 19 | private static RegistryEntry.Reference registerReference(Identifier id, Identifier soundId) { 20 | return Registry.registerReference(Registries.SOUND_EVENT, id, SoundEvent.of(soundId)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Fabric-1.20.1/src/main/java/top/gregtao/xibaopp/XibaoType.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.sound.MusicSound; 4 | import net.minecraft.util.Identifier; 5 | 6 | public enum XibaoType { 7 | XIBAO( 8 | XibaoPlusPlusMusic.XIBAO_MUSIC, 9 | new Identifier("xibaopp", "textures/xibao.png"), 10 | new Identifier[] { 11 | new Identifier("xibaopp", "textures/yellow_snow.png"), 12 | new Identifier("xibaopp", "textures/red_snow.png") 13 | }, 14 | "xibao" 15 | ), 16 | BEIBAO( 17 | XibaoPlusPlusMusic.BEIBAO_MUSIC, 18 | new Identifier("xibaopp", "textures/beibao.png"), 19 | new Identifier[] { 20 | new Identifier("xibaopp", "textures/white_snow.png") 21 | }, 22 | "beibao" 23 | ) 24 | ; 25 | public final MusicSound music; 26 | public final Identifier background; 27 | public final Identifier[] snows; 28 | public final String type; 29 | 30 | XibaoType(MusicSound music, Identifier background, Identifier[] snows, String type) { 31 | this.music = music; 32 | this.background = background; 33 | this.snows = snows; 34 | this.type = type; 35 | } 36 | 37 | public static XibaoType getByString(String type) { 38 | for (XibaoType xibaoType : values()) { 39 | if (type.equals(xibaoType.type)) return xibaoType; 40 | } 41 | return XIBAO; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Fabric-1.20.1/src/main/java/top/gregtao/xibaopp/mixin/DisconnectedScreenAccessor.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.gui.screen.DisconnectedScreen; 6 | import net.minecraft.text.Text; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.gen.Accessor; 9 | 10 | @Environment(EnvType.CLIENT) 11 | @Mixin(DisconnectedScreen.class) 12 | public interface DisconnectedScreenAccessor { 13 | 14 | @Accessor("reason") 15 | Text getReason(); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /Fabric-1.20.1/src/main/java/top/gregtao/xibaopp/mixin/DisconnectedScreenMixin.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.gui.DrawContext; 6 | import net.minecraft.client.gui.screen.DisconnectedScreen; 7 | import net.minecraft.client.gui.screen.Screen; 8 | import net.minecraft.client.gui.widget.ButtonWidget; 9 | import net.minecraft.text.Text; 10 | import org.spongepowered.asm.mixin.Mixin; 11 | import org.spongepowered.asm.mixin.injection.At; 12 | import org.spongepowered.asm.mixin.injection.Inject; 13 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 14 | import top.gregtao.xibaopp.SnowAnimation; 15 | import top.gregtao.xibaopp.XibaoPlusPlusConfig; 16 | import top.gregtao.xibaopp.util.RenderHelper; 17 | 18 | @Environment(EnvType.CLIENT) 19 | @Mixin(DisconnectedScreen.class) 20 | public class DisconnectedScreenMixin extends Screen { 21 | 22 | protected DisconnectedScreenMixin(Text title) { 23 | super(title); 24 | } 25 | 26 | @Inject(method = "init", at = @At("TAIL")) 27 | private void initInject(CallbackInfo ci) { 28 | XibaoPlusPlusConfig.shouldPlayMusic = true; 29 | XibaoPlusPlusConfig.tempSnow = false; 30 | this.addDrawableChild(ButtonWidget.builder(Text.translatable("gui.stopMusic"), 31 | button -> XibaoPlusPlusConfig.shouldPlayMusic = !XibaoPlusPlusConfig.shouldPlayMusic) 32 | .dimensions(this.width / 2 - 100, this.height - 22, 66, 20).build()); 33 | this.addDrawableChild(ButtonWidget.builder( 34 | Text.translatable("gui.dropSnow"), 35 | button -> { 36 | SnowAnimation.INSTANCE = new SnowAnimation(XibaoPlusPlusConfig.random); 37 | XibaoPlusPlusConfig.tempSnow = !XibaoPlusPlusConfig.tempSnow; 38 | }).dimensions(this.width / 2 - 33, this.height - 22, 66, 20).build()); 39 | this.addDrawableChild(ButtonWidget.builder( 40 | Text.translatable("gui.switchAlbum"), 41 | button -> XibaoPlusPlusConfig.switchAlbum()) 42 | .dimensions(this.width / 2 + 34, this.height - 22, 66, 20).build()); 43 | if (XibaoPlusPlusConfig.displaySnow) SnowAnimation.INSTANCE = new SnowAnimation(XibaoPlusPlusConfig.random); 44 | } 45 | 46 | @Inject(method = "render", at = @At(value = "INVOKE", 47 | target = "Lnet/minecraft/client/gui/screen/Screen;render(Lnet/minecraft/client/gui/DrawContext;IIF)V")) 48 | private void renderInject(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) { 49 | if (this.client == null) return; 50 | if (XibaoPlusPlusConfig.showPicture) { 51 | RenderHelper.renderStretchTexture(this.width, this.height, 225, 52 | XibaoPlusPlusConfig.type.background); 53 | } 54 | if (XibaoPlusPlusConfig.displaySnow || XibaoPlusPlusConfig.tempSnow) { 55 | SnowAnimation.INSTANCE.tick(this.width, this.height, XibaoPlusPlusConfig.type.snows); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Fabric-1.20.1/src/main/java/top/gregtao/xibaopp/mixin/MinecraftClientMixin.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.MinecraftClient; 6 | import net.minecraft.client.gui.screen.DisconnectedScreen; 7 | import net.minecraft.sound.MusicSound; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 12 | import top.gregtao.xibaopp.XibaoPlusPlusConfig; 13 | 14 | @Environment(EnvType.CLIENT) 15 | @Mixin(MinecraftClient.class) 16 | public class MinecraftClientMixin { 17 | 18 | @Inject(method = "getMusicType", at = @At("TAIL"), cancellable = true) 19 | public void getMusicTypeInject(CallbackInfoReturnable cir) { 20 | if (XibaoPlusPlusConfig.playMusic && XibaoPlusPlusConfig.shouldPlayMusic) { 21 | if (MinecraftClient.getInstance().currentScreen instanceof DisconnectedScreen) { 22 | cir.setReturnValue(XibaoPlusPlusConfig.type.music); 23 | } 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Fabric-1.20.1/src/main/java/top/gregtao/xibaopp/util/RenderHelper.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.util; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import net.minecraft.client.render.*; 5 | import net.minecraft.util.Identifier; 6 | 7 | public class RenderHelper { 8 | public static void renderStretchTexture(int width, int height, int light, Identifier source) { 9 | Tessellator tessellator = Tessellator.getInstance(); 10 | BufferBuilder bufferBuilder = tessellator.getBuffer(); 11 | RenderSystem.setShader(GameRenderer::getPositionTexColorProgram); 12 | RenderSystem.setShaderTexture(0, source); 13 | RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); 14 | bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); 15 | bufferBuilder.vertex(0.0D, height, 0.0D).texture(0, 1).color(light, light, light, 255).next(); 16 | bufferBuilder.vertex(width, height, 0.0D).texture(1, 1).color(light, light, light, 255).next(); 17 | bufferBuilder.vertex(width, 0.0D, 0.0D).texture(1, 0).color(light, light, light, 255).next(); 18 | bufferBuilder.vertex(0.0D, 0.0D, 0.0D).texture(0, 0).color(light, light, light, 255).next(); 19 | tessellator.draw(); 20 | } 21 | 22 | public static void renderParticle(int x, int y, int width, int height, Identifier source) { 23 | Tessellator tessellator = Tessellator.getInstance(); 24 | BufferBuilder bufferBuilder = tessellator.getBuffer(); 25 | RenderSystem.setShader(GameRenderer::getPositionTexColorProgram); 26 | RenderSystem.setShaderTexture(0, source); 27 | RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); 28 | bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); 29 | bufferBuilder.vertex(0.0D + x, height + y, 0.0D).texture(0, 1).color(255, 255, 255, 255).next(); 30 | bufferBuilder.vertex(width + x, height + y, 0.0D).texture(1, 1).color(255, 255, 255, 255).next(); 31 | bufferBuilder.vertex(width + x, 0.0D + y, 0.0D).texture(1, 0).color(255, 255, 255, 255).next(); 32 | bufferBuilder.vertex(0.0D + x, 0.0D + y, 0.0D).texture(0, 0).color(255, 255, 255, 255).next(); 33 | tessellator.draw(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Fabric-1.20.1/src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "xibaopp", 4 | "version": "${version}", 5 | 6 | "name": "Xibao", 7 | "description": "Congratulations! You had lost the connection!", 8 | "authors": [ 9 | "GregTao", 10 | "TeaCon(灵感)" 11 | ], 12 | "contact": { 13 | "email": "本模组内容若有侵权请联系gregtaoo@outlook.com删除" 14 | }, 15 | 16 | "license": "GPL v3", 17 | "icon": "assets/xibaopp/textures/logo.png", 18 | 19 | "environment": "*", 20 | "entrypoints": { 21 | "client": [ 22 | "top.gregtao.xibaopp.XibaoPlusPlusMain" 23 | ] 24 | }, 25 | "mixins": [ 26 | "xibaopp.mixins.json" 27 | ], 28 | 29 | "depends": { 30 | "fabricloader": ">=0.14.6", 31 | "fabric": "*", 32 | "minecraft": "1.20.1", 33 | "java": ">=17" 34 | }, 35 | "suggests": { 36 | "another-mod": "*" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Fabric-1.20.1/src/main/resources/xibaopp.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "top.gregtao.xibaopp.mixin", 5 | "compatibilityLevel": "JAVA_17", 6 | "mixins": [ 7 | ], 8 | "client": [ 9 | "DisconnectedScreenAccessor", 10 | "DisconnectedScreenMixin", 11 | "MinecraftClientMixin" 12 | ], 13 | "injectors": { 14 | "defaultRequire": 1 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Fabric-1.20.4/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx2G 2 | loom.platform=fabric 3 | 4 | minecraft_version=1.20.4 5 | yarn_mappings=1.20.4+build.3 6 | loader_version=0.15.11 7 | 8 | mod_version = 0.2.0-release-mc1.20.4 9 | maven_group = top.gregtao.xibaopp 10 | archives_base_name = XibaoPlusPlus-Fabric 11 | 12 | fabric_version=0.97.0+1.20.4 -------------------------------------------------------------------------------- /Fabric-1.20.4/src/main/java/top/gregtao/xibaopp/BackgroundWidget.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.client.MinecraftClient; 4 | import net.minecraft.client.gui.DrawContext; 5 | import net.minecraft.client.gui.Drawable; 6 | import net.minecraft.client.gui.Element; 7 | import net.minecraft.client.gui.Selectable; 8 | import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; 9 | import net.minecraft.client.util.Window; 10 | import top.gregtao.xibaopp.util.RenderHelper; 11 | 12 | public class BackgroundWidget implements Drawable, Element, Selectable { 13 | 14 | @Override 15 | public void render(DrawContext context, int mouseX, int mouseY, float delta) { 16 | MinecraftClient client = MinecraftClient.getInstance(); 17 | Window window = client.getWindow(); 18 | int width = window.getScaledWidth(), height = window.getScaledHeight(); 19 | if (XibaoPlusPlusConfig.showPicture) { 20 | RenderHelper.renderStretchTexture(width, height, 225, 21 | XibaoPlusPlusConfig.type.background); 22 | } 23 | if (XibaoPlusPlusConfig.displaySnow || XibaoPlusPlusConfig.tempSnow) { 24 | SnowAnimation.INSTANCE.tick(width, height, XibaoPlusPlusConfig.type.snows); 25 | } 26 | } 27 | 28 | @Override 29 | public void setFocused(boolean focused) { 30 | } 31 | 32 | @Override 33 | public boolean isFocused() { 34 | return false; 35 | } 36 | 37 | @Override 38 | public SelectionType getType() { 39 | return Selectable.SelectionType.NONE; 40 | } 41 | 42 | @Override 43 | public void appendNarrations(NarrationMessageBuilder builder) { 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Fabric-1.20.4/src/main/java/top/gregtao/xibaopp/SnowAnimation.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.util.Identifier; 4 | import top.gregtao.xibaopp.util.RenderHelper; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import java.util.Random; 9 | 10 | public class SnowAnimation { 11 | public static SnowAnimation INSTANCE; 12 | private Identifier[] source; 13 | private int lastWidth, lastHeight; 14 | private float amount = 0.1f; 15 | private final Random random; 16 | private final List snows; 17 | 18 | public SnowAnimation(Random random) { 19 | this.random = random; 20 | this.snows = new ArrayList<>(); 21 | } 22 | 23 | public void tick(int width, int height, Identifier[] source) { 24 | this.source = source; 25 | if (width != this.lastWidth || height != this.lastHeight) { 26 | this.snows.clear(); 27 | this.lastWidth = width; 28 | this.lastHeight = height; 29 | } 30 | this.spawnGroup(); 31 | for (Snow snow : this.snows) { 32 | RenderHelper.renderParticle(snow.x, height - snow.y, 4, 4, this.source[snow.source % this.source.length]); 33 | snow.move(); 34 | if (snow.y > height) { 35 | snow.removed = true; 36 | } 37 | } 38 | if (this.snows.size() > 500) { 39 | int i = 0; 40 | while (i < this.snows.size() && this.snows.get(i).removed) this.snows.remove(i); 41 | } 42 | } 43 | 44 | public void spawnGroup() { 45 | this.amount += 0.001f; 46 | float realAmount = Math.min(0.4f, this.amount); 47 | if (realAmount < 1) { 48 | if (this.random.nextInt((int) (1 / realAmount)) == 0) this.spawn(); 49 | } else { 50 | for (int i = 1; i <= realAmount; ++i) this.spawn(); 51 | } 52 | if (this.amount >= 0.6f) this.amount = 0.1f; 53 | } 54 | 55 | public int getSourceIndex() { 56 | return this.random.nextInt(this.source.length); 57 | } 58 | 59 | public void spawn() { 60 | int x = random.nextInt(this.lastWidth); 61 | int k = (random.nextInt(4)) * 2 + 1; 62 | this.snows.add(new Snow(x, random.nextInt(2) == 0 ? -k : k, this.getSourceIndex())); 63 | } 64 | 65 | } 66 | 67 | class Snow { 68 | public int baseX, x, y, k, source; 69 | public boolean removed = false; 70 | public Snow(int x, int k, int source) { 71 | this.baseX = this.x = x; 72 | this.k = k; 73 | this.source = source; 74 | this.y = 0; 75 | } 76 | public void move() { 77 | this.y++; 78 | this.x = this.baseX + this.y / this.k; 79 | } 80 | } -------------------------------------------------------------------------------- /Fabric-1.20.4/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusConfig.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.FileWriter; 6 | import java.io.IOException; 7 | import java.util.Properties; 8 | import java.util.Random; 9 | 10 | public class XibaoPlusPlusConfig { 11 | private static final File file = new File("xibao_plus_plus.properties"); 12 | 13 | public static boolean shouldPlayMusic = false; 14 | public static boolean tempSnow = false; 15 | public static Random random = new Random(); 16 | 17 | public static boolean playMusic = true; 18 | public static boolean showPicture = true; 19 | public static boolean displaySnow = false; 20 | 21 | public static XibaoType type = XibaoType.XIBAO; 22 | 23 | public static void loadConfig() throws Exception { 24 | if (!file.exists()) { 25 | storeConfig(); 26 | return; 27 | } 28 | Properties properties = new Properties(); 29 | properties.load(new FileInputStream(file)); 30 | playMusic = properties.getOrDefault("playMusic", "true").equals("true"); 31 | showPicture = properties.getOrDefault("showPicture", "true").equals("true"); 32 | displaySnow = properties.getOrDefault("displaySnow", "false").equals("true"); 33 | type = XibaoType.getByString(properties.getProperty("type")); 34 | } 35 | 36 | public static void storeConfig() throws IOException { 37 | Properties properties = new Properties(); 38 | properties.setProperty("playMusic", String.valueOf(playMusic)); 39 | properties.setProperty("showPicture", String.valueOf(showPicture)); 40 | properties.setProperty("displaySnow", String.valueOf(displaySnow)); 41 | properties.setProperty("type", type.type); 42 | properties.store(new FileWriter(file), "Xibao Plus Plus"); 43 | } 44 | 45 | public static void switchAlbum() { 46 | XibaoType[] types = XibaoType.values(); 47 | type = types[(type.ordinal() + 1) % types.length]; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Fabric-1.20.4/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusMain.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.fabricmc.api.ClientModInitializer; 4 | import net.fabricmc.api.EnvType; 5 | import net.fabricmc.api.Environment; 6 | 7 | @Environment(EnvType.CLIENT) 8 | public class XibaoPlusPlusMain implements ClientModInitializer { 9 | @Override 10 | public void onInitializeClient() { 11 | try { 12 | XibaoPlusPlusConfig.loadConfig(); 13 | } catch (Exception e) { 14 | throw new RuntimeException(e); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Fabric-1.20.4/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusMusic.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.registry.Registries; 4 | import net.minecraft.registry.Registry; 5 | import net.minecraft.registry.entry.RegistryEntry; 6 | import net.minecraft.sound.MusicSound; 7 | import net.minecraft.sound.SoundEvent; 8 | import net.minecraft.util.Identifier; 9 | 10 | public class XibaoPlusPlusMusic { 11 | public static RegistryEntry.Reference XIBAO_SOUND_EVENT = registerReference(new Identifier("xibaopp", "xibao")); 12 | public static MusicSound XIBAO_MUSIC = new MusicSound(XIBAO_SOUND_EVENT, 0, 0, true); 13 | public static RegistryEntry.Reference BEIBAO_SOUND_EVENT = registerReference(new Identifier("xibaopp", "beibao")); 14 | public static MusicSound BEIBAO_MUSIC = new MusicSound(BEIBAO_SOUND_EVENT, 0, 0, true); 15 | 16 | private static RegistryEntry.Reference registerReference(Identifier id) { 17 | return registerReference(id, id); 18 | } 19 | private static RegistryEntry.Reference registerReference(Identifier id, Identifier soundId) { 20 | return Registry.registerReference(Registries.SOUND_EVENT, id, SoundEvent.of(soundId)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Fabric-1.20.4/src/main/java/top/gregtao/xibaopp/XibaoType.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.sound.MusicSound; 4 | import net.minecraft.util.Identifier; 5 | 6 | public enum XibaoType { 7 | XIBAO( 8 | XibaoPlusPlusMusic.XIBAO_MUSIC, 9 | new Identifier("xibaopp", "textures/xibao.png"), 10 | new Identifier[] { 11 | new Identifier("xibaopp", "textures/yellow_snow.png"), 12 | new Identifier("xibaopp", "textures/red_snow.png") 13 | }, 14 | "xibao" 15 | ), 16 | BEIBAO( 17 | XibaoPlusPlusMusic.BEIBAO_MUSIC, 18 | new Identifier("xibaopp", "textures/beibao.png"), 19 | new Identifier[] { 20 | new Identifier("xibaopp", "textures/white_snow.png") 21 | }, 22 | "beibao" 23 | ) 24 | ; 25 | public final MusicSound music; 26 | public final Identifier background; 27 | public final Identifier[] snows; 28 | public final String type; 29 | 30 | XibaoType(MusicSound music, Identifier background, Identifier[] snows, String type) { 31 | this.music = music; 32 | this.background = background; 33 | this.snows = snows; 34 | this.type = type; 35 | } 36 | 37 | public static XibaoType getByString(String type) { 38 | for (XibaoType xibaoType : values()) { 39 | if (type.equals(xibaoType.type)) return xibaoType; 40 | } 41 | return XIBAO; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Fabric-1.20.4/src/main/java/top/gregtao/xibaopp/mixin/DisconnectedScreenAccessor.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.gui.screen.DisconnectedScreen; 6 | import net.minecraft.text.Text; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.gen.Accessor; 9 | 10 | @Environment(EnvType.CLIENT) 11 | @Mixin(DisconnectedScreen.class) 12 | public interface DisconnectedScreenAccessor { 13 | 14 | @Accessor("reason") 15 | Text getReason(); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /Fabric-1.20.4/src/main/java/top/gregtao/xibaopp/mixin/DisconnectedScreenMixin.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.gui.screen.DisconnectedScreen; 6 | import net.minecraft.client.gui.screen.Screen; 7 | import net.minecraft.client.gui.widget.ButtonWidget; 8 | import net.minecraft.text.Text; 9 | import org.spongepowered.asm.mixin.Mixin; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 13 | import top.gregtao.xibaopp.SnowAnimation; 14 | import top.gregtao.xibaopp.BackgroundWidget; 15 | import top.gregtao.xibaopp.XibaoPlusPlusConfig; 16 | 17 | @Environment(EnvType.CLIENT) 18 | @Mixin(DisconnectedScreen.class) 19 | public class DisconnectedScreenMixin extends Screen { 20 | 21 | protected DisconnectedScreenMixin(Text title) { 22 | super(title); 23 | } 24 | 25 | @Inject(method = "init", at = @At("TAIL")) 26 | private void initInject(CallbackInfo ci) { 27 | XibaoPlusPlusConfig.shouldPlayMusic = true; 28 | XibaoPlusPlusConfig.tempSnow = false; 29 | this.addDrawableChild(ButtonWidget.builder(Text.translatable("gui.stopMusic"), 30 | button -> XibaoPlusPlusConfig.shouldPlayMusic = !XibaoPlusPlusConfig.shouldPlayMusic) 31 | .dimensions(this.width / 2 - 100, this.height - 22, 66, 20).build()); 32 | this.addDrawableChild(ButtonWidget.builder( 33 | Text.translatable("gui.dropSnow"), 34 | button -> { 35 | SnowAnimation.INSTANCE = new SnowAnimation(XibaoPlusPlusConfig.random); 36 | XibaoPlusPlusConfig.tempSnow = !XibaoPlusPlusConfig.tempSnow; 37 | }).dimensions(this.width / 2 - 33, this.height - 22, 66, 20).build()); 38 | this.addDrawableChild(ButtonWidget.builder( 39 | Text.translatable("gui.switchAlbum"), 40 | button -> XibaoPlusPlusConfig.switchAlbum()) 41 | .dimensions(this.width / 2 + 34, this.height - 22, 66, 20).build()); 42 | if (XibaoPlusPlusConfig.displaySnow) SnowAnimation.INSTANCE = new SnowAnimation(XibaoPlusPlusConfig.random); 43 | this.addDrawableChild(new BackgroundWidget()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Fabric-1.20.4/src/main/java/top/gregtao/xibaopp/mixin/MinecraftClientMixin.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.MinecraftClient; 6 | import net.minecraft.client.gui.screen.DisconnectedScreen; 7 | import net.minecraft.sound.MusicSound; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 12 | import top.gregtao.xibaopp.XibaoPlusPlusConfig; 13 | 14 | @Environment(EnvType.CLIENT) 15 | @Mixin(MinecraftClient.class) 16 | public class MinecraftClientMixin { 17 | 18 | @Inject(method = "getMusicType", at = @At("TAIL"), cancellable = true) 19 | public void getMusicTypeInject(CallbackInfoReturnable cir) { 20 | if (XibaoPlusPlusConfig.playMusic && XibaoPlusPlusConfig.shouldPlayMusic) { 21 | if (MinecraftClient.getInstance().currentScreen instanceof DisconnectedScreen) { 22 | cir.setReturnValue(XibaoPlusPlusConfig.type.music); 23 | } 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Fabric-1.20.4/src/main/java/top/gregtao/xibaopp/util/RenderHelper.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.util; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import net.minecraft.client.render.*; 5 | import net.minecraft.util.Identifier; 6 | 7 | public class RenderHelper { 8 | public static void renderStretchTexture(int width, int height, int light, Identifier source) { 9 | Tessellator tessellator = Tessellator.getInstance(); 10 | BufferBuilder bufferBuilder = tessellator.getBuffer(); 11 | RenderSystem.setShader(GameRenderer::getPositionTexColorProgram); 12 | RenderSystem.setShaderTexture(0, source); 13 | RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); 14 | bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); 15 | bufferBuilder.vertex(0.0D, height, -1.0D).texture(0, 1).color(light, light, light, 255).next(); 16 | bufferBuilder.vertex(width, height, -1.0D).texture(1, 1).color(light, light, light, 255).next(); 17 | bufferBuilder.vertex(width, 0.0D, -1.0D).texture(1, 0).color(light, light, light, 255).next(); 18 | bufferBuilder.vertex(0.0D, 0.0D, -1.0D).texture(0, 0).color(light, light, light, 255).next(); 19 | tessellator.draw(); 20 | } 21 | 22 | public static void renderParticle(int x, int y, int width, int height, Identifier source) { 23 | Tessellator tessellator = Tessellator.getInstance(); 24 | BufferBuilder bufferBuilder = tessellator.getBuffer(); 25 | RenderSystem.setShader(GameRenderer::getPositionTexColorProgram); 26 | RenderSystem.setShaderTexture(0, source); 27 | RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); 28 | bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); 29 | bufferBuilder.vertex(0.0D + x, height + y, 0.0D).texture(0, 1).color(255, 255, 255, 255).next(); 30 | bufferBuilder.vertex(width + x, height + y, 0.0D).texture(1, 1).color(255, 255, 255, 255).next(); 31 | bufferBuilder.vertex(width + x, 0.0D + y, 0.0D).texture(1, 0).color(255, 255, 255, 255).next(); 32 | bufferBuilder.vertex(0.0D + x, 0.0D + y, 0.0D).texture(0, 0).color(255, 255, 255, 255).next(); 33 | tessellator.draw(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Fabric-1.20.4/src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "xibaopp", 4 | "version": "${version}", 5 | 6 | "name": "Xibao", 7 | "description": "Congratulations! You had lost the connection!", 8 | "authors": [ 9 | "GregTao", 10 | "TeaCon(灵感)" 11 | ], 12 | "contact": { 13 | "email": "本模组内容若有侵权请联系gregtaoo@outlook.com删除" 14 | }, 15 | 16 | "license": "GPL v3", 17 | "icon": "assets/xibaopp/textures/logo.png", 18 | 19 | "environment": "*", 20 | "entrypoints": { 21 | "client": [ 22 | "top.gregtao.xibaopp.XibaoPlusPlusMain" 23 | ] 24 | }, 25 | "mixins": [ 26 | "xibaopp.mixins.json" 27 | ], 28 | 29 | "depends": { 30 | "fabricloader": ">=0.14.6", 31 | "fabric": "*", 32 | "minecraft": "1.20.4", 33 | "java": ">=17" 34 | }, 35 | "suggests": { 36 | "another-mod": "*" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Fabric-1.20.4/src/main/resources/xibaopp.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "top.gregtao.xibaopp.mixin", 5 | "compatibilityLevel": "JAVA_17", 6 | "mixins": [ 7 | ], 8 | "client": [ 9 | "DisconnectedScreenAccessor", 10 | "DisconnectedScreenMixin", 11 | "MinecraftClientMixin" 12 | ], 13 | "injectors": { 14 | "defaultRequire": 1 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Fabric-1.20.6/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx2G 2 | loom.platform=fabric 3 | 4 | minecraft_version=1.20.6 5 | yarn_mappings=1.20.6+build.1 6 | loader_version=0.15.11 7 | 8 | mod_version = 0.2.0-release-mc1.20.6 9 | maven_group = top.gregtao.xibaopp 10 | archives_base_name = XibaoPlusPlus-Fabric 11 | 12 | fabric_version=0.98.0+1.20.6 -------------------------------------------------------------------------------- /Fabric-1.20.6/src/main/java/top/gregtao/xibaopp/BackgroundWidget.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.client.MinecraftClient; 4 | import net.minecraft.client.gui.DrawContext; 5 | import net.minecraft.client.gui.Drawable; 6 | import net.minecraft.client.gui.Element; 7 | import net.minecraft.client.gui.Selectable; 8 | import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; 9 | import net.minecraft.client.util.Window; 10 | import top.gregtao.xibaopp.util.RenderHelper; 11 | 12 | public class BackgroundWidget implements Drawable, Element, Selectable { 13 | 14 | @Override 15 | public void render(DrawContext context, int mouseX, int mouseY, float delta) { 16 | MinecraftClient client = MinecraftClient.getInstance(); 17 | Window window = client.getWindow(); 18 | int width = window.getScaledWidth(), height = window.getScaledHeight(); 19 | if (XibaoPlusPlusConfig.showPicture) { 20 | RenderHelper.renderStretchTexture(width, height, 225, 21 | XibaoPlusPlusConfig.type.background); 22 | } 23 | if (XibaoPlusPlusConfig.displaySnow || XibaoPlusPlusConfig.tempSnow) { 24 | SnowAnimation.INSTANCE.tick(width, height, XibaoPlusPlusConfig.type.snows); 25 | } 26 | } 27 | 28 | @Override 29 | public void setFocused(boolean focused) { 30 | } 31 | 32 | @Override 33 | public boolean isFocused() { 34 | return false; 35 | } 36 | 37 | @Override 38 | public SelectionType getType() { 39 | return Selectable.SelectionType.NONE; 40 | } 41 | 42 | @Override 43 | public void appendNarrations(NarrationMessageBuilder builder) { 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Fabric-1.20.6/src/main/java/top/gregtao/xibaopp/SnowAnimation.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.util.Identifier; 4 | import top.gregtao.xibaopp.util.RenderHelper; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import java.util.Random; 9 | 10 | public class SnowAnimation { 11 | public static SnowAnimation INSTANCE; 12 | private Identifier[] source; 13 | private int lastWidth, lastHeight; 14 | private float amount = 0.1f; 15 | private final Random random; 16 | private final List snows; 17 | 18 | public SnowAnimation(Random random) { 19 | this.random = random; 20 | this.snows = new ArrayList<>(); 21 | } 22 | 23 | public void tick(int width, int height, Identifier[] source) { 24 | this.source = source; 25 | if (width != this.lastWidth || height != this.lastHeight) { 26 | this.snows.clear(); 27 | this.lastWidth = width; 28 | this.lastHeight = height; 29 | } 30 | this.spawnGroup(); 31 | for (Snow snow : this.snows) { 32 | RenderHelper.renderParticle(snow.x, height - snow.y, 4, 4, this.source[snow.source % this.source.length]); 33 | snow.move(); 34 | if (snow.y > height) { 35 | snow.removed = true; 36 | } 37 | } 38 | if (this.snows.size() > 500) { 39 | int i = 0; 40 | while (i < this.snows.size() && this.snows.get(i).removed) this.snows.remove(i); 41 | } 42 | } 43 | 44 | public void spawnGroup() { 45 | this.amount += 0.001f; 46 | float realAmount = Math.min(0.4f, this.amount); 47 | if (realAmount < 1) { 48 | if (this.random.nextInt((int) (1 / realAmount)) == 0) this.spawn(); 49 | } else { 50 | for (int i = 1; i <= realAmount; ++i) this.spawn(); 51 | } 52 | if (this.amount >= 0.6f) this.amount = 0.1f; 53 | } 54 | 55 | public int getSourceIndex() { 56 | return this.random.nextInt(this.source.length); 57 | } 58 | 59 | public void spawn() { 60 | int x = random.nextInt(this.lastWidth); 61 | int k = (random.nextInt(4)) * 2 + 1; 62 | this.snows.add(new Snow(x, random.nextInt(2) == 0 ? -k : k, this.getSourceIndex())); 63 | } 64 | 65 | } 66 | 67 | class Snow { 68 | public int baseX, x, y, k, source; 69 | public boolean removed = false; 70 | public Snow(int x, int k, int source) { 71 | this.baseX = this.x = x; 72 | this.k = k; 73 | this.source = source; 74 | this.y = 0; 75 | } 76 | public void move() { 77 | this.y++; 78 | this.x = this.baseX + this.y / this.k; 79 | } 80 | } -------------------------------------------------------------------------------- /Fabric-1.20.6/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusConfig.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.FileWriter; 6 | import java.io.IOException; 7 | import java.util.Properties; 8 | import java.util.Random; 9 | 10 | public class XibaoPlusPlusConfig { 11 | private static final File file = new File("xibao_plus_plus.properties"); 12 | 13 | public static boolean shouldPlayMusic = false; 14 | public static boolean tempSnow = false; 15 | public static Random random = new Random(); 16 | 17 | public static boolean playMusic = true; 18 | public static boolean showPicture = true; 19 | public static boolean displaySnow = false; 20 | 21 | public static XibaoType type = XibaoType.XIBAO; 22 | 23 | public static void loadConfig() throws Exception { 24 | if (!file.exists()) { 25 | storeConfig(); 26 | return; 27 | } 28 | Properties properties = new Properties(); 29 | properties.load(new FileInputStream(file)); 30 | playMusic = properties.getOrDefault("playMusic", "true").equals("true"); 31 | showPicture = properties.getOrDefault("showPicture", "true").equals("true"); 32 | displaySnow = properties.getOrDefault("displaySnow", "false").equals("true"); 33 | type = XibaoType.getByString(properties.getProperty("type")); 34 | } 35 | 36 | public static void storeConfig() throws IOException { 37 | Properties properties = new Properties(); 38 | properties.setProperty("playMusic", String.valueOf(playMusic)); 39 | properties.setProperty("showPicture", String.valueOf(showPicture)); 40 | properties.setProperty("displaySnow", String.valueOf(displaySnow)); 41 | properties.setProperty("type", type.type); 42 | properties.store(new FileWriter(file), "Xibao Plus Plus"); 43 | } 44 | 45 | public static void switchAlbum() { 46 | XibaoType[] types = XibaoType.values(); 47 | type = types[(type.ordinal() + 1) % types.length]; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Fabric-1.20.6/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusMain.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.fabricmc.api.ClientModInitializer; 4 | import net.fabricmc.api.EnvType; 5 | import net.fabricmc.api.Environment; 6 | 7 | @Environment(EnvType.CLIENT) 8 | public class XibaoPlusPlusMain implements ClientModInitializer { 9 | @Override 10 | public void onInitializeClient() { 11 | try { 12 | XibaoPlusPlusConfig.loadConfig(); 13 | } catch (Exception e) { 14 | throw new RuntimeException(e); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Fabric-1.20.6/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusMusic.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.registry.Registries; 4 | import net.minecraft.registry.Registry; 5 | import net.minecraft.registry.entry.RegistryEntry; 6 | import net.minecraft.sound.MusicSound; 7 | import net.minecraft.sound.SoundEvent; 8 | import net.minecraft.util.Identifier; 9 | 10 | public class XibaoPlusPlusMusic { 11 | public static RegistryEntry.Reference XIBAO_SOUND_EVENT = registerReference(new Identifier("xibaopp", "xibao")); 12 | public static MusicSound XIBAO_MUSIC = new MusicSound(XIBAO_SOUND_EVENT, 0, 0, true); 13 | public static RegistryEntry.Reference BEIBAO_SOUND_EVENT = registerReference(new Identifier("xibaopp", "beibao")); 14 | public static MusicSound BEIBAO_MUSIC = new MusicSound(BEIBAO_SOUND_EVENT, 0, 0, true); 15 | 16 | private static RegistryEntry.Reference registerReference(Identifier id) { 17 | return registerReference(id, id); 18 | } 19 | private static RegistryEntry.Reference registerReference(Identifier id, Identifier soundId) { 20 | return Registry.registerReference(Registries.SOUND_EVENT, id, SoundEvent.of(soundId)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Fabric-1.20.6/src/main/java/top/gregtao/xibaopp/XibaoType.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.sound.MusicSound; 4 | import net.minecraft.util.Identifier; 5 | 6 | public enum XibaoType { 7 | XIBAO( 8 | XibaoPlusPlusMusic.XIBAO_MUSIC, 9 | new Identifier("xibaopp", "textures/xibao.png"), 10 | new Identifier[] { 11 | new Identifier("xibaopp", "textures/yellow_snow.png"), 12 | new Identifier("xibaopp", "textures/red_snow.png") 13 | }, 14 | "xibao" 15 | ), 16 | BEIBAO( 17 | XibaoPlusPlusMusic.BEIBAO_MUSIC, 18 | new Identifier("xibaopp", "textures/beibao.png"), 19 | new Identifier[] { 20 | new Identifier("xibaopp", "textures/white_snow.png") 21 | }, 22 | "beibao" 23 | ) 24 | ; 25 | public final MusicSound music; 26 | public final Identifier background; 27 | public final Identifier[] snows; 28 | public final String type; 29 | 30 | XibaoType(MusicSound music, Identifier background, Identifier[] snows, String type) { 31 | this.music = music; 32 | this.background = background; 33 | this.snows = snows; 34 | this.type = type; 35 | } 36 | 37 | public static XibaoType getByString(String type) { 38 | for (XibaoType xibaoType : values()) { 39 | if (type.equals(xibaoType.type)) return xibaoType; 40 | } 41 | return XIBAO; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Fabric-1.20.6/src/main/java/top/gregtao/xibaopp/mixin/DisconnectedScreenAccessor.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.gui.screen.DisconnectedScreen; 6 | import net.minecraft.text.Text; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.gen.Accessor; 9 | 10 | @Environment(EnvType.CLIENT) 11 | @Mixin(DisconnectedScreen.class) 12 | public interface DisconnectedScreenAccessor { 13 | 14 | @Accessor("reason") 15 | Text getReason(); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /Fabric-1.20.6/src/main/java/top/gregtao/xibaopp/mixin/DisconnectedScreenMixin.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.gui.screen.DisconnectedScreen; 6 | import net.minecraft.client.gui.screen.Screen; 7 | import net.minecraft.client.gui.widget.ButtonWidget; 8 | import net.minecraft.text.Text; 9 | import org.spongepowered.asm.mixin.Mixin; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 13 | import top.gregtao.xibaopp.SnowAnimation; 14 | import top.gregtao.xibaopp.BackgroundWidget; 15 | import top.gregtao.xibaopp.XibaoPlusPlusConfig; 16 | 17 | @Environment(EnvType.CLIENT) 18 | @Mixin(DisconnectedScreen.class) 19 | public class DisconnectedScreenMixin extends Screen { 20 | 21 | protected DisconnectedScreenMixin(Text title) { 22 | super(title); 23 | } 24 | 25 | @Inject(method = "init", at = @At("TAIL")) 26 | private void initInject(CallbackInfo ci) { 27 | XibaoPlusPlusConfig.shouldPlayMusic = true; 28 | XibaoPlusPlusConfig.tempSnow = false; 29 | this.addDrawableChild(ButtonWidget.builder(Text.translatable("gui.stopMusic"), 30 | button -> XibaoPlusPlusConfig.shouldPlayMusic = !XibaoPlusPlusConfig.shouldPlayMusic) 31 | .dimensions(this.width / 2 - 100, this.height - 22, 66, 20).build()); 32 | this.addDrawableChild(ButtonWidget.builder( 33 | Text.translatable("gui.dropSnow"), 34 | button -> { 35 | SnowAnimation.INSTANCE = new SnowAnimation(XibaoPlusPlusConfig.random); 36 | XibaoPlusPlusConfig.tempSnow = !XibaoPlusPlusConfig.tempSnow; 37 | }).dimensions(this.width / 2 - 33, this.height - 22, 66, 20).build()); 38 | this.addDrawableChild(ButtonWidget.builder( 39 | Text.translatable("gui.switchAlbum"), 40 | button -> XibaoPlusPlusConfig.switchAlbum()) 41 | .dimensions(this.width / 2 + 34, this.height - 22, 66, 20).build()); 42 | if (XibaoPlusPlusConfig.displaySnow) SnowAnimation.INSTANCE = new SnowAnimation(XibaoPlusPlusConfig.random); 43 | this.addDrawableChild(new BackgroundWidget()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Fabric-1.20.6/src/main/java/top/gregtao/xibaopp/mixin/MinecraftClientMixin.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.MinecraftClient; 6 | import net.minecraft.client.gui.screen.DisconnectedScreen; 7 | import net.minecraft.sound.MusicSound; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 12 | import top.gregtao.xibaopp.XibaoPlusPlusConfig; 13 | 14 | @Environment(EnvType.CLIENT) 15 | @Mixin(MinecraftClient.class) 16 | public class MinecraftClientMixin { 17 | 18 | @Inject(method = "getMusicType", at = @At("TAIL"), cancellable = true) 19 | public void getMusicTypeInject(CallbackInfoReturnable cir) { 20 | if (XibaoPlusPlusConfig.playMusic && XibaoPlusPlusConfig.shouldPlayMusic) { 21 | if (MinecraftClient.getInstance().currentScreen instanceof DisconnectedScreen) { 22 | cir.setReturnValue(XibaoPlusPlusConfig.type.music); 23 | } 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Fabric-1.20.6/src/main/java/top/gregtao/xibaopp/mixin/ScreenMixin.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.minecraft.client.MinecraftClient; 4 | import net.minecraft.client.gui.DrawContext; 5 | import net.minecraft.client.gui.screen.DisconnectedScreen; 6 | import net.minecraft.client.gui.screen.Screen; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Inject; 10 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 11 | 12 | @Mixin(Screen.class) 13 | public abstract class ScreenMixin { 14 | 15 | @Inject(method = "renderBackground(Lnet/minecraft/client/gui/DrawContext;IIF)V", at = @At("HEAD"), cancellable = true) 16 | public void renderBackgroundInject(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) { 17 | Screen screen = MinecraftClient.getInstance().currentScreen; 18 | if (screen instanceof DisconnectedScreen) { 19 | ci.cancel(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Fabric-1.20.6/src/main/java/top/gregtao/xibaopp/util/RenderHelper.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.util; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import net.minecraft.client.render.*; 5 | import net.minecraft.util.Identifier; 6 | 7 | public class RenderHelper { 8 | public static void renderStretchTexture(int width, int height, int light, Identifier source) { 9 | Tessellator tessellator = Tessellator.getInstance(); 10 | BufferBuilder bufferBuilder = tessellator.getBuffer(); 11 | RenderSystem.setShader(GameRenderer::getPositionTexColorProgram); 12 | RenderSystem.setShaderTexture(0, source); 13 | RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); 14 | bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); 15 | bufferBuilder.vertex(0.0D, height, -1.0D).texture(0, 1).color(light, light, light, 255).next(); 16 | bufferBuilder.vertex(width, height, -1.0D).texture(1, 1).color(light, light, light, 255).next(); 17 | bufferBuilder.vertex(width, 0.0D, -1.0D).texture(1, 0).color(light, light, light, 255).next(); 18 | bufferBuilder.vertex(0.0D, 0.0D, -1.0D).texture(0, 0).color(light, light, light, 255).next(); 19 | tessellator.draw(); 20 | } 21 | 22 | public static void renderParticle(int x, int y, int width, int height, Identifier source) { 23 | Tessellator tessellator = Tessellator.getInstance(); 24 | BufferBuilder bufferBuilder = tessellator.getBuffer(); 25 | RenderSystem.setShader(GameRenderer::getPositionTexColorProgram); 26 | RenderSystem.setShaderTexture(0, source); 27 | RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); 28 | bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); 29 | bufferBuilder.vertex(0.0D + x, height + y, 0.0D).texture(0, 1).color(255, 255, 255, 255).next(); 30 | bufferBuilder.vertex(width + x, height + y, 0.0D).texture(1, 1).color(255, 255, 255, 255).next(); 31 | bufferBuilder.vertex(width + x, 0.0D + y, 0.0D).texture(1, 0).color(255, 255, 255, 255).next(); 32 | bufferBuilder.vertex(0.0D + x, 0.0D + y, 0.0D).texture(0, 0).color(255, 255, 255, 255).next(); 33 | tessellator.draw(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Fabric-1.20.6/src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "xibaopp", 4 | "version": "${version}", 5 | 6 | "name": "Xibao", 7 | "description": "Congratulations! You had lost the connection!", 8 | "authors": [ 9 | "GregTao", 10 | "TeaCon(灵感)" 11 | ], 12 | "contact": { 13 | "email": "本模组内容若有侵权请联系gregtaoo@outlook.com删除" 14 | }, 15 | 16 | "license": "GPL v3", 17 | "icon": "assets/xibaopp/textures/logo.png", 18 | 19 | "environment": "*", 20 | "entrypoints": { 21 | "client": [ 22 | "top.gregtao.xibaopp.XibaoPlusPlusMain" 23 | ] 24 | }, 25 | "mixins": [ 26 | "xibaopp.mixins.json" 27 | ], 28 | 29 | "depends": { 30 | "fabricloader": ">=0.14.6", 31 | "fabric": "*", 32 | "minecraft": "1.20.6", 33 | "java": ">=21" 34 | }, 35 | "suggests": { 36 | "another-mod": "*" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Fabric-1.20.6/src/main/resources/xibaopp.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "top.gregtao.xibaopp.mixin", 5 | "compatibilityLevel": "JAVA_21", 6 | "mixins": [ 7 | ], 8 | "client": [ 9 | "DisconnectedScreenAccessor", 10 | "DisconnectedScreenMixin", 11 | "MinecraftClientMixin", 12 | "ScreenMixin" 13 | ], 14 | "injectors": { 15 | "defaultRequire": 1 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Fabric-1.20/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx2G 2 | loom.platform=fabric 3 | 4 | minecraft_version=1.20 5 | yarn_mappings=1.20+build.1 6 | loader_version=0.14.12 7 | 8 | mod_version = 0.2.0-release-mc1.20 9 | maven_group = top.gregtao.xibaopp 10 | archives_base_name = XibaoPlusPlus-Fabric 11 | 12 | fabric_version=0.83.0+1.20 -------------------------------------------------------------------------------- /Fabric-1.20/src/main/java/top/gregtao/xibaopp/SnowAnimation.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.util.Identifier; 4 | import top.gregtao.xibaopp.util.RenderHelper; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import java.util.Random; 9 | 10 | public class SnowAnimation { 11 | public static SnowAnimation INSTANCE; 12 | private Identifier[] source; 13 | private int lastWidth, lastHeight; 14 | private float amount = 0.1f; 15 | private final Random random; 16 | private final List snows; 17 | 18 | public SnowAnimation(Random random) { 19 | this.random = random; 20 | this.snows = new ArrayList<>(); 21 | } 22 | 23 | public void tick(int width, int height, Identifier[] source) { 24 | this.source = source; 25 | if (width != this.lastWidth || height != this.lastHeight) { 26 | this.snows.clear(); 27 | this.lastWidth = width; 28 | this.lastHeight = height; 29 | } 30 | this.spawnGroup(); 31 | for (Snow snow : this.snows) { 32 | RenderHelper.renderParticle(snow.x, height - snow.y, 4, 4, this.source[snow.source % this.source.length]); 33 | snow.move(); 34 | if (snow.y > height) { 35 | snow.removed = true; 36 | } 37 | } 38 | if (this.snows.size() > 500) { 39 | int i = 0; 40 | while (i < this.snows.size() && this.snows.get(i).removed) this.snows.remove(i); 41 | } 42 | } 43 | 44 | public void spawnGroup() { 45 | this.amount += 0.001f; 46 | float realAmount = Math.min(0.4f, this.amount); 47 | if (realAmount < 1) { 48 | if (this.random.nextInt((int) (1 / realAmount)) == 0) this.spawn(); 49 | } else { 50 | for (int i = 1; i <= realAmount; ++i) this.spawn(); 51 | } 52 | if (this.amount >= 0.6f) this.amount = 0.1f; 53 | } 54 | 55 | public int getSourceIndex() { 56 | return this.random.nextInt(this.source.length); 57 | } 58 | 59 | public void spawn() { 60 | int x = random.nextInt(this.lastWidth); 61 | int k = (random.nextInt(4)) * 2 + 1; 62 | this.snows.add(new Snow(x, random.nextInt(2) == 0 ? -k : k, this.getSourceIndex())); 63 | } 64 | 65 | } 66 | 67 | class Snow { 68 | public int baseX, x, y, k, source; 69 | public boolean removed = false; 70 | public Snow(int x, int k, int source) { 71 | this.baseX = this.x = x; 72 | this.k = k; 73 | this.source = source; 74 | this.y = 0; 75 | } 76 | public void move() { 77 | this.y++; 78 | this.x = this.baseX + this.y / this.k; 79 | } 80 | } -------------------------------------------------------------------------------- /Fabric-1.20/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusConfig.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.FileWriter; 6 | import java.io.IOException; 7 | import java.util.Properties; 8 | import java.util.Random; 9 | 10 | public class XibaoPlusPlusConfig { 11 | private static final File file = new File("xibao_plus_plus.properties"); 12 | 13 | public static boolean shouldPlayMusic = false; 14 | public static boolean tempSnow = false; 15 | public static Random random = new Random(); 16 | 17 | public static boolean playMusic = true; 18 | public static boolean showPicture = true; 19 | public static boolean displaySnow = false; 20 | 21 | public static XibaoType type = XibaoType.XIBAO; 22 | 23 | public static void loadConfig() throws Exception { 24 | if (!file.exists()) { 25 | storeConfig(); 26 | return; 27 | } 28 | Properties properties = new Properties(); 29 | properties.load(new FileInputStream(file)); 30 | playMusic = properties.getOrDefault("playMusic", "true").equals("true"); 31 | showPicture = properties.getOrDefault("showPicture", "true").equals("true"); 32 | displaySnow = properties.getOrDefault("displaySnow", "false").equals("true"); 33 | type = XibaoType.getByString(properties.getProperty("type")); 34 | } 35 | 36 | public static void storeConfig() throws IOException { 37 | Properties properties = new Properties(); 38 | properties.setProperty("playMusic", String.valueOf(playMusic)); 39 | properties.setProperty("showPicture", String.valueOf(showPicture)); 40 | properties.setProperty("displaySnow", String.valueOf(displaySnow)); 41 | properties.setProperty("type", type.type); 42 | properties.store(new FileWriter(file), "Xibao Plus Plus"); 43 | } 44 | 45 | public static void switchAlbum() { 46 | XibaoType[] types = XibaoType.values(); 47 | type = types[(type.ordinal() + 1) % types.length]; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Fabric-1.20/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusMain.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.fabricmc.api.ClientModInitializer; 4 | import net.fabricmc.api.EnvType; 5 | import net.fabricmc.api.Environment; 6 | 7 | @Environment(EnvType.CLIENT) 8 | public class XibaoPlusPlusMain implements ClientModInitializer { 9 | @Override 10 | public void onInitializeClient() { 11 | try { 12 | XibaoPlusPlusConfig.loadConfig(); 13 | } catch (Exception e) { 14 | throw new RuntimeException(e); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Fabric-1.20/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusMusic.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.registry.Registries; 4 | import net.minecraft.registry.Registry; 5 | import net.minecraft.registry.entry.RegistryEntry; 6 | import net.minecraft.sound.MusicSound; 7 | import net.minecraft.sound.SoundEvent; 8 | import net.minecraft.util.Identifier; 9 | 10 | public class XibaoPlusPlusMusic { 11 | public static RegistryEntry.Reference XIBAO_SOUND_EVENT = registerReference(new Identifier("xibaopp", "xibao")); 12 | public static MusicSound XIBAO_MUSIC = new MusicSound(XIBAO_SOUND_EVENT, 0, 0, true); 13 | public static RegistryEntry.Reference BEIBAO_SOUND_EVENT = registerReference(new Identifier("xibaopp", "beibao")); 14 | public static MusicSound BEIBAO_MUSIC = new MusicSound(BEIBAO_SOUND_EVENT, 0, 0, true); 15 | 16 | private static RegistryEntry.Reference registerReference(Identifier id) { 17 | return registerReference(id, id); 18 | } 19 | private static RegistryEntry.Reference registerReference(Identifier id, Identifier soundId) { 20 | return Registry.registerReference(Registries.SOUND_EVENT, id, SoundEvent.of(soundId)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Fabric-1.20/src/main/java/top/gregtao/xibaopp/XibaoType.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.sound.MusicSound; 4 | import net.minecraft.util.Identifier; 5 | 6 | public enum XibaoType { 7 | XIBAO( 8 | XibaoPlusPlusMusic.XIBAO_MUSIC, 9 | new Identifier("xibaopp", "textures/xibao.png"), 10 | new Identifier[] { 11 | new Identifier("xibaopp", "textures/yellow_snow.png"), 12 | new Identifier("xibaopp", "textures/red_snow.png") 13 | }, 14 | "xibao" 15 | ), 16 | BEIBAO( 17 | XibaoPlusPlusMusic.BEIBAO_MUSIC, 18 | new Identifier("xibaopp", "textures/beibao.png"), 19 | new Identifier[] { 20 | new Identifier("xibaopp", "textures/white_snow.png") 21 | }, 22 | "beibao" 23 | ) 24 | ; 25 | public final MusicSound music; 26 | public final Identifier background; 27 | public final Identifier[] snows; 28 | public final String type; 29 | 30 | XibaoType(MusicSound music, Identifier background, Identifier[] snows, String type) { 31 | this.music = music; 32 | this.background = background; 33 | this.snows = snows; 34 | this.type = type; 35 | } 36 | 37 | public static XibaoType getByString(String type) { 38 | for (XibaoType xibaoType : values()) { 39 | if (type.equals(xibaoType.type)) return xibaoType; 40 | } 41 | return XIBAO; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Fabric-1.20/src/main/java/top/gregtao/xibaopp/mixin/DisconnectedScreenAccessor.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.gui.screen.DisconnectedScreen; 6 | import net.minecraft.text.Text; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.gen.Accessor; 9 | 10 | @Environment(EnvType.CLIENT) 11 | @Mixin(DisconnectedScreen.class) 12 | public interface DisconnectedScreenAccessor { 13 | 14 | @Accessor("reason") 15 | Text getReason(); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /Fabric-1.20/src/main/java/top/gregtao/xibaopp/mixin/MinecraftClientMixin.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.MinecraftClient; 6 | import net.minecraft.client.gui.screen.DisconnectedScreen; 7 | import net.minecraft.sound.MusicSound; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 12 | import top.gregtao.xibaopp.XibaoPlusPlusConfig; 13 | 14 | @Environment(EnvType.CLIENT) 15 | @Mixin(MinecraftClient.class) 16 | public class MinecraftClientMixin { 17 | 18 | @Inject(method = "getMusicType", at = @At("TAIL"), cancellable = true) 19 | public void getMusicTypeInject(CallbackInfoReturnable cir) { 20 | if (XibaoPlusPlusConfig.playMusic && XibaoPlusPlusConfig.shouldPlayMusic) { 21 | if (MinecraftClient.getInstance().currentScreen instanceof DisconnectedScreen) { 22 | cir.setReturnValue(XibaoPlusPlusConfig.type.music); 23 | } 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Fabric-1.20/src/main/java/top/gregtao/xibaopp/util/RenderHelper.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.util; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import net.minecraft.client.render.*; 5 | import net.minecraft.util.Identifier; 6 | 7 | public class RenderHelper { 8 | public static void renderStretchTexture(int width, int height, int light, Identifier source) { 9 | Tessellator tessellator = Tessellator.getInstance(); 10 | BufferBuilder bufferBuilder = tessellator.getBuffer(); 11 | RenderSystem.setShader(GameRenderer::getPositionTexColorProgram); 12 | RenderSystem.setShaderTexture(0, source); 13 | RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); 14 | bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); 15 | bufferBuilder.vertex(0.0D, height, 0.0D).texture(0, 1).color(light, light, light, 255).next(); 16 | bufferBuilder.vertex(width, height, 0.0D).texture(1, 1).color(light, light, light, 255).next(); 17 | bufferBuilder.vertex(width, 0.0D, 0.0D).texture(1, 0).color(light, light, light, 255).next(); 18 | bufferBuilder.vertex(0.0D, 0.0D, 0.0D).texture(0, 0).color(light, light, light, 255).next(); 19 | tessellator.draw(); 20 | } 21 | 22 | public static void renderParticle(int x, int y, int width, int height, Identifier source) { 23 | Tessellator tessellator = Tessellator.getInstance(); 24 | BufferBuilder bufferBuilder = tessellator.getBuffer(); 25 | RenderSystem.setShader(GameRenderer::getPositionTexColorProgram); 26 | RenderSystem.setShaderTexture(0, source); 27 | RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); 28 | bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); 29 | bufferBuilder.vertex(0.0D + x, height + y, 0.0D).texture(0, 1).color(255, 255, 255, 255).next(); 30 | bufferBuilder.vertex(width + x, height + y, 0.0D).texture(1, 1).color(255, 255, 255, 255).next(); 31 | bufferBuilder.vertex(width + x, 0.0D + y, 0.0D).texture(1, 0).color(255, 255, 255, 255).next(); 32 | bufferBuilder.vertex(0.0D + x, 0.0D + y, 0.0D).texture(0, 0).color(255, 255, 255, 255).next(); 33 | tessellator.draw(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Fabric-1.20/src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "xibaopp", 4 | "version": "${version}", 5 | 6 | "name": "Xibao", 7 | "description": "Congratulations! You had lost the connection!", 8 | "authors": [ 9 | "GregTao", 10 | "TeaCon(灵感)" 11 | ], 12 | "contact": { 13 | "email": "本模组内容若有侵权请联系gregtaoo@outlook.com删除" 14 | }, 15 | 16 | "license": "GPL v3", 17 | "icon": "assets/xibaopp/textures/logo.png", 18 | 19 | "environment": "*", 20 | "entrypoints": { 21 | "client": [ 22 | "top.gregtao.xibaopp.XibaoPlusPlusMain" 23 | ] 24 | }, 25 | "mixins": [ 26 | "xibaopp.mixins.json" 27 | ], 28 | 29 | "depends": { 30 | "fabricloader": ">=0.14.6", 31 | "fabric": "*", 32 | "minecraft": "1.20", 33 | "java": ">=17" 34 | }, 35 | "suggests": { 36 | "another-mod": "*" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Fabric-1.20/src/main/resources/xibaopp.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "top.gregtao.xibaopp.mixin", 5 | "compatibilityLevel": "JAVA_17", 6 | "mixins": [ 7 | ], 8 | "client": [ 9 | "DisconnectedScreenAccessor", 10 | "DisconnectedScreenMixin", 11 | "MinecraftClientMixin" 12 | ], 13 | "injectors": { 14 | "defaultRequire": 1 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Fabric-1.21.1/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx2G 2 | loom.platform=fabric 3 | 4 | minecraft_version=1.21.1 5 | yarn_mappings=1.21.1+build.3 6 | loader_version=0.16.2 7 | 8 | mod_version = 0.2.0-release-mc1.21.1 9 | maven_group = top.gregtao.xibaopp 10 | archives_base_name = XibaoPlusPlus-Fabric 11 | 12 | fabric_version=0.102.1+1.21.1 -------------------------------------------------------------------------------- /Fabric-1.21.1/src/main/java/top/gregtao/xibaopp/BackgroundWidget.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.client.MinecraftClient; 4 | import net.minecraft.client.gui.DrawContext; 5 | import net.minecraft.client.gui.Drawable; 6 | import net.minecraft.client.gui.Element; 7 | import net.minecraft.client.gui.Selectable; 8 | import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; 9 | import net.minecraft.client.util.Window; 10 | import top.gregtao.xibaopp.util.RenderHelper; 11 | 12 | public class BackgroundWidget implements Drawable, Element, Selectable { 13 | 14 | @Override 15 | public void render(DrawContext context, int mouseX, int mouseY, float delta) { 16 | MinecraftClient client = MinecraftClient.getInstance(); 17 | Window window = client.getWindow(); 18 | int width = window.getScaledWidth(), height = window.getScaledHeight(); 19 | if (XibaoPlusPlusConfig.showPicture) { 20 | RenderHelper.renderStretchTexture(width, height, 225, 21 | XibaoPlusPlusConfig.type.background); 22 | } 23 | if (XibaoPlusPlusConfig.displaySnow || XibaoPlusPlusConfig.tempSnow) { 24 | SnowAnimation.INSTANCE.tick(width, height, XibaoPlusPlusConfig.type.snows); 25 | } 26 | } 27 | 28 | @Override 29 | public void setFocused(boolean focused) { 30 | } 31 | 32 | @Override 33 | public boolean isFocused() { 34 | return false; 35 | } 36 | 37 | @Override 38 | public SelectionType getType() { 39 | return Selectable.SelectionType.NONE; 40 | } 41 | 42 | @Override 43 | public void appendNarrations(NarrationMessageBuilder builder) { 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Fabric-1.21.1/src/main/java/top/gregtao/xibaopp/SnowAnimation.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.util.Identifier; 4 | import top.gregtao.xibaopp.util.RenderHelper; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import java.util.Random; 9 | 10 | public class SnowAnimation { 11 | public static SnowAnimation INSTANCE; 12 | private Identifier[] source; 13 | private int lastWidth, lastHeight; 14 | private float amount = 0.1f; 15 | private final Random random; 16 | private final List snows; 17 | 18 | public SnowAnimation(Random random) { 19 | this.random = random; 20 | this.snows = new ArrayList<>(); 21 | } 22 | 23 | public void tick(int width, int height, Identifier[] source) { 24 | this.source = source; 25 | if (width != this.lastWidth || height != this.lastHeight) { 26 | this.snows.clear(); 27 | this.lastWidth = width; 28 | this.lastHeight = height; 29 | } 30 | this.spawnGroup(); 31 | for (Snow snow : this.snows) { 32 | RenderHelper.renderParticle(snow.x, height - snow.y, 4, 4, this.source[snow.source % this.source.length]); 33 | snow.move(); 34 | if (snow.y > height) { 35 | snow.removed = true; 36 | } 37 | } 38 | if (this.snows.size() > 500) { 39 | int i = 0; 40 | while (i < this.snows.size() && this.snows.get(i).removed) this.snows.remove(i); 41 | } 42 | } 43 | 44 | public void spawnGroup() { 45 | this.amount += 0.001f; 46 | float realAmount = Math.min(0.4f, this.amount); 47 | if (realAmount < 1) { 48 | if (this.random.nextInt((int) (1 / realAmount)) == 0) this.spawn(); 49 | } else { 50 | for (int i = 1; i <= realAmount; ++i) this.spawn(); 51 | } 52 | if (this.amount >= 0.6f) this.amount = 0.1f; 53 | } 54 | 55 | public int getSourceIndex() { 56 | return this.random.nextInt(this.source.length); 57 | } 58 | 59 | public void spawn() { 60 | int x = random.nextInt(this.lastWidth); 61 | int k = (random.nextInt(4)) * 2 + 1; 62 | this.snows.add(new Snow(x, random.nextInt(2) == 0 ? -k : k, this.getSourceIndex())); 63 | } 64 | 65 | } 66 | 67 | class Snow { 68 | public int baseX, x, y, k, source; 69 | public boolean removed = false; 70 | public Snow(int x, int k, int source) { 71 | this.baseX = this.x = x; 72 | this.k = k; 73 | this.source = source; 74 | this.y = 0; 75 | } 76 | public void move() { 77 | this.y++; 78 | this.x = this.baseX + this.y / this.k; 79 | } 80 | } -------------------------------------------------------------------------------- /Fabric-1.21.1/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusConfig.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.FileWriter; 6 | import java.io.IOException; 7 | import java.util.Properties; 8 | import java.util.Random; 9 | 10 | public class XibaoPlusPlusConfig { 11 | private static final File file = new File("xibao_plus_plus.properties"); 12 | 13 | public static boolean shouldPlayMusic = false; 14 | public static boolean tempSnow = false; 15 | public static Random random = new Random(); 16 | 17 | public static boolean playMusic = true; 18 | public static boolean showPicture = true; 19 | public static boolean displaySnow = false; 20 | 21 | public static XibaoType type = XibaoType.XIBAO; 22 | 23 | public static void loadConfig() throws Exception { 24 | if (!file.exists()) { 25 | storeConfig(); 26 | return; 27 | } 28 | Properties properties = new Properties(); 29 | properties.load(new FileInputStream(file)); 30 | playMusic = properties.getOrDefault("playMusic", "true").equals("true"); 31 | showPicture = properties.getOrDefault("showPicture", "true").equals("true"); 32 | displaySnow = properties.getOrDefault("displaySnow", "false").equals("true"); 33 | type = XibaoType.getByString(properties.getProperty("type")); 34 | } 35 | 36 | public static void storeConfig() throws IOException { 37 | Properties properties = new Properties(); 38 | properties.setProperty("playMusic", String.valueOf(playMusic)); 39 | properties.setProperty("showPicture", String.valueOf(showPicture)); 40 | properties.setProperty("displaySnow", String.valueOf(displaySnow)); 41 | properties.setProperty("type", type.type); 42 | properties.store(new FileWriter(file), "Xibao Plus Plus"); 43 | } 44 | 45 | public static void switchAlbum() { 46 | XibaoType[] types = XibaoType.values(); 47 | type = types[(type.ordinal() + 1) % types.length]; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Fabric-1.21.1/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusMain.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.fabricmc.api.ClientModInitializer; 4 | import net.fabricmc.api.EnvType; 5 | import net.fabricmc.api.Environment; 6 | 7 | @Environment(EnvType.CLIENT) 8 | public class XibaoPlusPlusMain implements ClientModInitializer { 9 | @Override 10 | public void onInitializeClient() { 11 | try { 12 | XibaoPlusPlusConfig.loadConfig(); 13 | } catch (Exception e) { 14 | throw new RuntimeException(e); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Fabric-1.21.1/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusMusic.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.registry.Registries; 4 | import net.minecraft.registry.Registry; 5 | import net.minecraft.registry.entry.RegistryEntry; 6 | import net.minecraft.sound.MusicSound; 7 | import net.minecraft.sound.SoundEvent; 8 | import net.minecraft.util.Identifier; 9 | 10 | public class XibaoPlusPlusMusic { 11 | public static RegistryEntry.Reference XIBAO_SOUND_EVENT = registerReference(Identifier.of("xibaopp", "xibao")); 12 | public static MusicSound XIBAO_MUSIC = new MusicSound(XIBAO_SOUND_EVENT, 0, 0, true); 13 | public static RegistryEntry.Reference BEIBAO_SOUND_EVENT = registerReference(Identifier.of("xibaopp", "beibao")); 14 | public static MusicSound BEIBAO_MUSIC = new MusicSound(BEIBAO_SOUND_EVENT, 0, 0, true); 15 | 16 | private static RegistryEntry.Reference registerReference(Identifier id) { 17 | return registerReference(id, id); 18 | } 19 | private static RegistryEntry.Reference registerReference(Identifier id, Identifier soundId) { 20 | return Registry.registerReference(Registries.SOUND_EVENT, id, SoundEvent.of(soundId)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Fabric-1.21.1/src/main/java/top/gregtao/xibaopp/XibaoType.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.sound.MusicSound; 4 | import net.minecraft.util.Identifier; 5 | 6 | public enum XibaoType { 7 | XIBAO( 8 | XibaoPlusPlusMusic.XIBAO_MUSIC, 9 | Identifier.of("xibaopp", "textures/xibao.png"), 10 | new Identifier[] { 11 | Identifier.of("xibaopp", "textures/yellow_snow.png"), 12 | Identifier.of("xibaopp", "textures/red_snow.png") 13 | }, 14 | "xibao" 15 | ), 16 | BEIBAO( 17 | XibaoPlusPlusMusic.BEIBAO_MUSIC, 18 | Identifier.of("xibaopp", "textures/beibao.png"), 19 | new Identifier[] { 20 | Identifier.of("xibaopp", "textures/white_snow.png") 21 | }, 22 | "beibao" 23 | ) 24 | ; 25 | public final MusicSound music; 26 | public final Identifier background; 27 | public final Identifier[] snows; 28 | public final String type; 29 | 30 | XibaoType(MusicSound music, Identifier background, Identifier[] snows, String type) { 31 | this.music = music; 32 | this.background = background; 33 | this.snows = snows; 34 | this.type = type; 35 | } 36 | 37 | public static XibaoType getByString(String type) { 38 | for (XibaoType xibaoType : values()) { 39 | if (type.equals(xibaoType.type)) return xibaoType; 40 | } 41 | return XIBAO; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Fabric-1.21.1/src/main/java/top/gregtao/xibaopp/mixin/DisconnectedScreenAccessor.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.gui.screen.DisconnectedScreen; 6 | import net.minecraft.network.DisconnectionInfo; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.gen.Accessor; 9 | 10 | @Environment(EnvType.CLIENT) 11 | @Mixin(DisconnectedScreen.class) 12 | public interface DisconnectedScreenAccessor { 13 | 14 | @Accessor("info") 15 | DisconnectionInfo getInfo(); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /Fabric-1.21.1/src/main/java/top/gregtao/xibaopp/mixin/DisconnectedScreenMixin.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.gui.screen.DisconnectedScreen; 6 | import net.minecraft.client.gui.screen.Screen; 7 | import net.minecraft.client.gui.widget.ButtonWidget; 8 | import net.minecraft.text.Text; 9 | import org.spongepowered.asm.mixin.Mixin; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 13 | import top.gregtao.xibaopp.SnowAnimation; 14 | import top.gregtao.xibaopp.BackgroundWidget; 15 | import top.gregtao.xibaopp.XibaoPlusPlusConfig; 16 | 17 | @Environment(EnvType.CLIENT) 18 | @Mixin(DisconnectedScreen.class) 19 | public class DisconnectedScreenMixin extends Screen { 20 | 21 | protected DisconnectedScreenMixin(Text title) { 22 | super(title); 23 | } 24 | 25 | @Inject(method = "init", at = @At("TAIL")) 26 | private void initInject(CallbackInfo ci) { 27 | XibaoPlusPlusConfig.shouldPlayMusic = true; 28 | XibaoPlusPlusConfig.tempSnow = false; 29 | this.addDrawableChild(ButtonWidget.builder(Text.translatable("gui.stopMusic"), 30 | button -> XibaoPlusPlusConfig.shouldPlayMusic = !XibaoPlusPlusConfig.shouldPlayMusic) 31 | .dimensions(this.width / 2 - 100, this.height - 22, 66, 20).build()); 32 | this.addDrawableChild(ButtonWidget.builder( 33 | Text.translatable("gui.dropSnow"), 34 | button -> { 35 | SnowAnimation.INSTANCE = new SnowAnimation(XibaoPlusPlusConfig.random); 36 | XibaoPlusPlusConfig.tempSnow = !XibaoPlusPlusConfig.tempSnow; 37 | }).dimensions(this.width / 2 - 33, this.height - 22, 66, 20).build()); 38 | this.addDrawableChild(ButtonWidget.builder( 39 | Text.translatable("gui.switchAlbum"), 40 | button -> XibaoPlusPlusConfig.switchAlbum()) 41 | .dimensions(this.width / 2 + 34, this.height - 22, 66, 20).build()); 42 | if (XibaoPlusPlusConfig.displaySnow) SnowAnimation.INSTANCE = new SnowAnimation(XibaoPlusPlusConfig.random); 43 | this.addDrawableChild(new BackgroundWidget()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Fabric-1.21.1/src/main/java/top/gregtao/xibaopp/mixin/MinecraftClientMixin.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.MinecraftClient; 6 | import net.minecraft.client.gui.screen.DisconnectedScreen; 7 | import net.minecraft.sound.MusicSound; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 12 | import top.gregtao.xibaopp.XibaoPlusPlusConfig; 13 | 14 | @Environment(EnvType.CLIENT) 15 | @Mixin(MinecraftClient.class) 16 | public class MinecraftClientMixin { 17 | 18 | @Inject(method = "getMusicType", at = @At("TAIL"), cancellable = true) 19 | public void getMusicTypeInject(CallbackInfoReturnable cir) { 20 | if (XibaoPlusPlusConfig.playMusic && XibaoPlusPlusConfig.shouldPlayMusic) { 21 | if (MinecraftClient.getInstance().currentScreen instanceof DisconnectedScreen) { 22 | cir.setReturnValue(XibaoPlusPlusConfig.type.music); 23 | } 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Fabric-1.21.1/src/main/java/top/gregtao/xibaopp/mixin/ScreenMixin.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.minecraft.client.MinecraftClient; 4 | import net.minecraft.client.gui.DrawContext; 5 | import net.minecraft.client.gui.screen.DisconnectedScreen; 6 | import net.minecraft.client.gui.screen.Screen; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Inject; 10 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 11 | 12 | @Mixin(Screen.class) 13 | public abstract class ScreenMixin { 14 | 15 | @Inject(method = "renderBackground(Lnet/minecraft/client/gui/DrawContext;IIF)V", at = @At("HEAD"), cancellable = true) 16 | public void renderBackgroundInject(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) { 17 | Screen screen = MinecraftClient.getInstance().currentScreen; 18 | if (screen instanceof DisconnectedScreen) { 19 | ci.cancel(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Fabric-1.21.1/src/main/java/top/gregtao/xibaopp/util/RenderHelper.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.util; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import net.minecraft.client.render.*; 5 | import net.minecraft.util.Identifier; 6 | 7 | public class RenderHelper { 8 | public static void renderStretchTexture(int width, int height, int light, Identifier source) { 9 | Tessellator tessellator = Tessellator.getInstance(); 10 | BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); 11 | RenderSystem.setShader(GameRenderer::getPositionTexColorProgram); 12 | RenderSystem.setShaderTexture(0, source); 13 | RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); 14 | bufferBuilder.vertex(0.0F, (float) height, -1.0F).texture(0, 1).color(light, light, light, 255); 15 | bufferBuilder.vertex(width, height, -1.0F).texture(1, 1).color(light, light, light, 255); 16 | bufferBuilder.vertex(width, 0.0F, -1.0F).texture(1, 0).color(light, light, light, 255); 17 | bufferBuilder.vertex(0.0F, 0.0F, -1.0F).texture(0, 0).color(light, light, light, 255); 18 | BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); 19 | } 20 | 21 | public static void renderParticle(int x, int y, int width, int height, Identifier source) { 22 | Tessellator tessellator = Tessellator.getInstance(); 23 | BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); 24 | RenderSystem.setShader(GameRenderer::getPositionTexColorProgram); 25 | RenderSystem.setShaderTexture(0, source); 26 | RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); 27 | bufferBuilder.vertex(0.0F + x, height + y, 0.0F).texture(0, 1).color(255, 255, 255, 255); 28 | bufferBuilder.vertex(width + x, height + y, 0.0F).texture(1, 1).color(255, 255, 255, 255); 29 | bufferBuilder.vertex(width + x, 0.0F + y, 0.0F).texture(1, 0).color(255, 255, 255, 255); 30 | bufferBuilder.vertex(0.0F + x, 0.0F + y, 0.0F).texture(0, 0).color(255, 255, 255, 255); 31 | BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Fabric-1.21.1/src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "xibaopp", 4 | "version": "${version}", 5 | 6 | "name": "Xibao", 7 | "description": "Congratulations! You had lost the connection!", 8 | "authors": [ 9 | "GregTao", 10 | "TeaCon(灵感)" 11 | ], 12 | "contact": { 13 | "email": "本模组内容若有侵权请联系gregtaoo@outlook.com删除" 14 | }, 15 | 16 | "license": "GPL v3", 17 | "icon": "assets/xibaopp/textures/logo.png", 18 | 19 | "environment": "*", 20 | "entrypoints": { 21 | "client": [ 22 | "top.gregtao.xibaopp.XibaoPlusPlusMain" 23 | ] 24 | }, 25 | "mixins": [ 26 | "xibaopp.mixins.json" 27 | ], 28 | 29 | "depends": { 30 | "fabricloader": ">=0.14.6", 31 | "fabric": "*", 32 | "minecraft": "1.21.1", 33 | "java": ">=21" 34 | }, 35 | "suggests": { 36 | "another-mod": "*" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Fabric-1.21.1/src/main/resources/xibaopp.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "top.gregtao.xibaopp.mixin", 5 | "compatibilityLevel": "JAVA_21", 6 | "mixins": [ 7 | ], 8 | "client": [ 9 | "DisconnectedScreenAccessor", 10 | "DisconnectedScreenMixin", 11 | "MinecraftClientMixin", 12 | "ScreenMixin" 13 | ], 14 | "injectors": { 15 | "defaultRequire": 1 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Fabric-1.21.4/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx2G 2 | loom.platform=fabric 3 | 4 | minecraft_version=1.21.4 5 | yarn_mappings=1.21.4+build.8 6 | loader_version=0.16.10 7 | 8 | mod_version = 0.2.0-release-mc1.21.4 9 | maven_group = top.gregtao.xibaopp 10 | archives_base_name = XibaoPlusPlus-Fabric 11 | 12 | fabric_version=0.117.0+1.21.4 13 | -------------------------------------------------------------------------------- /Fabric-1.21.4/src/main/java/top/gregtao/xibaopp/BackgroundWidget.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.client.MinecraftClient; 4 | import net.minecraft.client.gui.DrawContext; 5 | import net.minecraft.client.gui.Drawable; 6 | import net.minecraft.client.gui.Element; 7 | import net.minecraft.client.gui.Selectable; 8 | import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; 9 | import net.minecraft.client.util.Window; 10 | import top.gregtao.xibaopp.util.RenderHelper; 11 | 12 | public class BackgroundWidget implements Drawable, Element, Selectable { 13 | 14 | @Override 15 | public void render(DrawContext context, int mouseX, int mouseY, float delta) { 16 | MinecraftClient client = MinecraftClient.getInstance(); 17 | Window window = client.getWindow(); 18 | int width = window.getScaledWidth(), height = window.getScaledHeight(); 19 | if (XibaoPlusPlusConfig.showPicture) { 20 | RenderHelper.renderStretchTexture(width, height, 225, 21 | XibaoPlusPlusConfig.type.background); 22 | } 23 | if (XibaoPlusPlusConfig.displaySnow || XibaoPlusPlusConfig.tempSnow) { 24 | SnowAnimation.INSTANCE.tick(width, height, XibaoPlusPlusConfig.type.snows); 25 | } 26 | } 27 | 28 | @Override 29 | public void setFocused(boolean focused) { 30 | } 31 | 32 | @Override 33 | public boolean isFocused() { 34 | return false; 35 | } 36 | 37 | @Override 38 | public SelectionType getType() { 39 | return Selectable.SelectionType.NONE; 40 | } 41 | 42 | @Override 43 | public void appendNarrations(NarrationMessageBuilder builder) { 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Fabric-1.21.4/src/main/java/top/gregtao/xibaopp/SnowAnimation.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.util.Identifier; 4 | import top.gregtao.xibaopp.util.RenderHelper; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import java.util.Random; 9 | 10 | public class SnowAnimation { 11 | public static SnowAnimation INSTANCE; 12 | private Identifier[] source; 13 | private int lastWidth, lastHeight; 14 | private float amount = 0.1f; 15 | private final Random random; 16 | private final List snows; 17 | 18 | public SnowAnimation(Random random) { 19 | this.random = random; 20 | this.snows = new ArrayList<>(); 21 | } 22 | 23 | public void tick(int width, int height, Identifier[] source) { 24 | this.source = source; 25 | if (width != this.lastWidth || height != this.lastHeight) { 26 | this.snows.clear(); 27 | this.lastWidth = width; 28 | this.lastHeight = height; 29 | } 30 | this.spawnGroup(); 31 | for (Snow snow : this.snows) { 32 | RenderHelper.renderParticle(snow.x, height - snow.y, 4, 4, this.source[snow.source % this.source.length]); 33 | snow.move(); 34 | if (snow.y > height) { 35 | snow.removed = true; 36 | } 37 | } 38 | if (this.snows.size() > 500) { 39 | int i = 0; 40 | while (i < this.snows.size() && this.snows.get(i).removed) this.snows.remove(i); 41 | } 42 | } 43 | 44 | public void spawnGroup() { 45 | this.amount += 0.001f; 46 | float realAmount = Math.min(0.4f, this.amount); 47 | if (realAmount < 1) { 48 | if (this.random.nextInt((int) (1 / realAmount)) == 0) this.spawn(); 49 | } else { 50 | for (int i = 1; i <= realAmount; ++i) this.spawn(); 51 | } 52 | if (this.amount >= 0.6f) this.amount = 0.1f; 53 | } 54 | 55 | public int getSourceIndex() { 56 | return this.random.nextInt(this.source.length); 57 | } 58 | 59 | public void spawn() { 60 | int x = random.nextInt(this.lastWidth); 61 | int k = (random.nextInt(4)) * 2 + 1; 62 | this.snows.add(new Snow(x, random.nextInt(2) == 0 ? -k : k, this.getSourceIndex())); 63 | } 64 | 65 | } 66 | 67 | class Snow { 68 | public int baseX, x, y, k, source; 69 | public boolean removed = false; 70 | public Snow(int x, int k, int source) { 71 | this.baseX = this.x = x; 72 | this.k = k; 73 | this.source = source; 74 | this.y = 0; 75 | } 76 | public void move() { 77 | this.y++; 78 | this.x = this.baseX + this.y / this.k; 79 | } 80 | } -------------------------------------------------------------------------------- /Fabric-1.21.4/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusConfig.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.FileWriter; 6 | import java.io.IOException; 7 | import java.util.Properties; 8 | import java.util.Random; 9 | 10 | public class XibaoPlusPlusConfig { 11 | private static final File file = new File("xibao_plus_plus.properties"); 12 | 13 | public static boolean shouldPlayMusic = false; 14 | public static boolean tempSnow = false; 15 | public static Random random = new Random(); 16 | 17 | public static boolean playMusic = true; 18 | public static boolean showPicture = true; 19 | public static boolean displaySnow = false; 20 | 21 | public static XibaoType type = XibaoType.XIBAO; 22 | 23 | public static void loadConfig() throws Exception { 24 | if (!file.exists()) { 25 | storeConfig(); 26 | return; 27 | } 28 | Properties properties = new Properties(); 29 | properties.load(new FileInputStream(file)); 30 | playMusic = properties.getOrDefault("playMusic", "true").equals("true"); 31 | showPicture = properties.getOrDefault("showPicture", "true").equals("true"); 32 | displaySnow = properties.getOrDefault("displaySnow", "false").equals("true"); 33 | type = XibaoType.getByString(properties.getProperty("type")); 34 | } 35 | 36 | public static void storeConfig() throws IOException { 37 | Properties properties = new Properties(); 38 | properties.setProperty("playMusic", String.valueOf(playMusic)); 39 | properties.setProperty("showPicture", String.valueOf(showPicture)); 40 | properties.setProperty("displaySnow", String.valueOf(displaySnow)); 41 | properties.setProperty("type", type.type); 42 | properties.store(new FileWriter(file), "Xibao Plus Plus"); 43 | } 44 | 45 | public static void switchAlbum() { 46 | XibaoType[] types = XibaoType.values(); 47 | type = types[(type.ordinal() + 1) % types.length]; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Fabric-1.21.4/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusMain.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.fabricmc.api.ClientModInitializer; 4 | import net.fabricmc.api.EnvType; 5 | import net.fabricmc.api.Environment; 6 | 7 | @Environment(EnvType.CLIENT) 8 | public class XibaoPlusPlusMain implements ClientModInitializer { 9 | @Override 10 | public void onInitializeClient() { 11 | try { 12 | XibaoPlusPlusConfig.loadConfig(); 13 | } catch (Exception e) { 14 | throw new RuntimeException(e); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Fabric-1.21.4/src/main/java/top/gregtao/xibaopp/XibaoPlusPlusMusic.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.registry.Registries; 4 | import net.minecraft.registry.Registry; 5 | import net.minecraft.registry.entry.RegistryEntry; 6 | import net.minecraft.sound.MusicSound; 7 | import net.minecraft.sound.SoundEvent; 8 | import net.minecraft.util.Identifier; 9 | 10 | public class XibaoPlusPlusMusic { 11 | public static RegistryEntry.Reference XIBAO_SOUND_EVENT = registerReference(Identifier.of("xibaopp", "xibao")); 12 | public static MusicSound XIBAO_MUSIC = new MusicSound(XIBAO_SOUND_EVENT, 0, 0, true); 13 | public static RegistryEntry.Reference BEIBAO_SOUND_EVENT = registerReference(Identifier.of("xibaopp", "beibao")); 14 | public static MusicSound BEIBAO_MUSIC = new MusicSound(BEIBAO_SOUND_EVENT, 0, 0, true); 15 | 16 | private static RegistryEntry.Reference registerReference(Identifier id) { 17 | return registerReference(id, id); 18 | } 19 | private static RegistryEntry.Reference registerReference(Identifier id, Identifier soundId) { 20 | return Registry.registerReference(Registries.SOUND_EVENT, id, SoundEvent.of(soundId)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Fabric-1.21.4/src/main/java/top/gregtao/xibaopp/XibaoType.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp; 2 | 3 | import net.minecraft.sound.MusicSound; 4 | import net.minecraft.util.Identifier; 5 | 6 | public enum XibaoType { 7 | XIBAO( 8 | XibaoPlusPlusMusic.XIBAO_MUSIC, 9 | Identifier.of("xibaopp", "textures/xibao.png"), 10 | new Identifier[] { 11 | Identifier.of("xibaopp", "textures/yellow_snow.png"), 12 | Identifier.of("xibaopp", "textures/red_snow.png") 13 | }, 14 | "xibao" 15 | ), 16 | BEIBAO( 17 | XibaoPlusPlusMusic.BEIBAO_MUSIC, 18 | Identifier.of("xibaopp", "textures/beibao.png"), 19 | new Identifier[] { 20 | Identifier.of("xibaopp", "textures/white_snow.png") 21 | }, 22 | "beibao" 23 | ) 24 | ; 25 | public final MusicSound music; 26 | public final Identifier background; 27 | public final Identifier[] snows; 28 | public final String type; 29 | 30 | XibaoType(MusicSound music, Identifier background, Identifier[] snows, String type) { 31 | this.music = music; 32 | this.background = background; 33 | this.snows = snows; 34 | this.type = type; 35 | } 36 | 37 | public static XibaoType getByString(String type) { 38 | for (XibaoType xibaoType : values()) { 39 | if (type.equals(xibaoType.type)) return xibaoType; 40 | } 41 | return XIBAO; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Fabric-1.21.4/src/main/java/top/gregtao/xibaopp/mixin/DisconnectedScreenAccessor.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.gui.screen.DisconnectedScreen; 6 | import net.minecraft.network.DisconnectionInfo; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.gen.Accessor; 9 | 10 | @Environment(EnvType.CLIENT) 11 | @Mixin(DisconnectedScreen.class) 12 | public interface DisconnectedScreenAccessor { 13 | 14 | @Accessor("info") 15 | DisconnectionInfo getInfo(); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /Fabric-1.21.4/src/main/java/top/gregtao/xibaopp/mixin/DisconnectedScreenMixin.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.gui.screen.DisconnectedScreen; 6 | import net.minecraft.client.gui.screen.Screen; 7 | import net.minecraft.client.gui.widget.ButtonWidget; 8 | import net.minecraft.text.Text; 9 | import org.spongepowered.asm.mixin.Mixin; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 13 | import top.gregtao.xibaopp.SnowAnimation; 14 | import top.gregtao.xibaopp.BackgroundWidget; 15 | import top.gregtao.xibaopp.XibaoPlusPlusConfig; 16 | 17 | @Environment(EnvType.CLIENT) 18 | @Mixin(DisconnectedScreen.class) 19 | public class DisconnectedScreenMixin extends Screen { 20 | 21 | protected DisconnectedScreenMixin(Text title) { 22 | super(title); 23 | } 24 | 25 | @Inject(method = "init", at = @At("HEAD")) 26 | private void initInject(CallbackInfo ci) { 27 | this.addDrawableChild(new BackgroundWidget()); 28 | XibaoPlusPlusConfig.shouldPlayMusic = true; 29 | XibaoPlusPlusConfig.tempSnow = false; 30 | this.addDrawableChild(ButtonWidget.builder(Text.translatable("gui.stopMusic"), 31 | button -> XibaoPlusPlusConfig.shouldPlayMusic = !XibaoPlusPlusConfig.shouldPlayMusic) 32 | .dimensions(this.width / 2 - 100, this.height - 22, 66, 20).build()); 33 | this.addDrawableChild(ButtonWidget.builder( 34 | Text.translatable("gui.dropSnow"), 35 | button -> { 36 | SnowAnimation.INSTANCE = new SnowAnimation(XibaoPlusPlusConfig.random); 37 | XibaoPlusPlusConfig.tempSnow = !XibaoPlusPlusConfig.tempSnow; 38 | }).dimensions(this.width / 2 - 33, this.height - 22, 66, 20).build()); 39 | this.addDrawableChild(ButtonWidget.builder( 40 | Text.translatable("gui.switchAlbum"), 41 | button -> XibaoPlusPlusConfig.switchAlbum()) 42 | .dimensions(this.width / 2 + 34, this.height - 22, 66, 20).build()); 43 | if (XibaoPlusPlusConfig.displaySnow) SnowAnimation.INSTANCE = new SnowAnimation(XibaoPlusPlusConfig.random); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Fabric-1.21.4/src/main/java/top/gregtao/xibaopp/mixin/MinecraftClientMixin.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.fabricmc.api.EnvType; 4 | import net.fabricmc.api.Environment; 5 | import net.minecraft.client.MinecraftClient; 6 | import net.minecraft.client.gui.screen.DisconnectedScreen; 7 | import net.minecraft.client.sound.MusicInstance; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 12 | import top.gregtao.xibaopp.XibaoPlusPlusConfig; 13 | 14 | @Environment(EnvType.CLIENT) 15 | @Mixin(MinecraftClient.class) 16 | public class MinecraftClientMixin { 17 | 18 | @Inject(method = "getMusicInstance()Lnet/minecraft/client/sound/MusicInstance;", at = @At("TAIL"), cancellable = true) 19 | public void getMusicTypeInject(CallbackInfoReturnable cir) { 20 | if (XibaoPlusPlusConfig.playMusic && XibaoPlusPlusConfig.shouldPlayMusic) { 21 | if (MinecraftClient.getInstance().currentScreen instanceof DisconnectedScreen) { 22 | cir.setReturnValue(new MusicInstance(XibaoPlusPlusConfig.type.music)); 23 | } 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Fabric-1.21.4/src/main/java/top/gregtao/xibaopp/mixin/ScreenMixin.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.mixin; 2 | 3 | import net.minecraft.client.MinecraftClient; 4 | import net.minecraft.client.gui.DrawContext; 5 | import net.minecraft.client.gui.screen.DisconnectedScreen; 6 | import net.minecraft.client.gui.screen.Screen; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Inject; 10 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 11 | 12 | @Mixin(Screen.class) 13 | public abstract class ScreenMixin { 14 | 15 | @Inject(method = "renderBackground(Lnet/minecraft/client/gui/DrawContext;IIF)V", at = @At("HEAD"), cancellable = true) 16 | public void renderBackgroundInject(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) { 17 | Screen screen = MinecraftClient.getInstance().currentScreen; 18 | if (screen instanceof DisconnectedScreen) { 19 | ci.cancel(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Fabric-1.21.4/src/main/java/top/gregtao/xibaopp/util/RenderHelper.java: -------------------------------------------------------------------------------- 1 | package top.gregtao.xibaopp.util; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import net.minecraft.client.gl.ShaderProgramKeys; 5 | import net.minecraft.client.render.*; 6 | import net.minecraft.util.Identifier; 7 | 8 | public class RenderHelper { 9 | public static void renderStretchTexture(int width, int height, int light, Identifier source) { 10 | Tessellator tessellator = Tessellator.getInstance(); 11 | BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); 12 | RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX); 13 | RenderSystem.setShaderTexture(0, source); 14 | RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); 15 | bufferBuilder.vertex(0.0F, (float) height, -1.0F).texture(0, 1).color(light, light, light, 255); 16 | bufferBuilder.vertex(width, height, -1.0F).texture(1, 1).color(light, light, light, 255); 17 | bufferBuilder.vertex(width, 0.0F, -1.0F).texture(1, 0).color(light, light, light, 255); 18 | bufferBuilder.vertex(0.0F, 0.0F, -1.0F).texture(0, 0).color(light, light, light, 255); 19 | BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); 20 | } 21 | 22 | public static void renderParticle(int x, int y, int width, int height, Identifier source) { 23 | Tessellator tessellator = Tessellator.getInstance(); 24 | BufferBuilder bufferBuilder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); 25 | RenderSystem.setShader(ShaderProgramKeys.POSITION_TEX); 26 | RenderSystem.setShaderTexture(0, source); 27 | RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); 28 | bufferBuilder.vertex(0.0F + x, height + y, 0.0F).texture(0, 1).color(255, 255, 255, 255); 29 | bufferBuilder.vertex(width + x, height + y, 0.0F).texture(1, 1).color(255, 255, 255, 255); 30 | bufferBuilder.vertex(width + x, 0.0F + y, 0.0F).texture(1, 0).color(255, 255, 255, 255); 31 | bufferBuilder.vertex(0.0F + x, 0.0F + y, 0.0F).texture(0, 0).color(255, 255, 255, 255); 32 | BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Fabric-1.21.4/src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "xibaopp", 4 | "version": "${version}", 5 | 6 | "name": "Xibao", 7 | "description": "Congratulations! You had lost the connection!", 8 | "authors": [ 9 | "GregTao", 10 | "TeaCon(灵感)" 11 | ], 12 | "contact": { 13 | "email": "本模组内容若有侵权请联系gregtaoo@outlook.com删除" 14 | }, 15 | 16 | "license": "GPL v3", 17 | "icon": "assets/xibaopp/textures/logo.png", 18 | 19 | "environment": "*", 20 | "entrypoints": { 21 | "client": [ 22 | "top.gregtao.xibaopp.XibaoPlusPlusMain" 23 | ] 24 | }, 25 | "mixins": [ 26 | "xibaopp.mixins.json" 27 | ], 28 | 29 | "depends": { 30 | "fabricloader": ">=0.16.10", 31 | "fabric": "*", 32 | "minecraft": "1.21.4", 33 | "java": ">=21" 34 | }, 35 | "suggests": { 36 | "another-mod": "*" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Fabric-1.21.4/src/main/resources/xibaopp.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "top.gregtao.xibaopp.mixin", 5 | "compatibilityLevel": "JAVA_21", 6 | "mixins": [ 7 | ], 8 | "client": [ 9 | "DisconnectedScreenAccessor", 10 | "DisconnectedScreenMixin", 11 | "MinecraftClientMixin", 12 | "ScreenMixin" 13 | ], 14 | "injectors": { 15 | "defaultRequire": 1 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 GregTao 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 自定义音乐/图片使用资源包 2 | 路径: 3 | - assets/xibaopp/sounds 4 | - assets/xibaopp/textures 5 | 6 | ### 感谢: 7 | - @HaiHome-114514 : 文言支持 8 | - @SkyDynamic : 1.19.4, 1.20, 1.20.1 更新支持 9 | 10 | 11 | 下载:[https://www.mcmod.cn/download/7249.html](https://www.mcmod.cn/download/7249.html) 12 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx2G 2 | #systemProp.https.proxyHost=127.0.0.1 3 | #systemProp.https.proxyPort=7890 4 | archives_base_name = XibaoPlusPlus-Fabric -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GregTaoo/Xibao-Plus-Plus/c49d940c0fadac521f32e2105d55d1622490cb18/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GregTaoo/Xibao-Plus-Plus/c49d940c0fadac521f32e2105d55d1622490cb18/gradlew -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /logo-1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GregTaoo/Xibao-Plus-Plus/c49d940c0fadac521f32e2105d55d1622490cb18/logo-1-1.png -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GregTaoo/Xibao-Plus-Plus/c49d940c0fadac521f32e2105d55d1622490cb18/logo.png -------------------------------------------------------------------------------- /resources/assets/xibaopp/README.md: -------------------------------------------------------------------------------- 1 | #### 如有侵权请联系删除! 2 | 3 | - 好运来 4 | - 春节序曲 5 | - 一剪梅 6 | - The Magnificent Seven -------------------------------------------------------------------------------- /resources/assets/xibaopp/lang/en_us.json: -------------------------------------------------------------------------------- 1 | { 2 | "gui.stopMusic": "Stop Music", 3 | "gui.dropSnow": "Flowers", 4 | "gui.switchAlbum": "Switch" 5 | } -------------------------------------------------------------------------------- /resources/assets/xibaopp/lang/lzh.json: -------------------------------------------------------------------------------- 1 | { 2 | "gui.stopMusic": "止樂", 3 | "gui.dropSnow": "散花", 4 | "gui.switchAlbum": "換樂" 5 | } -------------------------------------------------------------------------------- /resources/assets/xibaopp/lang/zh_cn.json: -------------------------------------------------------------------------------- 1 | { 2 | "gui.stopMusic": "停止音乐", 3 | "gui.dropSnow": "撒花", 4 | "gui.switchAlbum": "换碟" 5 | } -------------------------------------------------------------------------------- /resources/assets/xibaopp/sounds.json: -------------------------------------------------------------------------------- 1 | { 2 | "xibao": { 3 | "sounds": [ 4 | "xibaopp:haoyunlai", 5 | "xibaopp:chunjiexuqu", 6 | "xibaopp:the_magnificent_seven" 7 | ] 8 | }, 9 | "beibao": { 10 | "sounds": [ 11 | "xibaopp:yijianmei" 12 | ] 13 | } 14 | } -------------------------------------------------------------------------------- /resources/assets/xibaopp/sounds/chunjiexuqu.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GregTaoo/Xibao-Plus-Plus/c49d940c0fadac521f32e2105d55d1622490cb18/resources/assets/xibaopp/sounds/chunjiexuqu.ogg -------------------------------------------------------------------------------- /resources/assets/xibaopp/sounds/haoyunlai.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GregTaoo/Xibao-Plus-Plus/c49d940c0fadac521f32e2105d55d1622490cb18/resources/assets/xibaopp/sounds/haoyunlai.ogg -------------------------------------------------------------------------------- /resources/assets/xibaopp/sounds/the_magnificent_seven.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GregTaoo/Xibao-Plus-Plus/c49d940c0fadac521f32e2105d55d1622490cb18/resources/assets/xibaopp/sounds/the_magnificent_seven.ogg -------------------------------------------------------------------------------- /resources/assets/xibaopp/sounds/yijianmei.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GregTaoo/Xibao-Plus-Plus/c49d940c0fadac521f32e2105d55d1622490cb18/resources/assets/xibaopp/sounds/yijianmei.ogg -------------------------------------------------------------------------------- /resources/assets/xibaopp/textures/beibao.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GregTaoo/Xibao-Plus-Plus/c49d940c0fadac521f32e2105d55d1622490cb18/resources/assets/xibaopp/textures/beibao.png -------------------------------------------------------------------------------- /resources/assets/xibaopp/textures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GregTaoo/Xibao-Plus-Plus/c49d940c0fadac521f32e2105d55d1622490cb18/resources/assets/xibaopp/textures/logo.png -------------------------------------------------------------------------------- /resources/assets/xibaopp/textures/red_snow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GregTaoo/Xibao-Plus-Plus/c49d940c0fadac521f32e2105d55d1622490cb18/resources/assets/xibaopp/textures/red_snow.png -------------------------------------------------------------------------------- /resources/assets/xibaopp/textures/white_snow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GregTaoo/Xibao-Plus-Plus/c49d940c0fadac521f32e2105d55d1622490cb18/resources/assets/xibaopp/textures/white_snow.png -------------------------------------------------------------------------------- /resources/assets/xibaopp/textures/xibao.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GregTaoo/Xibao-Plus-Plus/c49d940c0fadac521f32e2105d55d1622490cb18/resources/assets/xibaopp/textures/xibao.png -------------------------------------------------------------------------------- /resources/assets/xibaopp/textures/yellow_snow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GregTaoo/Xibao-Plus-Plus/c49d940c0fadac521f32e2105d55d1622490cb18/resources/assets/xibaopp/textures/yellow_snow.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | maven { 4 | url 'https://maven.fabricmc.net/' 5 | } 6 | gradlePluginPortal() 7 | } 8 | } 9 | 10 | 11 | rootProject.name = 'Xibao-Fabric' 12 | include 'Fabric-1.21.4' 13 | include 'Fabric-1.21.1' 14 | include 'Fabric-1.20.6' 15 | include 'Fabric-1.20.4' 16 | include 'Fabric-1.20.1' 17 | include 'Fabric-1.20' 18 | include 'Fabric-1.19.4' 19 | include 'Fabric-1.19.3' 20 | include 'Fabric-1.19' 21 | include 'Fabric-1.18.2' 22 | include 'Fabric-1.17.1' 23 | include 'Fabric-1.16.5' --------------------------------------------------------------------------------