From a2d719300378d093ac79ed4a1c4d871128e471fd Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Mon, 25 Jan 2016 13:42:37 +0100 Subject: [PATCH] Capabilities for Phantomfaces --- .../mod/tile/TileEntityPhantomItemface.java | 12 ++++++++++++ .../mod/tile/TileEntityPhantomface.java | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomItemface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomItemface.java index fd8a5541f..8b81c3962 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomItemface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomItemface.java @@ -16,6 +16,7 @@ import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; +import net.minecraftforge.common.capabilities.Capability; public class TileEntityPhantomItemface extends TileEntityPhantomface{ @@ -122,4 +123,15 @@ public class TileEntityPhantomItemface extends TileEntityPhantomface{ this.getInventory().clear(); } } + + @Override + public T getCapability(Capability capability, EnumFacing facing){ + if(this.isBoundThingInRange()){ + TileEntity tile = worldObj.getTileEntity(this.boundPosition); + if(tile != null){ + return tile.getCapability(capability, facing); + } + } + return super.getCapability(capability, facing); + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java index d93fc32c0..6fdecdc56 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java @@ -23,6 +23,9 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumParticleTypes; import net.minecraft.world.World; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.CapabilityDispatcher; +import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -37,8 +40,12 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP private BlockPos boundPosBefore; private Block boundBlockBefore; + private CapabilityDispatcher capabilities; + public TileEntityPhantomface(String name){ super(0, name); + + this.capabilities = ForgeEventFactory.gatherCapabilities(this); } @Override @@ -181,4 +188,9 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP public boolean isItemValidForSlot(int slot, ItemStack stack){ return false; } + + @Override + public T getCapability(Capability capability, EnumFacing facing){ + return this.capabilities.getCapability(capability, facing); + } }