mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
Capabilities for Phantomfaces
This commit is contained in:
parent
235d86ab8c
commit
a2d7193003
2 changed files with 24 additions and 0 deletions
|
@ -16,6 +16,7 @@ import net.minecraft.inventory.ISidedInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
|
|
||||||
public class TileEntityPhantomItemface extends TileEntityPhantomface{
|
public class TileEntityPhantomItemface extends TileEntityPhantomface{
|
||||||
|
|
||||||
|
@ -122,4 +123,15 @@ public class TileEntityPhantomItemface extends TileEntityPhantomface{
|
||||||
this.getInventory().clear();
|
this.getInventory().clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> T getCapability(Capability<T> 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,9 @@ import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.EnumParticleTypes;
|
import net.minecraft.util.EnumParticleTypes;
|
||||||
import net.minecraft.world.World;
|
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.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
@ -37,8 +40,12 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
||||||
private BlockPos boundPosBefore;
|
private BlockPos boundPosBefore;
|
||||||
private Block boundBlockBefore;
|
private Block boundBlockBefore;
|
||||||
|
|
||||||
|
private CapabilityDispatcher capabilities;
|
||||||
|
|
||||||
public TileEntityPhantomface(String name){
|
public TileEntityPhantomface(String name){
|
||||||
super(0, name);
|
super(0, name);
|
||||||
|
|
||||||
|
this.capabilities = ForgeEventFactory.gatherCapabilities(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -181,4 +188,9 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
||||||
public boolean isItemValidForSlot(int slot, ItemStack stack){
|
public boolean isItemValidForSlot(int slot, ItemStack stack){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> T getCapability(Capability<T> capability, EnumFacing facing){
|
||||||
|
return this.capabilities.getCapability(capability, facing);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue