Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 304f394497 | |||
| 50f21125c8 | |||
| 30b85bd239 | |||
| 9ce00d338f | |||
| 11f5b71089 | |||
| e7da72163b | |||
| 6d7c65dd70 | |||
| 5e21101619 | |||
| 3db8d0185f | |||
| 2f5ecfe638 | |||
| 75843e802d | |||
| e41b6943aa | |||
| 92347ad2f5 | |||
| 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
|
||||
aegroup=appeng
|
||||
aebasename=appliedenergistics2
|
||||
trousers=omni-fixes-v47
|
||||
trousers=omni-fixes-v49b
|
||||
|
||||
#########################################################
|
||||
# Versions #
|
||||
|
||||
@@ -22,9 +22,10 @@ package appeng.client.render;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderItem;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
@@ -32,6 +33,7 @@ import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.util.IWideReadableNumberConverter;
|
||||
import appeng.util.ReadableNumberConverter;
|
||||
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.
|
||||
*
|
||||
@@ -147,9 +192,9 @@ public class TesrRenderHelper
|
||||
|
||||
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 String renderedStackSize = NUMBER_CONVERTER.toWideReadableForm( stackSize ) + "B";
|
||||
|
||||
@@ -31,8 +31,10 @@ public enum WailaText
|
||||
DeviceMissingChannel,
|
||||
|
||||
P2PUnlinked,
|
||||
P2PInputOneOutput,
|
||||
P2PInputManyOutputs,
|
||||
P2P_INPUT_ONE_OUTPUT,
|
||||
P2P_INPUT_MANY_OUTPUTS,
|
||||
P2P_OUTPUT_ONE_INPUT,
|
||||
P2P_OUTPUT_MANY_INPUTS,
|
||||
P2POutput,
|
||||
|
||||
Locked,
|
||||
|
||||
@@ -22,7 +22,6 @@ package appeng.crafting;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import appeng.me.cache.CraftingGridCache;
|
||||
import com.google.common.base.Stopwatch;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -72,8 +71,6 @@ public class CraftingJob implements Runnable, ICraftingJob
|
||||
private boolean done = false;
|
||||
private int time;
|
||||
private int incTime;
|
||||
private final ICraftingGrid cc;
|
||||
private final IStorageGrid sg;
|
||||
|
||||
private World wrapWorld( final World w )
|
||||
{
|
||||
@@ -87,9 +84,10 @@ public class CraftingJob implements Runnable, ICraftingJob
|
||||
this.actionSrc = actionSrc;
|
||||
|
||||
this.callback = callback;
|
||||
this.cc = grid.getCache( ICraftingGrid.class );
|
||||
this.sg = grid.getCache( IStorageGrid.class );
|
||||
this.original = new MECraftingInventory( sg.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ), actionSrc, false, false, false );
|
||||
final ICraftingGrid cc = grid.getCache( ICraftingGrid.class );
|
||||
final IStorageGrid sg = grid.getCache( IStorageGrid.class );
|
||||
this.original = new MECraftingInventory( sg
|
||||
.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ), actionSrc, false, false, false );
|
||||
|
||||
this.setTree( this.getCraftingTree( cc, what ) );
|
||||
this.availableCheck = null;
|
||||
@@ -382,11 +380,6 @@ public class CraftingJob implements Runnable, ICraftingJob
|
||||
}
|
||||
}
|
||||
|
||||
public void addIncompletablePattern( ICraftingPatternDetails details, IAEItemStack stack )
|
||||
{
|
||||
( (CraftingGridCache) cc ).getPatternStatusManager().put( details, stack );
|
||||
}
|
||||
|
||||
private static class TwoIntegers
|
||||
{
|
||||
private final long perOp = 0;
|
||||
|
||||
@@ -22,12 +22,10 @@ package appeng.crafting;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import appeng.util.item.OreHelper;
|
||||
import appeng.util.item.OreReference;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
@@ -120,29 +118,49 @@ public class CraftingTreeNode
|
||||
return this.parent.notRecursive( details );
|
||||
}
|
||||
|
||||
public CraftingTreeProcess getParent()
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
|
||||
IAEItemStack request( final MECraftingInventory inv, long l, final IActionSource src ) throws CraftBranchFailure, InterruptedException
|
||||
{
|
||||
this.job.handlePausing();
|
||||
final List<IAEItemStack> thingsUsed = new ArrayList<>();
|
||||
|
||||
this.what.setStackSize( l );
|
||||
if( this.getSlot() >= 0 && this.parent != null && this.parent.details.isCraftable() )
|
||||
IAEItemStack available = inv.extractItems( this.what, Actionable.MODULATE, src );
|
||||
|
||||
if( available != null )
|
||||
{
|
||||
if( !this.exhausted )
|
||||
{
|
||||
final IAEItemStack is = this.job.checkUse( available );
|
||||
|
||||
if( is != null )
|
||||
{
|
||||
thingsUsed.add( is.copy() );
|
||||
this.used.add( is );
|
||||
}
|
||||
}
|
||||
|
||||
this.bytes += available.getStackSize();
|
||||
l -= available.getStackSize();
|
||||
|
||||
if( l == 0 )
|
||||
{
|
||||
return available;
|
||||
}
|
||||
}
|
||||
|
||||
else if( this.getSlot() >= 0 && this.parent != null && this.parent.details.isCraftable() )
|
||||
{
|
||||
final Collection<IAEItemStack> itemList;
|
||||
final IItemList<IAEItemStack> inventoryList = inv.getItemList();
|
||||
|
||||
if( this.parent.details.canSubstitute() )
|
||||
{
|
||||
final List<IAEItemStack> substitutes = this.parent.details.getSubstituteInputs(this.slot);
|
||||
itemList = new ArrayList<>(substitutes.size());
|
||||
final List<IAEItemStack> substitutes = this.parent.details.getSubstituteInputs( this.slot );
|
||||
itemList = new ArrayList<>( substitutes.size() );
|
||||
|
||||
for (IAEItemStack stack : substitutes) {
|
||||
itemList.addAll(inventoryList.findFuzzy(stack, FuzzyMode.IGNORE_ALL));
|
||||
for( IAEItemStack stack : substitutes )
|
||||
{
|
||||
itemList.addAll( inventoryList.findFuzzy( stack, FuzzyMode.IGNORE_ALL ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -164,7 +182,7 @@ public class CraftingTreeNode
|
||||
fuzz = fuzz.copy();
|
||||
fuzz.setStackSize( l );
|
||||
|
||||
final IAEItemStack available = inv.extractItems( fuzz, Actionable.MODULATE, src );
|
||||
available = inv.extractItems( fuzz, Actionable.MODULATE, src );
|
||||
|
||||
if( available != null )
|
||||
{
|
||||
@@ -190,32 +208,6 @@ public class CraftingTreeNode
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final IAEItemStack available = inv.extractItems( this.what, Actionable.MODULATE, src );
|
||||
|
||||
if( available != null )
|
||||
{
|
||||
if( !this.exhausted )
|
||||
{
|
||||
final IAEItemStack is = this.job.checkUse( available );
|
||||
|
||||
if( is != null )
|
||||
{
|
||||
thingsUsed.add( is.copy() );
|
||||
this.used.add( is );
|
||||
}
|
||||
}
|
||||
|
||||
this.bytes += available.getStackSize();
|
||||
l -= available.getStackSize();
|
||||
|
||||
if( l == 0 )
|
||||
{
|
||||
return available;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( this.canEmit )
|
||||
{
|
||||
@@ -234,7 +226,7 @@ public class CraftingTreeNode
|
||||
{
|
||||
final CraftingTreeProcess pro = this.nodes.get( 0 );
|
||||
|
||||
while( pro.possible && l > 0 )
|
||||
while ( pro.possible && l > 0 )
|
||||
{
|
||||
final IAEItemStack madeWhat = pro.getAmountCrafted( this.what );
|
||||
|
||||
@@ -242,7 +234,7 @@ public class CraftingTreeNode
|
||||
|
||||
madeWhat.setStackSize( l );
|
||||
|
||||
final IAEItemStack available = inv.extractItems( madeWhat, Actionable.MODULATE, src );
|
||||
available = inv.extractItems( madeWhat, Actionable.MODULATE, src );
|
||||
|
||||
if( available != null )
|
||||
{
|
||||
@@ -266,13 +258,13 @@ public class CraftingTreeNode
|
||||
{
|
||||
try
|
||||
{
|
||||
while( pro.possible && l > 0 )
|
||||
while ( pro.possible && l > 0 )
|
||||
{
|
||||
final MECraftingInventory subInv = new MECraftingInventory( inv, true, true, true );
|
||||
pro.request( subInv, 1, src );
|
||||
|
||||
this.what.setStackSize( l );
|
||||
final IAEItemStack available = subInv.extractItems( this.what, Actionable.MODULATE, src );
|
||||
available = subInv.extractItems( this.what, Actionable.MODULATE, src );
|
||||
|
||||
if( available != null )
|
||||
{
|
||||
@@ -326,11 +318,10 @@ public class CraftingTreeNode
|
||||
if( this.missing > 0 )
|
||||
{
|
||||
job.addMissing( this.getStack( this.missing ) );
|
||||
addMissingIAEStack();
|
||||
}
|
||||
// missing = 0;
|
||||
|
||||
job.addBytes( 8 + this.bytes );
|
||||
job.addBytes( this.bytes );
|
||||
|
||||
for( final CraftingTreeProcess pro : this.nodes )
|
||||
{
|
||||
@@ -338,29 +329,6 @@ public class CraftingTreeNode
|
||||
}
|
||||
}
|
||||
|
||||
void addMissingIAEStack()
|
||||
{
|
||||
if( parent != null )
|
||||
{
|
||||
parent.addMissingIAEStack();
|
||||
if( missing > 0 )
|
||||
{
|
||||
if( this.parent.details.canSubstitute() && this.getSlot() >= 0 )
|
||||
{
|
||||
final List<IAEItemStack> substitutes = this.parent.details.getSubstituteInputs( this.slot );
|
||||
for( IAEItemStack stack : substitutes )
|
||||
{
|
||||
job.addIncompletablePattern( this.getParent().details, stack.copy().setStackSize( this.missing ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
job.addIncompletablePattern( this.getParent().details, this.getStack( this.missing ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IAEItemStack getStack( final long size )
|
||||
{
|
||||
final IAEItemStack is = this.what.copy();
|
||||
@@ -390,6 +358,10 @@ public class CraftingTreeNode
|
||||
|
||||
if( ex == null || ex.getStackSize() != i.getStackSize() )
|
||||
{
|
||||
if( src.player().isPresent() )
|
||||
{
|
||||
src.player().get().sendStatusMessage( new TextComponentString( "System reported " + i.getStackSize() + " " + i.getDefinition().getItem().getItemStackDisplayName( i.getDefinition() ) + " available but could not extract anything" ), false );
|
||||
}
|
||||
throw new CraftBranchFailure( i, i.getStackSize() );
|
||||
}
|
||||
|
||||
|
||||
@@ -23,10 +23,11 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import appeng.me.cache.CraftingGridCache;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
@@ -65,7 +66,7 @@ public class CraftingTreeProcess
|
||||
this.depth = depth;
|
||||
final World world = job.getWorld();
|
||||
|
||||
if( !( (CraftingGridCache) cc ).getPatternStatusManager().containsIncompletablePattern( details ) && details.isCraftable() )
|
||||
if( details.isCraftable() )
|
||||
{
|
||||
final IAEItemStack[] list = details.getInputs();
|
||||
|
||||
@@ -173,11 +174,6 @@ public class CraftingTreeProcess
|
||||
return this.parent == null || this.parent.notRecursive( details );
|
||||
}
|
||||
|
||||
public CraftingTreeNode getParent()
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
|
||||
long getTimes( final long remaining, final long stackSize )
|
||||
{
|
||||
if( this.limitQty || this.fullSimulation )
|
||||
@@ -245,7 +241,6 @@ public class CraftingTreeProcess
|
||||
o.setStackSize( o.getStackSize() * i );
|
||||
inv.injectItems( o, Actionable.MODULATE, src );
|
||||
}
|
||||
|
||||
this.crafts += i;
|
||||
}
|
||||
|
||||
@@ -257,7 +252,7 @@ public class CraftingTreeProcess
|
||||
pro.dive( job );
|
||||
}
|
||||
|
||||
job.addBytes( 8 + this.crafts + this.bytes );
|
||||
job.addBytes( this.crafts * 8 + this.bytes );
|
||||
}
|
||||
|
||||
IAEItemStack getAmountCrafted( IAEItemStack what2 )
|
||||
@@ -309,7 +304,7 @@ public class CraftingTreeProcess
|
||||
|
||||
void getPlan( final IItemList<IAEItemStack> plan )
|
||||
{
|
||||
for( IAEItemStack i : this.details.getCondensedOutputs() )
|
||||
for( IAEItemStack i : this.details.getOutputs() )
|
||||
{
|
||||
i = i.copy();
|
||||
i.setCountRequestable( i.getStackSize() * this.crafts );
|
||||
@@ -321,12 +316,4 @@ public class CraftingTreeProcess
|
||||
pro.getPlan( plan );
|
||||
}
|
||||
}
|
||||
|
||||
public void addMissingIAEStack()
|
||||
{
|
||||
if( parent != null )
|
||||
{
|
||||
parent.addMissingIAEStack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,9 +312,13 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
||||
if( src.player().isPresent() )
|
||||
{
|
||||
if( result == null )
|
||||
src.player().get().sendStatusMessage( new TextComponentString( "System reported " + extra.getStackSize() + " " + extra.getDefinition().getDisplayName() + " available but could not extract anything" ), false );
|
||||
{
|
||||
src.player().get().sendStatusMessage( new TextComponentString( "System reported " + extra.getStackSize() + " " + extra.getDefinition().getItem().getItemStackDisplayName( extra.getDefinition() ) + " available but could not extract anything" ), false );
|
||||
}
|
||||
else
|
||||
src.player().get().sendStatusMessage( new TextComponentString( "System reported " + extra.getStackSize() + " " + extra.getDefinition().getDisplayName() + " available but could only extract " + result.getStackSize() ), false );
|
||||
{
|
||||
src.player().get().sendStatusMessage( new TextComponentString( "System reported " + extra.getStackSize() + " " + extra.getDefinition().getItem().getItemStackDisplayName( extra.getDefinition() ) + " available but could only extract " + result.getStackSize() ), false );
|
||||
}
|
||||
}
|
||||
failed = true;
|
||||
if( !src.player().isPresent() ) break;
|
||||
|
||||
@@ -91,12 +91,10 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
private int isWorking = -1;
|
||||
private int priority;
|
||||
|
||||
private final MEMonitorPassThrough<IAEItemStack> items = new MEMonitorPassThrough<>( new NullInventory<IAEItemStack>(), AEApi.instance()
|
||||
.storage()
|
||||
.getStorageChannel( IItemStorageChannel.class ) );
|
||||
private final MEMonitorPassThrough<IAEFluidStack> fluids = new MEMonitorPassThrough<>( new NullInventory<IAEFluidStack>(), AEApi.instance()
|
||||
.storage()
|
||||
.getStorageChannel( IFluidStorageChannel.class ) );
|
||||
private final MEMonitorPassThrough<IAEItemStack> items = new MEMonitorPassThrough<>( new NullInventory<IAEItemStack>(), AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||
private final MEMonitorPassThrough<IAEFluidStack> fluids = new MEMonitorPassThrough<>( new NullInventory<IAEFluidStack>(), AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
|
||||
private boolean resetConfigCache;
|
||||
private IMEMonitor<IAEFluidStack> configCachedHandler;
|
||||
|
||||
public DualityFluidInterface( final AENetworkProxy networkProxy, final IFluidInterfaceHost ih )
|
||||
{
|
||||
@@ -146,7 +144,12 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
{
|
||||
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;
|
||||
@@ -383,7 +386,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
else
|
||||
else if( this.gridProxy.getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ).getStorageList().findPrecise( work ) != null )
|
||||
{
|
||||
final IAEFluidStack acquired = Platform.poweredExtraction( src, dest, work, this.interfaceRequestSource );
|
||||
if( acquired != null )
|
||||
@@ -450,7 +453,12 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
|
||||
if( inventory == this.config )
|
||||
{
|
||||
boolean cfg = hasConfig();
|
||||
this.readConfig();
|
||||
if( cfg != hasConfig )
|
||||
{
|
||||
resetConfigCache = true;
|
||||
}
|
||||
}
|
||||
else if( inventory == this.tanks )
|
||||
{
|
||||
@@ -555,7 +563,6 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
InterfaceInventory( final DualityFluidInterface tileInterface )
|
||||
{
|
||||
super( tileInterface.tanks );
|
||||
this.setActionSource( new MachineSource( tileInterface.iHost ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -232,18 +232,11 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
|
||||
|
||||
for( IFluidTankProperties tankProperty : tankProperties )
|
||||
{
|
||||
FluidStack newFS = tankProperty.getContents();
|
||||
if( this.mode == StorageFilter.EXTRACTABLE_ONLY && newFS != null )
|
||||
if( this.mode == StorageFilter.EXTRACTABLE_ONLY && this.fluidHandler.drain( 1, false ) == null )
|
||||
{
|
||||
if( this.fluidHandler.drain( 1, false ) == null )
|
||||
{
|
||||
newFS = null;
|
||||
}
|
||||
}
|
||||
if( newFS != null )
|
||||
{
|
||||
currentlyOnStorage.add( AEFluidStack.fromFluidStack( newFS ) );
|
||||
continue;
|
||||
}
|
||||
currentlyOnStorage.add( AEFluidStack.fromFluidStack( tankProperty.getContents() ) );
|
||||
}
|
||||
|
||||
for ( final IAEFluidStack is : currentlyCached )
|
||||
|
||||
@@ -178,8 +178,9 @@ public class PartFluidFormationPlane extends PartAbstractFormationPlane<IAEFluid
|
||||
this.stateChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void updateChannels( final MENetworkChannelsChanged changedChannels )
|
||||
public void chanRender( final MENetworkChannelsChanged changedChannels )
|
||||
{
|
||||
this.stateChanged();
|
||||
}
|
||||
|
||||
@@ -90,14 +90,16 @@ public class PartFluidInterface extends PartBasicState implements IGridTickable,
|
||||
return this.duality;
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void stateChange( final MENetworkChannelsChanged c )
|
||||
public void chanRender( final MENetworkChannelsChanged c )
|
||||
{
|
||||
this.duality.notifyNeighbors();
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void stateChange( final MENetworkPowerStatusChange c )
|
||||
public void powerRender( final MENetworkPowerStatusChange c )
|
||||
{
|
||||
this.duality.notifyNeighbors();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ package appeng.fluids.parts;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import appeng.api.networking.events.MENetworkChannelChanged;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.fluids.helper.IConfigurableFluidInventory;
|
||||
import appeng.me.cache.NetworkMonitor;
|
||||
@@ -118,7 +117,7 @@ public class PartFluidLevelEmitter extends PartUpgradeable implements IStackWatc
|
||||
{
|
||||
if( chan == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) && diffStack.equals( this.config.getFluidInSlot( 0 ) ) )
|
||||
{
|
||||
this.lastReportedValue += diffStack.getStackSize();
|
||||
this.lastReportedValue = fullStack.getStackSize();
|
||||
this.updateState();
|
||||
}
|
||||
}
|
||||
@@ -129,8 +128,9 @@ public class PartFluidLevelEmitter extends PartUpgradeable implements IStackWatc
|
||||
this.configureWatchers();
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void powerStatusChange( final MENetworkPowerStatusChange powerEvent )
|
||||
public void powerRender( final MENetworkPowerStatusChange powerEvent )
|
||||
{
|
||||
if (this.getProxy().isActive())
|
||||
{
|
||||
@@ -139,8 +139,9 @@ public class PartFluidLevelEmitter extends PartUpgradeable implements IStackWatc
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void channelChanged( final MENetworkChannelsChanged c )
|
||||
public void chanRender( final MENetworkChannelsChanged c )
|
||||
{
|
||||
if (this.getProxy().isActive())
|
||||
{
|
||||
|
||||
@@ -25,7 +25,10 @@ import java.util.Objects;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.fluids.helper.IConfigurableFluidInventory;
|
||||
import appeng.me.cache.GridStorageCache;
|
||||
import appeng.util.ConfigManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -170,7 +173,6 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
||||
|
||||
final MEInventoryHandler<IAEFluidStack> in = this.getInternalHandler();
|
||||
IItemList<IAEFluidStack> before = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList();
|
||||
boolean denyRead = false;
|
||||
if( in != null )
|
||||
{
|
||||
if( accessChanged )
|
||||
@@ -179,7 +181,7 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
||||
AccessRestriction oldAccess = (AccessRestriction) ( (ConfigManager) this.getConfigManager() ).getOldSetting( Settings.ACCESS );
|
||||
if( oldAccess.hasPermission( AccessRestriction.READ ) && !currentAccess.hasPermission( AccessRestriction.READ ) )
|
||||
{
|
||||
denyRead = true;
|
||||
readOncePass = true;
|
||||
}
|
||||
in.setBaseAccess( oldAccess );
|
||||
before = in.getAvailableItems( before );
|
||||
@@ -199,16 +201,14 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
||||
}
|
||||
|
||||
final MEInventoryHandler<IAEFluidStack> out = this.getInternalHandler();
|
||||
IItemList<IAEFluidStack> after = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList();
|
||||
|
||||
if( in != out || denyRead )
|
||||
if( in != out )
|
||||
{
|
||||
IItemList<IAEFluidStack> after = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList();
|
||||
|
||||
if( out != null && !denyRead )
|
||||
if( out != null )
|
||||
{
|
||||
after = out.getAvailableItems( after );
|
||||
}
|
||||
|
||||
Platform.postListChanges( before, after, this, this.source );
|
||||
}
|
||||
}
|
||||
@@ -227,7 +227,7 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
||||
{
|
||||
this.resetCacheLogic = 2;
|
||||
}
|
||||
else
|
||||
else if( this.resetCacheLogic < 2 )
|
||||
{
|
||||
this.resetCacheLogic = 1;
|
||||
}
|
||||
@@ -284,24 +284,34 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
||||
@Override
|
||||
public void postChange( final IBaseMonitor<IAEFluidStack> monitor, final Iterable<IAEFluidStack> change, final IActionSource source )
|
||||
{
|
||||
if( this.source.machine().map( machine -> machine == this ).orElse( false ) && monitor != null )
|
||||
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, source );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :(
|
||||
}
|
||||
return;
|
||||
}
|
||||
if( !currentAccess.hasPermission( AccessRestriction.READ ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
if( this.getProxy().isActive() )
|
||||
try
|
||||
{
|
||||
this.getProxy().getStorage().postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ), change, this.source );
|
||||
this.getProxy().getStorage().postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ), change, source );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :(
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :(
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,6 +336,10 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
||||
|
||||
this.handlerHash = newHandlerHash;
|
||||
this.handler = null;
|
||||
if( this.monitor != null )
|
||||
{
|
||||
( (IBaseMonitor<IAEFluidStack>) monitor ).removeListener( this );
|
||||
}
|
||||
this.monitor = null;
|
||||
if( target != null )
|
||||
{
|
||||
@@ -333,7 +347,8 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
||||
if( inv instanceof ITickingMonitor )
|
||||
{
|
||||
this.monitor = (ITickingMonitor) inv;
|
||||
this.monitor.setActionSource( new MachineSource( this ) );
|
||||
this.monitor.setActionSource( this.source );
|
||||
this.monitor.setMode( (StorageFilter) this.getConfigManager().getSetting( Settings.STORAGE_FILTER ) );
|
||||
}
|
||||
|
||||
if( inv != null )
|
||||
@@ -370,7 +385,10 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
||||
|
||||
if( inv instanceof IBaseMonitor )
|
||||
{
|
||||
( (IBaseMonitor<IAEFluidStack>) inv ).addListener( this, this.handler );
|
||||
if( ( (AccessRestriction) ( (ConfigManager) this.getConfigManager() ).getSetting( Settings.ACCESS ) ).hasPermission( AccessRestriction.READ ) )
|
||||
{
|
||||
( (IBaseMonitor<IAEFluidStack>) inv ).addListener( this, this.handler );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -399,7 +417,7 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
||||
try
|
||||
{
|
||||
// force grid to update handlers...
|
||||
this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
(( GridStorageCache ) this.getProxy().getGrid().getCache( IStorageGrid.class )).cellUpdate( null );
|
||||
}
|
||||
catch( final GridAccessException ignore )
|
||||
{
|
||||
|
||||
@@ -23,13 +23,9 @@ import java.util.*;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.api.networking.crafting.*;
|
||||
import appeng.integration.modules.gregtech.GTCEInventoryAdaptor;
|
||||
import appeng.me.cache.CraftingGridCache;
|
||||
import appeng.util.*;
|
||||
import appeng.util.inv.*;
|
||||
import com.google.common.collect.ImmutableCollection;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import de.ellpeck.actuallyadditions.api.tile.IPhantomTile;
|
||||
@@ -38,7 +34,6 @@ import gregtech.api.metatileentity.MetaTileEntity;
|
||||
import gregtech.api.metatileentity.MetaTileEntityHolder;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -68,6 +63,10 @@ import appeng.api.implementations.tiles.ICraftingMachine;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.crafting.ICraftingLink;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.networking.crafting.ICraftingProvider;
|
||||
import appeng.api.networking.crafting.ICraftingProviderHelper;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.networking.events.MENetworkCraftingPatternChange;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
@@ -109,6 +108,7 @@ import static gregtech.api.block.machines.BlockMachine.getMetaTileEntity;
|
||||
|
||||
public class DualityInterface implements IGridTickable, IStorageMonitorable, IInventoryDestination, IAEAppEngInventory, IConfigManagerHost, ICraftingProvider, IUpgradeableHost
|
||||
{
|
||||
private int[] failedCraftTriesSlot = {0,0,0,0,0,0,0,0,0};
|
||||
|
||||
public static final int NUMBER_OF_STORAGE_SLOTS = 9;
|
||||
public static final int NUMBER_OF_CONFIG_SLOTS = 9;
|
||||
@@ -140,15 +140,17 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
private int isWorking = -1;
|
||||
private final Accessor accessor = new Accessor();
|
||||
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 boolean resetConfigCache = true;
|
||||
private IMEMonitor<IAEItemStack> configCachedHandler;
|
||||
|
||||
public DualityInterface( final AENetworkProxy networkProxy, final IInterfaceHost ih )
|
||||
{
|
||||
this.gridProxy = networkProxy;
|
||||
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.INTERFACE_TERMINAL, YesNo.YES );
|
||||
|
||||
@@ -176,9 +178,14 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
{
|
||||
return;
|
||||
}
|
||||
if( inv == this.config )
|
||||
if( inv == this.config && ( !removed.isEmpty() || !added.isEmpty() ) )
|
||||
{
|
||||
boolean cfg = hasConfig();
|
||||
this.readConfig();
|
||||
if( cfg != hasConfig )
|
||||
{
|
||||
resetConfigCache = true;
|
||||
}
|
||||
}
|
||||
else if( inv == this.patterns && ( !removed.isEmpty() || !added.isEmpty() ) )
|
||||
{
|
||||
@@ -849,19 +856,26 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
throw new GridAccessException();
|
||||
}
|
||||
|
||||
final IAEItemStack acquired = Platform.poweredExtraction( src, this.destination, itemStack, this.interfaceRequestSource );
|
||||
if( acquired != null )
|
||||
IAEItemStack storedStack = this.gridProxy.getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ).getStorageList().findPrecise( itemStack );
|
||||
if( storedStack != null )
|
||||
{
|
||||
changed = true;
|
||||
final ItemStack issue = adaptor.addItems( acquired.createItemStack() );
|
||||
if( !issue.isEmpty() )
|
||||
if( storedStack.getStackSize() > 0 )
|
||||
{
|
||||
throw new IllegalStateException( "bad attempt at managing inventory. ( addItems )" );
|
||||
final IAEItemStack acquired = Platform.poweredExtraction( src, this.destination, itemStack, this.interfaceRequestSource );
|
||||
if( acquired != null )
|
||||
{
|
||||
changed = true;
|
||||
final ItemStack issue = adaptor.addItems( acquired.createItemStack() );
|
||||
if( !issue.isEmpty() )
|
||||
{
|
||||
throw new IllegalStateException( "bad attempt at managing inventory. ( addItems )" );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( storedStack.isCraftable() )
|
||||
{
|
||||
changed = this.handleCrafting( x, adaptor, itemStack ) || changed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
changed = this.handleCrafting( x, adaptor, itemStack ) || changed;
|
||||
}
|
||||
}
|
||||
else if( itemStack.getStackSize() < 0 )
|
||||
@@ -929,7 +943,17 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
{
|
||||
if( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 && itemStack != null )
|
||||
{
|
||||
return this.craftingTracker.handleCrafting( x, itemStack.getStackSize(), itemStack, d, this.iHost.getTileEntity().getWorld(), this.gridProxy.getGrid(), this.gridProxy.getCrafting(), this.mySource );
|
||||
if (this.failedCraftTriesSlot[x] <= 0)
|
||||
{
|
||||
boolean crafted = this.craftingTracker.handleCrafting( x, itemStack.getStackSize(), itemStack, d, this.iHost.getTileEntity().getWorld(),
|
||||
this.gridProxy.getGrid(), this.gridProxy.getCrafting(), this.mySource );
|
||||
|
||||
if (crafted) this.failedCraftTriesSlot[x] = 0;
|
||||
else{
|
||||
this.failedCraftTriesSlot[x] += 2;
|
||||
}
|
||||
}
|
||||
this.failedCraftTriesSlot[x] -= 1;
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
@@ -963,7 +987,12 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
{
|
||||
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;
|
||||
@@ -1571,7 +1600,6 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
public InterfaceInventory( final DualityInterface tileInterface )
|
||||
{
|
||||
super( new AdaptorItemHandler( tileInterface.storage ) );
|
||||
this.setActionSource( new MachineSource( DualityInterface.this.iHost ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,9 +22,6 @@ package appeng.helpers;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import appeng.api.networking.crafting.*;
|
||||
import appeng.me.cache.CraftingGridCache;
|
||||
import com.google.common.collect.ImmutableCollection;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -32,6 +29,10 @@ import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.crafting.ICraftingJob;
|
||||
import appeng.api.networking.crafting.ICraftingLink;
|
||||
import appeng.api.networking.crafting.ICraftingRequester;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
@@ -131,17 +132,6 @@ public class MultiCraftingTracker
|
||||
final IAEItemStack aisC = ais.copy();
|
||||
aisC.setStackSize( itemToCraft );
|
||||
|
||||
CraftingGridCache cgc = (CraftingGridCache) cg;
|
||||
|
||||
ImmutableCollection<ICraftingPatternDetails> cl = cgc.getCraftingFor( aisC, null, x, w );
|
||||
for( ICraftingPatternDetails craftingPatternDetails : cl )
|
||||
{
|
||||
if( cgc.getPatternStatusManager().containsIncompletablePattern( craftingPatternDetails ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
this.setJob( x, cg.beginCraftingJob( w, g, mySrc, aisC, null ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.outputs = out.toArray(new IAEItemStack[outputLength]);
|
||||
|
||||
@@ -35,6 +35,8 @@ public enum TheOneProbeText
|
||||
P2P_UNLINKED,
|
||||
P2P_INPUT_ONE_OUTPUT,
|
||||
P2P_INPUT_MANY_OUTPUTS,
|
||||
P2P_OUTPUT_ONE_INPUT,
|
||||
P2P_OUTPUT_MANY_INPUTS,
|
||||
P2P_OUTPUT,
|
||||
P2P_FREQUENCY,
|
||||
|
||||
|
||||
+29
-5
@@ -57,11 +57,11 @@ public class P2PStateInfoProvider implements IPartProbInfoProvider
|
||||
|
||||
// The default state
|
||||
int state = STATE_UNLINKED;
|
||||
int outputCount = 0;
|
||||
int outputCount = getOutputCount( tunnel );
|
||||
int inputCount = getInputCount( tunnel );
|
||||
|
||||
if( !tunnel.isOutput() )
|
||||
{
|
||||
outputCount = getOutputCount( tunnel );
|
||||
if( outputCount > 0 )
|
||||
{
|
||||
// Only set it to INPUT if we know there are any outputs
|
||||
@@ -70,8 +70,7 @@ public class P2PStateInfoProvider implements IPartProbInfoProvider
|
||||
}
|
||||
else
|
||||
{
|
||||
final PartP2PTunnel input = tunnel.getInput();
|
||||
if( input != null )
|
||||
if( inputCount > 0 )
|
||||
{
|
||||
state = STATE_OUTPUT;
|
||||
}
|
||||
@@ -83,7 +82,7 @@ public class P2PStateInfoProvider implements IPartProbInfoProvider
|
||||
probeInfo.text( TheOneProbeText.P2P_UNLINKED.getLocal() );
|
||||
break;
|
||||
case STATE_OUTPUT:
|
||||
probeInfo.text( TheOneProbeText.P2P_OUTPUT.getLocal() );
|
||||
probeInfo.text( getInputText( inputCount ) );
|
||||
break;
|
||||
case STATE_INPUT:
|
||||
probeInfo.text( getOutputText( outputCount ) );
|
||||
@@ -110,6 +109,19 @@ public class P2PStateInfoProvider implements IPartProbInfoProvider
|
||||
}
|
||||
}
|
||||
|
||||
private static int getInputCount( PartP2PTunnel tunnel )
|
||||
{
|
||||
try
|
||||
{
|
||||
return Iterators.size( tunnel.getInputs().iterator() );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// Well... unknown size it is!
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getOutputText( int outputs )
|
||||
{
|
||||
if( outputs <= 1 )
|
||||
@@ -122,4 +134,16 @@ public class P2PStateInfoProvider implements IPartProbInfoProvider
|
||||
}
|
||||
}
|
||||
|
||||
private static String getInputText( int inputs )
|
||||
{
|
||||
if( inputs <= 1 )
|
||||
{
|
||||
return TheOneProbeText.P2P_OUTPUT_ONE_INPUT.getLocal();
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.format( TheOneProbeText.P2P_OUTPUT_MANY_INPUTS.getLocal(), inputs );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package appeng.integration.modules.waila.part;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.integration.modules.theoneprobe.TheOneProbeText;
|
||||
import com.google.common.collect.Iterators;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -117,11 +118,11 @@ public final class P2PStateWailaDataProvider extends BasePartWailaDataProvider
|
||||
|
||||
// The default state
|
||||
int state = STATE_UNLINKED;
|
||||
int outputCount = 0;
|
||||
int outputCount = getOutputCount( tunnel );
|
||||
int inputCount = getInputCount( tunnel );
|
||||
|
||||
if( !tunnel.isOutput() )
|
||||
{
|
||||
outputCount = getOutputCount( tunnel );
|
||||
if( outputCount > 0 )
|
||||
{
|
||||
// Only set it to INPUT if we know there are any outputs
|
||||
@@ -130,8 +131,7 @@ public final class P2PStateWailaDataProvider extends BasePartWailaDataProvider
|
||||
}
|
||||
else
|
||||
{
|
||||
PartP2PTunnel input = tunnel.getInput();
|
||||
if( input != null )
|
||||
if( inputCount > 0 )
|
||||
{
|
||||
state = STATE_OUTPUT;
|
||||
}
|
||||
@@ -160,15 +160,40 @@ public final class P2PStateWailaDataProvider extends BasePartWailaDataProvider
|
||||
}
|
||||
}
|
||||
|
||||
private static int getInputCount( PartP2PTunnel tunnel )
|
||||
{
|
||||
try
|
||||
{
|
||||
return Iterators.size( tunnel.getInputs().iterator() );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
// Well... unknown size it is!
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static String getOutputText( int outputs )
|
||||
{
|
||||
if( outputs <= 1 )
|
||||
{
|
||||
return WailaText.P2PInputOneOutput.getLocal();
|
||||
return WailaText.P2P_INPUT_ONE_OUTPUT.getLocal();
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.format( WailaText.P2PInputManyOutputs.getLocal(), outputs );
|
||||
return String.format( WailaText.P2P_INPUT_MANY_OUTPUTS.getLocal(), outputs );
|
||||
}
|
||||
}
|
||||
|
||||
private static String getInputText( int inputs )
|
||||
{
|
||||
if( inputs <= 1 )
|
||||
{
|
||||
return WailaText.P2P_OUTPUT_ONE_INPUT.getLocal();
|
||||
}
|
||||
else
|
||||
{
|
||||
return String.format( WailaText.P2P_OUTPUT_MANY_INPUTS.getLocal(), inputs );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.items.contents;
|
||||
|
||||
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@@ -42,6 +43,8 @@ import appeng.me.helpers.MEMonitorHandler;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
|
||||
public class PortableCellViewer extends MEMonitorHandler<IAEItemStack> implements IPortableCell, IInventorySlotAware
|
||||
{
|
||||
@@ -83,6 +86,34 @@ public class PortableCellViewer extends MEMonitorHandler<IAEItemStack> implement
|
||||
return usePowerMultiplier.divide( this.ips.extractAEPower( this.target, amt, Actionable.MODULATE ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems( IAEItemStack input, Actionable mode, IActionSource src )
|
||||
{
|
||||
final long size = input.getStackSize();
|
||||
|
||||
final IAEItemStack injected = super.injectItems( input, mode, src );
|
||||
|
||||
if( mode == Actionable.MODULATE && ( injected == null || injected.getStackSize() != size ) )
|
||||
{
|
||||
this.notifyListenersOfChange( Collections.singletonList( input.copy().setStackSize( input.getStackSize() - ( injected == null ? 0 : injected.getStackSize() ) ) ), null);
|
||||
}
|
||||
|
||||
return injected;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems( IAEItemStack request, Actionable mode, IActionSource src )
|
||||
{
|
||||
final IAEItemStack extractable = super.extractItems( request, mode, src );
|
||||
|
||||
if( mode == Actionable.MODULATE && extractable != null )
|
||||
{
|
||||
this.notifyListenersOfChange( Collections.singletonList( request.copy().setStackSize( -extractable.getStackSize() ) ), null );
|
||||
}
|
||||
|
||||
return extractable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends IAEStack<T>> IMEMonitor<T> getInventory( IStorageChannel<T> channel )
|
||||
{
|
||||
|
||||
@@ -225,7 +225,7 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
|
||||
|
||||
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 );
|
||||
return out;
|
||||
|
||||
@@ -403,7 +403,7 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
|
||||
}
|
||||
else if( pos.entityHit.attackEntityFrom( dmgSrc, dmg ) )
|
||||
{
|
||||
hasDestroyed = true;
|
||||
hasDestroyed = pos.entityHit.isEntityAlive();
|
||||
}
|
||||
}
|
||||
else if( pos.typeOfHit == RayTraceResult.Type.BLOCK )
|
||||
|
||||
+35
-13
@@ -35,7 +35,6 @@ import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
import appeng.me.helpers.PatternStatusManager;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.ImmutableCollection;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -267,17 +266,17 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
// coalesce change events during a grid traversal to a single rebuild
|
||||
if (pauseRebuilds != 0)
|
||||
{
|
||||
rebuildNeeded.add( this );
|
||||
rebuildNeeded.add(this);
|
||||
return;
|
||||
}
|
||||
|
||||
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.
|
||||
this.craftingMethods.clear();
|
||||
this.craftableItems.clear();
|
||||
this.emitableItems.clear();
|
||||
( (GridStorageCache) this.storageGrid ).clearPatternStatus();
|
||||
|
||||
// re-create list..
|
||||
for( final ICraftingProvider provider : this.craftingProviders )
|
||||
@@ -290,7 +289,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
// new craftables!
|
||||
for( final ICraftingPatternDetails details : this.craftingMethods.keySet() )
|
||||
{
|
||||
for( IAEItemStack out : details.getCondensedOutputs() )
|
||||
for( IAEItemStack out : details.getOutputs() )
|
||||
{
|
||||
out = out.copy();
|
||||
out.reset();
|
||||
@@ -318,14 +317,42 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
ObjectSet<Entry<IAEItemStack, ImmutableList<ICraftingPatternDetails>>> i = oldItems.entrySet();
|
||||
for ( Entry<IAEItemStack, ImmutableList<ICraftingPatternDetails>> ais : i) {
|
||||
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();
|
||||
for ( Entry<IAEItemStack, ImmutableList<ICraftingPatternDetails>> ais : j) {
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -649,7 +676,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
|
||||
public boolean hasCpu( final ICraftingCPU cpu )
|
||||
{
|
||||
if( cpu instanceof CraftingCPUCluster )
|
||||
if (cpu instanceof CraftingCPUCluster)
|
||||
{
|
||||
return this.craftingCPUClusters.contains( (CraftingCPUCluster) cpu );
|
||||
}
|
||||
@@ -661,11 +688,6 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
return this.interestManager;
|
||||
}
|
||||
|
||||
public PatternStatusManager getPatternStatusManager()
|
||||
{
|
||||
return ( (GridStorageCache) this.storageGrid ).getPatternStatusManager();
|
||||
}
|
||||
|
||||
private static class ActiveCpuIterator implements Iterator<ICraftingCPU>
|
||||
{
|
||||
|
||||
|
||||
+115
-138
@@ -19,10 +19,21 @@
|
||||
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.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.Actionable;
|
||||
@@ -54,11 +65,9 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
{
|
||||
|
||||
private static final double MAX_BUFFER_STORAGE = 800;
|
||||
private static final Comparator<IEnergyGridProvider> COMPARATOR_HIGHEST_AMOUNT_STORED_FIRST = ( o1, o2 ) -> Double.compare( o2.getProviderStoredEnergy(),
|
||||
o1.getProviderStoredEnergy() );
|
||||
private static final Comparator<IEnergyGridProvider> COMPARATOR_HIGHEST_AMOUNT_STORED_FIRST = ( o1, o2 ) -> Double.compare( o2.getProviderStoredEnergy(), o1.getProviderStoredEnergy() );
|
||||
|
||||
private static final Comparator<IEnergyGridProvider> COMPARATOR_LOWEST_PERCENTAGE_FIRST = ( o1, o2 ) ->
|
||||
{
|
||||
private static final Comparator<IEnergyGridProvider> COMPARATOR_LOWEST_PERCENTAGE_FIRST = ( o1, o2 ) -> {
|
||||
final double percent1 = ( o1.getProviderStoredEnergy() + 1 ) / ( o1.getProviderMaxEnergy() + 1 );
|
||||
final double percent2 = ( o2.getProviderStoredEnergy() + 1 ) / ( o2.getProviderMaxEnergy() + 1 );
|
||||
|
||||
@@ -70,7 +79,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
// Should only be modified from the add/remove methods below to guard against
|
||||
// concurrent modifications
|
||||
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
|
||||
// when something externally
|
||||
// modifies the energy grid.
|
||||
@@ -78,7 +87,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
|
||||
// Should only be modified from the add/remove methods below to guard against
|
||||
// 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
|
||||
// when something externally
|
||||
// modifies the energy grid.
|
||||
@@ -115,16 +124,16 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
private double lastStoredPower = -1;
|
||||
|
||||
private final GridPowerStorage localStorage = new GridPowerStorage();
|
||||
private Set<IAEPowerStorage> providersToRemove = new HashSet<>();
|
||||
private Set<IAEPowerStorage> requestersToRemove = new HashSet<>();
|
||||
private Set<IAEPowerStorage> providerToRemove = new HashSet<>();
|
||||
private Set<IAEPowerStorage> requesterToRemove = 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 )
|
||||
{
|
||||
this.myGrid = g;
|
||||
this.requesters.put( 0, this.localStorage );
|
||||
this.providers.put( 1, this.localStorage );
|
||||
this.requesters.add( this.localStorage );
|
||||
this.providers.add( this.localStorage );
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
@@ -152,34 +161,33 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
{
|
||||
if( ev.storage.isAEPublicPowerStorage() )
|
||||
{
|
||||
switch ( ev.type )
|
||||
if( ev.type == PowerEventType.PROVIDE_POWER )
|
||||
{
|
||||
case PROVIDE_POWER:
|
||||
if( ev.storage.getPowerFlow() != AccessRestriction.WRITE )
|
||||
if( ev.storage.getPowerFlow() != AccessRestriction.WRITE )
|
||||
{
|
||||
if( !ongoingExtractOperation )
|
||||
{
|
||||
if( !ongoingExtractOperation )
|
||||
{
|
||||
addProvider( ev.storage );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.providersToAdd.add( ev.storage );
|
||||
}
|
||||
addProvider( ev.storage );
|
||||
}
|
||||
break;
|
||||
case REQUEST_POWER:
|
||||
if( ev.storage.getPowerFlow() != AccessRestriction.READ )
|
||||
else
|
||||
{
|
||||
if( !ongoingInjectOperation )
|
||||
{
|
||||
addRequester( ev.storage );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.requestersToAdd.add( ev.storage );
|
||||
}
|
||||
this.providersToAdd.add( ev.storage );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if( ev.type == PowerEventType.REQUEST_POWER )
|
||||
{
|
||||
if( ev.storage.getPowerFlow() != AccessRestriction.READ )
|
||||
{
|
||||
if( !ongoingInjectOperation )
|
||||
{
|
||||
addRequester( ev.storage );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.requesterToAdd.add( ev.storage );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -307,7 +315,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
{
|
||||
this.availableTicksSinceUpdate = 0;
|
||||
this.globalAvailablePower = 0;
|
||||
for( final IAEPowerStorage p : this.providers.values() )
|
||||
for( final IAEPowerStorage p : this.providers )
|
||||
{
|
||||
this.globalAvailablePower += p.getAECurrentPower();
|
||||
}
|
||||
@@ -324,50 +332,57 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
{
|
||||
double extractedPower = 0;
|
||||
|
||||
providersToAdd.forEach( provider -> {
|
||||
if( provider instanceof GridPowerStorage )
|
||||
{
|
||||
providers.put( 1, provider );
|
||||
}
|
||||
else
|
||||
{
|
||||
providers.put( 0, provider );
|
||||
}
|
||||
} );
|
||||
this.providers.addAll( providersToAdd );
|
||||
providersToAdd.clear();
|
||||
providers.removeIf( providerToRemove::contains );
|
||||
this.providerToRemove.clear();
|
||||
|
||||
final Iterator<IAEPowerStorage> it = this.providers.values().iterator();
|
||||
final Iterator<IAEPowerStorage> it = this.providers.iterator();
|
||||
|
||||
ongoingExtractOperation = true;
|
||||
boolean ls = false;
|
||||
try
|
||||
{
|
||||
while ( extractedPower < amt && it.hasNext() )
|
||||
{
|
||||
final IAEPowerStorage node = it.next();
|
||||
if( node != null )
|
||||
{
|
||||
if( node == localStorage && mode == Actionable.MODULATE )
|
||||
{
|
||||
ls = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
final double req = amt - extractedPower;
|
||||
final double newPower = node.extractAEPower( req, mode, PowerMultiplier.ONE );
|
||||
extractedPower += newPower;
|
||||
final double req = amt - extractedPower;
|
||||
final double newPower = node.extractAEPower( req, mode, PowerMultiplier.ONE );
|
||||
extractedPower += newPower;
|
||||
|
||||
if( newPower < req && mode == Actionable.MODULATE )
|
||||
if( newPower < req && mode == Actionable.MODULATE )
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
} finally
|
||||
{
|
||||
providersToRemove.forEach( provider -> {
|
||||
if( provider instanceof GridPowerStorage )
|
||||
{
|
||||
providers.remove( 1, provider );
|
||||
}
|
||||
else
|
||||
{
|
||||
providers.remove( 0, provider );
|
||||
}
|
||||
} );
|
||||
this.providersToRemove.clear();
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final double result = Math.min( extractedPower, amt );
|
||||
@@ -391,19 +406,12 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
{
|
||||
final double originalAmount = amt;
|
||||
|
||||
requestersToAdd.forEach( requester -> {
|
||||
if( requester instanceof GridPowerStorage )
|
||||
{
|
||||
requesters.put( 0, requester );
|
||||
}
|
||||
else
|
||||
{
|
||||
requesters.put( 1, requester );
|
||||
}
|
||||
} );
|
||||
requestersToAdd.clear();
|
||||
this.requesters.addAll( requesterToAdd );
|
||||
requesterToAdd.clear();
|
||||
requesters.removeIf( requesterToRemove::contains );
|
||||
this.requesterToRemove.clear();
|
||||
|
||||
final Iterator<IAEPowerStorage> it = this.requesters.values().iterator();
|
||||
final Iterator<IAEPowerStorage> it = this.requesters.iterator();
|
||||
|
||||
ongoingInjectOperation = true;
|
||||
try
|
||||
@@ -412,26 +420,22 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
{
|
||||
final IAEPowerStorage node = it.next();
|
||||
|
||||
amt = node.injectAEPower( amt, mode );
|
||||
if( node != null )
|
||||
{
|
||||
amt = node.injectAEPower( amt, mode );
|
||||
|
||||
if( amt > 0 && mode == Actionable.MODULATE )
|
||||
if( amt > 0 && mode == Actionable.MODULATE )
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
} finally
|
||||
{
|
||||
requestersToRemove.forEach( requester -> {
|
||||
if( requester instanceof GridPowerStorage )
|
||||
{
|
||||
requesters.remove( 0, requester );
|
||||
}
|
||||
else
|
||||
{
|
||||
requesters.remove( 1, requester );
|
||||
}
|
||||
} );
|
||||
this.requestersToRemove.clear();
|
||||
ongoingInjectOperation = false;
|
||||
}
|
||||
|
||||
@@ -450,8 +454,8 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
{
|
||||
double required = 0;
|
||||
|
||||
final Iterator<IAEPowerStorage> it = this.requesters.values().iterator();
|
||||
while( required < maxRequired && it.hasNext() )
|
||||
final Iterator<IAEPowerStorage> it = this.requesters.iterator();
|
||||
while ( required < maxRequired && it.hasNext() )
|
||||
{
|
||||
final IAEPowerStorage node = it.next();
|
||||
if( node.getPowerFlow() != AccessRestriction.READ )
|
||||
@@ -591,7 +595,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
}
|
||||
else
|
||||
{
|
||||
this.providersToRemove.add( ps );
|
||||
this.providerToRemove.add( ps );
|
||||
}
|
||||
if( !ongoingInjectOperation )
|
||||
{
|
||||
@@ -599,7 +603,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
}
|
||||
else
|
||||
{
|
||||
this.requestersToRemove.add( ps );
|
||||
this.requesterToRemove.add( ps );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -616,58 +620,31 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
}
|
||||
}
|
||||
|
||||
private void addRequester(IAEPowerStorage requester) {
|
||||
Preconditions.checkState(!ongoingInjectOperation,
|
||||
"Cannot modify energy requesters while energy is being injected.");
|
||||
if( requester instanceof GridPowerStorage )
|
||||
{
|
||||
requesters.put( 0, requester );
|
||||
}
|
||||
else
|
||||
{
|
||||
requesters.put( 1, requester );
|
||||
}
|
||||
private void addRequester( IAEPowerStorage requester )
|
||||
{
|
||||
Preconditions.checkState( !ongoingInjectOperation, "Cannot modify energy requesters while energy is being injected." );
|
||||
this.requesters.add( requester );
|
||||
}
|
||||
|
||||
private void removeRequester(IAEPowerStorage requester) {
|
||||
Preconditions.checkState(!ongoingInjectOperation,
|
||||
"Cannot modify energy requesters while energy is being injected.");
|
||||
if( requester instanceof GridPowerStorage )
|
||||
{
|
||||
requesters.remove( 0, requester );
|
||||
}
|
||||
else
|
||||
{
|
||||
requesters.remove( 1, requester );
|
||||
}
|
||||
private void removeRequester( IAEPowerStorage requester )
|
||||
{
|
||||
Preconditions.checkState( !ongoingInjectOperation, "Cannot modify energy requesters while energy is being injected." );
|
||||
this.requesters.remove( requester );
|
||||
}
|
||||
|
||||
private void addProvider(IAEPowerStorage provider) {
|
||||
Preconditions.checkState(!ongoingExtractOperation,
|
||||
"Cannot modify energy providers while energy is being extracted.");
|
||||
if( provider instanceof GridPowerStorage )
|
||||
{
|
||||
providers.put( 1, provider );
|
||||
}
|
||||
else
|
||||
{
|
||||
providers.put( 0, provider );
|
||||
}
|
||||
}
|
||||
|
||||
private void removeProvider(IAEPowerStorage provider)
|
||||
private void addProvider( IAEPowerStorage provider )
|
||||
{
|
||||
Preconditions.checkState( !ongoingExtractOperation, "Cannot modify energy providers while energy is being extracted." );
|
||||
if( provider instanceof GridPowerStorage )
|
||||
{
|
||||
providers.remove( 1, provider );
|
||||
}
|
||||
else
|
||||
{
|
||||
providers.remove( 0, provider );
|
||||
}
|
||||
this.providers.add( provider );
|
||||
}
|
||||
|
||||
private void removeProvider( IAEPowerStorage provider )
|
||||
{
|
||||
Preconditions.checkState( !ongoingExtractOperation, "Cannot modify energy providers while energy is being extracted." );
|
||||
this.providers.remove( provider );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addNode( final IGridNode node, final IGridHost machine )
|
||||
{
|
||||
@@ -717,7 +694,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
}
|
||||
else
|
||||
{
|
||||
this.requestersToAdd.add( ps );
|
||||
this.requesterToAdd.add( ps );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -845,4 +822,4 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-23
@@ -26,10 +26,7 @@ import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.me.helpers.PatternStatusManager;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
@@ -68,10 +65,6 @@ public class GridStorageCache implements IStorageGrid
|
||||
private final HashSet<ICellProvider> inactiveCellProviders = new HashSet<>();
|
||||
private final SetMultimap<IAEStack, ItemWatcher> interests = HashMultimap.create();
|
||||
private final GenericInterestManager<ItemWatcher> interestManager = new GenericInterestManager<>( this.interests );
|
||||
private final Multimap<ICraftingPatternDetails, IAEStack> patternDetails2IAEStackMultimap = HashMultimap.create();
|
||||
private final Multimap<IAEStack, ICraftingPatternDetails> iaeStack2PatternDetailsMultimap = HashMultimap.create();
|
||||
private final PatternStatusManager patternStatusManager = new PatternStatusManager( this.patternDetails2IAEStackMultimap, this.iaeStack2PatternDetailsMultimap );
|
||||
|
||||
private final HashMap<IGridNode, IStackWatcher> watchers = new HashMap<>();
|
||||
private Map<IStorageChannel<? extends IAEStack>, NetworkInventoryHandler<?>> storageNetworks;
|
||||
private Map<IStorageChannel<? extends IAEStack>, NetworkMonitor<?>> storageMonitors;
|
||||
@@ -101,7 +94,7 @@ public class GridStorageCache implements IStorageGrid
|
||||
|
||||
this.removeCellProvider( cc, tracker );
|
||||
this.inactiveCellProviders.remove( cc );
|
||||
this.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
cellUpdate( null );
|
||||
|
||||
tracker.applyChanges();
|
||||
}
|
||||
@@ -126,7 +119,7 @@ public class GridStorageCache implements IStorageGrid
|
||||
final ICellContainer cc = (ICellContainer) machine;
|
||||
this.inactiveCellProviders.add( cc );
|
||||
|
||||
this.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
cellUpdate( null );
|
||||
|
||||
if( node.isActive() )
|
||||
{
|
||||
@@ -177,7 +170,7 @@ public class GridStorageCache implements IStorageGrid
|
||||
|
||||
private CellChangeTracker addCellProvider( final ICellProvider cc, final CellChangeTracker tracker )
|
||||
{
|
||||
if( this.inactiveCellProviders.contains( cc ) )
|
||||
if( this.inactiveCellProviders.contains( cc ) && !this.activeCellProviders.contains( cc ))
|
||||
{
|
||||
this.inactiveCellProviders.remove( cc );
|
||||
this.activeCellProviders.add( cc );
|
||||
@@ -311,18 +304,6 @@ public class GridStorageCache implements IStorageGrid
|
||||
return this.interestManager;
|
||||
}
|
||||
|
||||
public PatternStatusManager getPatternStatusManager()
|
||||
{
|
||||
return this.patternStatusManager;
|
||||
}
|
||||
|
||||
public void clearPatternStatus()
|
||||
{
|
||||
System.out.println( "reseting pattern status due to pattern changes" );
|
||||
this.patternDetails2IAEStackMultimap.clear();
|
||||
this.iaeStack2PatternDetailsMultimap.clear();
|
||||
}
|
||||
|
||||
IGrid getGrid()
|
||||
{
|
||||
return this.myGrid;
|
||||
@@ -347,7 +328,10 @@ public class GridStorageCache implements IStorageGrid
|
||||
|
||||
public void applyChanges()
|
||||
{
|
||||
GridStorageCache.this.postChangesToNetwork( this.channel, this.up_or_down, this.list, this.src );
|
||||
if( !this.list.isEmpty() )
|
||||
{
|
||||
GridStorageCache.this.postChangesToNetwork( this.channel, this.up_or_down, this.list, this.src );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+117
-91
@@ -25,8 +25,6 @@ import javax.annotation.Nullable;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.networking.events.MENetworkStorageEvent;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
@@ -35,7 +33,6 @@ import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.me.storage.ItemWatcher;
|
||||
@@ -43,16 +40,17 @@ import com.google.common.collect.Queues;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Deque;
|
||||
import java.util.Iterator;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
|
||||
public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
||||
{
|
||||
@Nonnull
|
||||
private static final Deque<NetworkMonitor<?>> GLOBAL_DEPTH = Queues.newArrayDeque();
|
||||
private static final Set<NetworkMonitor<?>> NESTED_MONITORS = new HashSet<>();
|
||||
private static final HashMap<IActionSource, Set<NetworkMonitor<?>>> sourceSetHashMap = new HashMap<>();
|
||||
protected static boolean nested = false;
|
||||
protected boolean isNested = false;
|
||||
|
||||
@Nonnull
|
||||
private final GridStorageCache myGridCache;
|
||||
@@ -64,6 +62,7 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
||||
private final Object2ObjectMap<IMEMonitorHandlerReceiver<T>, Object> listeners;
|
||||
|
||||
private boolean sendEvent = false;
|
||||
private boolean forceUpdate = false;
|
||||
@Nonnegative
|
||||
private int localDepthSemaphore = 0;
|
||||
private long gridItemCount;
|
||||
@@ -138,17 +137,16 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long incGridCurrentCount(long count)
|
||||
public void incGridCurrentCount( long count )
|
||||
{
|
||||
if( myChannel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
|
||||
{
|
||||
return gridItemCount += count;
|
||||
gridItemCount += count;
|
||||
}
|
||||
else if( myChannel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
|
||||
{
|
||||
return gridFluidCount += count;
|
||||
gridFluidCount += count;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -201,6 +199,7 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
||||
{
|
||||
final Entry<IMEMonitorHandlerReceiver<T>, Object> o = i.next();
|
||||
final IMEMonitorHandlerReceiver<T> receiver = o.getKey();
|
||||
|
||||
if( receiver.isValid( o.getValue() ) )
|
||||
{
|
||||
receiver.postChange( this, diff, src );
|
||||
@@ -217,47 +216,55 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
||||
for( final T changedItem : input )
|
||||
{
|
||||
if (changedItem.isCraftable()) {
|
||||
this.cachedList.add( changedItem.copy().setCraftable( true ) );
|
||||
this.cachedList.add( changedItem );
|
||||
}
|
||||
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 )
|
||||
{
|
||||
if( GLOBAL_DEPTH.contains( this ) )
|
||||
|
||||
if( sourceSetHashMap.get( src ) != null && sourceSetHashMap.get( src ).contains( this ) )
|
||||
{
|
||||
NESTED_MONITORS.add( this );
|
||||
nested = true;
|
||||
return;
|
||||
}
|
||||
|
||||
GLOBAL_DEPTH.push( this );
|
||||
sourceSetHashMap.putIfAbsent( src, new HashSet<>() );
|
||||
sourceSetHashMap.get( src ).add( this );
|
||||
|
||||
this.sendEvent = true;
|
||||
|
||||
for( final T changedItem : changes )
|
||||
for( final T change : 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() );
|
||||
this.cachedList.add( changedItem );
|
||||
incGridCurrentCount( change.getStackSize() );
|
||||
this.cachedList.addStorage( 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() )
|
||||
{
|
||||
IAEStack<T> fullStack = this.getStorageList().findPrecise( changedItem );
|
||||
IAEStack<T> fullStack = this.getStorageList().findPrecise( change );
|
||||
|
||||
if( fullStack == null )
|
||||
{
|
||||
fullStack = changedItem.copy();
|
||||
fullStack = change.copy();
|
||||
fullStack.setStackSize( 0 );
|
||||
}
|
||||
|
||||
@@ -265,82 +272,102 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
if( changedItem instanceof IAEItemStack )
|
||||
{
|
||||
if( this.myGridCache.getPatternStatusManager().containsMissingIAEStack( changedItem ) )
|
||||
{
|
||||
this.myGridCache.getPatternStatusManager().enableTransactions();
|
||||
|
||||
for( ICraftingPatternDetails craftingPatternDetails : this.myGridCache.getPatternStatusManager().getIncompletablePattern( changedItem ) )
|
||||
{
|
||||
for( IAEStack stack : this.myGridCache.getPatternStatusManager().getMissingIAEStack( craftingPatternDetails ) )
|
||||
{
|
||||
if( craftingPatternDetails.canSubstitute() )
|
||||
{
|
||||
if( ( (IAEItemStack) stack ).getItem().isDamageable() )
|
||||
{
|
||||
if( ( (IAEStack) changedItem ).fuzzyComparison( stack, FuzzyMode.IGNORE_ALL ) )
|
||||
{
|
||||
if( changedItem.getStackSize() > 0 )
|
||||
{
|
||||
this.myGridCache.getPatternStatusManager().remove( craftingPatternDetails, stack );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ( (IAEItemStack) stack ).sameOre( (IAEItemStack) changedItem ) )
|
||||
{
|
||||
if( changedItem.getStackSize() > 0 )
|
||||
{
|
||||
if( changedItem.getStackSize() >= stack.getStackSize() )
|
||||
{
|
||||
this.myGridCache.getPatternStatusManager().remove( craftingPatternDetails, stack );
|
||||
}
|
||||
else
|
||||
{
|
||||
stack.decStackSize( changedItem.getStackSize() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( stack.equals( changedItem ) )
|
||||
{
|
||||
if( changedItem.getStackSize() > 0 )
|
||||
{
|
||||
if( changedItem.getStackSize() >= stack.getStackSize() )
|
||||
{
|
||||
this.myGridCache.getPatternStatusManager().remove( craftingPatternDetails, stack );
|
||||
}
|
||||
else
|
||||
{
|
||||
stack.decStackSize( changedItem.getStackSize() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.myGridCache.getPatternStatusManager().disableTransactions();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.notifyListenersOfChange( changes, src );
|
||||
|
||||
final NetworkMonitor<?> last = GLOBAL_DEPTH.pop();
|
||||
|
||||
if( last != this )
|
||||
sourceSetHashMap.get( src ).remove( this );
|
||||
if( sourceSetHashMap.get( src ).isEmpty() )
|
||||
{
|
||||
throw new IllegalStateException( "Invalid Access to Networked Storage API detected." );
|
||||
sourceSetHashMap.remove( src );
|
||||
}
|
||||
|
||||
if( sourceSetHashMap.isEmpty() )
|
||||
{
|
||||
for( NetworkMonitor<?> nm : NESTED_MONITORS )
|
||||
{
|
||||
nm.setupForceUpdate();
|
||||
}
|
||||
nested = false;
|
||||
NESTED_MONITORS.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void setupForceUpdate()
|
||||
{
|
||||
if( nested != isNested )
|
||||
{
|
||||
isNested = nested;
|
||||
forceUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
void forceUpdate()
|
||||
{
|
||||
forceUpdate = false;
|
||||
this.cachedList.resetStatus();
|
||||
this.getAvailableItems( this.cachedList );
|
||||
|
||||
long count = 0;
|
||||
for( T stack : this.cachedList )
|
||||
{
|
||||
count += stack.getStackSize();
|
||||
|
||||
if( this.myGridCache.getInterestManager().containsKey( stack ) )
|
||||
{
|
||||
final Collection<ItemWatcher> list = this.myGridCache.getInterestManager().get( stack );
|
||||
|
||||
if( !list.isEmpty() )
|
||||
{
|
||||
IAEStack<T> fullStack = this.getStorageList().findPrecise( stack );
|
||||
|
||||
if( fullStack == null )
|
||||
{
|
||||
fullStack = stack.copy();
|
||||
fullStack.setStackSize( 0 );
|
||||
}
|
||||
|
||||
this.myGridCache.getInterestManager().enableTransactions();
|
||||
|
||||
for ( final ItemWatcher iw : list )
|
||||
{
|
||||
iw.getHost().onStackChange( this.getStorageList(), fullStack, stack, null, this.getChannel() );
|
||||
}
|
||||
|
||||
this.myGridCache.getInterestManager().disableTransactions();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( myChannel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
|
||||
{
|
||||
gridItemCount = count;
|
||||
}
|
||||
else if( myChannel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
|
||||
{
|
||||
gridFluidCount = count;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,6 +378,5 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
||||
this.sendEvent = false;
|
||||
this.myGridCache.getGrid().postEvent( new MENetworkStorageEvent( this, this.myChannel ) );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+56
-17
@@ -19,7 +19,7 @@
|
||||
package appeng.me.cache;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Collection;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.collect.LinkedHashMultimap;
|
||||
@@ -46,7 +46,7 @@ public class P2PCache implements IGridCache
|
||||
private static final TunnelCollection<PartP2PTunnel> NULL_COLLECTION = new TunnelCollection<PartP2PTunnel>( null, null );
|
||||
|
||||
private final IGrid myGrid;
|
||||
private final HashMap<Short, PartP2PTunnel> inputs = new HashMap<>();
|
||||
private final Multimap<Short, PartP2PTunnel> inputs = LinkedHashMultimap.create();
|
||||
private final Multimap<Short, PartP2PTunnel> outputs = LinkedHashMultimap.create();
|
||||
private final Random frequencyGenerator;
|
||||
|
||||
@@ -110,10 +110,19 @@ public class P2PCache implements IGridCache
|
||||
}
|
||||
else
|
||||
{
|
||||
this.inputs.remove( t.getFrequency() );
|
||||
this.inputs.remove( t.getFrequency(), t );
|
||||
}
|
||||
|
||||
this.updateTunnel( t.getFrequency(), !t.isOutput(), false );
|
||||
if( this.inputs.get( t.getFrequency() ).isEmpty() )
|
||||
{
|
||||
this.inputs.removeAll( t.getFrequency() );
|
||||
}
|
||||
if( this.outputs.get( t.getFrequency() ).isEmpty() )
|
||||
{
|
||||
this.outputs.removeAll( t.getFrequency() );
|
||||
}
|
||||
|
||||
this.updateTunnel( t.getFrequency(), t.isOutput(), false );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +151,7 @@ public class P2PCache implements IGridCache
|
||||
this.inputs.put( t.getFrequency(), t );
|
||||
}
|
||||
|
||||
this.updateTunnel( t.getFrequency(), !t.isOutput(), false );
|
||||
this.updateTunnel( t.getFrequency(), t.isOutput(), false );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,6 +173,20 @@ public class P2PCache implements IGridCache
|
||||
|
||||
}
|
||||
|
||||
public void removeTunnel( final PartP2PTunnel t, short freq )
|
||||
{
|
||||
this.outputs.remove( freq, t );
|
||||
this.inputs.remove( freq, t );
|
||||
if( this.inputs.get( t.getFrequency() ).isEmpty() )
|
||||
{
|
||||
this.inputs.removeAll( t.getFrequency() );
|
||||
}
|
||||
if( this.outputs.get( t.getFrequency() ).isEmpty() )
|
||||
{
|
||||
this.outputs.removeAll( t.getFrequency() );
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTunnel( final short freq, final boolean updateOutputs, final boolean configChange )
|
||||
{
|
||||
for( final PartP2PTunnel p : this.outputs.get( freq ) )
|
||||
@@ -175,8 +198,7 @@ public class P2PCache implements IGridCache
|
||||
p.onTunnelNetworkChange();
|
||||
}
|
||||
|
||||
final PartP2PTunnel in = this.inputs.get( freq );
|
||||
if( in != null )
|
||||
for( final PartP2PTunnel in : this.inputs.get( freq ) )
|
||||
{
|
||||
if( configChange )
|
||||
{
|
||||
@@ -195,7 +217,7 @@ public class P2PCache implements IGridCache
|
||||
|
||||
if( this.inputs.containsValue( t ) )
|
||||
{
|
||||
this.inputs.remove( t.getFrequency() );
|
||||
this.inputs.remove( t.getFrequency(), t );
|
||||
}
|
||||
|
||||
t.setFrequency( newFrequency );
|
||||
@@ -211,7 +233,6 @@ public class P2PCache implements IGridCache
|
||||
|
||||
// AELog.info( "update-" + (t.output ? "output: " : "input: ") + t.freq );
|
||||
this.updateTunnel( t.getFrequency(), t.isOutput(), true );
|
||||
this.updateTunnel( t.getFrequency(), !t.isOutput(), true );
|
||||
}
|
||||
|
||||
public short newFrequency()
|
||||
@@ -236,25 +257,43 @@ public class P2PCache implements IGridCache
|
||||
|
||||
public TunnelCollection<PartP2PTunnel> getOutputs( final short freq, final Class<? extends PartP2PTunnel> c )
|
||||
{
|
||||
final PartP2PTunnel in = this.inputs.get( freq );
|
||||
Collection<PartP2PTunnel> in = this.inputs.get( freq );
|
||||
|
||||
if( in == null )
|
||||
{
|
||||
return NULL_COLLECTION;
|
||||
}
|
||||
|
||||
final TunnelCollection<PartP2PTunnel> out = this.inputs.get( freq ).getCollection( this.outputs.get( freq ), c );
|
||||
TunnelCollection<PartP2PTunnel> out;
|
||||
for( PartP2PTunnel part : this.inputs.get( freq ) )
|
||||
{
|
||||
out = part.getCollection( this.outputs.get( freq ), c );
|
||||
if( out != null )
|
||||
{
|
||||
return out;
|
||||
}
|
||||
}
|
||||
return NULL_COLLECTION;
|
||||
}
|
||||
|
||||
public TunnelCollection<PartP2PTunnel> getInputs( final short freq, final Class<? extends PartP2PTunnel> c )
|
||||
{
|
||||
Collection<PartP2PTunnel> out = this.outputs.get( freq );
|
||||
|
||||
if( out == null )
|
||||
{
|
||||
return NULL_COLLECTION;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
public PartP2PTunnel getInput( final short freq )
|
||||
{
|
||||
return this.inputs.get( freq );
|
||||
TunnelCollection<PartP2PTunnel> in;
|
||||
for( PartP2PTunnel part : this.outputs.get( freq ) )
|
||||
{
|
||||
in = part.getCollection( this.inputs.get( freq ), c );
|
||||
if( in != null )
|
||||
{
|
||||
return in;
|
||||
}
|
||||
}
|
||||
return NULL_COLLECTION;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,11 +23,10 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
|
||||
|
||||
public class GenericInterestManager<T>
|
||||
{
|
||||
@@ -102,30 +101,12 @@ public class GenericInterestManager<T>
|
||||
|
||||
public boolean containsKey( final IAEStack stack )
|
||||
{
|
||||
if( stack.isItem() && ( ( AEItemStack ) stack ).getItem().isDamageable() )
|
||||
{
|
||||
return this.container.keySet().stream().filter( s -> s.isItem() )
|
||||
.anyMatch( s -> s.fuzzyComparison( stack, FuzzyMode.IGNORE_ALL ) );
|
||||
}
|
||||
return this.container.containsKey( stack );
|
||||
}
|
||||
|
||||
public Collection<T> get( final IAEStack stack )
|
||||
{
|
||||
Collection<T> watchers = new ArrayList<>();
|
||||
if( stack.isItem() && ( ( AEItemStack ) stack ).getItem().isDamageable() )
|
||||
{
|
||||
this.container.keySet().stream().filter( s -> s.isItem() )
|
||||
.filter( k -> k.fuzzyComparison( stack, FuzzyMode.IGNORE_ALL ) )
|
||||
.forEach( key ->
|
||||
watchers.addAll( this.container.get( key ) )
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.container.get( stack );
|
||||
}
|
||||
return watchers;
|
||||
return this.container.get( stack );
|
||||
}
|
||||
|
||||
private class SavedTransactions
|
||||
@@ -142,4 +123,4 @@ public class GenericInterestManager<T>
|
||||
this.iw = watcher;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,8 +28,6 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
@@ -85,11 +83,7 @@ public class MEMonitorHandler<T extends IAEStack<T>> implements IMEMonitor<T>
|
||||
@Override
|
||||
public T injectItems( final T input, final Actionable mode, final IActionSource src )
|
||||
{
|
||||
if( mode == Actionable.SIMULATE )
|
||||
{
|
||||
return this.getHandler().injectItems( input, mode, src );
|
||||
}
|
||||
return this.monitorDifference( input.copy(), this.getHandler().injectItems( input, mode, src ), false, src );
|
||||
return this.getHandler().injectItems( input, mode, src );
|
||||
}
|
||||
|
||||
protected IMEInventoryHandler<T> getHandler()
|
||||
@@ -97,28 +91,7 @@ public class MEMonitorHandler<T extends IAEStack<T>> implements IMEMonitor<T>
|
||||
return this.internalHandler;
|
||||
}
|
||||
|
||||
private T monitorDifference( final T original, final T leftOvers, final boolean extraction, final IActionSource src )
|
||||
{
|
||||
final T diff = original.copy();
|
||||
|
||||
if( extraction )
|
||||
{
|
||||
diff.setStackSize( leftOvers == null ? 0 : -leftOvers.getStackSize() );
|
||||
}
|
||||
else if( leftOvers != null )
|
||||
{
|
||||
diff.decStackSize( leftOvers.getStackSize() );
|
||||
}
|
||||
|
||||
if( diff.getStackSize() != 0 )
|
||||
{
|
||||
this.postChangesToListeners( ImmutableList.of( diff ), src );
|
||||
}
|
||||
|
||||
return leftOvers;
|
||||
}
|
||||
|
||||
protected void postChangesToListeners( final Iterable<T> changes, final IActionSource src )
|
||||
public void postChangesToListeners( final Iterable<T> changes, final IActionSource src )
|
||||
{
|
||||
this.notifyListenersOfChange( changes, src );
|
||||
}
|
||||
@@ -150,11 +123,7 @@ public class MEMonitorHandler<T extends IAEStack<T>> implements IMEMonitor<T>
|
||||
@Override
|
||||
public T extractItems( final T request, final Actionable mode, final IActionSource src )
|
||||
{
|
||||
if( mode == Actionable.SIMULATE )
|
||||
{
|
||||
return this.getHandler().extractItems( request, mode, src );
|
||||
}
|
||||
return this.monitorDifference( request.copy(), this.getHandler().extractItems( request, mode, src ), true, src );
|
||||
return this.getHandler().extractItems( request, mode, src );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.me.helpers;
|
||||
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -55,4 +56,24 @@ public class MachineSource implements IActionSource
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals( Object o )
|
||||
{
|
||||
if( this == o )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if( o == null || getClass() != o.getClass() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
MachineSource that = (MachineSource) o;
|
||||
return via.equals( that.via );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hash( via );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,166 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.me.helpers;
|
||||
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class PatternStatusManager
|
||||
{
|
||||
|
||||
private final Multimap<ICraftingPatternDetails, IAEStack> patternDetailsIAEStackMultimap;
|
||||
private final Multimap<IAEStack, ICraftingPatternDetails> iaeStackPatternDetailsMultimap;
|
||||
|
||||
private List<SavedTransactions> transactions = null;
|
||||
private int transDepth = 0;
|
||||
|
||||
public PatternStatusManager( final Multimap<ICraftingPatternDetails, IAEStack> interests, final Multimap<IAEStack, ICraftingPatternDetails> interested )
|
||||
{
|
||||
this.patternDetailsIAEStackMultimap = interests;
|
||||
this.iaeStackPatternDetailsMultimap = interested;
|
||||
}
|
||||
|
||||
public void enableTransactions()
|
||||
{
|
||||
if( this.transDepth == 0 )
|
||||
{
|
||||
this.transactions = new ArrayList<>();
|
||||
}
|
||||
|
||||
this.transDepth++;
|
||||
}
|
||||
|
||||
public void disableTransactions()
|
||||
{
|
||||
this.transDepth--;
|
||||
|
||||
if( this.transDepth == 0 )
|
||||
{
|
||||
final List<SavedTransactions> myActions = this.transactions;
|
||||
this.transactions = null;
|
||||
|
||||
for( final SavedTransactions t : myActions )
|
||||
{
|
||||
if( t.put )
|
||||
{
|
||||
this.put( t.patternDetails, t.stack );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.remove( t.patternDetails, t.stack );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean put( final ICraftingPatternDetails craftingPatternDetails, final IAEStack debtStack )
|
||||
{
|
||||
if( this.transactions != null )
|
||||
{
|
||||
this.transactions.add( new SavedTransactions( true, craftingPatternDetails, debtStack ) );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.iaeStackPatternDetailsMultimap.put( debtStack, craftingPatternDetails );
|
||||
return this.patternDetailsIAEStackMultimap.put( craftingPatternDetails, debtStack );
|
||||
}
|
||||
}
|
||||
|
||||
public boolean remove( final ICraftingPatternDetails craftingPatternDetails, final IAEStack debtStack )
|
||||
{
|
||||
if( this.transactions != null )
|
||||
{
|
||||
this.transactions.add( new SavedTransactions( false, craftingPatternDetails, debtStack ) );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.iaeStackPatternDetailsMultimap.remove( debtStack, craftingPatternDetails );
|
||||
return this.patternDetailsIAEStackMultimap.remove( craftingPatternDetails, debtStack );
|
||||
}
|
||||
}
|
||||
|
||||
public boolean containsIncompletablePattern( final ICraftingPatternDetails craftingPatternDetails )
|
||||
{
|
||||
return this.patternDetailsIAEStackMultimap.containsKey( craftingPatternDetails );
|
||||
}
|
||||
|
||||
public boolean containsMissingIAEStack( final IAEStack stack )
|
||||
{
|
||||
if( ( (IAEItemStack) stack ).getItem().isDamageable() )
|
||||
{
|
||||
for( IAEStack i : iaeStackPatternDetailsMultimap.keySet() )
|
||||
{
|
||||
if( i.fuzzyComparison( stack, FuzzyMode.IGNORE_ALL ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return this.iaeStackPatternDetailsMultimap.containsKey( stack );
|
||||
}
|
||||
|
||||
public Collection<IAEStack> getMissingIAEStack( final ICraftingPatternDetails patternDetails )
|
||||
{
|
||||
return this.patternDetailsIAEStackMultimap.get( patternDetails );
|
||||
}
|
||||
|
||||
public Collection<ICraftingPatternDetails> getIncompletablePattern( final IAEStack stack )
|
||||
{
|
||||
Collection<ICraftingPatternDetails> a = new ArrayList<>();
|
||||
if( ( (IAEItemStack) stack ).getItem().isDamageable() )
|
||||
{
|
||||
for( IAEStack i : iaeStackPatternDetailsMultimap.keySet() )
|
||||
{
|
||||
if( i.fuzzyComparison( stack, FuzzyMode.IGNORE_ALL ) )
|
||||
{
|
||||
a.addAll( this.iaeStackPatternDetailsMultimap.get( i ) );
|
||||
}
|
||||
}
|
||||
return a;
|
||||
}
|
||||
return this.iaeStackPatternDetailsMultimap.get( stack );
|
||||
}
|
||||
|
||||
private class SavedTransactions
|
||||
{
|
||||
|
||||
private final boolean put;
|
||||
private final ICraftingPatternDetails patternDetails;
|
||||
private final IAEStack stack;
|
||||
|
||||
public SavedTransactions( final boolean putOperation, final ICraftingPatternDetails myPatternDetails, final IAEStack stack )
|
||||
{
|
||||
this.put = putOperation;
|
||||
this.patternDetails = myPatternDetails;
|
||||
this.stack = stack;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,19 +19,20 @@
|
||||
package appeng.me.storage;
|
||||
|
||||
|
||||
import appeng.core.features.registries.cell.CreativeCellHandler;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.helpers.MachineSource;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.storage.ICellHandler;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
|
||||
public class DriveWatcher<T extends IAEStack<T>> extends MEInventoryHandler<T>
|
||||
{
|
||||
@@ -39,16 +40,16 @@ public class DriveWatcher<T extends IAEStack<T>> extends MEInventoryHandler<T>
|
||||
private int oldStatus = 0;
|
||||
private final ItemStack is;
|
||||
private final ICellHandler handler;
|
||||
private final IChestOrDrive cord;
|
||||
private final TileDrive drive;
|
||||
private IActionSource source;
|
||||
|
||||
public DriveWatcher( final ICellInventoryHandler<T> i, final ItemStack is, final ICellHandler han, final IChestOrDrive cod )
|
||||
public DriveWatcher( final ICellInventoryHandler<T> i, final ItemStack is, final ICellHandler han, final TileDrive drive )
|
||||
{
|
||||
super( i, i.getChannel() );
|
||||
this.is = is;
|
||||
this.handler = han;
|
||||
this.cord = cod;
|
||||
this.source = new MachineSource( cod );
|
||||
this.drive = drive;
|
||||
this.source = new MachineSource( drive );
|
||||
}
|
||||
|
||||
public int getStatus()
|
||||
@@ -61,55 +62,58 @@ public class DriveWatcher<T extends IAEStack<T>> extends MEInventoryHandler<T>
|
||||
{
|
||||
final long size = input.getStackSize();
|
||||
|
||||
final T a = super.injectItems( input, type, src );
|
||||
final T remainder = super.injectItems( input, type, src );
|
||||
|
||||
if( type == Actionable.MODULATE && ( a == null || a.getStackSize() != size ) )
|
||||
if( type == Actionable.MODULATE && ( remainder == null || remainder.getStackSize() != size ) )
|
||||
{
|
||||
final int newStatus = this.getStatus();
|
||||
|
||||
if( newStatus != this.oldStatus )
|
||||
{
|
||||
this.cord.blinkCell( this.getSlot() );
|
||||
this.drive.blinkCell( this.getSlot() );
|
||||
this.oldStatus = newStatus;
|
||||
}
|
||||
try
|
||||
if (this.drive.getProxy().isActive() && !(handler instanceof CreativeCellHandler))
|
||||
{
|
||||
( (TileDrive) this.cord ).getProxy().getStorage().postAlterationOfStoredItems( this.getChannel(), ImmutableList.of( input.copy().setStackSize( input.getStackSize() - ( a == null ? 0 : a.getStackSize() ) ) ), this.source );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
try
|
||||
{
|
||||
this.drive.getProxy().getStorage().postAlterationOfStoredItems( this.getChannel(), Collections.singletonList( input.copy().setStackSize( input.getStackSize() - ( remainder == null ? 0 : remainder.getStackSize() ) ) ), this.source );
|
||||
} catch ( GridAccessException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return a;
|
||||
return remainder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T extractItems( final T request, final Actionable type, final IActionSource src )
|
||||
{
|
||||
final T a = super.extractItems( request, type, src );
|
||||
final T extractable = super.extractItems( request, type, src );
|
||||
|
||||
if( type == Actionable.MODULATE && a != null )
|
||||
if( type == Actionable.MODULATE && extractable != null )
|
||||
{
|
||||
final int newStatus = this.getStatus();
|
||||
|
||||
if( newStatus != this.oldStatus )
|
||||
{
|
||||
this.cord.blinkCell( this.getSlot() );
|
||||
this.drive.blinkCell( this.getSlot() );
|
||||
this.oldStatus = newStatus;
|
||||
}
|
||||
|
||||
try
|
||||
if (this.drive.getProxy().isActive() && !(handler instanceof CreativeCellHandler ))
|
||||
{
|
||||
( (TileDrive) this.cord ).getProxy().getStorage().postAlterationOfStoredItems( this.getChannel(), ImmutableList.of( request.copy().setStackSize( -a.getStackSize() ) ), this.source );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
try
|
||||
{
|
||||
this.drive.getProxy().getStorage().postAlterationOfStoredItems( this.getChannel(), Collections.singletonList( request.copy().setStackSize( -extractable.getStackSize() ) ), this.source );
|
||||
} catch ( GridAccessException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return a;
|
||||
return extractable;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,14 +19,11 @@
|
||||
package appeng.me.storage;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
||||
@@ -48,16 +45,14 @@ import appeng.api.storage.data.IItemList;
|
||||
public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack>, ITickingMonitor
|
||||
{
|
||||
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 NavigableMap<Integer, CachedFluidStack> memory;
|
||||
private IActionSource mySource;
|
||||
private StorageFilter mode = StorageFilter.EXTRACTABLE_ONLY;
|
||||
|
||||
public MEMonitorIFluidHandler( final IFluidHandler handler )
|
||||
{
|
||||
this.handler = handler;
|
||||
this.memory = new ConcurrentSkipListMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,11 +77,6 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack>, ITicki
|
||||
return input.copy();
|
||||
}
|
||||
|
||||
if( type == Actionable.MODULATE )
|
||||
{
|
||||
this.onTick();
|
||||
}
|
||||
|
||||
if( filled == input.getStackSize() )
|
||||
{
|
||||
return null;
|
||||
@@ -94,6 +84,15 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack>, ITicki
|
||||
|
||||
final IAEFluidStack o = input.copy();
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -107,13 +106,18 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack>, ITicki
|
||||
return null;
|
||||
}
|
||||
|
||||
if( type == Actionable.MODULATE )
|
||||
{
|
||||
this.onTick();
|
||||
}
|
||||
|
||||
final IAEFluidStack o = request.copy();
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -126,111 +130,51 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack>, ITicki
|
||||
@Override
|
||||
public TickRateModulation onTick()
|
||||
{
|
||||
final List<IAEFluidStack> changes = new ArrayList<>();
|
||||
|
||||
this.list.resetStatus();
|
||||
int high = 0;
|
||||
boolean changed = false;
|
||||
|
||||
final IFluidTankProperties[] props = this.handler.getTankProperties();
|
||||
for( int slot = 0; slot < this.handler.getTankProperties().length; ++slot )
|
||||
final List<IAEFluidStack> changes = new ArrayList<>();
|
||||
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 );
|
||||
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 ) )
|
||||
if( this.mode == StorageFilter.EXTRACTABLE_ONLY && this.handler.drain( 1, false ) == null )
|
||||
{
|
||||
final CachedFluidStack cis = new CachedFluidStack( newIS );
|
||||
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;
|
||||
continue;
|
||||
}
|
||||
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;
|
||||
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;
|
||||
}
|
||||
changes.add( is );
|
||||
}
|
||||
}
|
||||
|
||||
// detect dropped items; should fix non IISided Inventory Changes.
|
||||
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();
|
||||
}
|
||||
cache = currentlyOnStorage;
|
||||
|
||||
if( !changes.isEmpty() )
|
||||
{
|
||||
this.postDifference( changes );
|
||||
changed = true;
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
if( a != null )
|
||||
@@ -291,9 +235,9 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack>, ITicki
|
||||
@Override
|
||||
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;
|
||||
@@ -302,7 +246,7 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack>, ITicki
|
||||
@Override
|
||||
public IItemList<IAEFluidStack> getStorageList()
|
||||
{
|
||||
return this.list;
|
||||
return this.cache;
|
||||
}
|
||||
|
||||
private StorageFilter getMode()
|
||||
@@ -326,24 +270,4 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack>, ITicki
|
||||
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;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -50,16 +46,15 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
|
||||
{
|
||||
|
||||
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 NavigableMap<Integer, CachedItemStack> memory;
|
||||
private IActionSource mySource;
|
||||
private StorageFilter mode = StorageFilter.EXTRACTABLE_ONLY;
|
||||
|
||||
public MEMonitorIInventory( final InventoryAdaptor adaptor )
|
||||
{
|
||||
this.adaptor = adaptor;
|
||||
this.memory = new ConcurrentSkipListMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,11 +83,6 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
|
||||
out = this.adaptor.addItems( input.createItemStack() );
|
||||
}
|
||||
|
||||
if( type == Actionable.MODULATE )
|
||||
{
|
||||
this.onTick();
|
||||
}
|
||||
|
||||
if( out.isEmpty() )
|
||||
{
|
||||
return null;
|
||||
@@ -101,6 +91,15 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
|
||||
// better then doing construction from scratch :3
|
||||
final IAEItemStack o = input.copy();
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -129,6 +128,12 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -144,110 +149,52 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
|
||||
@Override
|
||||
public TickRateModulation onTick()
|
||||
{
|
||||
boolean changed = false;
|
||||
|
||||
final List<IAEItemStack> changes = new ArrayList<>();
|
||||
|
||||
this.list.resetStatus();
|
||||
int high = 0;
|
||||
boolean changed = false;
|
||||
for( final ItemSlot is : this.adaptor )
|
||||
IItemList<IAEItemStack> currentlyOnStorage = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
|
||||
for( final ItemSlot is : adaptor )
|
||||
{
|
||||
final CachedItemStack old = this.memory.get( is.getSlot() );
|
||||
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 ) )
|
||||
if( this.mode == StorageFilter.EXTRACTABLE_ONLY && !is.isExtractable() )
|
||||
{
|
||||
final CachedItemStack cis = new CachedItemStack( is.getItemStack() );
|
||||
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;
|
||||
continue;
|
||||
}
|
||||
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() );
|
||||
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;
|
||||
}
|
||||
changes.add( is );
|
||||
}
|
||||
}
|
||||
|
||||
// detect dropped items; should fix non IISided Inventory Changes.
|
||||
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();
|
||||
}
|
||||
cache = currentlyOnStorage;
|
||||
|
||||
if( !changes.isEmpty() )
|
||||
{
|
||||
this.postDifference( changes );
|
||||
changed = true;
|
||||
}
|
||||
|
||||
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 )
|
||||
{
|
||||
// AELog.info( a.getItemStack().getUnlocalizedName() + " @ " + a.getStackSize() );
|
||||
if( a != null )
|
||||
{
|
||||
final Iterator<Entry<IMEMonitorHandlerReceiver<IAEItemStack>, Object>> i = this.listeners.entrySet().iterator();
|
||||
@@ -306,9 +253,9 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
|
||||
@Override
|
||||
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;
|
||||
@@ -317,7 +264,7 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getStorageList()
|
||||
{
|
||||
return this.list;
|
||||
return this.cache;
|
||||
}
|
||||
|
||||
private StorageFilter getMode()
|
||||
@@ -341,24 +288,4 @@ public class MEMonitorIInventory implements IMEMonitor<IAEItemStack>, ITickingMo
|
||||
this.mySource = mySource;
|
||||
}
|
||||
|
||||
private static class CachedItemStack
|
||||
{
|
||||
|
||||
private final ItemStack itemStack;
|
||||
private final IAEItemStack aeStack;
|
||||
|
||||
public CachedItemStack( final ItemStack is )
|
||||
{
|
||||
if( is.isEmpty() )
|
||||
{
|
||||
this.itemStack = ItemStack.EMPTY;
|
||||
this.aeStack = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.itemStack = is.copy();
|
||||
this.aeStack = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( is );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,4 +171,5 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
|
||||
{
|
||||
this.changeSource = changeSource;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
package appeng.me.storage;
|
||||
|
||||
|
||||
import appeng.me.helpers.MEMonitorHandler;
|
||||
import appeng.me.helpers.MachineSource;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
@@ -35,16 +37,20 @@ import appeng.api.storage.data.IItemList;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.misc.TileSecurityStation;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
|
||||
public class SecurityStationInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
{
|
||||
|
||||
private final IItemList<IAEItemStack> storedItems = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
private final TileSecurityStation securityTile;
|
||||
private final MachineSource src;
|
||||
|
||||
public SecurityStationInventory( final TileSecurityStation ts )
|
||||
{
|
||||
this.securityTile = ts;
|
||||
this.src = new MachineSource( securityTile );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -61,6 +67,11 @@ public class SecurityStationInventory implements IMEInventoryHandler<IAEItemStac
|
||||
return null;
|
||||
}
|
||||
|
||||
if( securityTile.getProxy().isActive() )
|
||||
{
|
||||
( ( MEMonitorHandler<IAEItemStack> ) securityTile.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) ).postChangesToListeners( Collections.singletonList( input.copy() ), this.src );
|
||||
}
|
||||
|
||||
this.getStoredItems().add( input );
|
||||
this.securityTile.inventoryChanged();
|
||||
return null;
|
||||
@@ -101,6 +112,11 @@ public class SecurityStationInventory implements IMEInventoryHandler<IAEItemStac
|
||||
return output;
|
||||
}
|
||||
|
||||
if( securityTile.getProxy().isActive() )
|
||||
{
|
||||
( ( MEMonitorHandler<IAEItemStack> ) securityTile.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) ).postChangesToListeners( Collections.singletonList( target.copy().setStackSize( -target.getStackSize() ) ), this.src );
|
||||
}
|
||||
|
||||
target.setStackSize( 0 );
|
||||
this.securityTile.inventoryChanged();
|
||||
return output;
|
||||
|
||||
@@ -19,9 +19,6 @@
|
||||
package appeng.parts.automation;
|
||||
|
||||
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.me.cache.CraftingGridCache;
|
||||
import com.google.common.collect.ImmutableCollection;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
@@ -153,14 +150,18 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
|
||||
final IAEItemStack ais = this.getConfig().getAEStackInSlot( slotToExport );
|
||||
|
||||
if( ais == null || this.itemToSend <= 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if( ais == null || this.itemToSend <= 0 ) continue;
|
||||
|
||||
if( this.craftOnly() )
|
||||
{
|
||||
this.didSomething = this.craftingTracker.handleCrafting( slotToExport, this.itemToSend, ais, destination, this.getTile().getWorld(), this.getProxy().getGrid(), cg, this.mySrc ) || this.didSomething;
|
||||
if ( this.craftOnly() ) {
|
||||
if (this.failedCraftTriesSlot[x] <= 0) {
|
||||
|
||||
this.didSomething = this.craftingTracker.handleCrafting(slotToExport, this.itemToSend, ais, destination, this.getTile().getWorld(),
|
||||
this.getProxy().getGrid(), cg, this.mySrc) || this.didSomething;
|
||||
|
||||
if (this.didSomething) this.failedCraftTriesSlot[x] = 0;
|
||||
else this.failedCraftTriesSlot[x] += 2;
|
||||
}
|
||||
this.failedCraftTriesSlot[x] -= 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -187,7 +188,15 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
||||
|
||||
if( this.itemToSend == before && this.isCraftingEnabled() )
|
||||
{
|
||||
this.didSomething = this.craftingTracker.handleCrafting( slotToExport, this.itemToSend, ais, destination, this.getTile().getWorld(), this.getProxy().getGrid(), cg, this.mySrc ) || this.didSomething;
|
||||
if (this.failedCraftTriesSlot[x] <= 0) {
|
||||
|
||||
this.didSomething = this.craftingTracker.handleCrafting(slotToExport, this.itemToSend, ais, destination, this.getTile().getWorld(),
|
||||
this.getProxy().getGrid(), cg, this.mySrc) || this.didSomething;
|
||||
|
||||
if (this.didSomething) this.failedCraftTriesSlot[x] = 0;
|
||||
else this.failedCraftTriesSlot[x] += 2;
|
||||
}
|
||||
this.failedCraftTriesSlot[x] -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -187,8 +187,9 @@ public class PartFormationPlane extends PartAbstractFormationPlane<IAEItemStack>
|
||||
this.stateChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void updateChannels( final MENetworkChannelsChanged changedChannels )
|
||||
public void chanRender( final MENetworkChannelsChanged changedChannels )
|
||||
{
|
||||
this.stateChanged();
|
||||
}
|
||||
|
||||
@@ -184,8 +184,9 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
||||
return flipState ? this.reportingValue >= this.lastReportedValue + 1 : this.reportingValue < this.lastReportedValue + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void powerStatusChange( final MENetworkPowerStatusChange powerEvent )
|
||||
public void powerRender( final MENetworkPowerStatusChange powerEvent )
|
||||
{
|
||||
if (this.getProxy().isActive())
|
||||
{
|
||||
@@ -194,8 +195,9 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void channelChanged( final MENetworkChannelsChanged c )
|
||||
public void chanRender( final MENetworkChannelsChanged c )
|
||||
{
|
||||
if (this.getProxy().isActive())
|
||||
{
|
||||
@@ -288,37 +290,24 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
if( myStack == null )
|
||||
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 || myStack == null )
|
||||
{
|
||||
this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ).addListener( this, this.getProxy().getGrid() );
|
||||
this.getProxy()
|
||||
.getStorage()
|
||||
.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
|
||||
.addListener( this,
|
||||
this.getProxy().getGrid() );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ).removeListener( this );
|
||||
|
||||
if( this.myWatcher != null )
|
||||
{
|
||||
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||
{
|
||||
Optional<OreReference> ores = OreHelper.INSTANCE.getOre( myStack.getDefinition() );
|
||||
if( ores.isPresent() )
|
||||
{
|
||||
for( IAEItemStack iaeItemStack : ores.get().getAEEquivalents() )
|
||||
{
|
||||
this.myWatcher.add( iaeItemStack );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.myWatcher.add( myStack );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.myWatcher.add( myStack );
|
||||
}
|
||||
this.myWatcher.add( myStack );
|
||||
}
|
||||
}
|
||||
|
||||
this.updateReportingValue( this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
@@ -507,6 +496,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
||||
public void upgradesChanged()
|
||||
{
|
||||
this.configureWatchers();
|
||||
this.updateState();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -320,13 +320,13 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
||||
|
||||
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( !newIS.isEmpty() )
|
||||
if( this.mode == StorageFilter.EXTRACTABLE_ONLY && !is.isExtractable() )
|
||||
{
|
||||
currentlyOnStorage.add( is.getAEItemStack() );
|
||||
continue;
|
||||
}
|
||||
currentlyOnStorage.add( is.getAEItemStack() );
|
||||
}
|
||||
|
||||
for ( final IAEItemStack is : currentlyCached )
|
||||
|
||||
@@ -95,14 +95,16 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
|
||||
super( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void stateChange( final MENetworkChannelsChanged c )
|
||||
public void chanRender( final MENetworkChannelsChanged c )
|
||||
{
|
||||
this.duality.notifyNeighbors();
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void stateChange( final MENetworkPowerStatusChange c )
|
||||
public void powerRender( final MENetworkPowerStatusChange c )
|
||||
{
|
||||
this.duality.notifyNeighbors();
|
||||
}
|
||||
|
||||
@@ -23,8 +23,13 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
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.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
@@ -57,6 +62,7 @@ public abstract class PartSharedStorageBus extends PartUpgradeable implements IG
|
||||
private boolean wasActive = false;
|
||||
private int priority = 0;
|
||||
protected boolean accessChanged;
|
||||
protected boolean readOncePass;
|
||||
|
||||
public PartSharedStorageBus( ItemStack is )
|
||||
{
|
||||
@@ -81,8 +87,9 @@ public abstract class PartSharedStorageBus extends PartUpgradeable implements IG
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void updateChannels( final MENetworkChannelsChanged changedChannels )
|
||||
public void chanRender( final MENetworkChannelsChanged changedChannels )
|
||||
{
|
||||
this.updateStatus();
|
||||
}
|
||||
@@ -148,7 +155,7 @@ public abstract class PartSharedStorageBus extends PartUpgradeable implements IG
|
||||
@Override
|
||||
public void updateSetting( final IConfigManager manager, final Enum settingName, final Enum newValue )
|
||||
{
|
||||
if( settingName instanceof AccessRestriction )
|
||||
if( settingName.name().equals( "ACCESS" ) )
|
||||
{
|
||||
this.accessChanged = true;
|
||||
}
|
||||
@@ -161,7 +168,27 @@ public abstract class PartSharedStorageBus extends PartUpgradeable implements IG
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
else if( te == null || te instanceof TileFluidInterface )
|
||||
{
|
||||
this.resetCache( true );
|
||||
this.resetCache();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.resetCache( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,6 +197,7 @@ public abstract class PartSharedStorageBus extends PartUpgradeable implements IG
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.priority = data.getInteger( "priority" );
|
||||
this.accessChanged = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,8 +23,10 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import appeng.fluids.parts.FluidHandlerAdapter;
|
||||
import appeng.me.storage.MEPassThrough;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.me.cache.GridStorageCache;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.util.ConfigManager;
|
||||
import com.jaquadro.minecraft.storagedrawers.api.capabilities.IItemRepository;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -89,7 +91,6 @@ import appeng.me.GridAccessException;
|
||||
import appeng.me.helpers.MachineSource;
|
||||
import appeng.me.storage.ITickingMonitor;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.me.storage.MEMonitorIInventory;
|
||||
import appeng.parts.PartModel;
|
||||
import appeng.parts.automation.PartUpgradeable;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
@@ -125,6 +126,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
private boolean wasActive = false;
|
||||
private byte resetCacheLogic = 0;
|
||||
private boolean accessChanged;
|
||||
private boolean readOncePass;
|
||||
|
||||
@Reflected
|
||||
public PartStorageBus( final ItemStack is )
|
||||
@@ -161,8 +163,9 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@MENetworkEventSubscribe
|
||||
public void updateChannels( final MENetworkChannelsChanged changedChannels )
|
||||
public void chanRender( final MENetworkChannelsChanged changedChannels )
|
||||
{
|
||||
this.updateStatus();
|
||||
}
|
||||
@@ -176,7 +179,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
@Override
|
||||
public void updateSetting( final IConfigManager manager, final Enum settingName, final Enum newValue )
|
||||
{
|
||||
if( settingName instanceof AccessRestriction )
|
||||
if( settingName.name().equals( "ACCESS" ) )
|
||||
{
|
||||
this.accessChanged = true;
|
||||
}
|
||||
@@ -208,6 +211,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
super.readFromNBT( data );
|
||||
this.Config.readFromNBT( data, "config" );
|
||||
this.priority = data.getInteger( "priority" );
|
||||
this.accessChanged = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -242,7 +246,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
{
|
||||
this.resetCacheLogic = 2;
|
||||
}
|
||||
else
|
||||
else if( this.resetCacheLogic < 2 )
|
||||
{
|
||||
this.resetCacheLogic = 1;
|
||||
}
|
||||
@@ -266,24 +270,34 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
@Override
|
||||
public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final IActionSource source )
|
||||
{
|
||||
if( this.mySrc.machine().map( machine -> machine == this ).orElse( false ) && monitor != null )
|
||||
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( IItemStorageChannel.class ), change, source );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :(
|
||||
}
|
||||
return;
|
||||
}
|
||||
if( !currentAccess.hasPermission( AccessRestriction.READ ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
if( this.getProxy().isActive() )
|
||||
try
|
||||
{
|
||||
this.getProxy().getStorage().postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ), change, this.mySrc );
|
||||
this.getProxy().getStorage().postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ), change, source );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :(
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :(
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,10 +320,19 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
{
|
||||
if( pos.offset( this.getSide().getFacing() ).equals( neighbor ) )
|
||||
{
|
||||
|
||||
final TileEntity te = w.getTileEntity( neighbor );
|
||||
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
else if( te == null || te instanceof TileInterface )
|
||||
{
|
||||
this.resetCache( true );
|
||||
this.resetCache();
|
||||
@@ -365,8 +388,8 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
this.resetCacheLogic = 0;
|
||||
|
||||
final MEInventoryHandler<IAEItemStack> in = this.getInternalHandler();
|
||||
|
||||
IItemList<IAEItemStack> before = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
boolean denyRead = false;
|
||||
if( in != null )
|
||||
{
|
||||
if( accessChanged )
|
||||
@@ -375,7 +398,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
AccessRestriction oldAccess = (AccessRestriction) ( (ConfigManager) this.getConfigManager() ).getOldSetting( Settings.ACCESS );
|
||||
if( oldAccess.hasPermission( AccessRestriction.READ ) && !currentAccess.hasPermission( AccessRestriction.READ ) )
|
||||
{
|
||||
denyRead = true;
|
||||
readOncePass = true;
|
||||
}
|
||||
in.setBaseAccess( oldAccess );
|
||||
before = in.getAvailableItems( before );
|
||||
@@ -396,17 +419,15 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
|
||||
final MEInventoryHandler<IAEItemStack> out = this.getInternalHandler();
|
||||
|
||||
if( in != out || denyRead )
|
||||
{
|
||||
IItemList<IAEItemStack> after = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
IItemList<IAEItemStack> after = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||
|
||||
if( out != null && !denyRead )
|
||||
if( in != out )
|
||||
{
|
||||
if( out != null )
|
||||
{
|
||||
after = out.getAvailableItems( after );
|
||||
}
|
||||
|
||||
Platform.postListChanges( before, after, this, this.mySrc );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -498,21 +519,19 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
|
||||
this.handlerHash = newHandlerHash;
|
||||
this.handler = null;
|
||||
if( this.monitor != null )
|
||||
{
|
||||
( (IBaseMonitor<IAEItemStack>) monitor ).removeListener( this );
|
||||
}
|
||||
this.monitor = null;
|
||||
if( target != null )
|
||||
{
|
||||
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 )
|
||||
{
|
||||
this.monitor = (ITickingMonitor) inv;
|
||||
this.monitor.setActionSource( new MachineSource( this ) );
|
||||
this.monitor.setActionSource( mySrc );
|
||||
this.monitor.setMode( (StorageFilter) this.getConfigManager().getSetting( Settings.STORAGE_FILTER ) );
|
||||
}
|
||||
|
||||
@@ -551,7 +570,10 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
|
||||
if( inv instanceof IBaseMonitor )
|
||||
{
|
||||
( (IBaseMonitor<IAEItemStack>) inv ).addListener( this, this.handler );
|
||||
if( ( (AccessRestriction) ( (ConfigManager) this.getConfigManager() ).getSetting( Settings.ACCESS ) ).hasPermission( AccessRestriction.READ ) )
|
||||
{
|
||||
( (IBaseMonitor<IAEItemStack>) inv ).addListener( this, this.handler );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -580,7 +602,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
try
|
||||
{
|
||||
// force grid to update handlers...
|
||||
this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
(( GridStorageCache ) this.getProxy().getGrid().getCache( IStorageGrid.class )).cellUpdate( null );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
|
||||
@@ -83,10 +83,19 @@ public class PartP2PFluids extends PartP2PTunnel<PartP2PFluids> implements IFlui
|
||||
|
||||
if( this.isOutput() )
|
||||
{
|
||||
final PartP2PFluids in = this.getInput();
|
||||
if( in != null )
|
||||
try
|
||||
{
|
||||
in.onTunnelNetworkChange();
|
||||
for( PartP2PFluids in : this.getInputs() )
|
||||
{
|
||||
if( in != null )
|
||||
{
|
||||
in.onTunnelNetworkChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,13 +133,21 @@ public class PartP2PFluids extends PartP2PTunnel<PartP2PFluids> implements IFlui
|
||||
{
|
||||
if( !this.isOutput() )
|
||||
{
|
||||
final PartP2PFluids tun = this.getInput();
|
||||
if( tun != null )
|
||||
try
|
||||
{
|
||||
return ACTIVE_TANK;
|
||||
for( PartP2PFluids tun : this.getInputs() )
|
||||
{
|
||||
if( tun != null )
|
||||
{
|
||||
return ACTIVE_TANK;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return INACTIVE_TANK;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,10 +74,19 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IItemHa
|
||||
public void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor )
|
||||
{
|
||||
this.cachedInv = null;
|
||||
final PartP2PItems input = this.getInput();
|
||||
if( input != null && this.isOutput() )
|
||||
try
|
||||
{
|
||||
input.onTunnelNetworkChange();
|
||||
for( PartP2PItems input : this.getInputs() )
|
||||
{
|
||||
if( input != null && this.isOutput() )
|
||||
{
|
||||
input.onTunnelNetworkChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,10 +231,19 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IItemHa
|
||||
}
|
||||
else
|
||||
{
|
||||
final PartP2PItems input = this.getInput();
|
||||
if( input != null )
|
||||
try
|
||||
{
|
||||
input.getHost().notifyNeighbors();
|
||||
for( PartP2PItems input : this.getInputs() )
|
||||
{
|
||||
if( input != null )
|
||||
{
|
||||
input.getHost().notifyNeighbors();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,14 +196,23 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
|
||||
{
|
||||
if( this.isOutput() )
|
||||
{
|
||||
final PartP2PLight src = this.getInput();
|
||||
if( src != null && src.getProxy().isActive() )
|
||||
try
|
||||
{
|
||||
this.setLightLevel( src.lastValue );
|
||||
for( PartP2PLight src : this.getInputs() )
|
||||
{
|
||||
if( src != null && src.getProxy().isActive() )
|
||||
{
|
||||
this.setLightLevel( src.lastValue );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
this.getHost().markForUpdate();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -70,10 +70,19 @@ public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
|
||||
{
|
||||
if( this.isOutput() )
|
||||
{
|
||||
final PartP2PRedstone in = this.getInput();
|
||||
if( in != null )
|
||||
try
|
||||
{
|
||||
this.putInput( in.power );
|
||||
for( PartP2PRedstone in : this.getInputs() )
|
||||
{
|
||||
if( in != null )
|
||||
{
|
||||
this.putInput( in.power );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ import appeng.me.cache.P2PCache;
|
||||
import appeng.me.cache.helpers.TunnelCollection;
|
||||
import appeng.parts.PartBasicState;
|
||||
import appeng.util.Platform;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
|
||||
public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicState
|
||||
@@ -77,26 +78,13 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
return null;
|
||||
}
|
||||
|
||||
public T getInput()
|
||||
public TunnelCollection<T> getInputs() throws GridAccessException
|
||||
{
|
||||
if( this.getFrequency() == 0 )
|
||||
if( this.getProxy().isActive() && this.getFrequency() != 0 )
|
||||
{
|
||||
return null;
|
||||
return (TunnelCollection<T>) this.getProxy().getP2P().getInputs( this.getFrequency(), this.getClass() );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final PartP2PTunnel tunnel = this.getProxy().getP2P().getInput( this.getFrequency() );
|
||||
if( this.getClass().isInstance( tunnel ) )
|
||||
{
|
||||
return (T) tunnel;
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
return null;
|
||||
return new TunnelCollection( new ArrayList(), this.getClass() );
|
||||
}
|
||||
|
||||
public TunnelCollection<T> getOutputs() throws GridAccessException
|
||||
@@ -211,14 +199,28 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
final IPart testPart = ( (IPartItem) newType.getItem() ).createPartFromItemStack( newType );
|
||||
if( testPart instanceof PartP2PTunnel )
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
this.getProxy().getP2P().removeTunnel( this, this.getFrequency() );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
this.getHost().removePart( this.getSide(), true );
|
||||
|
||||
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( true );
|
||||
if( !Keyboard.isKeyDown( Keyboard.KEY_LCONTROL ) && !Keyboard.isKeyDown( Keyboard.KEY_RCONTROL ) )
|
||||
{
|
||||
newTunnel.setOutput( true );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
@@ -295,7 +297,17 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
final boolean oldOutput = this.isOutput();
|
||||
final short myFreq = this.getFrequency();
|
||||
|
||||
try
|
||||
{
|
||||
this.getProxy().getP2P().removeTunnel( this, this.getFrequency() );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
this.getHost().removePart( this.getSide(), false );
|
||||
|
||||
final AEPartLocation dir = this.getHost().addPart( newType, this.getSide(), player, hand );
|
||||
final IPart newBus = this.getHost().getPart( dir );
|
||||
|
||||
@@ -303,7 +315,6 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
{
|
||||
final PartP2PTunnel newTunnel = (PartP2PTunnel) newBus;
|
||||
newTunnel.setOutput( oldOutput );
|
||||
newTunnel.onTunnelNetworkChange();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -314,9 +325,10 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
{
|
||||
// :P
|
||||
}
|
||||
newTunnel.onTunnelNetworkChange();
|
||||
|
||||
}
|
||||
|
||||
Platform.notifyBlocksOfNeighbors( this.getTile().getWorld(), this.getTile().getPos() );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -350,9 +362,38 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
if( needsNewFrequency )
|
||||
{
|
||||
newFreq = this.getProxy().getP2P().newFrequency();
|
||||
}
|
||||
|
||||
this.getProxy().getP2P().updateFreq( this, newFreq );
|
||||
final ItemStack newType = this.getHost().getPart( this.getSide() ).getItemStack( PartItemStack.WRENCH );
|
||||
|
||||
try
|
||||
{
|
||||
this.getProxy().getP2P().removeTunnel( this, this.getFrequency() );
|
||||
}
|
||||
catch( GridAccessException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
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.getProxy().getP2P().updateFreq( newTunnel, newFreq );
|
||||
|
||||
newTunnel.onTunnelNetworkChange();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.getProxy().getP2P().updateFreq( this, newFreq );
|
||||
this.onTunnelNetworkChange();
|
||||
}
|
||||
Platform.notifyBlocksOfNeighbors( this.getTile().getWorld(), this.getTile().getPos() );
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
@@ -365,10 +406,17 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
final String type = p2pItem.getUnlocalizedName();
|
||||
|
||||
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 int[] colorCode = new int[] {
|
||||
final int[] colorCode = new int[]{
|
||||
colors[0].ordinal(), colors[0].ordinal(), colors[1].ordinal(), colors[1].ordinal(),
|
||||
colors[2].ordinal(), colors[2].ordinal(), colors[3].ordinal(), colors[3].ordinal(),
|
||||
};
|
||||
@@ -395,7 +443,6 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
|
||||
public void onTunnelNetworkChange()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected void queueTunnelDrain( final PowerUnits unit, final double f )
|
||||
|
||||
@@ -82,6 +82,7 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
|
||||
|
||||
private IAEItemStack configuredItem;
|
||||
private IAEFluidStack configuredFluid;
|
||||
private long configuredAmount;
|
||||
private String lastHumanReadableText;
|
||||
private boolean isLocked;
|
||||
private IStackWatcher myWatcher;
|
||||
@@ -208,14 +209,21 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
|
||||
fluidInTank = fluidHandlerItem.drain( Integer.MAX_VALUE, false );
|
||||
}
|
||||
|
||||
if (fluidInTank == null)
|
||||
if( fluidInTank == 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 )
|
||||
{
|
||||
this.configuredFluid = AEFluidStack.fromFluidStack( fluidInTank );
|
||||
this.configuredFluid = AEFluidStack.fromFluidStack( fluidInTank ).setStackSize( 0 );
|
||||
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 )
|
||||
{
|
||||
|
||||
if( this.configuredItem != null)
|
||||
{
|
||||
final IAEItemStack result = (IAEItemStack) monitor.getStorageList().findPrecise( (T) this.configuredItem );
|
||||
if( result == null )
|
||||
{
|
||||
this.configuredItem.setStackSize( 0 );
|
||||
this.configuredAmount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.configuredItem.setStackSize( result.getStackSize() );
|
||||
this.configuredAmount = result.getStackSize();
|
||||
}
|
||||
this.configuredItem.setStackSize( this.configuredAmount );
|
||||
}
|
||||
else if( this.configuredFluid != null)
|
||||
{
|
||||
final IAEFluidStack result = (IAEFluidStack) monitor.getStorageList().findPrecise( (T) this.configuredFluid );
|
||||
if( result == null )
|
||||
{
|
||||
this.configuredFluid.setStackSize( 0 );
|
||||
this.configuredAmount = 0;
|
||||
}
|
||||
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
|
||||
public void powerStatusChange( final MENetworkPowerStatusChange ev )
|
||||
{
|
||||
if( !this.getProxy().isPowered() )
|
||||
if( this.getProxy().isPowered() )
|
||||
{
|
||||
if( this.myWatcher != null )
|
||||
{
|
||||
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
|
||||
}
|
||||
this.configureWatchers();
|
||||
}
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void channelChanged( final MENetworkChannelsChanged c )
|
||||
{
|
||||
if( !this.getProxy().isPowered() )
|
||||
if( this.getProxy().isPowered() )
|
||||
{
|
||||
if( this.myWatcher != null )
|
||||
{
|
||||
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
|
||||
}
|
||||
this.configureWatchers();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStackChange( IItemList<?> o, IAEStack<?> fullStack, IAEStack<?> diffStack, IActionSource src, IStorageChannel<?> chan )
|
||||
{
|
||||
this.configuredAmount = fullStack.getStackSize();
|
||||
|
||||
if( this.configuredItem != null )
|
||||
{
|
||||
long diff = this.configuredItem.getStackSize() + diffStack.getStackSize();
|
||||
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();
|
||||
}
|
||||
this.configuredItem.setStackSize( this.configuredAmount );
|
||||
}
|
||||
else if( this.configuredFluid != null )
|
||||
{
|
||||
long diff = this.configuredFluid.getStackSize() + diffStack.getStackSize();
|
||||
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.configuredFluid.setStackSize( this.configuredAmount );
|
||||
}
|
||||
this.getHost().markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -137,14 +137,10 @@ public class PartConversionMonitor extends AbstractPartMonitor
|
||||
{
|
||||
this.insertItem( player, hand, false );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//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( getDisplayed() instanceof IAEItemStack || getDisplayed() == null )
|
||||
@@ -155,23 +151,16 @@ public class PartConversionMonitor extends AbstractPartMonitor
|
||||
{
|
||||
this.drainFluidContainer( player, hand );
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
return super.onPartActivate( player, hand, pos );
|
||||
}
|
||||
}
|
||||
else
|
||||
else if( this.getDisplayed() != null && this.getDisplayed().equals( player.getHeldItem( hand ) ) )
|
||||
{
|
||||
if( getDisplayed() instanceof IAEFluidStack || getDisplayed() == null )
|
||||
{
|
||||
return super.onPartActivate( player, hand, pos );
|
||||
}
|
||||
if( ( (IAEItemStack) this.getDisplayed() ).equals( eq ) )
|
||||
{
|
||||
this.insertItem( player, hand, false );
|
||||
}
|
||||
this.insertItem( player, hand, false );
|
||||
}
|
||||
|
||||
return true;
|
||||
return super.onPartActivate( player, hand, pos );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -192,7 +181,6 @@ public class PartConversionMonitor extends AbstractPartMonitor
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack eq = player.getHeldItem( hand );
|
||||
if( this.getDisplayed() != null && this.getDisplayed() instanceof IAEItemStack )
|
||||
{
|
||||
this.extractItem( player, ( (IAEItemStack) this.getDisplayed() ).getDefinition().getMaxStackSize() );
|
||||
@@ -282,7 +270,7 @@ public class PartConversionMonitor extends AbstractPartMonitor
|
||||
{
|
||||
if (!(this.getDisplayed() instanceof IAEItemStack))
|
||||
return;
|
||||
final IAEItemStack input = (IAEItemStack) this.getDisplayed();
|
||||
final IAEItemStack input = (IAEItemStack) this.getDisplayed().copy();
|
||||
if( input != null )
|
||||
{
|
||||
try
|
||||
|
||||
@@ -123,7 +123,7 @@ public class AppEngInternalInventory extends ItemStackHandler implements Iterabl
|
||||
ItemStack oldStack = this.previousStack;
|
||||
InvOperation op = InvOperation.SET;
|
||||
|
||||
if( newStack.isEmpty() || oldStack.isEmpty() || ItemStack.areItemsEqual( newStack, oldStack ) )
|
||||
if( newStack.isEmpty() || oldStack.isEmpty() || ( oldStack.getCount() < oldStack.getMaxStackSize() && oldStack.getCount() < this.getSlotLimit( slot ) && ItemStack.areItemsEqual( newStack, oldStack ) ) )
|
||||
{
|
||||
if( newStack.getCount() > oldStack.getCount() )
|
||||
{
|
||||
|
||||
@@ -155,7 +155,7 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( this.internalCurrentPower < 0.01 && amt > 0.01 )
|
||||
if( this.internalCurrentPower < 0.01 && amt > 0 )
|
||||
{
|
||||
this.getProxy().getNode().getGrid().postEvent( new MENetworkPowerStorage( this, PowerEventType.PROVIDE_POWER ) );
|
||||
}
|
||||
@@ -217,7 +217,7 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
|
||||
|
||||
final boolean wasFull = this.internalCurrentPower >= this.getInternalMaxPower() - 0.001;
|
||||
|
||||
if( wasFull && amt > 0.001 )
|
||||
if( wasFull && amt > 0 )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -26,6 +26,8 @@ import java.util.List;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.me.storage.BasicCellInventoryHandler;
|
||||
import appeng.me.storage.CreativeCellInventory;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -494,12 +496,14 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
try
|
||||
{
|
||||
this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
final IStorageGrid gs = this.getProxy().getStorage();
|
||||
Platform.postChanges( gs, removed, added, this.mySrc );
|
||||
if( this.getProxy().isActive() )
|
||||
{
|
||||
final IStorageGrid gs = this.getProxy().getStorage();
|
||||
Platform.postChanges( gs, removed, added, this.mySrc );
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException ignored )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// update the neighbors
|
||||
@@ -733,7 +737,15 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
{
|
||||
return input;
|
||||
}
|
||||
return super.injectItems( input, mode, src );
|
||||
T injected = super.injectItems( input, mode, src );
|
||||
if (mode == Actionable.MODULATE && ( injected == null || injected.getStackSize() != input.getStackSize() ))
|
||||
{
|
||||
if( TileChest.this.getProxy().isActive() && this.getInternalHandler().getCellInv() != null )
|
||||
{
|
||||
TileChest.this.cellHandler.postChangesToListeners(Collections.singletonList( input.copy().setStackSize( input.getStackSize() - ( injected == null ? 0 : injected.getStackSize() ) ) ), TileChest.this.mySrc );
|
||||
}
|
||||
}
|
||||
return injected;
|
||||
}
|
||||
|
||||
private boolean securityCheck( final EntityPlayer player, final SecurityPermissions requiredPermission )
|
||||
@@ -777,7 +789,15 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return super.extractItems( request, mode, src );
|
||||
T extracted = super.extractItems( request, mode, src );
|
||||
if( mode == Actionable.MODULATE && extracted != null )
|
||||
{
|
||||
if( TileChest.this.getProxy().isActive() && this.getInternalHandler().getCellInv() != null )
|
||||
{
|
||||
TileChest.this.cellHandler.postChangesToListeners(Collections.singletonList( request.copy().setStackSize( -extracted.getStackSize() ) ), TileChest.this.mySrc );
|
||||
}
|
||||
}
|
||||
return extracted;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -264,9 +264,11 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
try
|
||||
{
|
||||
this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||
|
||||
final IStorageGrid gs = this.getProxy().getStorage();
|
||||
Platform.postChanges( gs, removed, added, this.mySrc );
|
||||
if( this.getProxy().isActive() )
|
||||
{
|
||||
final IStorageGrid gs = this.getProxy().getStorage();
|
||||
Platform.postChanges( gs, removed, added, this.mySrc );
|
||||
}
|
||||
}
|
||||
catch( final GridAccessException ignored )
|
||||
{
|
||||
|
||||
@@ -405,8 +405,10 @@ waila.appliedenergistics2.Showing=Showing
|
||||
waila.appliedenergistics2.Contains=Contains
|
||||
waila.appliedenergistics2.Channels=%1$d of %2$d Channels
|
||||
waila.appliedenergistics2.P2PUnlinked=Unlinked
|
||||
waila.appliedenergistics2.P2PInputOneOutput=Linked (Input Side)
|
||||
waila.appliedenergistics2.P2PInputManyOutputs=Linked (Input Side) - %d Outputs
|
||||
waila.appliedenergistics2.p2p_input_one_output=Linked (Input Side) - 1 Output
|
||||
waila.appliedenergistics2.p2p_input_many_outputs=Linked (Input Side) - %d Outputs
|
||||
waila.appliedenergistics2.p2p_output_one_input=Linked (Output Side) - 1 Input
|
||||
waila.appliedenergistics2.p2p_output_many_inputs=Linked (Output Side) - %d Inputs
|
||||
waila.appliedenergistics2.P2POutput=Linked (Output Side)
|
||||
|
||||
// TheOneProbe
|
||||
@@ -420,8 +422,10 @@ theoneprobe.appliedenergistics2.showing=Showing
|
||||
theoneprobe.appliedenergistics2.contains=Contains
|
||||
theoneprobe.appliedenergistics2.channels=%1$d of %2$d Channels
|
||||
theoneprobe.appliedenergistics2.p2p_unlinked=Unlinked
|
||||
theoneprobe.appliedenergistics2.p2p_input_one_output=Linked (Input Side)
|
||||
theoneprobe.appliedenergistics2.p2p_input_one_output=Linked (Input Side) - 1 Output
|
||||
theoneprobe.appliedenergistics2.p2p_input_many_outputs=Linked (Input Side) - %d Outputs
|
||||
theoneprobe.appliedenergistics2.p2p_output_one_input=Linked (Output Side) - 1 Input
|
||||
theoneprobe.appliedenergistics2.p2p_output_many_inputs=Linked (Output Side) - %d Inputs
|
||||
theoneprobe.appliedenergistics2.p2p_output=Linked (Output Side)
|
||||
theoneprobe.appliedenergistics2.p2p_frequency=Frequency: %1$s
|
||||
theoneprobe.appliedenergistics2.stored_energy=%1$d / %2$d
|
||||
|
||||
Reference in New Issue
Block a user