2015-10-10 02:58:07 +02:00
|
|
|
/*
|
2016-05-16 22:52:27 +02:00
|
|
|
* This file ("TileEntityPhantomLiquiface.java") is part of the Actually Additions mod for Minecraft.
|
2015-10-10 02:58:07 +02:00
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
2016-05-16 22:52:27 +02:00
|
|
|
* http://ellpeck.de/actaddlicense
|
2015-10-10 02:58:07 +02:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2016-05-16 22:54:42 +02:00
|
|
|
* © 2015-2016 Ellpeck
|
2015-10-10 02:58:07 +02:00
|
|
|
*/
|
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.tile;
|
2015-10-10 02:58:07 +02:00
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
2016-06-07 23:22:26 +02:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2016-01-07 19:04:29 +01:00
|
|
|
import net.minecraft.util.EnumFacing;
|
2016-06-10 22:00:30 +02:00
|
|
|
import net.minecraftforge.fluids.Fluid;
|
|
|
|
import net.minecraftforge.fluids.FluidStack;
|
|
|
|
import net.minecraftforge.fluids.FluidTankInfo;
|
|
|
|
import net.minecraftforge.fluids.IFluidHandler;
|
2016-06-05 02:16:52 +02:00
|
|
|
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
2015-10-10 02:58:07 +02:00
|
|
|
|
2016-06-10 22:00:30 +02:00
|
|
|
public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements IFluidHandler{
|
2015-10-10 02:58:07 +02:00
|
|
|
|
|
|
|
public TileEntityPhantomLiquiface(){
|
|
|
|
super("liquiface");
|
|
|
|
this.type = BlockPhantom.Type.LIQUIFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void updateEntity(){
|
|
|
|
super.updateEntity();
|
|
|
|
|
2016-05-02 17:46:53 +02:00
|
|
|
if(!this.worldObj.isRemote){
|
2016-06-05 02:16:52 +02:00
|
|
|
if(this.isRedstonePowered && this.isBoundThingInRange()){
|
|
|
|
for(EnumFacing side : EnumFacing.values()){
|
|
|
|
WorldUtil.pushFluid(this, side);
|
2015-10-10 02:58:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isBoundThingInRange(){
|
2016-06-07 23:22:26 +02:00
|
|
|
if(super.isBoundThingInRange()){
|
|
|
|
TileEntity tile = this.worldObj.getTileEntity(this.boundPosition);
|
|
|
|
if(tile != null){
|
2016-06-10 22:00:30 +02:00
|
|
|
return tile instanceof IFluidHandler || tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null);
|
2016-06-07 23:22:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2015-10-10 02:58:07 +02:00
|
|
|
}
|
2016-06-10 22:00:30 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public int fill(EnumFacing from, FluidStack resource, boolean doFill){
|
|
|
|
if(this.isBoundThingInRange()){
|
|
|
|
return this.getHandler().fill(from, resource, doFill);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain){
|
|
|
|
if(this.isBoundThingInRange()){
|
|
|
|
return this.getHandler().drain(from, resource, doDrain);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain){
|
|
|
|
if(this.isBoundThingInRange()){
|
|
|
|
return this.getHandler().drain(from, maxDrain, doDrain);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canFill(EnumFacing from, Fluid fluid){
|
|
|
|
return this.isBoundThingInRange() && this.getHandler().canFill(from, fluid);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canDrain(EnumFacing from, Fluid fluid){
|
|
|
|
return this.isBoundThingInRange() && this.getHandler().canDrain(from, fluid);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public FluidTankInfo[] getTankInfo(EnumFacing from){
|
|
|
|
if(this.isBoundThingInRange()){
|
|
|
|
return this.getHandler().getTankInfo(from);
|
|
|
|
}
|
|
|
|
return new FluidTankInfo[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
public IFluidHandler getHandler(){
|
|
|
|
if(this.boundPosition != null){
|
|
|
|
TileEntity tile = this.worldObj.getTileEntity(this.boundPosition);
|
|
|
|
if(tile instanceof IFluidHandler){
|
|
|
|
return (IFluidHandler)tile;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2015-10-10 02:58:07 +02:00
|
|
|
}
|