From 623f260e2f1d586336fca13dc86bf2ffb0c6565c Mon Sep 17 00:00:00 2001 From: IlmarsXd Date: Tue, 21 Mar 2023 17:37:12 +0200 Subject: refactor modules --- .../dulkirmod/mixins/MixinEntityLivingBase.java | 6 +++-- .../java/dulkirmod/mixins/MixinGuiContainer.java | 7 +++--- .../java/dulkirmod/mixins/MixinItemRenderer.java | 11 +++++---- .../dulkirmod/mixins/MixinRendererManager.java | 28 +++++++--------------- src/main/java/dulkirmod/mixins/MixinWorld.java | 6 ++--- 5 files changed, 26 insertions(+), 32 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/dulkirmod/mixins/MixinEntityLivingBase.java b/src/main/java/dulkirmod/mixins/MixinEntityLivingBase.java index d746c23..bc9b48c 100644 --- a/src/main/java/dulkirmod/mixins/MixinEntityLivingBase.java +++ b/src/main/java/dulkirmod/mixins/MixinEntityLivingBase.java @@ -14,9 +14,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin({EntityLivingBase.class}) public abstract class MixinEntityLivingBase extends MixinEntity { - @Shadow public abstract boolean isPotionActive(Potion potionIn); + @Shadow + public abstract boolean isPotionActive(Potion potionIn); - @Shadow public abstract PotionEffect getActivePotionEffect(Potion potionIn); + @Shadow + public abstract PotionEffect getActivePotionEffect(Potion potionIn); @Inject(method = "getArmSwingAnimationEnd()I", at = @At("HEAD"), cancellable = true) public void adjustSwingLength(CallbackInfoReturnable cir) { diff --git a/src/main/java/dulkirmod/mixins/MixinGuiContainer.java b/src/main/java/dulkirmod/mixins/MixinGuiContainer.java index 50118f1..ac79168 100644 --- a/src/main/java/dulkirmod/mixins/MixinGuiContainer.java +++ b/src/main/java/dulkirmod/mixins/MixinGuiContainer.java @@ -17,12 +17,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(GuiContainer.class) public abstract class MixinGuiContainer extends GuiScreen { - @Inject(method="drawSlot", at=@At("HEAD"), cancellable = true) + @Inject(method = "drawSlot", at = @At("HEAD"), cancellable = true) public void drawSlot(Slot slotIn, CallbackInfo ci) { - if (Croesus.Companion.inCroesus() && Croesus.Companion.isChestOpened(slotIn)) { + if (Croesus.inCroesus() && Croesus.isChestOpened(slotIn)) { ci.cancel(); } - if (DungeonLeap.Companion.inLeapMenu() && DungeonLeap.Companion.isHighlightedLeapPlayer(slotIn)) { + if (DungeonLeap.inLeapMenu && DungeonLeap.isHighlightedLeapPlayer(slotIn)) { ci.cancel(); ItemStack stack = new ItemStack(Blocks.wool, 1, EnumDyeColor.GREEN.getMetadata()); @@ -44,6 +44,7 @@ public abstract class MixinGuiContainer extends GuiScreen { this.zLevel = 0.0F; } } + @Inject(method = "onGuiClosed", at = @At("HEAD")) private void onGuiClosed(CallbackInfo ci) { // reset values here diff --git a/src/main/java/dulkirmod/mixins/MixinItemRenderer.java b/src/main/java/dulkirmod/mixins/MixinItemRenderer.java index 3620817..51742b2 100644 --- a/src/main/java/dulkirmod/mixins/MixinItemRenderer.java +++ b/src/main/java/dulkirmod/mixins/MixinItemRenderer.java @@ -15,9 +15,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(value = {ItemRenderer.class}, priority = 1010) public class MixinItemRenderer { - @Shadow @Final private RenderItem itemRenderer; + @Shadow + @Final + private RenderItem itemRenderer; - @Shadow private ItemStack itemToRender; + @Shadow + private ItemStack itemToRender; @Inject(method = "transformFirstPersonItem(FF)V", at = @At("HEAD"), cancellable = true) public void itemTransform(float equipProgress, float swingProgress, CallbackInfo ci) { @@ -25,11 +28,11 @@ public class MixinItemRenderer { } @Inject(method = "doItemUsedTransformations", at = @At("HEAD"), cancellable = true) - public void useTransform(float swingProgress, CallbackInfo ci){ + public void useTransform(float swingProgress, CallbackInfo ci) { if (ItemAnimations.INSTANCE.scaledSwing(swingProgress)) ci.cancel(); } - @Inject(method ="performDrinking", at = @At("HEAD"), cancellable = true) + @Inject(method = "performDrinking", at = @At("HEAD"), cancellable = true) public void drinkTransform(AbstractClientPlayer clientPlayer, float partialTicks, CallbackInfo ci) { if (ItemAnimations.INSTANCE.rotationlessDrink(clientPlayer, partialTicks)) ci.cancel(); if (ItemAnimations.INSTANCE.scaledDrinking(clientPlayer, partialTicks, itemToRender)) ci.cancel(); diff --git a/src/main/java/dulkirmod/mixins/MixinRendererManager.java b/src/main/java/dulkirmod/mixins/MixinRendererManager.java index 964e690..d6e937e 100644 --- a/src/main/java/dulkirmod/mixins/MixinRendererManager.java +++ b/src/main/java/dulkirmod/mixins/MixinRendererManager.java @@ -1,5 +1,6 @@ package dulkirmod.mixins; +import dulkirmod.DulkirMod; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityArmorStand; @@ -10,42 +11,29 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import dulkirmod.DulkirMod; @Mixin(RenderManager.class) public class MixinRendererManager { @Inject(method = "doRenderEntity", at = @At("HEAD"), cancellable = true) - public void doRender( - Entity entity, - double x, - double y, - double z, - float entityYaw, - float partialTicks, - boolean p_147939_10_, - CallbackInfoReturnable cir - ) { + public void doRender(Entity entity, double x, double y, double z, float entityYaw, float partialTicks, boolean p_147939_10_, CallbackInfoReturnable cir) { if (!DulkirMod.Companion.getConfig().getHideHealerFairy()) return; if (entity instanceof EntityArmorStand) { - if (((EntityArmorStand) entity).getHeldItem() != null && ((EntityArmorStand) entity).getHeldItem().getItem() == Items.skull) { - ItemStack stack = ((EntityArmorStand) entity).getHeldItem(); + EntityArmorStand stand = (EntityArmorStand) entity; + if (stand.getHeldItem() != null && stand.getHeldItem().getItem() == Items.skull) { + ItemStack stack = stand.getHeldItem(); if (stack.hasTagCompound() && stack.getTagCompound().hasKey("SkullOwner")) { NBTTagCompound skullOwner = stack.getTagCompound().getCompoundTag("SkullOwner"); if (skullOwner.hasKey("Properties")) { NBTTagCompound properties = skullOwner.getCompoundTag("Properties"); if (properties.hasKey("textures")) { - //if (properties.getTagList("textures", 10).tagCount() >= 1) { - if ("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTZjM2UzMWNmYzY2NzMzMjc1YzQyZmNmYjVkOWE0NDM0MmQ2NDNiNTVjZDE0YzljNzdkMjczYTIzNTIifX19" - .equals(properties.getTagList("textures", 10).getCompoundTagAt(0).getString("Value"))) + String healerFairyTexture = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTZjM2UzMWNmYzY2NzMzMjc1YzQyZmNmYjVkOWE0NDM0MmQ2NDNiNTVjZDE0YzljNzdkMjczYTIzNTIifX19"; + if (healerFairyTexture.equals(properties.getTagList("textures", 10).getCompoundTagAt(0).getString("Value"))) { cir.cancel(); - //} + } } - } - } - } } } diff --git a/src/main/java/dulkirmod/mixins/MixinWorld.java b/src/main/java/dulkirmod/mixins/MixinWorld.java index cdbe9ae..1c75281 100644 --- a/src/main/java/dulkirmod/mixins/MixinWorld.java +++ b/src/main/java/dulkirmod/mixins/MixinWorld.java @@ -1,6 +1,7 @@ package dulkirmod.mixins; import dulkirmod.DulkirMod; +import dulkirmod.features.DragonTimer; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -11,9 +12,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; public class MixinWorld { @Inject(method = "spawnParticle(IZDDDDDD[I)V", at = @At("HEAD"), cancellable = true) - public void onInitGui(int particleID, boolean p_175720_2_, double xCoord, double yCoord, double zCoord, - double xOffset, double yOffset, double zOffset, int[] p_175720_15_, CallbackInfo ci) { - DulkirMod.Companion.getDragonTimer().handleNewParticle(particleID, xCoord, yCoord, zCoord); + public void onInitGui(int particleID, boolean p_175720_2_, double xCoord, double yCoord, double zCoord, double xOffset, double yOffset, double zOffset, int[] p_175720_15_, CallbackInfo ci) { + DragonTimer.INSTANCE.handleNewParticle(particleID, xCoord, yCoord, zCoord); if (particleID == 25 && DulkirMod.Companion.getConfig().getHideEnchantRune()) { ci.cancel(); -- cgit From f520f4bceee9243d585cc0146123c92981d90019 Mon Sep 17 00:00:00 2001 From: IlmarsXd Date: Tue, 21 Mar 2023 18:27:13 +0200 Subject: remove jvmfield/jvmstatic --- src/main/java/dulkirmod/mixins/MixinGuiContainer.java | 2 +- src/main/kotlin/dulkirmod/features/DungeonLeap.kt | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/dulkirmod/mixins/MixinGuiContainer.java b/src/main/java/dulkirmod/mixins/MixinGuiContainer.java index ac79168..97a4341 100644 --- a/src/main/java/dulkirmod/mixins/MixinGuiContainer.java +++ b/src/main/java/dulkirmod/mixins/MixinGuiContainer.java @@ -22,7 +22,7 @@ public abstract class MixinGuiContainer extends GuiScreen { if (Croesus.inCroesus() && Croesus.isChestOpened(slotIn)) { ci.cancel(); } - if (DungeonLeap.inLeapMenu && DungeonLeap.isHighlightedLeapPlayer(slotIn)) { + if (DungeonLeap.INSTANCE.getInLeapMenu() && DungeonLeap.INSTANCE.isHighlightedLeapPlayer(slotIn)) { ci.cancel(); ItemStack stack = new ItemStack(Blocks.wool, 1, EnumDyeColor.GREEN.getMetadata()); diff --git a/src/main/kotlin/dulkirmod/features/DungeonLeap.kt b/src/main/kotlin/dulkirmod/features/DungeonLeap.kt index 9c54c46..bfbfe50 100644 --- a/src/main/kotlin/dulkirmod/features/DungeonLeap.kt +++ b/src/main/kotlin/dulkirmod/features/DungeonLeap.kt @@ -10,7 +10,6 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import net.minecraftforge.fml.common.gameevent.TickEvent object DungeonLeap { - @JvmField var inLeapMenu = false var leapPlayers = BooleanArray(5) { false } @@ -44,7 +43,7 @@ object DungeonLeap { } } } - @JvmStatic + fun isHighlightedLeapPlayer(slotIn: Slot): Boolean { if (!inLeapMenu) return false if (slotIn.inventory == mc.thePlayer.inventory) return false -- cgit