Condensor improvements (#3636)
This commit is contained in:
+17
-18
@@ -19,31 +19,30 @@
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.fluids.util.FluidList;
|
||||
|
||||
|
||||
class CondenserFluidInventory implements IMEMonitor<IAEFluidStack>
|
||||
class CondenserVoidInventory<T extends IAEStack<T>> implements IMEMonitor<T>
|
||||
{
|
||||
|
||||
private final TileCondenser target;
|
||||
private final IStorageChannel<T> channel;
|
||||
|
||||
CondenserFluidInventory( final TileCondenser te )
|
||||
CondenserVoidInventory( final TileCondenser te, final IStorageChannel<T> channel )
|
||||
{
|
||||
this.target = te;
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack injectItems( final IAEFluidStack input, final Actionable mode, final IActionSource src )
|
||||
public T injectItems( final T input, final Actionable mode, final IActionSource src )
|
||||
{
|
||||
if( mode == Actionable.SIMULATE )
|
||||
{
|
||||
@@ -52,33 +51,33 @@ class CondenserFluidInventory implements IMEMonitor<IAEFluidStack>
|
||||
|
||||
if( input != null )
|
||||
{
|
||||
this.target.addPower( input.getStackSize() / 1000.0 );
|
||||
this.target.addPower( input.getStackSize() / (double) this.channel.transferFactor() );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack extractItems( final IAEFluidStack request, final Actionable mode, final IActionSource src )
|
||||
public T extractItems( final T request, final Actionable mode, final IActionSource src )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEFluidStack> getAvailableItems( final IItemList out )
|
||||
public IItemList<T> getAvailableItems( final IItemList<T> out )
|
||||
{
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEFluidStack> getStorageList()
|
||||
public IItemList<T> getStorageList()
|
||||
{
|
||||
return new FluidList();
|
||||
return this.channel.createList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStorageChannel<IAEFluidStack> getChannel()
|
||||
public IStorageChannel<T> getChannel()
|
||||
{
|
||||
return AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class );
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,13 +87,13 @@ class CondenserFluidInventory implements IMEMonitor<IAEFluidStack>
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPrioritized( final IAEFluidStack input )
|
||||
public boolean isPrioritized( final T input )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccept( final IAEFluidStack input )
|
||||
public boolean canAccept( final T input )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -118,13 +117,13 @@ class CondenserFluidInventory implements IMEMonitor<IAEFluidStack>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener( IMEMonitorHandlerReceiver<IAEFluidStack> l, Object verificationToken )
|
||||
public void addListener( IMEMonitorHandlerReceiver<T> l, Object verificationToken )
|
||||
{
|
||||
// Not implemented since the Condenser automatically voids everything, and there are no updates
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener( IMEMonitorHandlerReceiver<IAEFluidStack> l )
|
||||
public void removeListener( IMEMonitorHandlerReceiver<T> l )
|
||||
{
|
||||
// Not implemented since we don't remember registered listeners anyway
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.FluidTankProperties;
|
||||
@@ -45,6 +46,7 @@ import appeng.api.storage.IStorageMonitorable;
|
||||
import appeng.api.storage.IStorageMonitorableAccessor;
|
||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
@@ -294,10 +296,10 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost,
|
||||
}
|
||||
}
|
||||
|
||||
private static final IFluidTankProperties[] EMPTY = { new FluidTankProperties( null, 10, true, false ) };
|
||||
private static final IFluidTankProperties[] EMPTY = { new FluidTankProperties( null, Fluid.BUCKET_VOLUME, true, false ) };
|
||||
|
||||
/**
|
||||
* A fluid handler that exposes a 10 bucket tank that can only be filled, and - when filled - will add power
|
||||
* A fluid handler that exposes a 1 bucket tank that can only be filled, and - when filled - will add power
|
||||
* to this condenser.
|
||||
*/
|
||||
private class FluidHandler implements IFluidHandler
|
||||
@@ -314,7 +316,8 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost,
|
||||
{
|
||||
if( doFill )
|
||||
{
|
||||
TileCondenser.this.addPower( ( resource == null ? 0.0 : (double) resource.amount ) / 500.0 );
|
||||
final IStorageChannel<IAEFluidStack> chan = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class );
|
||||
TileCondenser.this.addPower( ( resource == null ? 0.0 : (double) resource.amount ) / chan.transferFactor() );
|
||||
}
|
||||
|
||||
return resource == null ? 0 : resource.amount;
|
||||
@@ -344,8 +347,6 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost,
|
||||
*/
|
||||
private class MEHandler implements IStorageMonitorableAccessor, IStorageMonitorable
|
||||
{
|
||||
private final CondenserFluidInventory fluidInventory = new CondenserFluidInventory( TileCondenser.this );
|
||||
|
||||
private final CondenserItemInventory itemInventory = new CondenserItemInventory( TileCondenser.this );
|
||||
|
||||
void outputChanged( ItemStack added, ItemStack removed )
|
||||
@@ -367,11 +368,10 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost,
|
||||
{
|
||||
return (IMEMonitor<T>) this.itemInventory;
|
||||
}
|
||||
else if( channel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
|
||||
else
|
||||
{
|
||||
return (IMEMonitor<T>) this.fluidInventory;
|
||||
return new CondenserVoidInventory<>( TileCondenser.this, channel );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user