Files
CatServer/patches/net/minecraft/tileentity/TileEntityLockable.java.patch
2019-02-24 22:29:41 +08:00

37 lines
1.6 KiB
Diff

--- ../src-base/minecraft/net/minecraft/tileentity/TileEntityLockable.java
+++ ../src-work/minecraft/net/minecraft/tileentity/TileEntityLockable.java
@@ -48,4 +48,33 @@
{
return (ITextComponent)(this.hasCustomName() ? new TextComponentString(this.getName()) : new TextComponentTranslation(this.getName(), new Object[0]));
}
+
+ private net.minecraftforge.items.IItemHandler itemHandler;
+
+ protected net.minecraftforge.items.IItemHandler createUnSidedHandler()
+ {
+ return new net.minecraftforge.items.wrapper.InvWrapper(this);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ @javax.annotation.Nullable
+ public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @javax.annotation.Nullable net.minecraft.util.EnumFacing facing)
+ {
+ if (capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
+ return (T) (itemHandler == null ? (itemHandler = createUnSidedHandler()) : itemHandler);
+ return super.getCapability(capability, facing);
+ }
+
+ @Override
+ public boolean hasCapability(net.minecraftforge.common.capabilities.Capability<?> capability, @javax.annotation.Nullable net.minecraft.util.EnumFacing facing)
+ {
+ return capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
+ }
+
+ @Override
+ public org.bukkit.Location getLocation() {
+ if (world == null) return null;
+ return new org.bukkit.Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ());
+ }
}