-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #489 from WaitingIdly/minecart-self-dropping
Minecart drops itself instead of splitting
- Loading branch information
Showing
6 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...va/mod/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<EntityItem> 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); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...od/acgaming/universaltweaks/tweaks/entities/minecart/mixin/UTEntityMinecartTypeMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] | ||
} |