reformatted all src files (#141)
This commit is contained in:
@@ -19,8 +19,6 @@
|
||||
package appeng.fluids.parts;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.*;
|
||||
import appeng.api.networking.IGridNode;
|
||||
@@ -80,6 +78,8 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -90,18 +90,17 @@ import java.util.Objects;
|
||||
* @version rv6 - 22/05/2018
|
||||
* @since rv6 22/05/2018
|
||||
*/
|
||||
public class PartFluidStorageBus extends PartUpgradeable implements IGridTickable, ICellContainer, IMEMonitorHandlerReceiver<IAEFluidStack>, IAEFluidInventory, IConfigurableFluidInventory, IPriorityHost
|
||||
{
|
||||
public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/fluid_storage_bus_base" );
|
||||
public class PartFluidStorageBus extends PartUpgradeable implements IGridTickable, ICellContainer, IMEMonitorHandlerReceiver<IAEFluidStack>, IAEFluidInventory, IConfigurableFluidInventory, IPriorityHost {
|
||||
public static final ResourceLocation MODEL_BASE = new ResourceLocation(AppEng.MOD_ID, "part/fluid_storage_bus_base");
|
||||
@PartModels
|
||||
public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/fluid_storage_bus_off" ) );
|
||||
public static final IPartModel MODELS_OFF = new PartModel(MODEL_BASE, new ResourceLocation(AppEng.MOD_ID, "part/fluid_storage_bus_off"));
|
||||
@PartModels
|
||||
public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/fluid_storage_bus_on" ) );
|
||||
public static final IPartModel MODELS_ON = new PartModel(MODEL_BASE, new ResourceLocation(AppEng.MOD_ID, "part/fluid_storage_bus_on"));
|
||||
@PartModels
|
||||
public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/fluid_storage_bus_has_channel" ) );
|
||||
public static final IPartModel MODELS_HAS_CHANNEL = new PartModel(MODEL_BASE, new ResourceLocation(AppEng.MOD_ID, "part/fluid_storage_bus_has_channel"));
|
||||
|
||||
private final IActionSource source;
|
||||
private final AEFluidInventory config = new AEFluidInventory( this, 63 );
|
||||
private final AEFluidInventory config = new AEFluidInventory(this, 63);
|
||||
private int priority = 0;
|
||||
private boolean cached = false;
|
||||
private ITickingMonitor monitor = null;
|
||||
@@ -112,35 +111,28 @@ public class PartFluidStorageBus extends PartUpgradeable implements IGridTickabl
|
||||
private boolean accessChanged;
|
||||
private boolean readOncePass;
|
||||
|
||||
public PartFluidStorageBus( ItemStack is )
|
||||
{
|
||||
super( is );
|
||||
this.getConfigManager().registerSetting( Settings.ACCESS, AccessRestriction.READ_WRITE );
|
||||
this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
this.getConfigManager().registerSetting( Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY );
|
||||
this.source = new MachineSource( this );
|
||||
public PartFluidStorageBus(ItemStack is) {
|
||||
super(is);
|
||||
this.getConfigManager().registerSetting(Settings.ACCESS, AccessRestriction.READ_WRITE);
|
||||
this.getConfigManager().registerSetting(Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL);
|
||||
this.getConfigManager().registerSetting(Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY);
|
||||
this.source = new MachineSource(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender( final MENetworkPowerStatusChange c )
|
||||
{
|
||||
public void powerRender(final MENetworkPowerStatusChange c) {
|
||||
this.updateStatus();
|
||||
}
|
||||
|
||||
protected void updateStatus()
|
||||
{
|
||||
protected void updateStatus() {
|
||||
final boolean currentActive = this.getProxy().isActive();
|
||||
if( this.wasActive != currentActive )
|
||||
{
|
||||
if (this.wasActive != currentActive) {
|
||||
this.wasActive = currentActive;
|
||||
try
|
||||
{
|
||||
this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
try {
|
||||
this.getProxy().getGrid().postEvent(new MENetworkCellArrayUpdate());
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
} catch (final GridAccessException e) {
|
||||
// :P
|
||||
}
|
||||
}
|
||||
@@ -148,277 +140,218 @@ public class PartFluidStorageBus extends PartUpgradeable implements IGridTickabl
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void chanRender( final MENetworkChannelsChanged changedChannels )
|
||||
{
|
||||
public void chanRender(final MENetworkChannelsChanged changedChannels) {
|
||||
this.updateStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getUpgradeSlots()
|
||||
{
|
||||
protected int getUpgradeSlots() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting( final IConfigManager manager, final Enum settingName, final Enum newValue )
|
||||
{
|
||||
if( settingName.name().equals( "ACCESS" ) )
|
||||
{
|
||||
public void updateSetting(final IConfigManager manager, final Enum settingName, final Enum newValue) {
|
||||
if (settingName.name().equals("ACCESS")) {
|
||||
this.accessChanged = true;
|
||||
}
|
||||
this.resetCache( true );
|
||||
this.resetCache(true);
|
||||
this.getHost().markForSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFluidInventoryChanged( IAEFluidTank inv, int slot )
|
||||
{
|
||||
if( inv == this.config )
|
||||
{
|
||||
this.resetCache( true );
|
||||
public void onFluidInventoryChanged(IAEFluidTank inv, int slot) {
|
||||
if (inv == this.config) {
|
||||
this.resetCache(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void upgradesChanged()
|
||||
{
|
||||
public void upgradesChanged() {
|
||||
super.upgradesChanged();
|
||||
this.resetCache( true );
|
||||
this.resetCache(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.config.readFromNBT( data, "config" );
|
||||
this.priority = data.getInteger( "priority" );
|
||||
public void readFromNBT(final NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
this.config.readFromNBT(data, "config");
|
||||
this.priority = data.getInteger("priority");
|
||||
this.accessChanged = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.config.writeToNBT( data, "config" );
|
||||
data.setInteger( "priority", this.priority );
|
||||
public void writeToNBT(final NBTTagCompound data) {
|
||||
super.writeToNBT(data);
|
||||
this.config.writeToNBT(data, "config");
|
||||
data.setInteger("priority", this.priority);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidHandler getFluidInventoryByName( final String name )
|
||||
{
|
||||
if( name.equals( "config" ) )
|
||||
{
|
||||
public IFluidHandler getFluidInventoryByName(final String name) {
|
||||
if (name.equals("config")) {
|
||||
return this.config;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void resetCache( final boolean fullReset )
|
||||
{
|
||||
if( this.getHost() == null || this.getHost().getTile() == null || this.getHost().getTile().getWorld() == null || this.getHost().getTile().getWorld().isRemote )
|
||||
{
|
||||
protected void resetCache(final boolean fullReset) {
|
||||
if (this.getHost() == null || this.getHost().getTile() == null || this.getHost().getTile().getWorld() == null || this.getHost().getTile().getWorld().isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( fullReset )
|
||||
{
|
||||
if (fullReset) {
|
||||
this.resetCacheLogic = 2;
|
||||
}
|
||||
else if( this.resetCacheLogic < 2 )
|
||||
{
|
||||
} else if (this.resetCacheLogic < 2) {
|
||||
this.resetCacheLogic = 1;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
this.getProxy().getTick().alertDevice( this.getProxy().getNode() );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
try {
|
||||
this.getProxy().getTick().alertDevice(this.getProxy().getNode());
|
||||
} catch (final GridAccessException e) {
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid( final Object verificationToken )
|
||||
{
|
||||
public boolean isValid(final Object verificationToken) {
|
||||
return this.handler == verificationToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postChange( final IBaseMonitor<IAEFluidStack> monitor, final Iterable<IAEFluidStack> change, final IActionSource source )
|
||||
{
|
||||
if( this.getProxy().isActive() )
|
||||
{
|
||||
AccessRestriction currentAccess = (AccessRestriction) ( (ConfigManager) this.getConfigManager() ).getSetting( Settings.ACCESS );
|
||||
if( readOncePass )
|
||||
{
|
||||
public void postChange(final IBaseMonitor<IAEFluidStack> monitor, final Iterable<IAEFluidStack> change, final IActionSource source) {
|
||||
if (this.getProxy().isActive()) {
|
||||
AccessRestriction currentAccess = (AccessRestriction) ((ConfigManager) this.getConfigManager()).getSetting(Settings.ACCESS);
|
||||
if (readOncePass) {
|
||||
readOncePass = false;
|
||||
try
|
||||
{
|
||||
this.getProxy().getStorage().postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ), change, this.source );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
try {
|
||||
this.getProxy().getStorage().postAlterationOfStoredItems(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class), change, this.source);
|
||||
} catch (final GridAccessException e) {
|
||||
// :(
|
||||
}
|
||||
return;
|
||||
}
|
||||
if( !currentAccess.hasPermission( AccessRestriction.READ ) )
|
||||
{
|
||||
if (!currentAccess.hasPermission(AccessRestriction.READ)) {
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
this.getProxy().getStorage().postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ), change, source );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
try {
|
||||
this.getProxy().getStorage().postAlterationOfStoredItems(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class), change, source);
|
||||
} catch (final GridAccessException e) {
|
||||
// :(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListUpdate()
|
||||
{
|
||||
public void onListUpdate() {
|
||||
// not used here.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBoxes( final IPartCollisionHelper bch )
|
||||
{
|
||||
bch.addBox( 3, 3, 15, 13, 13, 16 );
|
||||
bch.addBox( 2, 2, 14, 14, 14, 15 );
|
||||
bch.addBox( 5, 5, 12, 11, 11, 14 );
|
||||
public void getBoxes(final IPartCollisionHelper bch) {
|
||||
bch.addBox(3, 3, 15, 13, 13, 16);
|
||||
bch.addBox(2, 2, 14, 14, 14, 15);
|
||||
bch.addBox(5, 5, 12, 11, 11, 14);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor )
|
||||
{
|
||||
if( pos.offset( this.getSide().getFacing() ).equals( neighbor ) )
|
||||
{
|
||||
public void onNeighborChanged(IBlockAccess w, BlockPos pos, BlockPos neighbor) {
|
||||
if (pos.offset(this.getSide().getFacing()).equals(neighbor)) {
|
||||
|
||||
final TileEntity te = w.getTileEntity( neighbor );
|
||||
final TileEntity te = w.getTileEntity(neighbor);
|
||||
|
||||
// In case the TE was destroyed, we have to do a full reset immediately.
|
||||
if( te instanceof TileCableBus )
|
||||
{
|
||||
IPart iPart = ( (TileCableBus) te ).getPart( this.getSide().getOpposite() );
|
||||
if( iPart == null || iPart instanceof PartFluidInterface )
|
||||
{
|
||||
this.resetCache( true );
|
||||
if (te instanceof TileCableBus) {
|
||||
IPart iPart = ((TileCableBus) te).getPart(this.getSide().getOpposite());
|
||||
if (iPart == null || iPart instanceof PartFluidInterface) {
|
||||
this.resetCache(true);
|
||||
this.resetCache();
|
||||
}
|
||||
}
|
||||
else if( te == null || te instanceof TileFluidInterface )
|
||||
{
|
||||
this.resetCache( true );
|
||||
} else if (te == null || te instanceof TileFluidInterface) {
|
||||
this.resetCache(true);
|
||||
this.resetCache();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.resetCache( false );
|
||||
} else {
|
||||
this.resetCache(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getCableConnectionLength( AECableType cable )
|
||||
{
|
||||
public float getCableConnectionLength(AECableType cable) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartActivate( final EntityPlayer player, final EnumHand hand, final Vec3d pos )
|
||||
{
|
||||
if( Platform.isServer() )
|
||||
{
|
||||
Platform.openGUI( player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_STORAGEBUS_FLUID );
|
||||
public boolean onPartActivate(final EntityPlayer player, final EnumHand hand, final Vec3d pos) {
|
||||
if (Platform.isServer()) {
|
||||
Platform.openGUI(player, this.getHost().getTile(), this.getSide(), GuiBridge.GUI_STORAGEBUS_FLUID);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest( IGridNode node )
|
||||
{
|
||||
return new TickingRequest( TickRates.FluidStorageBus.getMin(), TickRates.FluidStorageBus.getMax(), monitor == null, true );
|
||||
public TickingRequest getTickingRequest(IGridNode node) {
|
||||
return new TickingRequest(TickRates.FluidStorageBus.getMin(), TickRates.FluidStorageBus.getMax(), monitor == null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TickRateModulation tickingRequest( IGridNode node, int ticksSinceLastCall )
|
||||
{
|
||||
if( this.resetCacheLogic != 0 )
|
||||
{
|
||||
public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall) {
|
||||
if (this.resetCacheLogic != 0) {
|
||||
this.resetCache();
|
||||
}
|
||||
|
||||
if( this.monitor != null )
|
||||
{
|
||||
if (this.monitor != null) {
|
||||
return this.monitor.onTick();
|
||||
}
|
||||
|
||||
return TickRateModulation.SLEEP;
|
||||
}
|
||||
|
||||
protected void resetCache()
|
||||
{
|
||||
protected void resetCache() {
|
||||
final boolean fullReset = this.resetCacheLogic == 2;
|
||||
this.resetCacheLogic = 0;
|
||||
|
||||
final MEInventoryHandler<IAEFluidStack> in = this.getInternalHandler();
|
||||
IItemList<IAEFluidStack> before = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList();
|
||||
if( in != null )
|
||||
{
|
||||
if( accessChanged )
|
||||
{
|
||||
AccessRestriction currentAccess = (AccessRestriction) ( (ConfigManager) this.getConfigManager() ).getSetting( Settings.ACCESS );
|
||||
AccessRestriction oldAccess = (AccessRestriction) ( (ConfigManager) this.getConfigManager() ).getOldSetting( Settings.ACCESS );
|
||||
if( oldAccess.hasPermission( AccessRestriction.READ ) && !currentAccess.hasPermission( AccessRestriction.READ ) )
|
||||
{
|
||||
IItemList<IAEFluidStack> before = AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class).createList();
|
||||
if (in != null) {
|
||||
if (accessChanged) {
|
||||
AccessRestriction currentAccess = (AccessRestriction) ((ConfigManager) this.getConfigManager()).getSetting(Settings.ACCESS);
|
||||
AccessRestriction oldAccess = (AccessRestriction) ((ConfigManager) this.getConfigManager()).getOldSetting(Settings.ACCESS);
|
||||
if (oldAccess.hasPermission(AccessRestriction.READ) && !currentAccess.hasPermission(AccessRestriction.READ)) {
|
||||
readOncePass = true;
|
||||
}
|
||||
in.setBaseAccess( oldAccess );
|
||||
before = in.getAvailableItems( before );
|
||||
in.setBaseAccess( currentAccess );
|
||||
in.setBaseAccess(oldAccess);
|
||||
before = in.getAvailableItems(before);
|
||||
in.setBaseAccess(currentAccess);
|
||||
accessChanged = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
before = in.getAvailableItems( before );
|
||||
} else {
|
||||
before = in.getAvailableItems(before);
|
||||
}
|
||||
}
|
||||
|
||||
this.cached = false;
|
||||
if( fullReset )
|
||||
{
|
||||
if (fullReset) {
|
||||
this.handlerHash = 0;
|
||||
}
|
||||
|
||||
final MEInventoryHandler<IAEFluidStack> out = this.getInternalHandler();
|
||||
IItemList<IAEFluidStack> after = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList();
|
||||
IItemList<IAEFluidStack> after = AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class).createList();
|
||||
|
||||
if( in != out )
|
||||
{
|
||||
if( out != null )
|
||||
{
|
||||
after = out.getAvailableItems( after );
|
||||
if (in != out) {
|
||||
if (out != null) {
|
||||
after = out.getAvailableItems(after);
|
||||
}
|
||||
Platform.postListChanges( before, after, this, this.source );
|
||||
Platform.postListChanges(before, after, this, this.source);
|
||||
}
|
||||
}
|
||||
|
||||
private IMEInventory<IAEFluidStack> getInventoryWrapper( TileEntity target )
|
||||
{
|
||||
private IMEInventory<IAEFluidStack> getInventoryWrapper(TileEntity target) {
|
||||
EnumFacing targetSide = this.getSide().getFacing().getOpposite();
|
||||
// Prioritize a handler to directly link to another ME network
|
||||
IStorageMonitorableAccessor accessor = target.getCapability( Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide );
|
||||
if( accessor != null )
|
||||
{
|
||||
IStorageMonitorable inventory = accessor.getInventory( this.source );
|
||||
if( inventory != null )
|
||||
{
|
||||
return inventory.getInventory( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
|
||||
IStorageMonitorableAccessor accessor = target.getCapability(Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide);
|
||||
if (accessor != null) {
|
||||
IStorageMonitorable inventory = accessor.getInventory(this.source);
|
||||
if (inventory != null) {
|
||||
return inventory.getInventory(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class));
|
||||
}
|
||||
|
||||
// So this could / can be a design decision. If the tile does support our custom capability,
|
||||
@@ -429,43 +362,36 @@ public class PartFluidStorageBus extends PartUpgradeable implements IGridTickabl
|
||||
}
|
||||
|
||||
// Check via cap for IItemHandler
|
||||
IFluidHandler handlerExt = target.getCapability( CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, targetSide );
|
||||
if( handlerExt != null )
|
||||
{
|
||||
return new FluidHandlerAdapter( handlerExt, this );
|
||||
IFluidHandler handlerExt = target.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, targetSide);
|
||||
if (handlerExt != null) {
|
||||
return new FluidHandlerAdapter(handlerExt, this);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private int createHandlerHash( TileEntity target )
|
||||
{
|
||||
if( target == null )
|
||||
{
|
||||
private int createHandlerHash(TileEntity target) {
|
||||
if (target == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
final EnumFacing targetSide = this.getSide().getFacing().getOpposite();
|
||||
|
||||
if( target.hasCapability( Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide ) )
|
||||
{
|
||||
return Objects.hash( target, target.getCapability( Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide ) );
|
||||
if (target.hasCapability(Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide)) {
|
||||
return Objects.hash(target, target.getCapability(Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide));
|
||||
}
|
||||
|
||||
final IFluidHandler fluidHandler = target.getCapability( CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, targetSide );
|
||||
final IFluidHandler fluidHandler = target.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, targetSide);
|
||||
|
||||
if( fluidHandler != null )
|
||||
{
|
||||
return Objects.hash( target, fluidHandler, fluidHandler.getTankProperties().length );
|
||||
if (fluidHandler != null) {
|
||||
return Objects.hash(target, fluidHandler, fluidHandler.getTankProperties().length);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public MEInventoryHandler<IAEFluidStack> getInternalHandler()
|
||||
{
|
||||
if( this.cached )
|
||||
{
|
||||
public MEInventoryHandler<IAEFluidStack> getInternalHandler() {
|
||||
if (this.cached) {
|
||||
return this.handler;
|
||||
}
|
||||
|
||||
@@ -473,98 +399,76 @@ public class PartFluidStorageBus extends PartUpgradeable implements IGridTickabl
|
||||
|
||||
this.cached = true;
|
||||
final TileEntity self = this.getHost().getTile();
|
||||
final TileEntity target = self.getWorld().getTileEntity( self.getPos().offset( this.getSide().getFacing() ) );
|
||||
final int newHandlerHash = this.createHandlerHash( target );
|
||||
final TileEntity target = self.getWorld().getTileEntity(self.getPos().offset(this.getSide().getFacing()));
|
||||
final int newHandlerHash = this.createHandlerHash(target);
|
||||
|
||||
if( newHandlerHash != 0 && newHandlerHash == this.handlerHash )
|
||||
{
|
||||
if (newHandlerHash != 0 && newHandlerHash == this.handlerHash) {
|
||||
return this.handler;
|
||||
}
|
||||
|
||||
this.handlerHash = newHandlerHash;
|
||||
this.handler = null;
|
||||
if( this.monitor != null )
|
||||
{
|
||||
( (IBaseMonitor<IAEFluidStack>) monitor ).removeListener( this );
|
||||
if (this.monitor != null) {
|
||||
((IBaseMonitor<IAEFluidStack>) monitor).removeListener(this);
|
||||
}
|
||||
this.monitor = null;
|
||||
if( target != null )
|
||||
{
|
||||
IMEInventory<IAEFluidStack> inv = this.getInventoryWrapper( target );
|
||||
if( inv instanceof ITickingMonitor )
|
||||
{
|
||||
if (target != null) {
|
||||
IMEInventory<IAEFluidStack> inv = this.getInventoryWrapper(target);
|
||||
if (inv instanceof ITickingMonitor) {
|
||||
this.monitor = (ITickingMonitor) inv;
|
||||
this.monitor.setActionSource( this.source );
|
||||
this.monitor.setMode( (StorageFilter) this.getConfigManager().getSetting( Settings.STORAGE_FILTER ) );
|
||||
this.monitor.setActionSource(this.source);
|
||||
this.monitor.setMode((StorageFilter) this.getConfigManager().getSetting(Settings.STORAGE_FILTER));
|
||||
}
|
||||
|
||||
if( inv != null )
|
||||
{
|
||||
this.handler = new MEInventoryHandler<>( inv, AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
|
||||
if (inv != null) {
|
||||
this.handler = new MEInventoryHandler<>(inv, AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class));
|
||||
|
||||
this.handler.setBaseAccess( (AccessRestriction) this.getConfigManager().getSetting( Settings.ACCESS ) );
|
||||
this.handler.setWhitelist( this.getInstalledUpgrades( Upgrades.INVERTER ) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST );
|
||||
this.handler.setPriority( this.getPriority() );
|
||||
this.handler.setBaseAccess((AccessRestriction) this.getConfigManager().getSetting(Settings.ACCESS));
|
||||
this.handler.setWhitelist(this.getInstalledUpgrades(Upgrades.INVERTER) > 0 ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST);
|
||||
this.handler.setPriority(this.getPriority());
|
||||
|
||||
final IItemList<IAEFluidStack> priorityList = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList();
|
||||
final IItemList<IAEFluidStack> priorityList = AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class).createList();
|
||||
|
||||
final int slotsToUse = 18 + this.getInstalledUpgrades( Upgrades.CAPACITY ) * 9;
|
||||
for( int x = 0; x < this.config.getSlots() && x < slotsToUse; x++ )
|
||||
{
|
||||
final IAEFluidStack is = this.config.getFluidInSlot( x );
|
||||
if( is != null )
|
||||
{
|
||||
priorityList.add( is );
|
||||
final int slotsToUse = 18 + this.getInstalledUpgrades(Upgrades.CAPACITY) * 9;
|
||||
for (int x = 0; x < this.config.getSlots() && x < slotsToUse; x++) {
|
||||
final IAEFluidStack is = this.config.getFluidInSlot(x);
|
||||
if (is != null) {
|
||||
priorityList.add(is);
|
||||
}
|
||||
}
|
||||
|
||||
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
{
|
||||
this.handler.setPartitionList( new FuzzyPriorityList<IAEFluidStack>( priorityList, (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.handler.setPartitionList( new PrecisePriorityList<IAEFluidStack>( priorityList ) );
|
||||
if (this.getInstalledUpgrades(Upgrades.FUZZY) > 0) {
|
||||
this.handler.setPartitionList(new FuzzyPriorityList<IAEFluidStack>(priorityList, (FuzzyMode) this.getConfigManager().getSetting(Settings.FUZZY_MODE)));
|
||||
} else {
|
||||
this.handler.setPartitionList(new PrecisePriorityList<IAEFluidStack>(priorityList));
|
||||
}
|
||||
|
||||
if( inv instanceof IBaseMonitor )
|
||||
{
|
||||
if( ( (AccessRestriction) ( (ConfigManager) this.getConfigManager() ).getSetting( Settings.ACCESS ) ).hasPermission( AccessRestriction.READ ) )
|
||||
{
|
||||
( (IBaseMonitor<IAEFluidStack>) inv ).addListener( this, this.handler );
|
||||
if (inv instanceof IBaseMonitor) {
|
||||
if (((AccessRestriction) ((ConfigManager) this.getConfigManager()).getSetting(Settings.ACCESS)).hasPermission(AccessRestriction.READ)) {
|
||||
((IBaseMonitor<IAEFluidStack>) inv).addListener(this, this.handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update sleep state...
|
||||
if( wasSleeping != ( this.monitor == null ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
if (wasSleeping != (this.monitor == null)) {
|
||||
try {
|
||||
final ITickManager tm = this.getProxy().getTick();
|
||||
if( this.monitor == null )
|
||||
{
|
||||
tm.sleepDevice( this.getProxy().getNode() );
|
||||
if (this.monitor == null) {
|
||||
tm.sleepDevice(this.getProxy().getNode());
|
||||
} else {
|
||||
tm.wakeDevice(this.getProxy().getNode());
|
||||
}
|
||||
else
|
||||
{
|
||||
tm.wakeDevice( this.getProxy().getNode() );
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException ignore )
|
||||
{
|
||||
} catch (final GridAccessException ignore) {
|
||||
// :(
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
// force grid to update handlers...
|
||||
( (GridStorageCache) this.getProxy().getGrid().getCache( IStorageGrid.class ) ).cellUpdate( null );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
((GridStorageCache) this.getProxy().getGrid().getCache(IStorageGrid.class)).cellUpdate(null);
|
||||
} catch (final GridAccessException e) {
|
||||
// :3
|
||||
}
|
||||
|
||||
@@ -572,77 +476,61 @@ public class PartFluidStorageBus extends PartUpgradeable implements IGridTickabl
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IMEInventoryHandler> getCellArray( final IStorageChannel channel )
|
||||
{
|
||||
if( channel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
|
||||
{
|
||||
public List<IMEInventoryHandler> getCellArray(final IStorageChannel channel) {
|
||||
if (channel == AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class)) {
|
||||
final IMEInventoryHandler<IAEFluidStack> out = this.getInternalHandler();
|
||||
if( out != null )
|
||||
{
|
||||
return Collections.singletonList( out );
|
||||
if (out != null) {
|
||||
return Collections.singletonList(out);
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority()
|
||||
{
|
||||
public int getPriority() {
|
||||
return this.priority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority( int newValue )
|
||||
{
|
||||
public void setPriority(int newValue) {
|
||||
this.priority = newValue;
|
||||
this.getHost().markForSave();
|
||||
this.resetCache( true );
|
||||
this.resetCache(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void blinkCell( int slot )
|
||||
{
|
||||
public void blinkCell(int slot) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges( @Nullable ICellInventory<?> cellInventory )
|
||||
{
|
||||
public void saveChanges(@Nullable ICellInventory<?> cellInventory) {
|
||||
|
||||
}
|
||||
|
||||
public IAEFluidTank getConfig()
|
||||
{
|
||||
public IAEFluidTank getConfig() {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IPartModel getStaticModels()
|
||||
{
|
||||
if( this.isActive() && this.isPowered() )
|
||||
{
|
||||
public IPartModel getStaticModels() {
|
||||
if (this.isActive() && this.isPowered()) {
|
||||
return MODELS_HAS_CHANNEL;
|
||||
}
|
||||
else if( this.isPowered() )
|
||||
{
|
||||
} else if (this.isPowered()) {
|
||||
return MODELS_ON;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return MODELS_OFF;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStackRepresentation()
|
||||
{
|
||||
return AEApi.instance().definitions().parts().fluidStorageBus().maybeStack( 1 ).orElse( ItemStack.EMPTY );
|
||||
public ItemStack getItemStackRepresentation() {
|
||||
return AEApi.instance().definitions().parts().fluidStorageBus().maybeStack(1).orElse(ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuiBridge getGuiBridge()
|
||||
{
|
||||
public GuiBridge getGuiBridge() {
|
||||
return GuiBridge.GUI_STORAGEBUS_FLUID;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user