|
| 1 | +package org.teneted.neotenet.mixin.world.entity.vehicle; |
| 2 | + |
| 3 | +import net.minecraft.core.NonNullList; |
| 4 | +import net.minecraft.world.entity.EntityType; |
| 5 | +import net.minecraft.world.entity.vehicle.AbstractMinecart; |
| 6 | +import net.minecraft.world.entity.vehicle.AbstractMinecartContainer; |
| 7 | +import net.minecraft.world.entity.vehicle.ContainerEntity; |
| 8 | +import net.minecraft.world.item.ItemStack; |
| 9 | +import net.minecraft.world.level.Level; |
| 10 | +import org.bukkit.Location; |
| 11 | +import org.bukkit.craftbukkit.entity.CraftHumanEntity; |
| 12 | +import org.bukkit.entity.HumanEntity; |
| 13 | +import org.bukkit.inventory.InventoryHolder; |
| 14 | +import org.spongepowered.asm.mixin.Mixin; |
| 15 | +import org.spongepowered.asm.mixin.Shadow; |
| 16 | + |
| 17 | +import java.util.List; |
| 18 | + |
| 19 | +@Mixin(AbstractMinecartContainer.class) |
| 20 | +public abstract class MixinAbstractMinecartContainer extends AbstractMinecart implements ContainerEntity { |
| 21 | + |
| 22 | + @Shadow |
| 23 | + private NonNullList<ItemStack> itemStacks; |
| 24 | + // CraftBukkit start |
| 25 | + public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); |
| 26 | + private int maxStack = MAX_STACK; |
| 27 | + |
| 28 | + protected MixinAbstractMinecartContainer(EntityType<?> p_38087_, Level p_38088_) { |
| 29 | + super(p_38087_, p_38088_); |
| 30 | + } |
| 31 | + |
| 32 | + public List<ItemStack> getContents() { |
| 33 | + return this.itemStacks; |
| 34 | + } |
| 35 | + |
| 36 | + public void onOpen(CraftHumanEntity who) { |
| 37 | + transaction.add(who); |
| 38 | + } |
| 39 | + |
| 40 | + public void onClose(CraftHumanEntity who) { |
| 41 | + transaction.remove(who); |
| 42 | + } |
| 43 | + |
| 44 | + public List<HumanEntity> getViewers() { |
| 45 | + return transaction; |
| 46 | + } |
| 47 | + |
| 48 | + public InventoryHolder getOwner() { |
| 49 | + org.bukkit.entity.Entity cart = getBukkitEntity(); |
| 50 | + if(cart instanceof InventoryHolder) return (InventoryHolder) cart; |
| 51 | + return null; |
| 52 | + } |
| 53 | + |
| 54 | + @Override |
| 55 | + public int getMaxStackSize() { |
| 56 | + return maxStack; |
| 57 | + } |
| 58 | + |
| 59 | + public void setMaxStackSize(int size) { |
| 60 | + maxStack = size; |
| 61 | + } |
| 62 | + |
| 63 | + @Override |
| 64 | + public Location getLocation() { |
| 65 | + return getBukkitEntity().getLocation(); |
| 66 | + } |
| 67 | + // CraftBukkit end |
| 68 | +} |
0 commit comments