Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 517bd77df7 | |||
| 19f928a9a5 | |||
| 73251a0fe5 | |||
| 9335daff7d | |||
| cc5377d53b | |||
| 059f20d801 | |||
| d229570495 | |||
| c284748b6c | |||
| 880a9c8821 | |||
| c68c02ef3b | |||
| 89c4d2736c | |||
| 01778794e5 | |||
| 8f2a06e457 | |||
| 2d71b75019 | |||
| 9f09cd04d4 | |||
| b041fae0d5 | |||
| c466a0e00e |
+1
-1
@@ -3,7 +3,7 @@ aechannel=stable
|
|||||||
aebuild=7
|
aebuild=7
|
||||||
aegroup=appeng
|
aegroup=appeng
|
||||||
aebasename=appliedenergistics2
|
aebasename=appliedenergistics2
|
||||||
trousers=omni-fixes-v46e
|
trousers=omni-fixes-v46aa
|
||||||
|
|
||||||
#########################################################
|
#########################################################
|
||||||
# Versions #
|
# Versions #
|
||||||
|
|||||||
@@ -22,9 +22,10 @@ package appeng.client.render;
|
|||||||
import appeng.api.storage.data.IAEFluidStack;
|
import appeng.api.storage.data.IAEFluidStack;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.FontRenderer;
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.*;
|
||||||
import net.minecraft.client.renderer.OpenGlHelper;
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
import net.minecraft.client.renderer.RenderItem;
|
import net.minecraft.client.renderer.texture.TextureMap;
|
||||||
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
|
||||||
@@ -32,6 +33,7 @@ import appeng.api.storage.data.IAEItemStack;
|
|||||||
import appeng.util.IWideReadableNumberConverter;
|
import appeng.util.IWideReadableNumberConverter;
|
||||||
import appeng.util.ReadableNumberConverter;
|
import appeng.util.ReadableNumberConverter;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -121,6 +123,49 @@ public class TesrRenderHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void renderFluid2d( FluidStack fluidStack, float scale )
|
||||||
|
{
|
||||||
|
if( fluidStack != null )
|
||||||
|
{
|
||||||
|
GlStateManager.pushMatrix();
|
||||||
|
int color = fluidStack.getFluid().getColor( fluidStack );
|
||||||
|
float r = ( color >> 16 & 255 ) / 255.0f;
|
||||||
|
float g = ( color >> 8 & 255 ) / 255.0f;
|
||||||
|
float b = ( color & 255 ) / 255.0f;
|
||||||
|
TextureAtlasSprite sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite( fluidStack.getFluid().getStill( fluidStack ).toString() );
|
||||||
|
GlStateManager.enableBlend();
|
||||||
|
GlStateManager.blendFunc( GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA );
|
||||||
|
GlStateManager.disableAlpha();
|
||||||
|
GlStateManager.disableLighting();
|
||||||
|
Minecraft.getMinecraft().getTextureManager().bindTexture( TextureMap.LOCATION_BLOCKS_TEXTURE );
|
||||||
|
Tessellator tess = Tessellator.getInstance();
|
||||||
|
BufferBuilder buf = tess.getBuffer();
|
||||||
|
|
||||||
|
float width = 0.4f;
|
||||||
|
float height = 0.4f;
|
||||||
|
float alpha = 1.0f;
|
||||||
|
float z = 0.0001f;
|
||||||
|
float x = -0.20f;
|
||||||
|
float y = -0.25f;
|
||||||
|
|
||||||
|
buf.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR );
|
||||||
|
double uMin = sprite.getInterpolatedU( 16D - width * 16D ), uMax = sprite.getInterpolatedU( width * 16D );
|
||||||
|
double vMin = sprite.getMinV(), vMax = sprite.getInterpolatedV( height * 16D );
|
||||||
|
buf.pos( x, y, z ).tex( uMin, vMin ).color( r, g, b, alpha ).endVertex();
|
||||||
|
buf.pos( x, y + height, z ).tex( uMin, vMax ).color( r, g, b, alpha ).endVertex();
|
||||||
|
buf.pos( x + width, y + height, z ).tex( uMax, vMax ).color( r, g, b, alpha ).endVertex();
|
||||||
|
buf.pos( x + width, y, z ).tex( uMax, vMin ).color( r, g, b, alpha ).endVertex();
|
||||||
|
|
||||||
|
tess.draw();
|
||||||
|
GlStateManager.enableLighting();
|
||||||
|
GlStateManager.enableAlpha();
|
||||||
|
GlStateManager.disableBlend();
|
||||||
|
GlStateManager.color( 1F, 1F, 1F, 1F );
|
||||||
|
GlStateManager.popMatrix();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render an item in 2D and the given text below it.
|
* Render an item in 2D and the given text below it.
|
||||||
*
|
*
|
||||||
@@ -147,9 +192,9 @@ public class TesrRenderHelper
|
|||||||
|
|
||||||
public static void renderFluid2dWithAmount( IAEFluidStack fluidStack, float scale, float spacing )
|
public static void renderFluid2dWithAmount( IAEFluidStack fluidStack, float scale, float spacing )
|
||||||
{
|
{
|
||||||
final ItemStack renderStack = fluidStack.asItemStackRepresentation();
|
final FluidStack renderStack = fluidStack.getFluidStack();
|
||||||
|
|
||||||
TesrRenderHelper.renderItem2d( renderStack, scale );
|
TesrRenderHelper.renderFluid2d( renderStack, scale );
|
||||||
|
|
||||||
final long stackSize = fluidStack.getStackSize() / 1000;
|
final long stackSize = fluidStack.getStackSize() / 1000;
|
||||||
final String renderedStackSize = NUMBER_CONVERTER.toWideReadableForm( stackSize ) + "B";
|
final String renderedStackSize = NUMBER_CONVERTER.toWideReadableForm( stackSize ) + "B";
|
||||||
|
|||||||
@@ -305,7 +305,7 @@ public class CraftingTreeProcess
|
|||||||
|
|
||||||
void getPlan( final IItemList<IAEItemStack> plan )
|
void getPlan( final IItemList<IAEItemStack> plan )
|
||||||
{
|
{
|
||||||
for( IAEItemStack i : this.details.getCondensedOutputs() )
|
for( IAEItemStack i : this.details.getOutputs() )
|
||||||
{
|
{
|
||||||
i = i.copy();
|
i = i.copy();
|
||||||
i.setCountRequestable( i.getStackSize() * this.crafts );
|
i.setCountRequestable( i.getStackSize() * this.crafts );
|
||||||
|
|||||||
@@ -91,12 +91,10 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
|||||||
private int isWorking = -1;
|
private int isWorking = -1;
|
||||||
private int priority;
|
private int priority;
|
||||||
|
|
||||||
private final MEMonitorPassThrough<IAEItemStack> items = new MEMonitorPassThrough<>( new NullInventory<IAEItemStack>(), AEApi.instance()
|
private final MEMonitorPassThrough<IAEItemStack> items = new MEMonitorPassThrough<>( new NullInventory<IAEItemStack>(), AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||||
.storage()
|
private final MEMonitorPassThrough<IAEFluidStack> fluids = new MEMonitorPassThrough<>( new NullInventory<IAEFluidStack>(), AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
|
||||||
.getStorageChannel( IItemStorageChannel.class ) );
|
private boolean resetConfigCache;
|
||||||
private final MEMonitorPassThrough<IAEFluidStack> fluids = new MEMonitorPassThrough<>( new NullInventory<IAEFluidStack>(), AEApi.instance()
|
private IMEMonitor<IAEFluidStack> configCachedHandler;
|
||||||
.storage()
|
|
||||||
.getStorageChannel( IFluidStorageChannel.class ) );
|
|
||||||
|
|
||||||
public DualityFluidInterface( final AENetworkProxy networkProxy, final IFluidInterfaceHost ih )
|
public DualityFluidInterface( final AENetworkProxy networkProxy, final IFluidInterfaceHost ih )
|
||||||
{
|
{
|
||||||
@@ -146,7 +144,12 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
|||||||
{
|
{
|
||||||
if( this.hasConfig() )
|
if( this.hasConfig() )
|
||||||
{
|
{
|
||||||
return (IMEMonitor<T>) new InterfaceInventory( this );
|
if( resetConfigCache )
|
||||||
|
{
|
||||||
|
resetConfigCache = false;
|
||||||
|
configCachedHandler = new InterfaceInventory( this );
|
||||||
|
}
|
||||||
|
return (IMEMonitor<T>) configCachedHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (IMEMonitor<T>) this.fluids;
|
return (IMEMonitor<T>) this.fluids;
|
||||||
@@ -450,7 +453,12 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
|||||||
|
|
||||||
if( inventory == this.config )
|
if( inventory == this.config )
|
||||||
{
|
{
|
||||||
|
boolean cfg = hasConfig();
|
||||||
this.readConfig();
|
this.readConfig();
|
||||||
|
if( cfg != hasConfig )
|
||||||
|
{
|
||||||
|
resetConfigCache = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if( inventory == this.tanks )
|
else if( inventory == this.tanks )
|
||||||
{
|
{
|
||||||
@@ -555,7 +563,6 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
|||||||
InterfaceInventory( final DualityFluidInterface tileInterface )
|
InterfaceInventory( final DualityFluidInterface tileInterface )
|
||||||
{
|
{
|
||||||
super( tileInterface.tanks );
|
super( tileInterface.tanks );
|
||||||
this.setActionSource( new MachineSource( tileInterface.iHost ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -232,18 +232,11 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
|
|||||||
|
|
||||||
for( IFluidTankProperties tankProperty : tankProperties )
|
for( IFluidTankProperties tankProperty : tankProperties )
|
||||||
{
|
{
|
||||||
FluidStack newFS = tankProperty.getContents();
|
if( this.mode == StorageFilter.EXTRACTABLE_ONLY && this.fluidHandler.drain( 1, false ) == null )
|
||||||
if( this.mode == StorageFilter.EXTRACTABLE_ONLY && newFS != null )
|
|
||||||
{
|
{
|
||||||
if( this.fluidHandler.drain( 1, false ) == null )
|
continue;
|
||||||
{
|
|
||||||
newFS = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if( newFS != null )
|
|
||||||
{
|
|
||||||
currentlyOnStorage.add( AEFluidStack.fromFluidStack( newFS ) );
|
|
||||||
}
|
}
|
||||||
|
currentlyOnStorage.add( AEFluidStack.fromFluidStack( tankProperty.getContents() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( final IAEFluidStack is : currentlyCached )
|
for ( final IAEFluidStack is : currentlyCached )
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
|||||||
{
|
{
|
||||||
this.resetCacheLogic = 2;
|
this.resetCacheLogic = 2;
|
||||||
}
|
}
|
||||||
else
|
else if( this.resetCacheLogic < 2 )
|
||||||
{
|
{
|
||||||
this.resetCacheLogic = 1;
|
this.resetCacheLogic = 1;
|
||||||
}
|
}
|
||||||
@@ -326,6 +326,10 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
|||||||
|
|
||||||
this.handlerHash = newHandlerHash;
|
this.handlerHash = newHandlerHash;
|
||||||
this.handler = null;
|
this.handler = null;
|
||||||
|
if( this.monitor != null )
|
||||||
|
{
|
||||||
|
( (IBaseMonitor<IAEFluidStack>) monitor ).removeListener( this );
|
||||||
|
}
|
||||||
this.monitor = null;
|
this.monitor = null;
|
||||||
if( target != null )
|
if( target != null )
|
||||||
{
|
{
|
||||||
@@ -334,6 +338,7 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
|||||||
{
|
{
|
||||||
this.monitor = (ITickingMonitor) inv;
|
this.monitor = (ITickingMonitor) inv;
|
||||||
this.monitor.setActionSource( new MachineSource( this ) );
|
this.monitor.setActionSource( new MachineSource( this ) );
|
||||||
|
this.monitor.setMode( (StorageFilter) this.getConfigManager().getSetting( Settings.STORAGE_FILTER ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( inv != null )
|
if( inv != null )
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import java.util.*;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import appeng.api.definitions.IItemDefinition;
|
|
||||||
import appeng.integration.modules.gregtech.GTCEInventoryAdaptor;
|
import appeng.integration.modules.gregtech.GTCEInventoryAdaptor;
|
||||||
import appeng.util.*;
|
import appeng.util.*;
|
||||||
import appeng.util.inv.*;
|
import appeng.util.inv.*;
|
||||||
@@ -35,7 +34,6 @@ import gregtech.api.metatileentity.MetaTileEntity;
|
|||||||
import gregtech.api.metatileentity.MetaTileEntityHolder;
|
import gregtech.api.metatileentity.MetaTileEntityHolder;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
import net.minecraft.inventory.InventoryCrafting;
|
import net.minecraft.inventory.InventoryCrafting;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
@@ -142,15 +140,17 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
|||||||
private int isWorking = -1;
|
private int isWorking = -1;
|
||||||
private final Accessor accessor = new Accessor();
|
private final Accessor accessor = new Accessor();
|
||||||
private EnumSet<EnumFacing> visitedFaces = EnumSet.noneOf( EnumFacing.class );
|
private EnumSet<EnumFacing> visitedFaces = EnumSet.noneOf( EnumFacing.class );
|
||||||
private EnumMap<EnumFacing,List<ItemStack>> waitingToSendFacing = new EnumMap<>(EnumFacing.class);
|
private EnumMap<EnumFacing, List<ItemStack>> waitingToSendFacing = new EnumMap<>( EnumFacing.class );
|
||||||
private GTCEInventoryAdaptor GTad;
|
private GTCEInventoryAdaptor GTad;
|
||||||
|
private boolean resetConfigCache = true;
|
||||||
|
private IMEMonitor<IAEItemStack> configCachedHandler;
|
||||||
|
|
||||||
public DualityInterface( final AENetworkProxy networkProxy, final IInterfaceHost ih )
|
public DualityInterface( final AENetworkProxy networkProxy, final IInterfaceHost ih )
|
||||||
{
|
{
|
||||||
this.gridProxy = networkProxy;
|
this.gridProxy = networkProxy;
|
||||||
this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
this.gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||||
|
|
||||||
this.upgrades = new StackUpgradeInventory( this.gridProxy.getMachineRepresentation(), this, 4);
|
this.upgrades = new StackUpgradeInventory( this.gridProxy.getMachineRepresentation(), this, 4 );
|
||||||
this.cm.registerSetting( Settings.BLOCK, YesNo.NO );
|
this.cm.registerSetting( Settings.BLOCK, YesNo.NO );
|
||||||
this.cm.registerSetting( Settings.INTERFACE_TERMINAL, YesNo.YES );
|
this.cm.registerSetting( Settings.INTERFACE_TERMINAL, YesNo.YES );
|
||||||
|
|
||||||
@@ -178,9 +178,14 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if( inv == this.config )
|
if( inv == this.config && ( !removed.isEmpty() || !added.isEmpty() ) )
|
||||||
{
|
{
|
||||||
|
boolean cfg = hasConfig();
|
||||||
this.readConfig();
|
this.readConfig();
|
||||||
|
if( cfg != hasConfig )
|
||||||
|
{
|
||||||
|
resetConfigCache = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if( inv == this.patterns && ( !removed.isEmpty() || !added.isEmpty() ) )
|
else if( inv == this.patterns && ( !removed.isEmpty() || !added.isEmpty() ) )
|
||||||
{
|
{
|
||||||
@@ -975,7 +980,12 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
|||||||
{
|
{
|
||||||
if( this.hasConfig() )
|
if( this.hasConfig() )
|
||||||
{
|
{
|
||||||
return (IMEMonitor<T>) new InterfaceInventory( this );
|
if( resetConfigCache )
|
||||||
|
{
|
||||||
|
resetConfigCache = false;
|
||||||
|
configCachedHandler = new InterfaceInventory( this );
|
||||||
|
}
|
||||||
|
return (IMEMonitor<T>) configCachedHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (IMEMonitor<T>) this.items;
|
return (IMEMonitor<T>) this.items;
|
||||||
@@ -1583,7 +1593,6 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
|||||||
public InterfaceInventory( final DualityInterface tileInterface )
|
public InterfaceInventory( final DualityInterface tileInterface )
|
||||||
{
|
{
|
||||||
super( new AdaptorItemHandler( tileInterface.storage ) );
|
super( new AdaptorItemHandler( tileInterface.storage ) );
|
||||||
this.setActionSource( new MachineSource( DualityInterface.this.iHost ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final int outputLength = this.isCrafting ? CRAFTING_OUTPUT_LIMIT : PROCESSING_OUTPUT_LIMIT;
|
final int outputLength = out.size();
|
||||||
|
|
||||||
this.inputs = in.toArray(new IAEItemStack[ALL_INPUT_LIMIT]);
|
this.inputs = in.toArray(new IAEItemStack[ALL_INPUT_LIMIT]);
|
||||||
this.outputs = out.toArray(new IAEItemStack[outputLength]);
|
this.outputs = out.toArray(new IAEItemStack[outputLength]);
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
|
|||||||
|
|
||||||
final ICraftingPatternDetails details = this.getPatternForItem( item, w );
|
final ICraftingPatternDetails details = this.getPatternForItem( item, w );
|
||||||
|
|
||||||
out = details != null ? details.getCondensedOutputs()[0].createItemStack() : ItemStack.EMPTY;
|
out = details != null ? details.getOutputs()[0].createItemStack() : ItemStack.EMPTY;
|
||||||
|
|
||||||
SIMPLE_CACHE.put( item, out );
|
SIMPLE_CACHE.put( item, out );
|
||||||
return out;
|
return out;
|
||||||
|
|||||||
+32
-4
@@ -35,7 +35,6 @@ import java.util.concurrent.Executors;
|
|||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
|
|
||||||
import appeng.api.storage.data.IAEFluidStack;
|
|
||||||
import com.google.common.collect.HashMultimap;
|
import com.google.common.collect.HashMultimap;
|
||||||
import com.google.common.collect.ImmutableCollection;
|
import com.google.common.collect.ImmutableCollection;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
@@ -272,6 +271,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Object2ObjectMap<IAEItemStack, ImmutableList<ICraftingPatternDetails>> oldItems = new Object2ObjectOpenHashMap<>(this.craftableItems);
|
final Object2ObjectMap<IAEItemStack, ImmutableList<ICraftingPatternDetails>> oldItems = new Object2ObjectOpenHashMap<>(this.craftableItems);
|
||||||
|
final Set<IAEItemStack> oldEmitableItems = new HashSet<>(this.emitableItems);
|
||||||
|
|
||||||
// erase list.
|
// erase list.
|
||||||
this.craftingMethods.clear();
|
this.craftingMethods.clear();
|
||||||
@@ -289,7 +289,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
|||||||
// new craftables!
|
// new craftables!
|
||||||
for( final ICraftingPatternDetails details : this.craftingMethods.keySet() )
|
for( final ICraftingPatternDetails details : this.craftingMethods.keySet() )
|
||||||
{
|
{
|
||||||
for( IAEItemStack out : details.getCondensedOutputs() )
|
for( IAEItemStack out : details.getOutputs() )
|
||||||
{
|
{
|
||||||
out = out.copy();
|
out = out.copy();
|
||||||
out.reset();
|
out.reset();
|
||||||
@@ -317,14 +317,42 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
|||||||
ObjectSet<Entry<IAEItemStack, ImmutableList<ICraftingPatternDetails>>> i = oldItems.entrySet();
|
ObjectSet<Entry<IAEItemStack, ImmutableList<ICraftingPatternDetails>>> i = oldItems.entrySet();
|
||||||
for ( Entry<IAEItemStack, ImmutableList<ICraftingPatternDetails>> ais : i) {
|
for ( Entry<IAEItemStack, ImmutableList<ICraftingPatternDetails>> ais : i) {
|
||||||
if (!this.craftableItems.containsKey( ais.getKey() )) {
|
if (!this.craftableItems.containsKey( ais.getKey() )) {
|
||||||
craftablesChanged.put( ais.getKey().setCraftable( false ), ais.getValue() );
|
IAEItemStack changedStack = ais.getKey().copy();
|
||||||
|
changedStack.reset();
|
||||||
|
changedStack.setCraftable( false );
|
||||||
|
craftablesChanged.put( changedStack, ais.getValue() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectSet<Entry<IAEItemStack, ImmutableList<ICraftingPatternDetails>>> j = this.craftableItems.entrySet();
|
ObjectSet<Entry<IAEItemStack, ImmutableList<ICraftingPatternDetails>>> j = this.craftableItems.entrySet();
|
||||||
for ( Entry<IAEItemStack, ImmutableList<ICraftingPatternDetails>> ais : j) {
|
for ( Entry<IAEItemStack, ImmutableList<ICraftingPatternDetails>> ais : j) {
|
||||||
if (!oldItems.containsKey( ais )){
|
if (!oldItems.containsKey( ais )){
|
||||||
craftablesChanged.put( ais.getKey().setCraftable( true ), ais.getValue() );
|
IAEItemStack changedStack = ais.getKey().copy();
|
||||||
|
changedStack.reset();
|
||||||
|
changedStack.setCraftable( true );
|
||||||
|
craftablesChanged.put( changedStack, ais.getValue() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for( final IAEItemStack st : oldEmitableItems )
|
||||||
|
{
|
||||||
|
if( !emitableItems.contains( st ) )
|
||||||
|
{
|
||||||
|
IAEItemStack changedStack = st.copy();
|
||||||
|
changedStack.reset();
|
||||||
|
changedStack.setCraftable( false );
|
||||||
|
craftablesChanged.put( changedStack, null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for( final IAEItemStack st : this.emitableItems )
|
||||||
|
{
|
||||||
|
if( !oldEmitableItems.contains( st ) )
|
||||||
|
{
|
||||||
|
IAEItemStack changedStack = st.copy();
|
||||||
|
changedStack.reset();
|
||||||
|
changedStack.setCraftable( true );
|
||||||
|
craftablesChanged.put( changedStack, null );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+67
-97
@@ -19,10 +19,21 @@
|
|||||||
package appeng.me.cache;
|
package appeng.me.cache;
|
||||||
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.Collection;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.NavigableSet;
|
||||||
|
import java.util.PriorityQueue;
|
||||||
|
import java.util.Queue;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.collect.*;
|
import com.google.common.collect.HashMultiset;
|
||||||
|
import com.google.common.collect.Multiset;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
import appeng.api.config.AccessRestriction;
|
import appeng.api.config.AccessRestriction;
|
||||||
import appeng.api.config.Actionable;
|
import appeng.api.config.Actionable;
|
||||||
@@ -70,7 +81,7 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
// Should only be modified from the add/remove methods below to guard against
|
// Should only be modified from the add/remove methods below to guard against
|
||||||
// concurrent modifications
|
// concurrent modifications
|
||||||
private final double averageLength = 40.0;
|
private final double averageLength = 40.0;
|
||||||
private final Multimap<Integer,IAEPowerStorage> providers = HashMultimap.create();
|
private final Set<IAEPowerStorage> providers = new LinkedHashSet<>();
|
||||||
// Used to track whether an extraction is currently in progress, to fail fast
|
// Used to track whether an extraction is currently in progress, to fail fast
|
||||||
// when something externally
|
// when something externally
|
||||||
// modifies the energy grid.
|
// modifies the energy grid.
|
||||||
@@ -78,7 +89,7 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
|
|
||||||
// Should only be modified from the add/remove methods below to guard against
|
// Should only be modified from the add/remove methods below to guard against
|
||||||
// concurrent modifications
|
// concurrent modifications
|
||||||
private final Multimap<Integer,IAEPowerStorage> requesters = HashMultimap.create();
|
private final Set<IAEPowerStorage> requesters = new LinkedHashSet<>();
|
||||||
// Used to track whether an injection is currently in progress, to fail fast
|
// Used to track whether an injection is currently in progress, to fail fast
|
||||||
// when something externally
|
// when something externally
|
||||||
// modifies the energy grid.
|
// modifies the energy grid.
|
||||||
@@ -115,16 +126,16 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
private double lastStoredPower = -1;
|
private double lastStoredPower = -1;
|
||||||
|
|
||||||
private final GridPowerStorage localStorage = new GridPowerStorage();
|
private final GridPowerStorage localStorage = new GridPowerStorage();
|
||||||
private Set<IAEPowerStorage> providersToRemove = new HashSet<>();
|
private Set<IAEPowerStorage> providerToRemove = new HashSet<>();
|
||||||
private Set<IAEPowerStorage> requestersToRemove = new HashSet<>();
|
private Set<IAEPowerStorage> requesterToRemove = new HashSet<>();
|
||||||
private Set<IAEPowerStorage> providersToAdd = new HashSet<>();
|
private Set<IAEPowerStorage> providersToAdd = new HashSet<>();
|
||||||
private Set<IAEPowerStorage> requestersToAdd = new HashSet<>();
|
private Set<IAEPowerStorage> requesterToAdd = new HashSet<>();
|
||||||
|
|
||||||
public EnergyGridCache( final IGrid g )
|
public EnergyGridCache( final IGrid g )
|
||||||
{
|
{
|
||||||
this.myGrid = g;
|
this.myGrid = g;
|
||||||
this.requesters.put( 0, this.localStorage );
|
this.requesters.add( this.localStorage );
|
||||||
this.providers.put( 1, this.localStorage );
|
this.providers.add( this.localStorage );
|
||||||
}
|
}
|
||||||
|
|
||||||
@MENetworkEventSubscribe
|
@MENetworkEventSubscribe
|
||||||
@@ -176,7 +187,7 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.requestersToAdd.add( ev.storage );
|
this.requesterToAdd.add( ev.storage );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -307,7 +318,7 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
{
|
{
|
||||||
this.availableTicksSinceUpdate = 0;
|
this.availableTicksSinceUpdate = 0;
|
||||||
this.globalAvailablePower = 0;
|
this.globalAvailablePower = 0;
|
||||||
for( final IAEPowerStorage p : this.providers.values() )
|
for( final IAEPowerStorage p : this.providers )
|
||||||
{
|
{
|
||||||
this.globalAvailablePower += p.getAECurrentPower();
|
this.globalAvailablePower += p.getAECurrentPower();
|
||||||
}
|
}
|
||||||
@@ -324,27 +335,25 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
{
|
{
|
||||||
double extractedPower = 0;
|
double extractedPower = 0;
|
||||||
|
|
||||||
providersToAdd.forEach( provider -> {
|
this.providers.addAll( providersToAdd );
|
||||||
if( provider instanceof GridPowerStorage )
|
|
||||||
{
|
|
||||||
providers.put( 1, provider );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
providers.put( 0, provider );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
providersToAdd.clear();
|
providersToAdd.clear();
|
||||||
|
|
||||||
final Iterator<IAEPowerStorage> it = this.providers.values().iterator();
|
final Iterator<IAEPowerStorage> it = this.providers.iterator();
|
||||||
|
|
||||||
ongoingExtractOperation = true;
|
ongoingExtractOperation = true;
|
||||||
|
boolean ls = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
while ( extractedPower < amt && it.hasNext() )
|
while ( extractedPower < amt && it.hasNext() )
|
||||||
{
|
{
|
||||||
final IAEPowerStorage node = it.next();
|
final IAEPowerStorage node = it.next();
|
||||||
|
|
||||||
|
if( node == localStorage && mode == Actionable.MODULATE )
|
||||||
|
{
|
||||||
|
ls = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
final double req = amt - extractedPower;
|
final double req = amt - extractedPower;
|
||||||
final double newPower = node.extractAEPower( req, mode, PowerMultiplier.ONE );
|
final double newPower = node.extractAEPower( req, mode, PowerMultiplier.ONE );
|
||||||
extractedPower += newPower;
|
extractedPower += newPower;
|
||||||
@@ -356,20 +365,25 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
}
|
}
|
||||||
} finally
|
} finally
|
||||||
{
|
{
|
||||||
providersToRemove.forEach( provider -> {
|
|
||||||
if( provider instanceof GridPowerStorage )
|
|
||||||
{
|
|
||||||
providers.remove( 1, provider );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
providers.remove( 0, provider );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
this.providersToRemove.clear();
|
|
||||||
ongoingExtractOperation = false;
|
ongoingExtractOperation = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( ls && extractedPower < amt )
|
||||||
|
{
|
||||||
|
final double req = amt - extractedPower;
|
||||||
|
final double newPower = localStorage.extractAEPower( req, mode, PowerMultiplier.ONE );
|
||||||
|
|
||||||
|
extractedPower += newPower;
|
||||||
|
|
||||||
|
if( newPower < req )
|
||||||
|
{
|
||||||
|
providers.remove( localStorage );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
providers.removeIf( p -> providerToRemove.contains( p ) );
|
||||||
|
this.providerToRemove.clear();
|
||||||
|
|
||||||
final double result = Math.min( extractedPower, amt );
|
final double result = Math.min( extractedPower, amt );
|
||||||
|
|
||||||
if( mode == Actionable.MODULATE )
|
if( mode == Actionable.MODULATE )
|
||||||
@@ -391,19 +405,10 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
{
|
{
|
||||||
final double originalAmount = amt;
|
final double originalAmount = amt;
|
||||||
|
|
||||||
requestersToAdd.forEach( requester -> {
|
this.requesters.addAll( requesterToAdd );
|
||||||
if( requester instanceof GridPowerStorage )
|
requesterToAdd.clear();
|
||||||
{
|
|
||||||
requesters.put( 0, requester );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
requesters.put( 1, requester );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
requestersToAdd.clear();
|
|
||||||
|
|
||||||
final Iterator<IAEPowerStorage> it = this.requesters.values().iterator();
|
final Iterator<IAEPowerStorage> it = this.requesters.iterator();
|
||||||
|
|
||||||
ongoingInjectOperation = true;
|
ongoingInjectOperation = true;
|
||||||
try
|
try
|
||||||
@@ -421,20 +426,12 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
}
|
}
|
||||||
} finally
|
} finally
|
||||||
{
|
{
|
||||||
requestersToRemove.forEach( requester -> {
|
|
||||||
if( requester instanceof GridPowerStorage )
|
|
||||||
{
|
|
||||||
requesters.remove( 0, requester );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
requesters.remove( 1, requester );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
this.requestersToRemove.clear();
|
|
||||||
ongoingInjectOperation = false;
|
ongoingInjectOperation = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
requesters.removeIf( r -> requesterToRemove.contains( r ) );
|
||||||
|
this.requesterToRemove.clear();
|
||||||
|
|
||||||
final double overflow = Math.max( 0.0, amt );
|
final double overflow = Math.max( 0.0, amt );
|
||||||
|
|
||||||
if( mode == Actionable.MODULATE )
|
if( mode == Actionable.MODULATE )
|
||||||
@@ -450,8 +447,8 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
{
|
{
|
||||||
double required = 0;
|
double required = 0;
|
||||||
|
|
||||||
final Iterator<IAEPowerStorage> it = this.requesters.values().iterator();
|
final Iterator<IAEPowerStorage> it = this.requesters.iterator();
|
||||||
while( required < maxRequired && it.hasNext() )
|
while ( required < maxRequired && it.hasNext() )
|
||||||
{
|
{
|
||||||
final IAEPowerStorage node = it.next();
|
final IAEPowerStorage node = it.next();
|
||||||
if( node.getPowerFlow() != AccessRestriction.READ )
|
if( node.getPowerFlow() != AccessRestriction.READ )
|
||||||
@@ -591,7 +588,7 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.providersToRemove.add( ps );
|
this.providerToRemove.add( ps );
|
||||||
}
|
}
|
||||||
if( !ongoingInjectOperation )
|
if( !ongoingInjectOperation )
|
||||||
{
|
{
|
||||||
@@ -599,7 +596,7 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.requestersToRemove.add( ps );
|
this.requesterToRemove.add( ps );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -619,55 +616,28 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
private void addRequester(IAEPowerStorage requester) {
|
private void addRequester(IAEPowerStorage requester) {
|
||||||
Preconditions.checkState(!ongoingInjectOperation,
|
Preconditions.checkState(!ongoingInjectOperation,
|
||||||
"Cannot modify energy requesters while energy is being injected.");
|
"Cannot modify energy requesters while energy is being injected.");
|
||||||
if( requester instanceof GridPowerStorage )
|
this.requesters.add(requester);
|
||||||
{
|
|
||||||
requesters.put( 0, requester );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
requesters.put( 1, requester );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeRequester(IAEPowerStorage requester) {
|
private void removeRequester(IAEPowerStorage requester) {
|
||||||
Preconditions.checkState(!ongoingInjectOperation,
|
Preconditions.checkState(!ongoingInjectOperation,
|
||||||
"Cannot modify energy requesters while energy is being injected.");
|
"Cannot modify energy requesters while energy is being injected.");
|
||||||
if( requester instanceof GridPowerStorage )
|
this.requesters.remove(requester);
|
||||||
{
|
|
||||||
requesters.remove( 0, requester );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
requesters.remove( 1, requester );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addProvider(IAEPowerStorage provider) {
|
private void addProvider(IAEPowerStorage provider) {
|
||||||
Preconditions.checkState(!ongoingExtractOperation,
|
Preconditions.checkState(!ongoingExtractOperation,
|
||||||
"Cannot modify energy providers while energy is being extracted.");
|
"Cannot modify energy providers while energy is being extracted.");
|
||||||
if( provider instanceof GridPowerStorage )
|
this.providers.add(provider);
|
||||||
{
|
|
||||||
providers.put( 1, provider );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
providers.put( 0, provider );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeProvider(IAEPowerStorage provider)
|
private void removeProvider(IAEPowerStorage provider) {
|
||||||
{
|
Preconditions.checkState(!ongoingExtractOperation,
|
||||||
Preconditions.checkState( !ongoingExtractOperation, "Cannot modify energy providers while energy is being extracted." );
|
"Cannot modify energy providers while energy is being extracted.");
|
||||||
if( provider instanceof GridPowerStorage )
|
this.providers.remove(provider);
|
||||||
{
|
|
||||||
providers.remove( 1, provider );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
providers.remove( 0, provider );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addNode( final IGridNode node, final IGridHost machine )
|
public void addNode( final IGridNode node, final IGridHost machine )
|
||||||
{
|
{
|
||||||
@@ -717,7 +687,7 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.requestersToAdd.add( ps );
|
this.requesterToAdd.add( ps );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -845,4 +815,4 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -109,6 +109,9 @@ public class GridStorageCache implements IStorageGrid
|
|||||||
this.watchers.remove( node );
|
this.watchers.remove( node );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.storageMonitors.forEach( ( channel, monitor ) -> monitor.forceUpdate() );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -137,6 +140,9 @@ public class GridStorageCache implements IStorageGrid
|
|||||||
this.watchers.put( node, iw );
|
this.watchers.put( node, iw );
|
||||||
swh.updateWatcher( iw );
|
swh.updateWatcher( iw );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.storageMonitors.forEach( ( channel, monitor ) -> monitor.forceUpdate() );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+68
-17
@@ -61,6 +61,7 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
|||||||
private final Object2ObjectMap<IMEMonitorHandlerReceiver<T>, Object> listeners;
|
private final Object2ObjectMap<IMEMonitorHandlerReceiver<T>, Object> listeners;
|
||||||
|
|
||||||
private boolean sendEvent = false;
|
private boolean sendEvent = false;
|
||||||
|
private boolean forceUpdate = false;
|
||||||
@Nonnegative
|
@Nonnegative
|
||||||
private int localDepthSemaphore = 0;
|
private int localDepthSemaphore = 0;
|
||||||
private long gridItemCount;
|
private long gridItemCount;
|
||||||
@@ -124,6 +125,10 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
|||||||
|
|
||||||
public long getGridCurrentCount()
|
public long getGridCurrentCount()
|
||||||
{
|
{
|
||||||
|
if( forceUpdate )
|
||||||
|
{
|
||||||
|
getStorageList();
|
||||||
|
}
|
||||||
if( myChannel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
|
if( myChannel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
|
||||||
{
|
{
|
||||||
return gridItemCount;
|
return gridItemCount;
|
||||||
@@ -135,23 +140,42 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long incGridCurrentCount(long count)
|
public void incGridCurrentCount(long count)
|
||||||
{
|
{
|
||||||
if( myChannel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
|
if( myChannel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
|
||||||
{
|
{
|
||||||
return gridItemCount += count;
|
gridItemCount += count;
|
||||||
}
|
}
|
||||||
else if( myChannel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
|
else if( myChannel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
|
||||||
{
|
{
|
||||||
return gridFluidCount += count;
|
gridFluidCount += count;
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public IItemList<T> getStorageList()
|
public IItemList<T> getStorageList()
|
||||||
{
|
{
|
||||||
|
if( forceUpdate )
|
||||||
|
{
|
||||||
|
forceUpdate = false;
|
||||||
|
this.cachedList.resetStatus();
|
||||||
|
this.getAvailableItems( this.cachedList );
|
||||||
|
|
||||||
|
long count = 0;
|
||||||
|
for (T stack : this.cachedList) {
|
||||||
|
count += stack.getStackSize();
|
||||||
|
}
|
||||||
|
if( myChannel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
|
||||||
|
{
|
||||||
|
gridItemCount = count;
|
||||||
|
}
|
||||||
|
else if( myChannel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
|
||||||
|
{
|
||||||
|
gridFluidCount = count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return this.cachedList;
|
return this.cachedList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,47 +238,52 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
|||||||
for( final T changedItem : input )
|
for( final T changedItem : input )
|
||||||
{
|
{
|
||||||
if (changedItem.isCraftable()) {
|
if (changedItem.isCraftable()) {
|
||||||
this.cachedList.add( changedItem.copy().setCraftable( true ) );
|
this.cachedList.add( changedItem );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.cachedList.findPrecise( changedItem ).setCraftable( false );
|
T i = this.cachedList.findPrecise( changedItem );
|
||||||
|
if (i != null)
|
||||||
|
i.setCraftable( false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void postChange( final boolean add, final Iterable<T> changes, final IActionSource src )
|
protected void postChange( final boolean add, final Iterable<T> changes, final IActionSource src )
|
||||||
{
|
{
|
||||||
if( GLOBAL_DEPTH.contains( this ) )
|
if( this.localDepthSemaphore > 0 || GLOBAL_DEPTH.contains( this ) )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.localDepthSemaphore++;
|
||||||
GLOBAL_DEPTH.push( this );
|
GLOBAL_DEPTH.push( this );
|
||||||
|
|
||||||
this.sendEvent = true;
|
this.sendEvent = true;
|
||||||
|
|
||||||
for( final T changedItem : changes )
|
for( final T changed : changes )
|
||||||
{
|
{
|
||||||
if( !add && changedItem != null )
|
T change = changed;
|
||||||
|
if( !add && change != null )
|
||||||
{
|
{
|
||||||
changedItem.setStackSize( -changedItem.getStackSize() );
|
change = changed.copy();
|
||||||
|
change.setStackSize( -change.getStackSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
incGridCurrentCount( changedItem.getStackSize() );
|
incGridCurrentCount( change.getStackSize() );
|
||||||
this.cachedList.add( changedItem );
|
this.cachedList.add( change );
|
||||||
|
|
||||||
if( this.myGridCache.getInterestManager().containsKey( changedItem ) )
|
if( this.myGridCache.getInterestManager().containsKey( change ) )
|
||||||
{
|
{
|
||||||
final Collection<ItemWatcher> list = this.myGridCache.getInterestManager().get( changedItem );
|
final Collection<ItemWatcher> list = this.myGridCache.getInterestManager().get( change );
|
||||||
|
|
||||||
if( !list.isEmpty() )
|
if( !list.isEmpty() )
|
||||||
{
|
{
|
||||||
IAEStack<T> fullStack = this.getStorageList().findPrecise( changedItem );
|
IAEStack<T> fullStack = this.getStorageList().findPrecise( change );
|
||||||
|
|
||||||
if( fullStack == null )
|
if( fullStack == null )
|
||||||
{
|
{
|
||||||
fullStack = changedItem.copy();
|
fullStack = change.copy();
|
||||||
fullStack.setStackSize( 0 );
|
fullStack.setStackSize( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,7 +291,7 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
|||||||
|
|
||||||
for( final ItemWatcher iw : list )
|
for( final ItemWatcher iw : list )
|
||||||
{
|
{
|
||||||
iw.getHost().onStackChange( this.getStorageList(), fullStack, changedItem, src, this.getChannel() );
|
iw.getHost().onStackChange( this.getStorageList(), fullStack, change, src, this.getChannel() );
|
||||||
}
|
}
|
||||||
|
|
||||||
this.myGridCache.getInterestManager().disableTransactions();
|
this.myGridCache.getInterestManager().disableTransactions();
|
||||||
@@ -273,6 +302,7 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
|||||||
this.notifyListenersOfChange( changes, src );
|
this.notifyListenersOfChange( changes, src );
|
||||||
|
|
||||||
final NetworkMonitor<?> last = GLOBAL_DEPTH.pop();
|
final NetworkMonitor<?> last = GLOBAL_DEPTH.pop();
|
||||||
|
this.localDepthSemaphore--;
|
||||||
|
|
||||||
if( last != this )
|
if( last != this )
|
||||||
{
|
{
|
||||||
@@ -280,6 +310,27 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void forceUpdate()
|
||||||
|
{
|
||||||
|
this.forceUpdate = true;
|
||||||
|
|
||||||
|
final Iterator<Entry<IMEMonitorHandlerReceiver<T>, Object>> i = this.getListeners();
|
||||||
|
while ( i.hasNext() )
|
||||||
|
{
|
||||||
|
final Entry<IMEMonitorHandlerReceiver<T>, Object> o = i.next();
|
||||||
|
final IMEMonitorHandlerReceiver<T> receiver = o.getKey();
|
||||||
|
|
||||||
|
if( receiver.isValid( o.getValue() ) )
|
||||||
|
{
|
||||||
|
receiver.onListUpdate();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void onTick()
|
void onTick()
|
||||||
{
|
{
|
||||||
if( this.sendEvent )
|
if( this.sendEvent )
|
||||||
|
|||||||
@@ -19,14 +19,11 @@
|
|||||||
package appeng.me.storage;
|
package appeng.me.storage;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.NavigableMap;
|
|
||||||
import java.util.concurrent.ConcurrentSkipListMap;
|
import java.util.concurrent.ConcurrentSkipListMap;
|
||||||
|
|
||||||
|
import appeng.fluids.util.AEFluidStack;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||||
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
||||||
@@ -48,16 +45,14 @@ import appeng.api.storage.data.IItemList;
|
|||||||
public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack>, ITickingMonitor
|
public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack>, ITickingMonitor
|
||||||
{
|
{
|
||||||
private final IFluidHandler handler;
|
private final IFluidHandler handler;
|
||||||
private final IItemList<IAEFluidStack> list = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList();
|
private IItemList<IAEFluidStack> cache = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList();
|
||||||
private final HashMap<IMEMonitorHandlerReceiver<IAEFluidStack>, Object> listeners = new HashMap<>();
|
private final HashMap<IMEMonitorHandlerReceiver<IAEFluidStack>, Object> listeners = new HashMap<>();
|
||||||
private final NavigableMap<Integer, CachedFluidStack> memory;
|
|
||||||
private IActionSource mySource;
|
private IActionSource mySource;
|
||||||
private StorageFilter mode = StorageFilter.EXTRACTABLE_ONLY;
|
private StorageFilter mode = StorageFilter.EXTRACTABLE_ONLY;
|
||||||
|
|
||||||
public MEMonitorIFluidHandler( final IFluidHandler handler )
|
public MEMonitorIFluidHandler( final IFluidHandler handler )
|
||||||
{
|
{
|
||||||
this.handler = handler;
|
this.handler = handler;
|
||||||
this.memory = new ConcurrentSkipListMap<>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -82,11 +77,6 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack>, ITicki
|
|||||||
return input.copy();
|
return input.copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( type == Actionable.MODULATE )
|
|
||||||
{
|
|
||||||
this.onTick();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( filled == input.getStackSize() )
|
if( filled == input.getStackSize() )
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
@@ -94,6 +84,15 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack>, ITicki
|
|||||||
|
|
||||||
final IAEFluidStack o = input.copy();
|
final IAEFluidStack o = input.copy();
|
||||||
o.setStackSize( input.getStackSize() - filled );
|
o.setStackSize( input.getStackSize() - filled );
|
||||||
|
|
||||||
|
if( type == Actionable.MODULATE )
|
||||||
|
{
|
||||||
|
IAEFluidStack added = o.copy();
|
||||||
|
this.cache.add( added );
|
||||||
|
this.postDifference( Collections.singletonList( added ) );
|
||||||
|
this.onTick();
|
||||||
|
}
|
||||||
|
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,13 +106,18 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack>, ITicki
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( type == Actionable.MODULATE )
|
|
||||||
{
|
|
||||||
this.onTick();
|
|
||||||
}
|
|
||||||
|
|
||||||
final IAEFluidStack o = request.copy();
|
final IAEFluidStack o = request.copy();
|
||||||
o.setStackSize( removed.amount );
|
o.setStackSize( removed.amount );
|
||||||
|
|
||||||
|
if( type == Actionable.MODULATE )
|
||||||
|
{
|
||||||
|
IAEFluidStack cachedStack = this.cache.findPrecise( request );
|
||||||
|
if( cachedStack != null )
|
||||||
|
{
|
||||||
|
cachedStack.decStackSize( o.getStackSize() );
|
||||||
|
this.postDifference( Collections.singletonList( o.copy().setStackSize( -o.getStackSize() ) ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,111 +130,51 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack>, ITicki
|
|||||||
@Override
|
@Override
|
||||||
public TickRateModulation onTick()
|
public TickRateModulation onTick()
|
||||||
{
|
{
|
||||||
final List<IAEFluidStack> changes = new ArrayList<>();
|
|
||||||
|
|
||||||
this.list.resetStatus();
|
|
||||||
int high = 0;
|
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
|
|
||||||
final IFluidTankProperties[] props = this.handler.getTankProperties();
|
final List<IAEFluidStack> changes = new ArrayList<>();
|
||||||
for( int slot = 0; slot < this.handler.getTankProperties().length; ++slot )
|
final IFluidTankProperties[] tankProperties = this.handler.getTankProperties();
|
||||||
|
|
||||||
|
IItemList<IAEFluidStack> currentlyOnStorage = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList();
|
||||||
|
|
||||||
|
for( IFluidTankProperties tankProperty : tankProperties )
|
||||||
{
|
{
|
||||||
final CachedFluidStack old = this.memory.get( slot );
|
if( this.mode == StorageFilter.EXTRACTABLE_ONLY && this.handler.drain( 1, false ) == null )
|
||||||
high = Math.max( high, slot );
|
|
||||||
|
|
||||||
final FluidStack newIS = !props[slot].canDrain() && this.getMode() == StorageFilter.EXTRACTABLE_ONLY ? null : props[slot].getContents();
|
|
||||||
final FluidStack oldIS = old == null ? null : old.fluidStack;
|
|
||||||
|
|
||||||
if( isDifferent( newIS, oldIS ) )
|
|
||||||
{
|
{
|
||||||
final CachedFluidStack cis = new CachedFluidStack( newIS );
|
continue;
|
||||||
this.memory.put( slot, cis );
|
|
||||||
|
|
||||||
if( old != null && old.aeStack != null )
|
|
||||||
{
|
|
||||||
old.aeStack.setStackSize( -old.aeStack.getStackSize() );
|
|
||||||
changes.add( old.aeStack );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( cis.aeStack != null )
|
|
||||||
{
|
|
||||||
changes.add( cis.aeStack );
|
|
||||||
this.list.add( cis.aeStack );
|
|
||||||
}
|
|
||||||
|
|
||||||
changed = true;
|
|
||||||
}
|
}
|
||||||
else
|
currentlyOnStorage.add( AEFluidStack.fromFluidStack( tankProperty.getContents() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( final IAEFluidStack is : cache )
|
||||||
|
{
|
||||||
|
is.setStackSize( -is.getStackSize() );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( final IAEFluidStack is : currentlyOnStorage )
|
||||||
|
{
|
||||||
|
cache.add( is );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( final IAEFluidStack is : cache )
|
||||||
|
{
|
||||||
|
if( is.getStackSize() != 0 )
|
||||||
{
|
{
|
||||||
final int newSize = newIS == null ? 0 : newIS.amount;
|
changes.add( is );
|
||||||
final int diff = newSize - ( oldIS == null ? 0 : oldIS.amount );
|
|
||||||
|
|
||||||
IAEFluidStack stack = null;
|
|
||||||
|
|
||||||
if( newIS != null )
|
|
||||||
{
|
|
||||||
stack = ( old == null || old.aeStack == null ? AEApi.instance()
|
|
||||||
.storage()
|
|
||||||
.getStorageChannel( IFluidStorageChannel.class )
|
|
||||||
.createStack( newIS ) : old.aeStack.copy() );
|
|
||||||
}
|
|
||||||
if( stack != null )
|
|
||||||
{
|
|
||||||
stack.setStackSize( newSize );
|
|
||||||
this.list.add( stack );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( diff != 0 && stack != null )
|
|
||||||
{
|
|
||||||
final CachedFluidStack cis = new CachedFluidStack( newIS );
|
|
||||||
this.memory.put( slot, cis );
|
|
||||||
|
|
||||||
final IAEFluidStack a = stack.copy();
|
|
||||||
a.setStackSize( diff );
|
|
||||||
changes.add( a );
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// detect dropped items; should fix non IISided Inventory Changes.
|
cache = currentlyOnStorage;
|
||||||
final NavigableMap<Integer, CachedFluidStack> end = this.memory.tailMap( high, false );
|
|
||||||
if( !end.isEmpty() )
|
|
||||||
{
|
|
||||||
for( final CachedFluidStack cis : end.values() )
|
|
||||||
{
|
|
||||||
if( cis != null && cis.aeStack != null )
|
|
||||||
{
|
|
||||||
final IAEFluidStack a = cis.aeStack.copy();
|
|
||||||
a.setStackSize( -a.getStackSize() );
|
|
||||||
changes.add( a );
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !changes.isEmpty() )
|
if( !changes.isEmpty() )
|
||||||
{
|
{
|
||||||
this.postDifference( changes );
|
this.postDifference( changes );
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return changed ? TickRateModulation.URGENT : TickRateModulation.SLOWER;
|
return changed ? TickRateModulation.URGENT : TickRateModulation.SLOWER;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isDifferent( FluidStack a, FluidStack b )
|
|
||||||
{
|
|
||||||
if( a == b )
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if( a == null || b == null )
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return !a.getFluid().equals( b.getFluid() );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void postDifference( final Iterable<IAEFluidStack> a )
|
private void postDifference( final Iterable<IAEFluidStack> a )
|
||||||
{
|
{
|
||||||
if( a != null )
|
if( a != null )
|
||||||
@@ -291,9 +235,9 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack>, ITicki
|
|||||||
@Override
|
@Override
|
||||||
public IItemList<IAEFluidStack> getAvailableItems( final IItemList out )
|
public IItemList<IAEFluidStack> getAvailableItems( final IItemList out )
|
||||||
{
|
{
|
||||||
for( final CachedFluidStack is : this.memory.values() )
|
for( final IAEFluidStack fs : cache )
|
||||||
{
|
{
|
||||||
out.addStorage( is.aeStack );
|
out.addStorage( fs );
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
@@ -302,7 +246,7 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack>, ITicki
|
|||||||
@Override
|
@Override
|
||||||
public IItemList<IAEFluidStack> getStorageList()
|
public IItemList<IAEFluidStack> getStorageList()
|
||||||
{
|
{
|
||||||
return this.list;
|
return this.cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
private StorageFilter getMode()
|
private StorageFilter getMode()
|
||||||
@@ -326,24 +270,4 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack>, ITicki
|
|||||||
this.mySource = mySource;
|
this.mySource = mySource;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class CachedFluidStack
|
|
||||||
{
|
|
||||||
|
|
||||||
private final FluidStack fluidStack;
|
|
||||||
private final IAEFluidStack aeStack;
|
|
||||||
|
|
||||||
CachedFluidStack( final FluidStack is )
|
|
||||||
{
|
|
||||||
if( is == null )
|
|
||||||
{
|
|
||||||
this.fluidStack = null;
|
|
||||||
this.aeStack = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.fluidStack = is.copy();
|
|
||||||
this.aeStack = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createStack( is );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,12 +19,8 @@
|
|||||||
package appeng.me.storage;
|
package appeng.me.storage;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.NavigableMap;
|
|
||||||
import java.util.concurrent.ConcurrentSkipListMap;
|
import java.util.concurrent.ConcurrentSkipListMap;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
@@ -50,16 +46,15 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
|
|||||||
{
|
{
|
||||||
|
|
||||||
private final InventoryAdaptor adaptor;
|
private final InventoryAdaptor adaptor;
|
||||||
private final IItemList<IAEItemStack> list = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
private IItemList<IAEItemStack> cache = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||||
|
|
||||||
private final HashMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new HashMap<>();
|
private final HashMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new HashMap<>();
|
||||||
private final NavigableMap<Integer, CachedItemStack> memory;
|
|
||||||
private IActionSource mySource;
|
private IActionSource mySource;
|
||||||
private StorageFilter mode = StorageFilter.EXTRACTABLE_ONLY;
|
private StorageFilter mode = StorageFilter.EXTRACTABLE_ONLY;
|
||||||
|
|
||||||
public MEMonitorIInventory( final InventoryAdaptor adaptor )
|
public MEMonitorIInventory( final InventoryAdaptor adaptor )
|
||||||
{
|
{
|
||||||
this.adaptor = adaptor;
|
this.adaptor = adaptor;
|
||||||
this.memory = new ConcurrentSkipListMap<>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -88,11 +83,6 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
|
|||||||
out = this.adaptor.addItems( input.createItemStack() );
|
out = this.adaptor.addItems( input.createItemStack() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( type == Actionable.MODULATE )
|
|
||||||
{
|
|
||||||
this.onTick();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( out.isEmpty() )
|
if( out.isEmpty() )
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
@@ -101,6 +91,15 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
|
|||||||
// better then doing construction from scratch :3
|
// better then doing construction from scratch :3
|
||||||
final IAEItemStack o = input.copy();
|
final IAEItemStack o = input.copy();
|
||||||
o.setStackSize( out.getCount() );
|
o.setStackSize( out.getCount() );
|
||||||
|
|
||||||
|
if( type == Actionable.MODULATE )
|
||||||
|
{
|
||||||
|
IAEItemStack added = o.copy();
|
||||||
|
this.cache.add( added );
|
||||||
|
this.postDifference( Collections.singletonList( added ) );
|
||||||
|
this.onTick();
|
||||||
|
}
|
||||||
|
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,6 +128,12 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
|
|||||||
|
|
||||||
if( type == Actionable.MODULATE )
|
if( type == Actionable.MODULATE )
|
||||||
{
|
{
|
||||||
|
IAEItemStack cachedStack = this.cache.findPrecise( request );
|
||||||
|
if( cachedStack != null )
|
||||||
|
{
|
||||||
|
cachedStack.decStackSize( o.getStackSize() );
|
||||||
|
this.postDifference( Collections.singletonList( o.copy().setStackSize( -o.getStackSize() ) ) );
|
||||||
|
}
|
||||||
this.onTick();
|
this.onTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,110 +149,52 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
|
|||||||
@Override
|
@Override
|
||||||
public TickRateModulation onTick()
|
public TickRateModulation onTick()
|
||||||
{
|
{
|
||||||
|
boolean changed = false;
|
||||||
|
|
||||||
final List<IAEItemStack> changes = new ArrayList<>();
|
final List<IAEItemStack> changes = new ArrayList<>();
|
||||||
|
|
||||||
this.list.resetStatus();
|
IItemList<IAEItemStack> currentlyOnStorage = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||||
int high = 0;
|
|
||||||
boolean changed = false;
|
for( final ItemSlot is : adaptor )
|
||||||
for( final ItemSlot is : this.adaptor )
|
|
||||||
{
|
{
|
||||||
final CachedItemStack old = this.memory.get( is.getSlot() );
|
if( this.mode == StorageFilter.EXTRACTABLE_ONLY && !is.isExtractable() )
|
||||||
high = Math.max( high, is.getSlot() );
|
|
||||||
|
|
||||||
final ItemStack newIS = !is.isExtractable() && this.getMode() == StorageFilter.EXTRACTABLE_ONLY ? ItemStack.EMPTY : is.getItemStack();
|
|
||||||
final ItemStack oldIS = old == null ? ItemStack.EMPTY : old.itemStack;
|
|
||||||
|
|
||||||
if( this.isDifferent( newIS, oldIS ) )
|
|
||||||
{
|
{
|
||||||
final CachedItemStack cis = new CachedItemStack( is.getItemStack() );
|
continue;
|
||||||
this.memory.put( is.getSlot(), cis );
|
|
||||||
|
|
||||||
if( old != null && old.aeStack != null )
|
|
||||||
{
|
|
||||||
old.aeStack.setStackSize( -old.aeStack.getStackSize() );
|
|
||||||
changes.add( old.aeStack );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( cis.aeStack != null )
|
|
||||||
{
|
|
||||||
changes.add( cis.aeStack );
|
|
||||||
this.list.add( cis.aeStack );
|
|
||||||
}
|
|
||||||
|
|
||||||
changed = true;
|
|
||||||
}
|
}
|
||||||
else
|
currentlyOnStorage.add( is.getAEItemStack() );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( final IAEItemStack is : cache )
|
||||||
|
{
|
||||||
|
is.setStackSize( -is.getStackSize() );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( final IAEItemStack is : currentlyOnStorage )
|
||||||
|
{
|
||||||
|
cache.add( is );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( final IAEItemStack is : cache )
|
||||||
|
{
|
||||||
|
if( is.getStackSize() != 0 )
|
||||||
{
|
{
|
||||||
final int newSize = ( newIS.isEmpty() ? 0 : newIS.getCount() );
|
changes.add( is );
|
||||||
final int diff = newSize - ( oldIS.isEmpty() ? 0 : oldIS.getCount() );
|
|
||||||
|
|
||||||
final IAEItemStack stack = ( old == null || old.aeStack == null ? AEApi.instance()
|
|
||||||
.storage()
|
|
||||||
.getStorageChannel( IItemStorageChannel.class )
|
|
||||||
.createStack( newIS ) : old.aeStack.copy() );
|
|
||||||
if( stack != null )
|
|
||||||
{
|
|
||||||
stack.setStackSize( newSize );
|
|
||||||
this.list.add( stack );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( diff != 0 && stack != null )
|
|
||||||
{
|
|
||||||
final CachedItemStack cis = new CachedItemStack( is.getItemStack() );
|
|
||||||
this.memory.put( is.getSlot(), cis );
|
|
||||||
|
|
||||||
final IAEItemStack a = stack.copy();
|
|
||||||
a.setStackSize( diff );
|
|
||||||
changes.add( a );
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// detect dropped items; should fix non IISided Inventory Changes.
|
cache = currentlyOnStorage;
|
||||||
final NavigableMap<Integer, CachedItemStack> end = this.memory.tailMap( high, false );
|
|
||||||
if( !end.isEmpty() )
|
|
||||||
{
|
|
||||||
for( final CachedItemStack cis : end.values() )
|
|
||||||
{
|
|
||||||
if( cis != null && cis.aeStack != null )
|
|
||||||
{
|
|
||||||
final IAEItemStack a = cis.aeStack.copy();
|
|
||||||
a.setStackSize( -a.getStackSize() );
|
|
||||||
changes.add( a );
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !changes.isEmpty() )
|
if( !changes.isEmpty() )
|
||||||
{
|
{
|
||||||
this.postDifference( changes );
|
this.postDifference( changes );
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return changed ? TickRateModulation.URGENT : TickRateModulation.SLOWER;
|
return changed ? TickRateModulation.URGENT : TickRateModulation.SLOWER;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isDifferent( final ItemStack a, final ItemStack b )
|
|
||||||
{
|
|
||||||
if( a == b && b.isEmpty() )
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ( a.isEmpty() && !b.isEmpty() ) || ( !a.isEmpty() && b.isEmpty() ) )
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return !Platform.itemComparisons().isSameItem( a, b );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void postDifference( final Iterable<IAEItemStack> a )
|
private void postDifference( final Iterable<IAEItemStack> a )
|
||||||
{
|
{
|
||||||
// AELog.info( a.getItemStack().getUnlocalizedName() + " @ " + a.getStackSize() );
|
|
||||||
if( a != null )
|
if( a != null )
|
||||||
{
|
{
|
||||||
final Iterator<Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object>> i = this.listeners.entrySet().iterator();
|
final Iterator<Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object>> i = this.listeners.entrySet().iterator();
|
||||||
@@ -306,9 +253,9 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
|
|||||||
@Override
|
@Override
|
||||||
public IItemList<IAEItemStack> getAvailableItems( final IItemList out )
|
public IItemList<IAEItemStack> getAvailableItems( final IItemList out )
|
||||||
{
|
{
|
||||||
for( final CachedItemStack is : this.memory.values() )
|
for( IAEItemStack is : cache )
|
||||||
{
|
{
|
||||||
out.addStorage( is.aeStack );
|
out.addStorage( is );
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
@@ -317,7 +264,7 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
|
|||||||
@Override
|
@Override
|
||||||
public IItemList<IAEItemStack> getStorageList()
|
public IItemList<IAEItemStack> getStorageList()
|
||||||
{
|
{
|
||||||
return this.list;
|
return this.cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
private StorageFilter getMode()
|
private StorageFilter getMode()
|
||||||
|
|||||||
@@ -507,6 +507,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
|||||||
public void upgradesChanged()
|
public void upgradesChanged()
|
||||||
{
|
{
|
||||||
this.configureWatchers();
|
this.configureWatchers();
|
||||||
|
this.updateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -320,13 +320,13 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
|||||||
|
|
||||||
IItemList<IAEItemStack> currentlyOnStorage = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
IItemList<IAEItemStack> currentlyOnStorage = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||||
|
|
||||||
for ( final ItemSlot is : this )
|
for( final ItemSlot is : this )
|
||||||
{
|
{
|
||||||
final ItemStack newIS = !is.isExtractable() && this.getMode() == StorageFilter.EXTRACTABLE_ONLY ? ItemStack.EMPTY : is.getItemStack();
|
if( this.mode == StorageFilter.EXTRACTABLE_ONLY && !is.isExtractable() )
|
||||||
if( !newIS.isEmpty() )
|
|
||||||
{
|
{
|
||||||
currentlyOnStorage.add( is.getAEItemStack() );
|
continue;
|
||||||
}
|
}
|
||||||
|
currentlyOnStorage.add( is.getAEItemStack() );
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( final IAEItemStack is : currentlyCached )
|
for ( final IAEItemStack is : currentlyCached )
|
||||||
|
|||||||
@@ -23,8 +23,13 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import appeng.api.config.AccessRestriction;
|
import appeng.api.config.AccessRestriction;
|
||||||
|
import appeng.fluids.parts.PartFluidInterface;
|
||||||
|
import appeng.fluids.tile.TileFluidInterface;
|
||||||
|
import appeng.tile.misc.TileInterface;
|
||||||
|
import appeng.tile.networking.TileCableBus;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
|
||||||
@@ -161,7 +166,27 @@ public abstract class PartSharedStorageBus extends PartUpgradeable implements IG
|
|||||||
{
|
{
|
||||||
if( pos.offset( this.getSide().getFacing() ).equals( neighbor ) )
|
if( pos.offset( this.getSide().getFacing() ).equals( neighbor ) )
|
||||||
{
|
{
|
||||||
this.resetCache( false );
|
|
||||||
|
final TileEntity te = w.getTileEntity( neighbor );
|
||||||
|
|
||||||
|
// In case the TE was destroyed, we have to do a full reset immediately.
|
||||||
|
if( te instanceof TileCableBus )
|
||||||
|
{
|
||||||
|
if( ( (TileCableBus) te ).getPart( this.getSide().getOpposite() ) instanceof PartFluidInterface )
|
||||||
|
{
|
||||||
|
this.resetCache( true );
|
||||||
|
this.resetCache();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( te == null || te instanceof TileFluidInterface )
|
||||||
|
{
|
||||||
|
this.resetCache( true );
|
||||||
|
this.resetCache();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.resetCache( false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ import java.util.Objects;
|
|||||||
|
|
||||||
import appeng.fluids.parts.FluidHandlerAdapter;
|
import appeng.fluids.parts.FluidHandlerAdapter;
|
||||||
import appeng.me.storage.MEPassThrough;
|
import appeng.me.storage.MEPassThrough;
|
||||||
|
import appeng.parts.AEBasePart;
|
||||||
|
import appeng.tile.misc.TileInterface;
|
||||||
|
import appeng.tile.networking.TileCableBus;
|
||||||
import appeng.util.ConfigManager;
|
import appeng.util.ConfigManager;
|
||||||
import com.jaquadro.minecraft.storagedrawers.api.capabilities.IItemRepository;
|
import com.jaquadro.minecraft.storagedrawers.api.capabilities.IItemRepository;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
@@ -242,7 +245,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
|||||||
{
|
{
|
||||||
this.resetCacheLogic = 2;
|
this.resetCacheLogic = 2;
|
||||||
}
|
}
|
||||||
else
|
else if( this.resetCacheLogic < 2 )
|
||||||
{
|
{
|
||||||
this.resetCacheLogic = 1;
|
this.resetCacheLogic = 1;
|
||||||
}
|
}
|
||||||
@@ -306,10 +309,19 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
|||||||
{
|
{
|
||||||
if( pos.offset( this.getSide().getFacing() ).equals( 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.
|
// In case the TE was destroyed, we have to do a full reset immediately.
|
||||||
if( te == null )
|
if( te instanceof TileCableBus )
|
||||||
|
{
|
||||||
|
if( ( (TileCableBus) te ).getPart( this.getSide().getOpposite() ) instanceof PartInterface )
|
||||||
|
{
|
||||||
|
this.resetCache( true );
|
||||||
|
this.resetCache();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( te == null || te instanceof TileInterface )
|
||||||
{
|
{
|
||||||
this.resetCache( true );
|
this.resetCache( true );
|
||||||
this.resetCache();
|
this.resetCache();
|
||||||
@@ -498,17 +510,15 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
|||||||
|
|
||||||
this.handlerHash = newHandlerHash;
|
this.handlerHash = newHandlerHash;
|
||||||
this.handler = null;
|
this.handler = null;
|
||||||
|
if( this.monitor != null )
|
||||||
|
{
|
||||||
|
( (IBaseMonitor<IAEItemStack>) monitor ).removeListener( this );
|
||||||
|
}
|
||||||
this.monitor = null;
|
this.monitor = null;
|
||||||
if( target != null )
|
if( target != null )
|
||||||
{
|
{
|
||||||
IMEInventory<IAEItemStack> inv = this.getInventoryWrapper( target );
|
IMEInventory<IAEItemStack> inv = this.getInventoryWrapper( target );
|
||||||
|
|
||||||
if( inv instanceof MEMonitorIInventory )
|
|
||||||
{
|
|
||||||
final MEMonitorIInventory h = (MEMonitorIInventory) inv;
|
|
||||||
h.setMode( (StorageFilter) this.getConfigManager().getSetting( Settings.STORAGE_FILTER ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( inv instanceof ITickingMonitor )
|
if( inv instanceof ITickingMonitor )
|
||||||
{
|
{
|
||||||
this.monitor = (ITickingMonitor) inv;
|
this.monitor = (ITickingMonitor) inv;
|
||||||
|
|||||||
@@ -350,9 +350,25 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
|||||||
if( needsNewFrequency )
|
if( needsNewFrequency )
|
||||||
{
|
{
|
||||||
newFreq = this.getProxy().getP2P().newFrequency();
|
newFreq = this.getProxy().getP2P().newFrequency();
|
||||||
}
|
|
||||||
|
|
||||||
this.getProxy().getP2P().updateFreq( this, newFreq );
|
final ItemStack newType = this.getHost().getPart( this.getSide() ).getItemStack( PartItemStack.WRENCH );
|
||||||
|
|
||||||
|
this.getHost().removePart( this.getSide(), false );
|
||||||
|
final AEPartLocation dir = this.getHost().addPart( newType, this.getSide(), player, hand );
|
||||||
|
final IPart newBus = this.getHost().getPart( dir );
|
||||||
|
|
||||||
|
if( newBus instanceof PartP2PTunnel )
|
||||||
|
{
|
||||||
|
final PartP2PTunnel newTunnel = (PartP2PTunnel) newBus;
|
||||||
|
newTunnel.setOutput( false );
|
||||||
|
newTunnel.onTunnelNetworkChange();
|
||||||
|
newTunnel.getProxy().getP2P().updateFreq( newTunnel, newFreq );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.getProxy().getP2P().updateFreq( this, newFreq );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch( final GridAccessException e )
|
catch( final GridAccessException e )
|
||||||
{
|
{
|
||||||
@@ -365,10 +381,17 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
|||||||
final String type = p2pItem.getUnlocalizedName();
|
final String type = p2pItem.getUnlocalizedName();
|
||||||
|
|
||||||
p2pItem.writeToNBT( data );
|
p2pItem.writeToNBT( data );
|
||||||
data.setShort( "freq", this.getFrequency() );
|
if( needsNewFrequency )
|
||||||
|
{
|
||||||
|
data.setShort( "freq", newFreq );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data.setShort( "freq", this.getFrequency() );
|
||||||
|
}
|
||||||
|
|
||||||
final AEColor[] colors = Platform.p2p().toColors( this.getFrequency() );
|
final AEColor[] colors = Platform.p2p().toColors( this.getFrequency() );
|
||||||
final int[] colorCode = new int[] {
|
final int[] colorCode = new int[]{
|
||||||
colors[0].ordinal(), colors[0].ordinal(), colors[1].ordinal(), colors[1].ordinal(),
|
colors[0].ordinal(), colors[0].ordinal(), colors[1].ordinal(), colors[1].ordinal(),
|
||||||
colors[2].ordinal(), colors[2].ordinal(), colors[3].ordinal(), colors[3].ordinal(),
|
colors[2].ordinal(), colors[2].ordinal(), colors[3].ordinal(), colors[3].ordinal(),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
|
|||||||
|
|
||||||
private IAEItemStack configuredItem;
|
private IAEItemStack configuredItem;
|
||||||
private IAEFluidStack configuredFluid;
|
private IAEFluidStack configuredFluid;
|
||||||
|
private long configuredAmount;
|
||||||
private String lastHumanReadableText;
|
private String lastHumanReadableText;
|
||||||
private boolean isLocked;
|
private boolean isLocked;
|
||||||
private IStackWatcher myWatcher;
|
private IStackWatcher myWatcher;
|
||||||
@@ -208,14 +209,21 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
|
|||||||
fluidInTank = fluidHandlerItem.drain( Integer.MAX_VALUE, false );
|
fluidInTank = fluidHandlerItem.drain( Integer.MAX_VALUE, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fluidInTank == null)
|
if( fluidInTank == null )
|
||||||
{
|
{
|
||||||
this.configuredFluid = null;
|
this.configuredFluid = null;
|
||||||
this.configuredItem = AEItemStack.fromItemStack( eq );
|
if( !eq.isEmpty() )
|
||||||
|
{
|
||||||
|
this.configuredItem = AEItemStack.fromItemStack( eq ).setStackSize( 0 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.configuredItem = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if( fluidInTank.amount > 0 )
|
else if( fluidInTank.amount > 0 )
|
||||||
{
|
{
|
||||||
this.configuredFluid = AEFluidStack.fromFluidStack( fluidInTank );
|
this.configuredFluid = AEFluidStack.fromFluidStack( fluidInTank ).setStackSize( 0 );
|
||||||
this.configuredItem = null;
|
this.configuredItem = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,30 +307,31 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
|
|||||||
|
|
||||||
private <T extends IAEStack<T>> void updateReportingValue ( final IMEMonitor<T> monitor )
|
private <T extends IAEStack<T>> void updateReportingValue ( final IMEMonitor<T> monitor )
|
||||||
{
|
{
|
||||||
|
|
||||||
if( this.configuredItem != null)
|
if( this.configuredItem != null)
|
||||||
{
|
{
|
||||||
final IAEItemStack result = (IAEItemStack) monitor.getStorageList().findPrecise( (T) this.configuredItem );
|
final IAEItemStack result = (IAEItemStack) monitor.getStorageList().findPrecise( (T) this.configuredItem );
|
||||||
if( result == null )
|
if( result == null )
|
||||||
{
|
{
|
||||||
this.configuredItem.setStackSize( 0 );
|
this.configuredAmount = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.configuredItem.setStackSize( result.getStackSize() );
|
this.configuredAmount = result.getStackSize();
|
||||||
}
|
}
|
||||||
|
this.configuredItem.setStackSize( this.configuredAmount );
|
||||||
}
|
}
|
||||||
else if( this.configuredFluid != null)
|
else if( this.configuredFluid != null)
|
||||||
{
|
{
|
||||||
final IAEFluidStack result = (IAEFluidStack) monitor.getStorageList().findPrecise( (T) this.configuredFluid );
|
final IAEFluidStack result = (IAEFluidStack) monitor.getStorageList().findPrecise( (T) this.configuredFluid );
|
||||||
if( result == null )
|
if( result == null )
|
||||||
{
|
{
|
||||||
this.configuredFluid.setStackSize( 0 );
|
this.configuredAmount = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.configuredFluid.setStackSize( result.getStackSize() );
|
this.configuredAmount = result.getStackSize();
|
||||||
}
|
}
|
||||||
|
this.configuredFluid.setStackSize( this.configuredAmount );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -390,108 +399,35 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
|
|||||||
@MENetworkEventSubscribe
|
@MENetworkEventSubscribe
|
||||||
public void powerStatusChange( final MENetworkPowerStatusChange ev )
|
public void powerStatusChange( final MENetworkPowerStatusChange ev )
|
||||||
{
|
{
|
||||||
if( !this.getProxy().isPowered() )
|
if( this.getProxy().isPowered() )
|
||||||
{
|
{
|
||||||
if( this.myWatcher != null )
|
this.configureWatchers();
|
||||||
{
|
|
||||||
if( this.configuredItem != null )
|
|
||||||
{
|
|
||||||
this.configuredItem.setStackSize( 0 );
|
|
||||||
}
|
|
||||||
if( this.configuredFluid != null )
|
|
||||||
{
|
|
||||||
this.configuredFluid.setStackSize( 0 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if( this.configuredItem != null )
|
|
||||||
{
|
|
||||||
this.updateReportingValue( this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) );
|
|
||||||
}
|
|
||||||
if( this.configuredFluid != null )
|
|
||||||
{
|
|
||||||
this.updateReportingValue( this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch( final GridAccessException e )
|
|
||||||
{
|
|
||||||
// ;P
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@MENetworkEventSubscribe
|
@MENetworkEventSubscribe
|
||||||
public void channelChanged( final MENetworkChannelsChanged c )
|
public void channelChanged( final MENetworkChannelsChanged c )
|
||||||
{
|
{
|
||||||
if( !this.getProxy().isPowered() )
|
if( this.getProxy().isPowered() )
|
||||||
{
|
{
|
||||||
if( this.myWatcher != null )
|
this.configureWatchers();
|
||||||
{
|
|
||||||
if( this.configuredItem != null )
|
|
||||||
{
|
|
||||||
this.configuredItem.setStackSize( 0 );
|
|
||||||
}
|
|
||||||
if( this.configuredFluid != null )
|
|
||||||
{
|
|
||||||
this.configuredFluid.setStackSize( 0 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if( this.configuredItem != null )
|
|
||||||
{
|
|
||||||
this.updateReportingValue( this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) );
|
|
||||||
}
|
|
||||||
if( this.configuredFluid != null )
|
|
||||||
{
|
|
||||||
this.updateReportingValue( this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch( final GridAccessException e )
|
|
||||||
{
|
|
||||||
// ;P
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStackChange( IItemList<?> o, IAEStack<?> fullStack, IAEStack<?> diffStack, IActionSource src, IStorageChannel<?> chan )
|
public void onStackChange( IItemList<?> o, IAEStack<?> fullStack, IAEStack<?> diffStack, IActionSource src, IStorageChannel<?> chan )
|
||||||
{
|
{
|
||||||
|
this.configuredAmount = this.configuredAmount + diffStack.getStackSize();
|
||||||
|
|
||||||
if( this.configuredItem != null )
|
if( this.configuredItem != null )
|
||||||
{
|
{
|
||||||
long diff = this.configuredItem.getStackSize() + diffStack.getStackSize();
|
this.configuredItem.setStackSize( this.configuredAmount );
|
||||||
this.configuredItem.setStackSize( diff >= 0 ? this.configuredItem.getStackSize() + diffStack.getStackSize() : 0 );
|
|
||||||
|
|
||||||
final long stackSize = this.configuredItem.getStackSize();
|
|
||||||
final String humanReadableText = NUMBER_CONVERTER.toWideReadableForm( stackSize );
|
|
||||||
|
|
||||||
if( !humanReadableText.equals( this.lastHumanReadableText ) )
|
|
||||||
{
|
|
||||||
this.lastHumanReadableText = humanReadableText;
|
|
||||||
this.getHost().markForUpdate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if( this.configuredFluid != null )
|
else if( this.configuredFluid != null )
|
||||||
{
|
{
|
||||||
long diff = this.configuredFluid.getStackSize() + diffStack.getStackSize();
|
this.configuredFluid.setStackSize( this.configuredAmount );
|
||||||
this.configuredFluid.setStackSize( diff >= 0 ? this.configuredFluid.getStackSize() + diffStack.getStackSize() : 0 );
|
|
||||||
|
|
||||||
final long stackSize = this.configuredFluid.getStackSize() / 1000;
|
|
||||||
final String humanReadableText = NUMBER_CONVERTER.toWideReadableForm( stackSize ) + "B";
|
|
||||||
|
|
||||||
if( !humanReadableText.equals( this.lastHumanReadableText ) )
|
|
||||||
{
|
|
||||||
this.lastHumanReadableText = humanReadableText;
|
|
||||||
this.getHost().markForUpdate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
this.getHost().markForUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -137,14 +137,10 @@ public class PartConversionMonitor extends AbstractPartMonitor
|
|||||||
{
|
{
|
||||||
this.insertItem( player, hand, false );
|
this.insertItem( player, hand, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//If its a fluid container, grab its fluidstack. if its empty pass its itemstack;
|
//If its a fluid container, grab its fluidstack. if its empty pass its itemstack;
|
||||||
|
|
||||||
if (eq.isEmpty()){
|
|
||||||
return super.onPartActivate( player, hand, pos );
|
|
||||||
}
|
|
||||||
if( fluidInTank != null && fluidInTank.amount > 0 )
|
if( fluidInTank != null && fluidInTank.amount > 0 )
|
||||||
{
|
{
|
||||||
if( getDisplayed() instanceof IAEItemStack || getDisplayed() == null )
|
if( getDisplayed() instanceof IAEItemStack || getDisplayed() == null )
|
||||||
@@ -155,23 +151,16 @@ public class PartConversionMonitor extends AbstractPartMonitor
|
|||||||
{
|
{
|
||||||
this.drainFluidContainer( player, hand );
|
this.drainFluidContainer( player, hand );
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
return super.onPartActivate( player, hand, pos );
|
return super.onPartActivate( player, hand, pos );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if( this.getDisplayed() != null && this.getDisplayed().equals( player.getHeldItem( hand ) ) )
|
||||||
{
|
{
|
||||||
if( getDisplayed() instanceof IAEFluidStack || getDisplayed() == null )
|
this.insertItem( player, hand, false );
|
||||||
{
|
|
||||||
return super.onPartActivate( player, hand, pos );
|
|
||||||
}
|
|
||||||
if( ( (IAEItemStack) this.getDisplayed() ).equals( eq ) )
|
|
||||||
{
|
|
||||||
this.insertItem( player, hand, false );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return super.onPartActivate( player, hand, pos );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -192,7 +181,6 @@ public class PartConversionMonitor extends AbstractPartMonitor
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack eq = player.getHeldItem( hand );
|
|
||||||
if( this.getDisplayed() != null && this.getDisplayed() instanceof IAEItemStack )
|
if( this.getDisplayed() != null && this.getDisplayed() instanceof IAEItemStack )
|
||||||
{
|
{
|
||||||
this.extractItem( player, ( (IAEItemStack) this.getDisplayed() ).getDefinition().getMaxStackSize() );
|
this.extractItem( player, ( (IAEItemStack) this.getDisplayed() ).getDefinition().getMaxStackSize() );
|
||||||
@@ -282,7 +270,7 @@ public class PartConversionMonitor extends AbstractPartMonitor
|
|||||||
{
|
{
|
||||||
if (!(this.getDisplayed() instanceof IAEItemStack))
|
if (!(this.getDisplayed() instanceof IAEItemStack))
|
||||||
return;
|
return;
|
||||||
final IAEItemStack input = (IAEItemStack) this.getDisplayed();
|
final IAEItemStack input = (IAEItemStack) this.getDisplayed().copy();
|
||||||
if( input != null )
|
if( input != null )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -494,12 +494,14 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||||
final IStorageGrid gs = this.getProxy().getStorage();
|
if( this.getProxy().isActive() )
|
||||||
Platform.postChanges( gs, removed, added, this.mySrc );
|
{
|
||||||
|
final IStorageGrid gs = this.getProxy().getStorage();
|
||||||
|
Platform.postChanges( gs, removed, added, this.mySrc );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch( final GridAccessException ignored )
|
catch( final GridAccessException ignored )
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the neighbors
|
// update the neighbors
|
||||||
|
|||||||
@@ -264,9 +264,11 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||||
|
if( this.getProxy().isActive() )
|
||||||
final IStorageGrid gs = this.getProxy().getStorage();
|
{
|
||||||
Platform.postChanges( gs, removed, added, this.mySrc );
|
final IStorageGrid gs = this.getProxy().getStorage();
|
||||||
|
Platform.postChanges( gs, removed, added, this.mySrc );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch( final GridAccessException ignored )
|
catch( final GridAccessException ignored )
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user