mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
Make Phantomfaces only actually support the capabilities they advertise
This commit is contained in:
parent
7b4e5f9c46
commit
7ff81ad637
5 changed files with 29 additions and 3 deletions
|
@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom;
|
|||
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
|
||||
public class TileEntityPhantomEnergyface extends TileEntityPhantomface implements ISharingEnergyProvider{
|
||||
|
@ -44,6 +45,11 @@ public class TileEntityPhantomEnergyface extends TileEntityPhantomface implement
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCapabilitySupported(Capability<?> capability){
|
||||
return capability == CapabilityEnergy.ENERGY || capability == TeslaUtil.teslaHolder || capability == TeslaUtil.teslaConsumer || capability == TeslaUtil.teslaProducer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyToSplitShare(){
|
||||
return Integer.MAX_VALUE;
|
||||
|
|
|
@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
|
||||
public class TileEntityPhantomItemface extends TileEntityPhantomface{
|
||||
|
@ -43,6 +44,11 @@ public class TileEntityPhantomItemface extends TileEntityPhantomface{
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCapabilitySupported(Capability<?> capability){
|
||||
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack stack){
|
||||
return this.isBoundThingInRange();
|
||||
|
|
|
@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
|||
import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements ISharingFluidHandler{
|
||||
|
@ -37,6 +38,11 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCapabilitySupported(Capability<?> capability){
|
||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxFluidAmountToSplitShare(){
|
||||
return Integer.MAX_VALUE;
|
||||
|
|
|
@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
@ -61,4 +62,9 @@ public class TileEntityPhantomRedstoneface extends TileEntityPhantomface{
|
|||
|
||||
super.onUpdateSent();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCapabilitySupported(Capability<?> capability){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import net.minecraftforge.common.capabilities.Capability;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntityPhantomface extends TileEntityInventoryBase implements IPhantomTile{
|
||||
public abstract class TileEntityPhantomface extends TileEntityInventoryBase implements IPhantomTile{
|
||||
|
||||
public static final int RANGE = 16;
|
||||
public BlockPos boundPosition;
|
||||
|
@ -170,9 +170,11 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
|||
return this.range;
|
||||
}
|
||||
|
||||
protected abstract boolean isCapabilitySupported(Capability<?> capability);
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing){
|
||||
if(this.isBoundThingInRange()){
|
||||
if(this.isBoundThingInRange() && this.isCapabilitySupported(capability)){
|
||||
TileEntity tile = this.world.getTileEntity(this.getBoundPosition());
|
||||
if(tile != null){
|
||||
return tile.hasCapability(capability, facing);
|
||||
|
@ -183,7 +185,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
|||
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing){
|
||||
if(this.isBoundThingInRange()){
|
||||
if(this.isBoundThingInRange() && this.isCapabilitySupported(capability)){
|
||||
TileEntity tile = this.world.getTileEntity(this.getBoundPosition());
|
||||
if(tile != null){
|
||||
return tile.getCapability(capability, facing);
|
||||
|
|
Loading…
Reference in a new issue