diff --git a/README.md b/README.md index 3f575fd3..b8585cef 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/UTEntityMinecartMixin.java b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartMixin.java new file mode 100644 index 00000000..dbf6a429 --- /dev/null +++ b/src/main/java/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartMixin.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 = EntityMinecart.class) +public abstract class UTEntityMinecartMixin +{ + @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) + { + 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/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 new file mode 100644 index 00000000..d3e1e7aa --- /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": ["UTEntityMinecartMixin", "UTEntityMinecartTypeMixin"] +} \ No newline at end of file