mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 08:48:34 +01:00
Fixed Phantom Energyface not working for certain tesla machines and Liquiface crashing with capabilities
Closes #226
This commit is contained in:
parent
340d7cf780
commit
41019417f4
2 changed files with 125 additions and 23 deletions
|
@ -110,11 +110,20 @@ public class TileEntityPhantomEnergyface extends TileEntityPhantomface implement
|
||||||
public boolean isBoundThingInRange(){
|
public boolean isBoundThingInRange(){
|
||||||
if(super.isBoundThingInRange()){
|
if(super.isBoundThingInRange()){
|
||||||
TileEntity tile = this.worldObj.getTileEntity(this.boundPosition);
|
TileEntity tile = this.worldObj.getTileEntity(this.boundPosition);
|
||||||
return tile != null && (tile instanceof IEnergyHandler || (ActuallyAdditions.teslaLoaded && tile.hasCapability(TeslaUtil.teslaHolder, null)));
|
if(tile != null){
|
||||||
}
|
if(tile instanceof IEnergyHandler){
|
||||||
else{
|
return true;
|
||||||
return false;
|
}
|
||||||
|
else if(ActuallyAdditions.teslaLoaded){
|
||||||
|
for(EnumFacing facing : EnumFacing.values()){
|
||||||
|
if(tile.hasCapability(TeslaUtil.teslaHolder, facing)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -13,8 +13,12 @@ package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom;
|
import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraftforge.fluids.*;
|
import net.minecraftforge.fluids.Fluid;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
import net.minecraftforge.fluids.FluidTankInfo;
|
||||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||||
|
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||||
|
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
||||||
|
|
||||||
public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements ISharingFluidHandler{
|
public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements ISharingFluidHandler{
|
||||||
|
|
||||||
|
@ -28,7 +32,16 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
|
||||||
if(super.isBoundThingInRange()){
|
if(super.isBoundThingInRange()){
|
||||||
TileEntity tile = this.worldObj.getTileEntity(this.boundPosition);
|
TileEntity tile = this.worldObj.getTileEntity(this.boundPosition);
|
||||||
if(tile != null){
|
if(tile != null){
|
||||||
return tile instanceof IFluidHandler || tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null);
|
if(tile instanceof net.minecraftforge.fluids.IFluidHandler){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
for(EnumFacing facing : EnumFacing.values()){
|
||||||
|
if(tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -37,7 +50,20 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
|
||||||
@Override
|
@Override
|
||||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill){
|
public int fill(EnumFacing from, FluidStack resource, boolean doFill){
|
||||||
if(this.isBoundThingInRange()){
|
if(this.isBoundThingInRange()){
|
||||||
return this.getHandler().fill(from, resource, doFill);
|
TileEntity tile = this.worldObj.getTileEntity(this.boundPosition);
|
||||||
|
if(tile != null){
|
||||||
|
if(tile instanceof net.minecraftforge.fluids.IFluidHandler){
|
||||||
|
return ((net.minecraftforge.fluids.IFluidHandler)tile).fill(from, resource, doFill);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, from)){
|
||||||
|
IFluidHandler cap = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, from);
|
||||||
|
if(cap != null){
|
||||||
|
return cap.fill(resource, doFill);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +71,20 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
|
||||||
@Override
|
@Override
|
||||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain){
|
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain){
|
||||||
if(this.isBoundThingInRange()){
|
if(this.isBoundThingInRange()){
|
||||||
return this.getHandler().drain(from, resource, doDrain);
|
TileEntity tile = this.worldObj.getTileEntity(this.boundPosition);
|
||||||
|
if(tile != null){
|
||||||
|
if(tile instanceof net.minecraftforge.fluids.IFluidHandler){
|
||||||
|
return ((net.minecraftforge.fluids.IFluidHandler)tile).drain(from, resource, doDrain);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, from)){
|
||||||
|
IFluidHandler cap = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, from);
|
||||||
|
if(cap != null){
|
||||||
|
return cap.drain(resource, doDrain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -53,37 +92,91 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
|
||||||
@Override
|
@Override
|
||||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain){
|
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain){
|
||||||
if(this.isBoundThingInRange()){
|
if(this.isBoundThingInRange()){
|
||||||
return this.getHandler().drain(from, maxDrain, doDrain);
|
TileEntity tile = this.worldObj.getTileEntity(this.boundPosition);
|
||||||
|
if(tile != null){
|
||||||
|
if(tile instanceof net.minecraftforge.fluids.IFluidHandler){
|
||||||
|
return ((net.minecraftforge.fluids.IFluidHandler)tile).drain(from, maxDrain, doDrain);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, from)){
|
||||||
|
IFluidHandler cap = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, from);
|
||||||
|
if(cap != null){
|
||||||
|
return cap.drain(maxDrain, doDrain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canFill(EnumFacing from, Fluid fluid){
|
public boolean canFill(EnumFacing from, Fluid fluid){
|
||||||
return this.isBoundThingInRange() && this.getHandler().canFill(from, fluid);
|
if(this.isBoundThingInRange()){
|
||||||
|
TileEntity tile = this.worldObj.getTileEntity(this.boundPosition);
|
||||||
|
if(tile != null){
|
||||||
|
if(tile instanceof net.minecraftforge.fluids.IFluidHandler){
|
||||||
|
return ((net.minecraftforge.fluids.IFluidHandler)tile).canFill(from, fluid);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, from)){
|
||||||
|
IFluidHandler cap = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, from);
|
||||||
|
if(cap != null){
|
||||||
|
FluidStack stack = new FluidStack(fluid, 1);
|
||||||
|
IFluidTankProperties[] props = cap.getTankProperties();
|
||||||
|
if(props != null){
|
||||||
|
for(IFluidTankProperties prop : props){
|
||||||
|
if(prop.canFillFluidType(stack)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canDrain(EnumFacing from, Fluid fluid){
|
public boolean canDrain(EnumFacing from, Fluid fluid){
|
||||||
return this.isBoundThingInRange() && this.getHandler().canDrain(from, fluid);
|
if(this.isBoundThingInRange()){
|
||||||
|
TileEntity tile = this.worldObj.getTileEntity(this.boundPosition);
|
||||||
|
if(tile != null){
|
||||||
|
if(tile instanceof net.minecraftforge.fluids.IFluidHandler){
|
||||||
|
return ((net.minecraftforge.fluids.IFluidHandler)tile).canDrain(from, fluid);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, from)){
|
||||||
|
IFluidHandler cap = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, from);
|
||||||
|
if(cap != null){
|
||||||
|
FluidStack stack = new FluidStack(fluid, 1);
|
||||||
|
IFluidTankProperties[] props = cap.getTankProperties();
|
||||||
|
if(props != null){
|
||||||
|
for(IFluidTankProperties prop : props){
|
||||||
|
if(prop.canDrainFluidType(stack)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FluidTankInfo[] getTankInfo(EnumFacing from){
|
public FluidTankInfo[] getTankInfo(EnumFacing from){
|
||||||
if(this.isBoundThingInRange()){
|
TileEntity tile = this.worldObj.getTileEntity(this.boundPosition);
|
||||||
return this.getHandler().getTankInfo(from);
|
if(tile instanceof net.minecraftforge.fluids.IFluidHandler){
|
||||||
|
return ((net.minecraftforge.fluids.IFluidHandler)tile).getTankInfo(from);
|
||||||
}
|
}
|
||||||
return new FluidTankInfo[0];
|
else{
|
||||||
}
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue