From c98725ad2ce9a86b41c544b9ebe2bea2af4bddf4 Mon Sep 17 00:00:00 2001 From: Waiting Idly <25394029+WaitingIdly@users.noreply.github.com> Date: Mon, 10 Jun 2024 00:48:46 -0700 Subject: [PATCH 1/2] Minecart Drops Itself --- README.md | 1 + .../config/UTConfigTweaks.java | 5 ++++ .../universaltweaks/core/UTLoadingPlugin.java | 1 + .../mixin/UTEntityMinecartChestMixin.java | 29 +++++++++++++++++++ .../mixin/UTEntityMinecartFurnaceMixin.java | 28 ++++++++++++++++++ .../mixin/UTEntityMinecartHopperMixin.java | 29 +++++++++++++++++++ .../minecart/mixin/UTEntityMinecartMixin.java | 21 ++++++++++++++ .../mixin/UTEntityMinecartTNTMixin.java | 28 ++++++++++++++++++ .../mixins.tweaks.entities.minecart.json | 7 +++++ 9 files changed, 149 insertions(+) create mode 100644 src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartChestMixin.java create mode 100644 src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartFurnaceMixin.java create mode 100644 src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartHopperMixin.java create mode 100644 src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartMixin.java create mode 100644 src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartTNTMixin.java create mode 100644 src/main/resources/mixins.tweaks.entities.minecart.json diff --git a/README.md b/README.md index fdcdddab..f8cf4034 100644 --- a/README.md +++ b/README.md @@ -183,6 +183,7 @@ All changes are toggleable via config files. * **Load Sounds:** Plays sounds when the game or the world are loaded * **Mending Overpowered:** If mending fix is enabled, repairs entire damaged inventory with XP * **Mending:** Only repairs damaged equipment with XP +* **Minecart Drops Itself:** Replaces vanilla Minecarts dropping a Minecart and the contained item, and instead drop the combined item * **Mob Despawn Improvement:** Mobs carrying picked up items will drop their equipment and despawn properly * **Modern Knockback:** Backports 1.16+ knockback to 1.12: Knockback resistance is now a scale instead of a probability * **More Banner Layers:** Sets the amount of applicable pattern layers for banners diff --git a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java index 5be472a0..427eae48 100644 --- a/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java +++ b/src/main/java/mod/acgaming/universaltweaks/config/UTConfigTweaks.java @@ -536,6 +536,11 @@ public static class EntitiesCategory @Config.Comment("Backports 1.16+ knockback to 1.12: Knockback resistance is now a scale instead of a probability") public boolean utModernKnockbackToggle = true; + @Config.RequiresMcRestart + @Config.Name("Minecart Drops Itself") + @Config.Comment("Replaces vanilla Minecarts dropping a Minecart and the contained item, and instead drop the combined item") + public boolean utMinecartDropsType = false; + @Config.RequiresMcRestart @Config.Name("No Portal Spawning") @Config.Comment("Prevents zombie pigmen spawning from nether portals") diff --git a/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java b/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java index c9ba086d..4ae9eabc 100644 --- a/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java +++ b/src/main/java/mod/acgaming/universaltweaks/core/UTLoadingPlugin.java @@ -100,6 +100,7 @@ public class UTLoadingPlugin implements IFMLLoadingPlugin, IEarlyMixinLoader put("mixins.tweaks.entities.damage.velocity.json", () -> UTConfigTweaks.ENTITIES.DAMAGE_VELOCITY.utDamageVelocityToggle); put("mixins.tweaks.entities.despawning.json", () -> UTConfigTweaks.ENTITIES.utMobDespawnToggle); put("mixins.tweaks.entities.loot.json", () -> UTConfigTweaks.ENTITIES.utCreeperMusicDiscsToggle); + put("mixins.tweaks.entities.minecart.json", () -> UTConfigTweaks.ENTITIES.utMinecartDropsType); put("mixins.tweaks.entities.playerdismount.json", () -> UTConfigTweaks.MISC.utUseSeparateDismountKey); put("mixins.tweaks.entities.saturation.json", () -> UTConfigTweaks.ENTITIES.utRidingExhaustion != 0.0D); put("mixins.tweaks.entities.spawning.caps.json", () -> UTConfigTweaks.ENTITIES.SPAWN_CAPS.utSpawnCapsToggle); diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartChestMixin.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartChestMixin.java new file mode 100644 index 00000000..278b8dfc --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartChestMixin.java @@ -0,0 +1,29 @@ +package mod.acgaming.universaltweaks.tweaks.entities.minecart.mixin; + +import net.minecraft.entity.item.*; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import mod.acgaming.universaltweaks.config.UTConfigTweaks; + +// Courtesy of WaitingIdly +@Mixin(value = EntityMinecartChest.class) +public abstract class UTEntityMinecartChestMixin +{ + @WrapOperation(method = "killMinecart", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/EntityMinecartChest;dropItemWithOffset(Lnet/minecraft/item/Item;IF)Lnet/minecraft/entity/item/EntityItem;")) + private EntityItem utDropMinecartType(EntityMinecartChest instance, Item item, int size, float offsetY, Operation original) + { + if (!UTConfigTweaks.ENTITIES.utMinecartDropsType) + { + return original.call(instance, item, size, offsetY); + } + ItemStack itemstack = instance.getCartItem().copy(); + if (instance.hasCustomName()) itemstack.setStackDisplayName(instance.getCustomNameTag()); + return instance.entityDropItem(itemstack, offsetY); + } +} \ No newline at end of file diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartFurnaceMixin.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartFurnaceMixin.java new file mode 100644 index 00000000..90a1eca9 --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartFurnaceMixin.java @@ -0,0 +1,28 @@ +package mod.acgaming.universaltweaks.tweaks.entities.minecart.mixin; + +import net.minecraft.entity.item.*; +import net.minecraft.item.ItemStack; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import mod.acgaming.universaltweaks.config.UTConfigTweaks; + +// Courtesy of WaitingIdly +@Mixin(value = EntityMinecartFurnace.class) +public abstract class UTEntityMinecartFurnaceMixin +{ + @WrapOperation(method = "killMinecart", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/EntityMinecartFurnace;entityDropItem(Lnet/minecraft/item/ItemStack;F)Lnet/minecraft/entity/item/EntityItem;")) + private EntityItem utDropMinecartType(EntityMinecartFurnace instance, ItemStack item, float offsetY, Operation original) + { + if (!UTConfigTweaks.ENTITIES.utMinecartDropsType) + { + return original.call(instance, item, offsetY); + } + ItemStack itemstack = instance.getCartItem().copy(); + if (instance.hasCustomName()) itemstack.setStackDisplayName(instance.getCustomNameTag()); + return instance.entityDropItem(itemstack, offsetY); + } +} \ No newline at end of file diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartHopperMixin.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartHopperMixin.java new file mode 100644 index 00000000..cc77bdf9 --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartHopperMixin.java @@ -0,0 +1,29 @@ +package mod.acgaming.universaltweaks.tweaks.entities.minecart.mixin; + +import net.minecraft.entity.item.*; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import mod.acgaming.universaltweaks.config.UTConfigTweaks; + +// Courtesy of WaitingIdly +@Mixin(value = EntityMinecartHopper.class) +public abstract class UTEntityMinecartHopperMixin +{ + @WrapOperation(method = "killMinecart", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/EntityMinecartHopper;dropItemWithOffset(Lnet/minecraft/item/Item;IF)Lnet/minecraft/entity/item/EntityItem;")) + private EntityItem utDropMinecartType(EntityMinecartHopper instance, Item item, int size, float offsetY, Operation original) + { + if (!UTConfigTweaks.ENTITIES.utMinecartDropsType) + { + return original.call(instance, item, size, offsetY); + } + ItemStack itemstack = instance.getCartItem().copy(); + if (instance.hasCustomName()) itemstack.setStackDisplayName(instance.getCustomNameTag()); + return instance.entityDropItem(itemstack, offsetY); + } +} \ No newline at end of file diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartMixin.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartMixin.java new file mode 100644 index 00000000..f1c12ce7 --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartMixin.java @@ -0,0 +1,21 @@ +package mod.acgaming.universaltweaks.tweaks.entities.minecart.mixin; + +import net.minecraft.entity.item.*; +import net.minecraft.item.ItemStack; + +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import mod.acgaming.universaltweaks.config.UTConfigTweaks; + +// Courtesy of WaitingIdly +@Mixin(value = EntityMinecart.class) +public abstract class UTEntityMinecartMixin +{ + @WrapWithCondition(method = "killMinecart", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/EntityMinecart;entityDropItem(Lnet/minecraft/item/ItemStack;F)Lnet/minecraft/entity/item/EntityItem;")) + private boolean utPreventDroppingNormalMinecart(EntityMinecart instance, ItemStack item, float y) + { + return !UTConfigTweaks.ENTITIES.utMinecartDropsType || !(instance instanceof EntityMinecartFurnace || instance instanceof EntityMinecartChest || instance instanceof EntityMinecartTNT || instance instanceof EntityMinecartHopper); + } +} \ No newline at end of file diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartTNTMixin.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartTNTMixin.java new file mode 100644 index 00000000..79ee850a --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartTNTMixin.java @@ -0,0 +1,28 @@ +package mod.acgaming.universaltweaks.tweaks.entities.minecart.mixin; + +import net.minecraft.entity.item.*; +import net.minecraft.item.ItemStack; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import mod.acgaming.universaltweaks.config.UTConfigTweaks; + +// Courtesy of WaitingIdly +@Mixin(value = EntityMinecartTNT.class) +public abstract class UTEntityMinecartTNTMixin +{ + @WrapOperation(method = "killMinecart", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/EntityMinecartTNT;entityDropItem(Lnet/minecraft/item/ItemStack;F)Lnet/minecraft/entity/item/EntityItem;")) + private EntityItem utDropMinecartType(EntityMinecartTNT instance, ItemStack item, float offsetY, Operation original) + { + if (!UTConfigTweaks.ENTITIES.utMinecartDropsType) + { + return original.call(instance, item, offsetY); + } + ItemStack itemstack = instance.getCartItem().copy(); + if (instance.hasCustomName()) itemstack.setStackDisplayName(instance.getCustomNameTag()); + return instance.entityDropItem(itemstack, offsetY); + } +} \ No newline at end of file diff --git a/src/main/resources/mixins.tweaks.entities.minecart.json b/src/main/resources/mixins.tweaks.entities.minecart.json new file mode 100644 index 00000000..057f7382 --- /dev/null +++ b/src/main/resources/mixins.tweaks.entities.minecart.json @@ -0,0 +1,7 @@ +{ + "package": "mod.acgaming.universaltweaks.tweaks.entities.minecart.mixin", + "refmap": "universaltweaks.refmap.json", + "minVersion": "0.8", + "compatibilityLevel": "JAVA_8", + "mixins": ["UTEntityMinecartChestMixin", "UTEntityMinecartFurnaceMixin", "UTEntityMinecartHopperMixin", "UTEntityMinecartMixin", "UTEntityMinecartTNTMixin"] +} \ No newline at end of file From f1de32509e6ce87dbc8e838c5c72982b1af57066 Mon Sep 17 00:00:00 2001 From: Waiting Idly <25394029+WaitingIdly@users.noreply.github.com> Date: Mon, 10 Jun 2024 01:00:32 -0700 Subject: [PATCH 2/2] simplify mixins --- .../mixin/UTEntityMinecartChestMixin.java | 29 ------------------- .../mixin/UTEntityMinecartFurnaceMixin.java | 28 ------------------ .../mixin/UTEntityMinecartHopperMixin.java | 29 ------------------- .../minecart/mixin/UTEntityMinecartMixin.java | 15 +++++++--- .../mixin/UTEntityMinecartTNTMixin.java | 28 ------------------ .../mixin/UTEntityMinecartTypeMixin.java | 23 +++++++++++++++ .../mixins.tweaks.entities.minecart.json | 2 +- 7 files changed, 35 insertions(+), 119 deletions(-) delete mode 100644 src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartChestMixin.java delete mode 100644 src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartFurnaceMixin.java delete mode 100644 src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartHopperMixin.java delete mode 100644 src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartTNTMixin.java create mode 100644 src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartTypeMixin.java diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartChestMixin.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartChestMixin.java deleted file mode 100644 index 278b8dfc..00000000 --- a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartChestMixin.java +++ /dev/null @@ -1,29 +0,0 @@ -package mod.acgaming.universaltweaks.tweaks.entities.minecart.mixin; - -import net.minecraft.entity.item.*; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -import mod.acgaming.universaltweaks.config.UTConfigTweaks; - -// Courtesy of WaitingIdly -@Mixin(value = EntityMinecartChest.class) -public abstract class UTEntityMinecartChestMixin -{ - @WrapOperation(method = "killMinecart", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/EntityMinecartChest;dropItemWithOffset(Lnet/minecraft/item/Item;IF)Lnet/minecraft/entity/item/EntityItem;")) - private EntityItem utDropMinecartType(EntityMinecartChest instance, Item item, int size, float offsetY, Operation original) - { - if (!UTConfigTweaks.ENTITIES.utMinecartDropsType) - { - return original.call(instance, item, size, offsetY); - } - ItemStack itemstack = instance.getCartItem().copy(); - if (instance.hasCustomName()) itemstack.setStackDisplayName(instance.getCustomNameTag()); - return instance.entityDropItem(itemstack, offsetY); - } -} \ No newline at end of file diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartFurnaceMixin.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartFurnaceMixin.java deleted file mode 100644 index 90a1eca9..00000000 --- a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartFurnaceMixin.java +++ /dev/null @@ -1,28 +0,0 @@ -package mod.acgaming.universaltweaks.tweaks.entities.minecart.mixin; - -import net.minecraft.entity.item.*; -import net.minecraft.item.ItemStack; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -import mod.acgaming.universaltweaks.config.UTConfigTweaks; - -// Courtesy of WaitingIdly -@Mixin(value = EntityMinecartFurnace.class) -public abstract class UTEntityMinecartFurnaceMixin -{ - @WrapOperation(method = "killMinecart", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/EntityMinecartFurnace;entityDropItem(Lnet/minecraft/item/ItemStack;F)Lnet/minecraft/entity/item/EntityItem;")) - private EntityItem utDropMinecartType(EntityMinecartFurnace instance, ItemStack item, float offsetY, Operation original) - { - if (!UTConfigTweaks.ENTITIES.utMinecartDropsType) - { - return original.call(instance, item, offsetY); - } - ItemStack itemstack = instance.getCartItem().copy(); - if (instance.hasCustomName()) itemstack.setStackDisplayName(instance.getCustomNameTag()); - return instance.entityDropItem(itemstack, offsetY); - } -} \ No newline at end of file diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartHopperMixin.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartHopperMixin.java deleted file mode 100644 index cc77bdf9..00000000 --- a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartHopperMixin.java +++ /dev/null @@ -1,29 +0,0 @@ -package mod.acgaming.universaltweaks.tweaks.entities.minecart.mixin; - -import net.minecraft.entity.item.*; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -import mod.acgaming.universaltweaks.config.UTConfigTweaks; - -// Courtesy of WaitingIdly -@Mixin(value = EntityMinecartHopper.class) -public abstract class UTEntityMinecartHopperMixin -{ - @WrapOperation(method = "killMinecart", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/EntityMinecartHopper;dropItemWithOffset(Lnet/minecraft/item/Item;IF)Lnet/minecraft/entity/item/EntityItem;")) - private EntityItem utDropMinecartType(EntityMinecartHopper instance, Item item, int size, float offsetY, Operation original) - { - if (!UTConfigTweaks.ENTITIES.utMinecartDropsType) - { - return original.call(instance, item, size, offsetY); - } - ItemStack itemstack = instance.getCartItem().copy(); - if (instance.hasCustomName()) itemstack.setStackDisplayName(instance.getCustomNameTag()); - return instance.entityDropItem(itemstack, offsetY); - } -} \ No newline at end of file diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartMixin.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartMixin.java index f1c12ce7..dbf6a429 100644 --- a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartMixin.java +++ b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartMixin.java @@ -3,7 +3,8 @@ import net.minecraft.entity.item.*; import net.minecraft.item.ItemStack; -import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -13,9 +14,15 @@ @Mixin(value = EntityMinecart.class) public abstract class UTEntityMinecartMixin { - @WrapWithCondition(method = "killMinecart", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/EntityMinecart;entityDropItem(Lnet/minecraft/item/ItemStack;F)Lnet/minecraft/entity/item/EntityItem;")) - private boolean utPreventDroppingNormalMinecart(EntityMinecart instance, ItemStack item, float y) + @WrapOperation(method = "killMinecart", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/EntityMinecart;entityDropItem(Lnet/minecraft/item/ItemStack;F)Lnet/minecraft/entity/item/EntityItem;")) + private EntityItem utDropMinecartType(EntityMinecart instance, ItemStack item, float y, Operation original) { - return !UTConfigTweaks.ENTITIES.utMinecartDropsType || !(instance instanceof EntityMinecartFurnace || instance instanceof EntityMinecartChest || instance instanceof EntityMinecartTNT || instance instanceof EntityMinecartHopper); + if (!UTConfigTweaks.ENTITIES.utMinecartDropsType || !(instance instanceof EntityMinecartFurnace || instance instanceof EntityMinecartChest || instance instanceof EntityMinecartTNT || instance instanceof EntityMinecartHopper)) + { + return original.call(instance, instance, y); + } + ItemStack itemstack = instance.getCartItem().copy(); + if (instance.hasCustomName()) itemstack.setStackDisplayName(instance.getCustomNameTag()); + return original.call(instance, itemstack, y); } } \ No newline at end of file diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartTNTMixin.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartTNTMixin.java deleted file mode 100644 index 79ee850a..00000000 --- a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartTNTMixin.java +++ /dev/null @@ -1,28 +0,0 @@ -package mod.acgaming.universaltweaks.tweaks.entities.minecart.mixin; - -import net.minecraft.entity.item.*; -import net.minecraft.item.ItemStack; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -import mod.acgaming.universaltweaks.config.UTConfigTweaks; - -// Courtesy of WaitingIdly -@Mixin(value = EntityMinecartTNT.class) -public abstract class UTEntityMinecartTNTMixin -{ - @WrapOperation(method = "killMinecart", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/item/EntityMinecartTNT;entityDropItem(Lnet/minecraft/item/ItemStack;F)Lnet/minecraft/entity/item/EntityItem;")) - private EntityItem utDropMinecartType(EntityMinecartTNT instance, ItemStack item, float offsetY, Operation original) - { - if (!UTConfigTweaks.ENTITIES.utMinecartDropsType) - { - return original.call(instance, item, offsetY); - } - ItemStack itemstack = instance.getCartItem().copy(); - if (instance.hasCustomName()) itemstack.setStackDisplayName(instance.getCustomNameTag()); - return instance.entityDropItem(itemstack, offsetY); - } -} \ No newline at end of file diff --git a/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartTypeMixin.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartTypeMixin.java new file mode 100644 index 00000000..40d7bede --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartTypeMixin.java @@ -0,0 +1,23 @@ +package mod.acgaming.universaltweaks.tweaks.entities.minecart.mixin; + +import net.minecraft.entity.item.EntityMinecartChest; +import net.minecraft.entity.item.EntityMinecartFurnace; +import net.minecraft.entity.item.EntityMinecartHopper; +import net.minecraft.entity.item.EntityMinecartTNT; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import mod.acgaming.universaltweaks.config.UTConfigTweaks; + +// Courtesy of WaitingIdly +@Mixin(value = {EntityMinecartFurnace.class, EntityMinecartChest.class, EntityMinecartTNT.class, EntityMinecartHopper.class}) +public abstract class UTEntityMinecartTypeMixin +{ + @ModifyExpressionValue(method = "killMinecart", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/GameRules;getBoolean(Ljava/lang/String;)Z")) + private boolean utPreventDropMinecartType(boolean original) + { + return !UTConfigTweaks.ENTITIES.utMinecartDropsType && original; + } +} \ No newline at end of file diff --git a/src/main/resources/mixins.tweaks.entities.minecart.json b/src/main/resources/mixins.tweaks.entities.minecart.json index 057f7382..d3e1e7aa 100644 --- a/src/main/resources/mixins.tweaks.entities.minecart.json +++ b/src/main/resources/mixins.tweaks.entities.minecart.json @@ -3,5 +3,5 @@ "refmap": "universaltweaks.refmap.json", "minVersion": "0.8", "compatibilityLevel": "JAVA_8", - "mixins": ["UTEntityMinecartChestMixin", "UTEntityMinecartFurnaceMixin", "UTEntityMinecartHopperMixin", "UTEntityMinecartMixin", "UTEntityMinecartTNTMixin"] + "mixins": ["UTEntityMinecartMixin", "UTEntityMinecartTypeMixin"] } \ No newline at end of file