diff --git a/gradle.properties b/gradle.properties index ab82f98..2b54143 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,16 +3,16 @@ org.gradle.jvmargs=-Xmx1G # minecraft, mappings and loader dependencies # check these on https://modmuss50.me/fabric.html -minecraft_version=1.20.6 -quilt_mappings=6 +minecraft_version=1.21-rc1 +quilt_mappings=2 loader_version=0.15.11 # mod properties -mod_version=1.3.1+mc1.20.6 +mod_version=1.3.2+mc1.21 maven_group=rainglow archives_base_name=rainglow # other dependencies java_version=21 -mod_menu_version=10.0.0-beta.1 -fabric_api_version=0.98.0+1.20.6 +mod_menu_version=11.0.0-beta.1 +fabric_api_version=0.100.1+1.21 diff --git a/src/main/java/io/ix0rai/rainglow/Rainglow.java b/src/main/java/io/ix0rai/rainglow/Rainglow.java index b4c5f6a..d8474fa 100644 --- a/src/main/java/io/ix0rai/rainglow/Rainglow.java +++ b/src/main/java/io/ix0rai/rainglow/Rainglow.java @@ -54,7 +54,7 @@ public void onInitialize() { } public static Identifier id(String id) { - return new Identifier(MOD_ID, id); + return Identifier.of(MOD_ID, id); } public static String generateRandomColourId(World world, RandomGenerator random) { diff --git a/src/main/java/io/ix0rai/rainglow/config/CustomModeScreen.java b/src/main/java/io/ix0rai/rainglow/config/CustomModeScreen.java index 02df6b1..1e56d4a 100644 --- a/src/main/java/io/ix0rai/rainglow/config/CustomModeScreen.java +++ b/src/main/java/io/ix0rai/rainglow/config/CustomModeScreen.java @@ -28,21 +28,24 @@ public class CustomModeScreen extends GameOptionsScreen implements ScreenWithUns public CustomModeScreen(Screen parent) { super(parent, MinecraftClient.getInstance().options, TITLE); - this.saveButton = ButtonWidget.builder(Rainglow.translatableText("config.save"), button -> { - boolean hasColourSelected = false; - for (DeferredSaveOption option : this.options) { - if (option.deferredValue) { - hasColourSelected = true; - break; - } - } - - if (!hasColourSelected) { - sendNoColoursToast(); - } else { - this.save(); - } - }).build(); + + this.saveButton = ButtonWidget.builder( + Rainglow.translatableText("config.save"), + button -> { + boolean hasColourSelected = false; + for (DeferredSaveOption option : this.options) { + if (option.deferredValue) { + hasColourSelected = true; + break; + } + } + + if (!hasColourSelected) { + sendNoColoursToast(); + } else { + this.save(); + } + }).build(); this.saveButton.active = false; } @@ -51,15 +54,15 @@ private void createColourToggles() { for (RainglowColour colour : RainglowColour.values()) { this.options.add(DeferredSaveOption.createDeferredBoolean( - "colour." + colour.getId(), - null, - Rainglow.CONFIG.customColours.getRealValue().contains(colour.getId()), - enabled -> { - if (enabled) { - Rainglow.CONFIG.customColours.getRealValue().add(colour.getId()); - } - }, - enabled -> this.saveButton.active = true + "colour." + colour.getId(), + null, + Rainglow.CONFIG.customColours.getRealValue().contains(colour.getId()), + enabled -> { + if (enabled) { + Rainglow.CONFIG.customColours.getRealValue().add(colour.getId()); + } + }, + enabled -> this.saveButton.active = true )); } } @@ -81,7 +84,7 @@ public void init() { headerFooterWidget.addToHeader(new TextWidget(TITLE, this.textRenderer), settings -> settings.alignHorizontallyCenter().setBottomPadding(28)); if (!this.isConfirming) { - ButtonListWidget buttonListWidget = headerFooterWidget.addToContents(new ButtonListWidget(this.client, this.width, this.height, this)); + ButtonListWidget buttonListWidget = headerFooterWidget.addToContents(new ButtonListWidget(this.client, this.width, this)); createColourToggles(); buttonListWidget.addEntries(this.options.toArray(new Option[0])); @@ -96,6 +99,14 @@ public void init() { headerFooterWidget.arrangeElements(); } + @Override + protected void method_60325() {} + + @Override + protected void repositionElements() { + this.clearAndInit(); + } + private static void sendNoColoursToast() { Toast toast = new SystemToast(SystemToast.Id.PACK_LOAD_FAILURE, Rainglow.translatableText("config.no_custom_colours"), Rainglow.translatableText("config.no_custom_colours_description")); MinecraftClient.getInstance().getToastManager().add(toast); diff --git a/src/main/java/io/ix0rai/rainglow/config/RainglowConfigScreen.java b/src/main/java/io/ix0rai/rainglow/config/RainglowConfigScreen.java index 1b5c1c3..ca600bf 100644 --- a/src/main/java/io/ix0rai/rainglow/config/RainglowConfigScreen.java +++ b/src/main/java/io/ix0rai/rainglow/config/RainglowConfigScreen.java @@ -100,7 +100,11 @@ public void init() { } contentLayout.add(gridWidget); - contentLayout.add(ButtonWidget.builder(Rainglow.translatableText("config.custom"), button -> MinecraftClient.getInstance().setScreen(new CustomModeScreen(this))).width(308).position(4, 0).build(), LayoutSettings.create().setPadding(4, 0)); + contentLayout.add(ButtonWidget.builder( + Rainglow.translatableText("config.custom"), + button -> MinecraftClient.getInstance().setScreen(new CustomModeScreen(this)) + ).width(308).position(4, 0).build(), + LayoutSettings.create().setPadding(4, 0)); headerFooterWidget.addToContents(contentLayout); @@ -128,14 +132,14 @@ private DeferredSaveOption createEntityToggle(RainglowEntity entity) { private DeferredSaveOption createColourRaritySlider(RainglowEntity entity) { return sliders.computeIfAbsent(entity, e -> DeferredSaveOption.createDeferredRangedInt( - "config." + e.getId() + "_rarity", - "tooltip.rarity", - Rainglow.CONFIG.rarities.getRealValue().get(e.getId()), - 0, - 100, - rarity -> Rainglow.CONFIG.rarities.getRealValue().put(e.getId(), rarity), + "config." + e.getId() + "_rarity", + "tooltip.rarity", + Rainglow.CONFIG.rarities.getRealValue().get(e.getId()), + 0, + 100, + rarity -> Rainglow.CONFIG.rarities.getRealValue().put(e.getId(), rarity), rarity -> this.saveButton.active = true - )); + )); } public CyclingButtonWidget createModeButton() { diff --git a/src/main/java/io/ix0rai/rainglow/config/ScreenWithUnsavedWarning.java b/src/main/java/io/ix0rai/rainglow/config/ScreenWithUnsavedWarning.java index 389d003..6ac0f8a 100644 --- a/src/main/java/io/ix0rai/rainglow/config/ScreenWithUnsavedWarning.java +++ b/src/main/java/io/ix0rai/rainglow/config/ScreenWithUnsavedWarning.java @@ -16,7 +16,7 @@ public interface ScreenWithUnsavedWarning { void clearAndInit(); - default void setUpUnsavedWarning(HeaderFooterLayoutWidget headerFooterWidget, TextRenderer renderer, Screen parent) { + default void setUpUnsavedWarning(HeaderFooterLayoutWidget headerFooterWidget, TextRenderer renderer, Screen parent) { LinearLayoutWidget contentWidget = headerFooterWidget.addToContents(new LinearLayoutWidget(250, 100, LinearLayoutWidget.Orientation.VERTICAL).setSpacing(8)); contentWidget.add(new TextWidget(Rainglow.translatableText("config.unsaved_warning"), renderer), LayoutSettings::alignHorizontallyCenter); diff --git a/src/main/java/io/ix0rai/rainglow/data/RainglowColour.java b/src/main/java/io/ix0rai/rainglow/data/RainglowColour.java index f87b2e9..0b29c6b 100644 --- a/src/main/java/io/ix0rai/rainglow/data/RainglowColour.java +++ b/src/main/java/io/ix0rai/rainglow/data/RainglowColour.java @@ -58,15 +58,15 @@ public Identifier getTexture(RainglowEntity entityType) { switch (entity) { case GLOW_SQUID -> { String textureName = RainglowEntity.GLOW_SQUID.getDefaultColour() == this ? "glow_squid" : this.getId(); - this.textures.put(entity, new Identifier("textures/entity/squid/" + textureName + ".png")); + this.textures.put(entity, Identifier.ofDefault("textures/entity/squid/" + textureName + ".png")); } case ALLAY -> { String textureName = RainglowEntity.ALLAY.getDefaultColour() == this ? "allay" : this.getId(); - this.textures.put(entity, new Identifier("textures/entity/allay/" + textureName + ".png")); + this.textures.put(entity, Identifier.ofDefault("textures/entity/allay/" + textureName + ".png")); } case SLIME -> { String textureName = RainglowEntity.SLIME.getDefaultColour() == this ? "slime" : this.getId(); - this.textures.put(entity, new Identifier("textures/entity/slime/" + textureName + ".png")); + this.textures.put(entity, Identifier.ofDefault("textures/entity/slime/" + textureName + ".png")); } } } diff --git a/src/main/java/io/ix0rai/rainglow/mixin/GlowSquidEntityMixin.java b/src/main/java/io/ix0rai/rainglow/mixin/GlowSquidEntityMixin.java index bf24d8e..fad2f04 100644 --- a/src/main/java/io/ix0rai/rainglow/mixin/GlowSquidEntityMixin.java +++ b/src/main/java/io/ix0rai/rainglow/mixin/GlowSquidEntityMixin.java @@ -34,13 +34,13 @@ protected void initDataTracker(Builder builder, CallbackInfo ci) { @Inject(method = "writeCustomDataToNbt", at = @At("TAIL")) public void writeCustomDataToNbt(NbtCompound nbt, CallbackInfo ci) { - RainglowColour colour = Rainglow.getColour(this.getWorld(), RainglowEntity.GLOW_SQUID, this.getDataTracker(), this.getRandom()); + RainglowColour colour = Rainglow.getColour(this.getWorld(), RainglowEntity.GLOW_SQUID, this.getDataTracker(), this.random); nbt.putString(Rainglow.CUSTOM_NBT_KEY, colour.getId()); } @Inject(method = "readCustomDataFromNbt", at = @At("TAIL")) public void readCustomDataFromNbt(NbtCompound nbt, CallbackInfo ci) { - this.setVariant(RainglowEntity.GLOW_SQUID.readNbt(this.getWorld(), nbt, this.getRandom())); + this.setVariant(RainglowEntity.GLOW_SQUID.readNbt(this.getWorld(), nbt, this.random)); } /** @@ -49,7 +49,7 @@ public void readCustomDataFromNbt(NbtCompound nbt, CallbackInfo ci) { */ @Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;addParticle(Lnet/minecraft/particle/ParticleEffect;DDDDDD)V"), cancellable = true) public void tickMovement(CallbackInfo ci) { - RainglowColour colour = Rainglow.getColour(this.getWorld(), RainglowEntity.GLOW_SQUID, this.getDataTracker(), this.getRandom()); + RainglowColour colour = Rainglow.getColour(this.getWorld(), RainglowEntity.GLOW_SQUID, this.getDataTracker(), this.random); if (colour != RainglowColour.BLUE) { // we add 100 to g to let the mixin know that we want to override the method @@ -60,7 +60,7 @@ public void tickMovement(CallbackInfo ci) { @Override public RainglowColour getVariant() { - return Rainglow.getColour(this.getWorld(), RainglowEntity.GLOW_SQUID, this.getDataTracker(), this.getRandom()); + return Rainglow.getColour(this.getWorld(), RainglowEntity.GLOW_SQUID, this.getDataTracker(), this.random); } @Override @@ -85,7 +85,7 @@ protected SquidEntityMixin(EntityType entityType, private int spawnParticles(ServerWorld instance, ParticleEffect particle, double x, double y, double z, int count, double deltaX, double deltaY, double deltaZ, double speed) { if (((Object) this) instanceof GlowSquidEntity) { // send in custom colour data - RainglowColour colour = Rainglow.getColour(this.getWorld(), RainglowEntity.GLOW_SQUID, this.getDataTracker(), this.getRandom()); + RainglowColour colour = Rainglow.getColour(this.getWorld(), RainglowEntity.GLOW_SQUID, this.getDataTracker(), this.random); int index = colour.ordinal(); // round x to 1 decimal place and append index data to the next two return ((ServerWorld) this.getWorld()).spawnParticles(particle, (Math.round(x * 10)) / 10D + index / 1000D, y + 0.5, z, 0, deltaX, deltaY, deltaZ, speed); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index e183bb0..78929db 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -37,14 +37,14 @@ }, "depends": { - "fabricloader": ">=0.14.19", + "fabricloader": ">=0.15.11", "fabric-resource-loader-v0": "*", "fabric-networking-api-v1": "*", - "minecraft": ">=1.20.6" + "minecraft": ">=1.21-" }, "suggests": { - "modmenu": ">=7.0.0" + "modmenu": ">=11.0.0-" }, "custom": {