diff --git a/gradle.properties b/gradle.properties index ab82f98..e02c57e 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-pre2 +quilt_mappings=3 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.99.4+1.21 diff --git a/src/main/java/io/ix0rai/rainglow/Rainglow.java b/src/main/java/io/ix0rai/rainglow/Rainglow.java index b4c5f6a..ea0985c 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.method_60655(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..3aea6df 100644 --- a/src/main/java/io/ix0rai/rainglow/config/CustomModeScreen.java +++ b/src/main/java/io/ix0rai/rainglow/config/CustomModeScreen.java @@ -4,120 +4,62 @@ import io.ix0rai.rainglow.data.RainglowColour; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.screen.option.GameOptionsScreen; -import net.minecraft.client.gui.widget.button.ButtonWidget; -import net.minecraft.client.gui.widget.layout.HeaderFooterLayoutWidget; -import net.minecraft.client.gui.widget.layout.LinearLayoutWidget; -import net.minecraft.client.gui.widget.list.ButtonListWidget; -import net.minecraft.client.gui.widget.text.TextWidget; import net.minecraft.client.option.Option; import net.minecraft.client.toast.SystemToast; import net.minecraft.client.toast.Toast; -import net.minecraft.text.CommonTexts; import net.minecraft.text.Text; -import java.util.ArrayList; -import java.util.List; - -public class CustomModeScreen extends GameOptionsScreen implements ScreenWithUnsavedWarning { - private final ButtonWidget saveButton; - private final List> options = new ArrayList<>(); - private boolean isConfirming; - +public class CustomModeScreen extends SaveableGameOptionsScreen { private static final Text TITLE = Rainglow.translatableText("config.custom"); 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.active = false; + super(parent, TITLE); } - private void createColourToggles() { - this.options.clear(); + @Override + protected boolean validate() { + boolean hasColourSelected = false; + for (DeferredSaveOption option : this.options) { + if ((boolean) option.deferredValue) { + hasColourSelected = true; + break; + } + } - 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 - )); + if (!hasColourSelected) { + sendNoColoursToast(); } + return hasColourSelected; } - private void save() { + @Override + protected void save() { Rainglow.CONFIG.customColours.getRealValue().clear(); - - for (DeferredSaveOption option : this.options) { - option.save(); - } - + super.save(); Rainglow.CONFIG.save(); - this.saveButton.active = false; } @Override - public void init() { - HeaderFooterLayoutWidget headerFooterWidget = new HeaderFooterLayoutWidget(this, 61, 33); - 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)); - createColourToggles(); - buttonListWidget.addEntries(this.options.toArray(new Option[0])); - - LinearLayoutWidget linearLayout = headerFooterWidget.addToFooter(LinearLayoutWidget.createHorizontal().setSpacing(8)); - linearLayout.add(ButtonWidget.builder(CommonTexts.DONE, button -> this.closeScreen()).build()); - linearLayout.add(this.saveButton); - } else { - this.setUpUnsavedWarning(headerFooterWidget, this.textRenderer, this.parent); + protected void method_60325() { + 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 + )); } - headerFooterWidget.visitWidgets(this::addDrawableSelectableElement); - headerFooterWidget.arrangeElements(); + this.field_51824.addEntries(this.options.toArray(new Option[0])); } 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); } - - @Override - public void setConfirming(boolean confirming) { - this.isConfirming = confirming; - } - - @Override - public void clearAndInit() { - super.clearAndInit(); - } - - @Override - public void closeScreen() { - if (this.saveButton.active) { - this.isConfirming = true; - this.clearAndInit(); - } else { - MinecraftClient.getInstance().setScreen(this.parent); - } - } } diff --git a/src/main/java/io/ix0rai/rainglow/config/RainglowConfigScreen.java b/src/main/java/io/ix0rai/rainglow/config/RainglowConfigScreen.java index 1b5c1c3..51ebb0f 100644 --- a/src/main/java/io/ix0rai/rainglow/config/RainglowConfigScreen.java +++ b/src/main/java/io/ix0rai/rainglow/config/RainglowConfigScreen.java @@ -10,41 +10,25 @@ import net.minecraft.client.gui.widget.button.ButtonWidget; import net.minecraft.client.gui.widget.button.CyclingButtonWidget; import net.minecraft.client.gui.widget.layout.GridWidget; -import net.minecraft.client.gui.widget.layout.HeaderFooterLayoutWidget; import net.minecraft.client.gui.widget.layout.LayoutSettings; import net.minecraft.client.gui.widget.layout.LinearLayoutWidget; import net.minecraft.client.gui.widget.text.TextWidget; -import net.minecraft.client.option.Option; -import net.minecraft.text.CommonTexts; import net.minecraft.text.Style; import net.minecraft.text.Text; import net.minecraft.util.Language; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -public class RainglowConfigScreen extends Screen implements ScreenWithUnsavedWarning { +public class RainglowConfigScreen extends SaveableGameOptionsScreen { private static final Text TITLE = Rainglow.translatableText("config.title"); public static final Text YES = Text.translatable("gui.yes").styled(style -> style.withColor(0x00FF00)); public static final Text NO = Text.translatable("gui.no").styled(style -> style.withColor(0xFF0000)); - private final Screen parent; - private final Map> toggles = new HashMap<>(); - private final Map> sliders = new HashMap<>(); - private final ButtonWidget saveButton; - private RainglowMode mode; - private boolean isConfirming; public RainglowConfigScreen(@Nullable Screen parent) { - super(TITLE); - this.parent = parent; + super(parent, TITLE); + this.mode = getMode(); - this.saveButton = ButtonWidget.builder(Rainglow.translatableText("config.save"), button -> this.save()).build(); - this.saveButton.active = false; } private void setMode(RainglowMode mode) { @@ -74,68 +58,66 @@ private TextWidget getInfoText() { } @Override - public void init() { - HeaderFooterLayoutWidget headerFooterWidget = new HeaderFooterLayoutWidget(this, 61, 33); - LinearLayoutWidget headerLayout = headerFooterWidget.addToHeader(LinearLayoutWidget.createVertical().setSpacing(8)); - - if (!this.isConfirming) { - // header - headerLayout.add(new TextWidget(TITLE, this.textRenderer), settings -> settings.alignHorizontallyCenter().alignVerticallyTop().setPadding(12)); - headerLayout.add(createModeButton(), LayoutSettings::alignVerticallyBottom); - headerLayout.add(getInfoText(), LayoutSettings::alignHorizontallyCenter); - - // contents - LinearLayoutWidget contentLayout = LinearLayoutWidget.createVertical(); - - GridWidget gridWidget = new GridWidget(); - gridWidget.getDefaultSettings().setHorizontalPadding(4).setBottomPadding(4).alignHorizontallyCenter(); + protected void save() { + super.save(); + this.setMode(this.mode); + } - GridWidget.AdditionHelper mainAdditionHelper = gridWidget.createAdditionHelper(2); - for (RainglowEntity entity : RainglowEntity.values()) { - DeferredSaveOption entityToggle = createEntityToggle(entity); - mainAdditionHelper.add(entityToggle.createButton(MinecraftClient.getInstance().options)); - entityToggle.set(entityToggle.deferredValue); + @Override + protected void method_60329() { + LinearLayoutWidget contentLayout = LinearLayoutWidget.createVertical().setSpacing(8); - mainAdditionHelper.add(createColourRaritySlider(entity).createButton(MinecraftClient.getInstance().options)); - } + contentLayout.add(createModeButton(), LayoutSettings::alignHorizontallyCenter); + contentLayout.add(getInfoText(), LayoutSettings::alignHorizontallyCenter); - 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)); + GridWidget gridWidget = new GridWidget(); + gridWidget.getDefaultSettings().setHorizontalPadding(4).setBottomPadding(4).alignHorizontallyCenter(); - headerFooterWidget.addToContents(contentLayout); + GridWidget.AdditionHelper mainAdditionHelper = gridWidget.createAdditionHelper(2); + for (RainglowEntity entity : RainglowEntity.values()) { + DeferredSaveOption entityToggle = createEntityToggle(entity); + mainAdditionHelper.add(entityToggle.createButton(MinecraftClient.getInstance().options)); + entityToggle.set(entityToggle.deferredValue); + this.options.add(entityToggle); - // footer - LinearLayoutWidget linearLayout = headerFooterWidget.addToFooter(LinearLayoutWidget.createHorizontal().setSpacing(8)); - linearLayout.add(ButtonWidget.builder(CommonTexts.DONE, button -> this.closeScreen()).build()); - linearLayout.add(this.saveButton); - } else { - this.setUpUnsavedWarning(headerFooterWidget, this.textRenderer, this.parent); + DeferredSaveOption raritySlider = createColourRaritySlider(entity); + mainAdditionHelper.add(raritySlider.createButton(MinecraftClient.getInstance().options)); + this.options.add(raritySlider); } - headerFooterWidget.visitWidgets(this::addDrawableSelectableElement); - headerFooterWidget.arrangeElements(); + contentLayout.add(gridWidget); + contentLayout.add(ButtonWidget.builder( + Rainglow.translatableText("config.custom"), + button -> MinecraftClient.getInstance().setScreen(new CustomModeScreen(this)) + ).width(308).build(), + LayoutSettings::alignHorizontallyCenter); + + this.field_49503.addToContents(contentLayout); } + @Override + protected void method_60325() {} + private DeferredSaveOption createEntityToggle(RainglowEntity entity) { - return toggles.computeIfAbsent(entity, e -> DeferredSaveOption.createDeferredBoolean( - "config.enable_" + e.getId(), + return DeferredSaveOption.createDeferredBoolean( + "config.enable_" + entity.getId(), "tooltip.entity_toggle", - Rainglow.CONFIG.toggles.getRealValue().get(e.getId()), - enabled -> Rainglow.CONFIG.toggles.getRealValue().put(e.getId(), enabled), + Rainglow.CONFIG.toggles.getRealValue().get(entity.getId()), + enabled -> Rainglow.CONFIG.toggles.getRealValue().put(entity.getId(), enabled), enabled -> this.saveButton.active = true - )); + ); } 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), + return DeferredSaveOption.createDeferredRangedInt( + "config." + entity.getId() + "_rarity", + "tooltip.rarity", + Rainglow.CONFIG.rarities.getRealValue().get(entity.getId()), + 0, + 100, + rarity -> Rainglow.CONFIG.rarities.getRealValue().put(entity.getId(), rarity), rarity -> this.saveButton.active = true - )); + ); } public CyclingButtonWidget createModeButton() { @@ -151,25 +133,11 @@ public CyclingButtonWidget createModeButton() { Rainglow.translatableText("config.mode"), (cyclingButtonWidget, mode) -> { this.saveButton.active = true; - RainglowConfigScreen.this.mode = mode; + this.mode = mode; } ); } - private void save() { - Collection> options = new ArrayList<>(this.sliders.values()); - options.addAll(this.toggles.values()); - - for (Option option : options) { - if (option instanceof DeferredSaveOption) { - ((DeferredSaveOption) option).save(); - } - } - - this.setMode(this.mode); - this.saveButton.active = false; - } - private Tooltip createColourListLabel(RainglowMode mode) { // creates a label and appends all the colours that will be applied in the given mode StringBuilder text = new StringBuilder(Language.getInstance().get(Rainglow.translatableTextKey("config.colours_to_apply"))); @@ -199,24 +167,4 @@ private Tooltip createColourListLabel(RainglowMode mode) { Style style = Style.EMPTY.withColor(mode.getText().getStyle().getColor()); return Tooltip.create(Text.literal(text.toString()).setStyle(style)); } - - @Override - public void closeScreen() { - if (this.saveButton.active) { - this.isConfirming = true; - this.clearAndInit(); - } else { - MinecraftClient.getInstance().setScreen(this.parent); - } - } - - @Override - public void setConfirming(boolean confirming) { - this.isConfirming = confirming; - } - - @Override - public void clearAndInit() { - super.clearAndInit(); - } } diff --git a/src/main/java/io/ix0rai/rainglow/config/SaveableGameOptionsScreen.java b/src/main/java/io/ix0rai/rainglow/config/SaveableGameOptionsScreen.java new file mode 100644 index 0000000..1e63431 --- /dev/null +++ b/src/main/java/io/ix0rai/rainglow/config/SaveableGameOptionsScreen.java @@ -0,0 +1,89 @@ +package io.ix0rai.rainglow.config; + +import io.ix0rai.rainglow.Rainglow; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.screen.option.GameOptionsScreen; +import net.minecraft.client.gui.widget.button.ButtonWidget; +import net.minecraft.client.gui.widget.layout.HeaderFooterLayoutWidget; +import net.minecraft.client.gui.widget.layout.LayoutSettings; +import net.minecraft.client.gui.widget.layout.LinearLayoutWidget; +import net.minecraft.client.gui.widget.text.TextWidget; +import net.minecraft.text.CommonTexts; +import net.minecraft.text.Text; + +import java.util.ArrayList; +import java.util.List; + +public abstract class SaveableGameOptionsScreen extends GameOptionsScreen { + protected final ButtonWidget saveButton; + protected final List> options = new ArrayList<>(); + + public SaveableGameOptionsScreen(Screen parent, Text title) { + super(parent, MinecraftClient.getInstance().options, title); + + this.saveButton = ButtonWidget.builder( + Rainglow.translatableText("config.save"), + button -> { + if (this.validate()) { + this.save(); + } + }).build(); + this.saveButton.active = false; + } + + protected boolean validate() { + return true; + } + + protected void save() { + for (DeferredSaveOption option : this.options) { + option.save(); + } + + this.saveButton.active = false; + } + + @Override + protected void method_31387() { + LinearLayoutWidget linearLayout = this.field_49503.addToFooter(LinearLayoutWidget.createHorizontal().setSpacing(8)); + linearLayout.add(ButtonWidget.builder(CommonTexts.DONE, button -> this.closeScreen()).build()); + linearLayout.add(this.saveButton); + } + + @Override + public void closeScreen() { + if (this.saveButton.active) { + MinecraftClient.getInstance().setScreen(new ConfirmScreen(this.title)); + } else { + MinecraftClient.getInstance().setScreen(this.parent); + } + } + + public class ConfirmScreen extends Screen { + protected ConfirmScreen(Text title) { + super(title); + } + + @Override + protected void init() { + HeaderFooterLayoutWidget headerFooterWidget = new HeaderFooterLayoutWidget(this, 61, 33); + headerFooterWidget.addToHeader(new TextWidget(this.title, this.textRenderer), settings -> settings.alignHorizontallyCenter().setBottomPadding(28)); + + LinearLayoutWidget contentWidget = headerFooterWidget.addToContents(new LinearLayoutWidget(250, 100, LinearLayoutWidget.Orientation.VERTICAL).setSpacing(8)); + contentWidget.add(new TextWidget(Rainglow.translatableText("config.unsaved_warning"), this.textRenderer), LayoutSettings::alignHorizontallyCenter); + + LinearLayoutWidget buttons = new LinearLayoutWidget(250, 20, LinearLayoutWidget.Orientation.HORIZONTAL).setSpacing(8); + buttons.add(ButtonWidget.builder( + Rainglow.translatableText("config.continue_editing"), + (buttonWidget) -> MinecraftClient.getInstance().setScreen(SaveableGameOptionsScreen.this) + ).build()); + buttons.add(ButtonWidget.builder(CommonTexts.YES, (buttonWidget) -> MinecraftClient.getInstance().setScreen(parent)).build()); + + contentWidget.add(buttons, LayoutSettings::alignHorizontallyCenter); + + headerFooterWidget.visitWidgets(this::addDrawableSelectableElement); + headerFooterWidget.arrangeElements(); + } + } +} diff --git a/src/main/java/io/ix0rai/rainglow/config/ScreenWithUnsavedWarning.java b/src/main/java/io/ix0rai/rainglow/config/ScreenWithUnsavedWarning.java deleted file mode 100644 index 389d003..0000000 --- a/src/main/java/io/ix0rai/rainglow/config/ScreenWithUnsavedWarning.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.ix0rai.rainglow.config; - -import io.ix0rai.rainglow.Rainglow; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.widget.button.ButtonWidget; -import net.minecraft.client.gui.widget.layout.HeaderFooterLayoutWidget; -import net.minecraft.client.gui.widget.layout.LayoutSettings; -import net.minecraft.client.gui.widget.layout.LinearLayoutWidget; -import net.minecraft.client.gui.widget.text.TextWidget; -import net.minecraft.text.CommonTexts; - -public interface ScreenWithUnsavedWarning { - void setConfirming(boolean confirming); - - void clearAndInit(); - - 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); - - LinearLayoutWidget buttons = new LinearLayoutWidget(250, 20, LinearLayoutWidget.Orientation.HORIZONTAL).setSpacing(8); - buttons.add(ButtonWidget.builder(Rainglow.translatableText("config.continue_editing"), (buttonWidget) -> { - this.setConfirming(false); - this.clearAndInit(); - }).build()); - buttons.add(ButtonWidget.builder(CommonTexts.YES, (buttonWidget) -> MinecraftClient.getInstance().setScreen(parent)).build()); - - contentWidget.add(buttons, 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..20f057a 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.method_60656("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.method_60656("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.method_60656("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..580f8fd 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -40,7 +40,7 @@ "fabricloader": ">=0.14.19", "fabric-resource-loader-v0": "*", "fabric-networking-api-v1": "*", - "minecraft": ">=1.20.6" + "minecraft": ">=1.21-" }, "suggests": {