diff options
author | inglettronald <71849533+inglettronald@users.noreply.github.com> | 2023-03-21 18:08:57 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-21 18:08:57 -0500 |
commit | 2cb6f4cffee0ab505b35938cf71518e4640a229a (patch) | |
tree | 02224acacc7e7823079a8e2cc24377eafe33700c /src/main/java | |
parent | 05c6b155f1de3a96ef081627ff7805238742162f (diff) | |
parent | 3968c49ccfb1fb3b0c6a8274f4d45ed0ba50ec48 (diff) | |
download | DulkirMod-2cb6f4cffee0ab505b35938cf71518e4640a229a.tar.gz DulkirMod-2cb6f4cffee0ab505b35938cf71518e4640a229a.tar.bz2 DulkirMod-2cb6f4cffee0ab505b35938cf71518e4640a229a.zip |
Merge pull request #11 from IlmarsXd/master
refactor modules (class -> object), add memory leak fix
Diffstat (limited to 'src/main/java')
5 files changed, 26 insertions, 32 deletions
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<Integer> cir) { diff --git a/src/main/java/dulkirmod/mixins/MixinGuiContainer.java b/src/main/java/dulkirmod/mixins/MixinGuiContainer.java index 50118f1..97a4341 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.INSTANCE.getInLeapMenu() && DungeonLeap.INSTANCE.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<Boolean> cir - ) { + public void doRender(Entity entity, double x, double y, double z, float entityYaw, float partialTicks, boolean p_147939_10_, CallbackInfoReturnable<Boolean> 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(); |