Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d48c24a2e1 | |||
| b6eef99312 | |||
| decb869011 | |||
| 5877fd2def |
+1
-1
@@ -3,7 +3,7 @@ aechannel=stable
|
|||||||
aebuild=7
|
aebuild=7
|
||||||
aegroup=appeng
|
aegroup=appeng
|
||||||
aebasename=appliedenergistics2
|
aebasename=appliedenergistics2
|
||||||
trousers=omni-fixes-v47i
|
trousers=omni-fixes-v44
|
||||||
|
|
||||||
#########################################################
|
#########################################################
|
||||||
# Versions #
|
# Versions #
|
||||||
|
|||||||
@@ -44,11 +44,8 @@ public interface IStackWatcherHost
|
|||||||
/**
|
/**
|
||||||
* Called when a watched item changes amounts.
|
* Called when a watched item changes amounts.
|
||||||
*
|
*
|
||||||
* @param o changed item list
|
|
||||||
* @param fullStack old stack
|
|
||||||
* @param diffStack new stack
|
* @param diffStack new stack
|
||||||
* @param src action source
|
|
||||||
* @param chan storage channel
|
* @param chan storage channel
|
||||||
*/
|
*/
|
||||||
void onStackChange( IItemList<?> o, IAEStack<?> fullStack, IAEStack<?> diffStack, IActionSource src, IStorageChannel<?> chan );
|
void onStackChange( IAEStack<?> diffStack, IStorageChannel<?> chan );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,4 +52,9 @@ public interface IMEMonitorHandlerReceiver<T extends IAEStack<T>>
|
|||||||
* called when the list updates its contents, this is mostly for handling power events.
|
* called when the list updates its contents, this is mostly for handling power events.
|
||||||
*/
|
*/
|
||||||
void onListUpdate();
|
void onListUpdate();
|
||||||
|
|
||||||
|
default boolean hasListeners()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,11 +237,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
|||||||
int interfaceDim = dimHashMap.get( guiButtonHashMap.get( this.selectedButton ) );
|
int interfaceDim = dimHashMap.get( guiButtonHashMap.get( this.selectedButton ) );
|
||||||
if( playerDim != interfaceDim )
|
if( playerDim != interfaceDim )
|
||||||
{
|
{
|
||||||
try {
|
mc.player.sendStatusMessage( new TextComponentString( "Interface located at dimension: " + interfaceDim + " [" + DimensionManager.getWorld( interfaceDim ).provider.getDimensionType().getName() + "] and cant be highlighted" ), false );
|
||||||
mc.player.sendStatusMessage( new TextComponentString( "Interface located at dimension: " + interfaceDim + " [" + DimensionManager.getWorld( interfaceDim ).provider.getDimensionType().getName() + "] and cant be highlighted" ), false );
|
|
||||||
} catch(Exception e){
|
|
||||||
mc.player.sendStatusMessage( new TextComponentString( "Interface is located in another dimension and cannot be highlighted" ), false );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -270,15 +270,12 @@ public class GuiUpgradeable extends AEBaseGui implements IJEIGhostIngredients
|
|||||||
@Override
|
@Override
|
||||||
public Rectangle getArea()
|
public Rectangle getArea()
|
||||||
{
|
{
|
||||||
if( slot instanceof SlotFake && ( (SlotFake) slot ).isSlotEnabled() )
|
if( slot instanceof SlotFake )
|
||||||
{
|
|
||||||
return new Rectangle( getGuiLeft() + ( (SlotFake) slot ).xPos, getGuiTop() + ( (SlotFake) slot ).yPos, 16, 16 );
|
return new Rectangle( getGuiLeft() + ( (SlotFake) slot ).xPos, getGuiTop() + ( (SlotFake) slot ).yPos, 16, 16 );
|
||||||
}
|
else
|
||||||
else if( slot instanceof GuiFluidSlot && ( (GuiFluidSlot) slot ).isSlotEnabled() )
|
|
||||||
{
|
{
|
||||||
return new Rectangle( getGuiLeft() + ( (GuiFluidSlot) slot ).xPos(), getGuiTop() + ( (GuiFluidSlot) slot ).yPos(), 16, 16 );
|
return new Rectangle( getGuiLeft() + ( (GuiFluidSlot) slot ).xPos(), getGuiTop() + ( (GuiFluidSlot) slot ).yPos(), 16, 16 );
|
||||||
}
|
}
|
||||||
return new Rectangle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -287,7 +284,7 @@ public class GuiUpgradeable extends AEBaseGui implements IJEIGhostIngredients
|
|||||||
PacketInventoryAction p = null;
|
PacketInventoryAction p = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if( slot instanceof SlotFake && ( (SlotFake) slot ).isSlotEnabled() )
|
if( slot instanceof SlotFake )
|
||||||
{
|
{
|
||||||
if( finalItemStack.isEmpty() && finalFluidStack != null )
|
if( finalItemStack.isEmpty() && finalFluidStack != null )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ import net.minecraft.item.ItemStack;
|
|||||||
|
|
||||||
public abstract class GuiCustomSlot extends Gui implements ITooltip
|
public abstract class GuiCustomSlot extends Gui implements ITooltip
|
||||||
{
|
{
|
||||||
protected final int x;
|
private final int x;
|
||||||
protected final int y;
|
private final int y;
|
||||||
protected final int id;
|
private final int id;
|
||||||
|
|
||||||
public GuiCustomSlot( final int id, final int x, final int y )
|
public GuiCustomSlot( final int id, final int x, final int y )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,10 +22,9 @@ package appeng.client.render;
|
|||||||
import appeng.api.storage.data.IAEFluidStack;
|
import appeng.api.storage.data.IAEFluidStack;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.FontRenderer;
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
import net.minecraft.client.renderer.*;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
import net.minecraft.client.renderer.OpenGlHelper;
|
||||||
import net.minecraft.client.renderer.texture.TextureMap;
|
import net.minecraft.client.renderer.RenderItem;
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
|
||||||
@@ -33,7 +32,6 @@ import appeng.api.storage.data.IAEItemStack;
|
|||||||
import appeng.util.IWideReadableNumberConverter;
|
import appeng.util.IWideReadableNumberConverter;
|
||||||
import appeng.util.ReadableNumberConverter;
|
import appeng.util.ReadableNumberConverter;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -123,49 +121,6 @@ public class TesrRenderHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void renderFluid2d( FluidStack fluidStack, float scale )
|
|
||||||
{
|
|
||||||
if( fluidStack != null )
|
|
||||||
{
|
|
||||||
GlStateManager.pushMatrix();
|
|
||||||
int color = fluidStack.getFluid().getColor( fluidStack );
|
|
||||||
float r = ( color >> 16 & 255 ) / 255.0f;
|
|
||||||
float g = ( color >> 8 & 255 ) / 255.0f;
|
|
||||||
float b = ( color & 255 ) / 255.0f;
|
|
||||||
TextureAtlasSprite sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite( fluidStack.getFluid().getStill( fluidStack ).toString() );
|
|
||||||
GlStateManager.enableBlend();
|
|
||||||
GlStateManager.blendFunc( GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA );
|
|
||||||
GlStateManager.disableAlpha();
|
|
||||||
GlStateManager.disableLighting();
|
|
||||||
Minecraft.getMinecraft().getTextureManager().bindTexture( TextureMap.LOCATION_BLOCKS_TEXTURE );
|
|
||||||
Tessellator tess = Tessellator.getInstance();
|
|
||||||
BufferBuilder buf = tess.getBuffer();
|
|
||||||
|
|
||||||
float width = 0.4f;
|
|
||||||
float height = 0.4f;
|
|
||||||
float alpha = 1.0f;
|
|
||||||
float z = 0.0001f;
|
|
||||||
float x = -0.20f;
|
|
||||||
float y = -0.25f;
|
|
||||||
|
|
||||||
buf.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR );
|
|
||||||
double uMin = sprite.getInterpolatedU( 16D - width * 16D ), uMax = sprite.getInterpolatedU( width * 16D );
|
|
||||||
double vMin = sprite.getMinV(), vMax = sprite.getInterpolatedV( height * 16D );
|
|
||||||
buf.pos( x, y, z ).tex( uMin, vMin ).color( r, g, b, alpha ).endVertex();
|
|
||||||
buf.pos( x, y + height, z ).tex( uMin, vMax ).color( r, g, b, alpha ).endVertex();
|
|
||||||
buf.pos( x + width, y + height, z ).tex( uMax, vMax ).color( r, g, b, alpha ).endVertex();
|
|
||||||
buf.pos( x + width, y, z ).tex( uMax, vMin ).color( r, g, b, alpha ).endVertex();
|
|
||||||
|
|
||||||
tess.draw();
|
|
||||||
GlStateManager.enableLighting();
|
|
||||||
GlStateManager.enableAlpha();
|
|
||||||
GlStateManager.disableBlend();
|
|
||||||
GlStateManager.color( 1F, 1F, 1F, 1F );
|
|
||||||
GlStateManager.popMatrix();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render an item in 2D and the given text below it.
|
* Render an item in 2D and the given text below it.
|
||||||
*
|
*
|
||||||
@@ -192,9 +147,9 @@ public class TesrRenderHelper
|
|||||||
|
|
||||||
public static void renderFluid2dWithAmount( IAEFluidStack fluidStack, float scale, float spacing )
|
public static void renderFluid2dWithAmount( IAEFluidStack fluidStack, float scale, float spacing )
|
||||||
{
|
{
|
||||||
final FluidStack renderStack = fluidStack.getFluidStack();
|
final ItemStack renderStack = fluidStack.asItemStackRepresentation();
|
||||||
|
|
||||||
TesrRenderHelper.renderFluid2d( renderStack, scale );
|
TesrRenderHelper.renderItem2d( renderStack, scale );
|
||||||
|
|
||||||
final long stackSize = fluidStack.getStackSize() / 1000;
|
final long stackSize = fluidStack.getStackSize() / 1000;
|
||||||
final String renderedStackSize = NUMBER_CONVERTER.toWideReadableForm( stackSize ) + "B";
|
final String renderedStackSize = NUMBER_CONVERTER.toWideReadableForm( stackSize ) + "B";
|
||||||
|
|||||||
@@ -245,10 +245,7 @@ public class PacketJEIRecipe extends AppEngPacket
|
|||||||
|
|
||||||
if( out != null )
|
if( out != null )
|
||||||
{
|
{
|
||||||
if (!cct.useRealItems())
|
out.setStackSize( recipe[x][y].getCount() );
|
||||||
{
|
|
||||||
out.setStackSize( recipe[x][y].getCount() );
|
|
||||||
}
|
|
||||||
currentItem = out.createItemStack();
|
currentItem = out.createItemStack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
package appeng.core.sync.packets;
|
package appeng.core.sync.packets;
|
||||||
|
|
||||||
|
|
||||||
import appeng.fluids.container.ContainerFluidInterface;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
|
|
||||||
@@ -91,9 +90,5 @@ public class PacketTargetFluidStack extends AppEngPacket
|
|||||||
{
|
{
|
||||||
( (ContainerFluidTerminal) player.openContainer ).setTargetStack( this.stack );
|
( (ContainerFluidTerminal) player.openContainer ).setTargetStack( this.stack );
|
||||||
}
|
}
|
||||||
else if( player.openContainer instanceof ContainerFluidInterface )
|
|
||||||
{
|
|
||||||
( (ContainerFluidInterface) player.openContainer ).setTargetStack( this.stack );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ public class CraftingJob implements Runnable, ICraftingJob
|
|||||||
private final IItemList<IAEItemStack> missing = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
private final IItemList<IAEItemStack> missing = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||||
private final HashMap<String, TwoIntegers> opsAndMultiplier = new HashMap<>();
|
private final HashMap<String, TwoIntegers> opsAndMultiplier = new HashMap<>();
|
||||||
private final Object monitor = new Object();
|
private final Object monitor = new Object();
|
||||||
private final Stopwatch watch = Stopwatch.createUnstarted();
|
|
||||||
private CraftingTreeNode tree;
|
private CraftingTreeNode tree;
|
||||||
private final IAEItemStack output;
|
private final IAEItemStack output;
|
||||||
private boolean simulate = false;
|
private boolean simulate = false;
|
||||||
@@ -67,10 +66,7 @@ public class CraftingJob implements Runnable, ICraftingJob
|
|||||||
private long bytes = 0;
|
private long bytes = 0;
|
||||||
private final IActionSource actionSrc;
|
private final IActionSource actionSrc;
|
||||||
private final ICraftingCallback callback;
|
private final ICraftingCallback callback;
|
||||||
private boolean running = false;
|
|
||||||
private boolean done = false;
|
private boolean done = false;
|
||||||
private int time;
|
|
||||||
private int incTime;
|
|
||||||
|
|
||||||
private World wrapWorld( final World w )
|
private World wrapWorld( final World w )
|
||||||
{
|
{
|
||||||
@@ -137,7 +133,6 @@ public class CraftingJob implements Runnable, ICraftingJob
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
TickHandler.INSTANCE.registerCraftingSimulation( this.world, this );
|
TickHandler.INSTANCE.registerCraftingSimulation( this.world, this );
|
||||||
this.handlePausing();
|
|
||||||
|
|
||||||
final Stopwatch timer = Stopwatch.createStarted();
|
final Stopwatch timer = Stopwatch.createStarted();
|
||||||
|
|
||||||
@@ -219,41 +214,6 @@ public class CraftingJob implements Runnable, ICraftingJob
|
|||||||
this.finish();
|
this.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
void handlePausing() throws InterruptedException
|
|
||||||
{
|
|
||||||
if( !this.actionSrc.player().isPresent() && this.incTime > 100 )
|
|
||||||
{
|
|
||||||
this.incTime = 0;
|
|
||||||
synchronized ( this.monitor )
|
|
||||||
{
|
|
||||||
if( this.watch.elapsed( TimeUnit.MICROSECONDS ) > this.time )
|
|
||||||
{
|
|
||||||
this.running = false;
|
|
||||||
this.watch.stop();
|
|
||||||
this.monitor.notify();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !this.running )
|
|
||||||
{
|
|
||||||
AELog.craftingDebug( "crafting job will now sleep" );
|
|
||||||
|
|
||||||
while ( !this.running )
|
|
||||||
{
|
|
||||||
this.monitor.wait();
|
|
||||||
}
|
|
||||||
|
|
||||||
AELog.craftingDebug( "crafting job now active" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( Thread.interrupted() )
|
|
||||||
{
|
|
||||||
throw new InterruptedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.incTime++;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void finish()
|
private void finish()
|
||||||
{
|
{
|
||||||
if( this.callback != null )
|
if( this.callback != null )
|
||||||
@@ -265,7 +225,6 @@ public class CraftingJob implements Runnable, ICraftingJob
|
|||||||
|
|
||||||
synchronized( this.monitor )
|
synchronized( this.monitor )
|
||||||
{
|
{
|
||||||
this.running = false;
|
|
||||||
this.done = true;
|
this.done = true;
|
||||||
this.monitor.notify();
|
this.monitor.notify();
|
||||||
}
|
}
|
||||||
@@ -311,41 +270,13 @@ public class CraftingJob implements Runnable, ICraftingJob
|
|||||||
/**
|
/**
|
||||||
* @return true if this needs more simulation
|
* @return true if this needs more simulation
|
||||||
*/
|
*/
|
||||||
public boolean simulateFor(final int milli)
|
public boolean simulateFor()
|
||||||
{
|
{
|
||||||
this.time = milli;
|
synchronized( this.monitor ) {
|
||||||
|
if ( this.done ) {
|
||||||
synchronized ( this.monitor )
|
|
||||||
{
|
|
||||||
if( this.done )
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if( !this.actionSrc.player().isPresent() )
|
|
||||||
{
|
|
||||||
this.watch.reset();
|
|
||||||
this.watch.start();
|
|
||||||
this.running = true;
|
|
||||||
|
|
||||||
AELog.craftingDebug( "main thread is now going to sleep" );
|
|
||||||
|
|
||||||
this.monitor.notify();
|
|
||||||
|
|
||||||
while ( this.running )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.monitor.wait();
|
|
||||||
}
|
|
||||||
catch( final InterruptedException ignored )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AELog.craftingDebug( "main thread is now active" );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import net.minecraft.util.text.TextComponentString;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import appeng.api.AEApi;
|
import appeng.api.AEApi;
|
||||||
@@ -120,47 +119,22 @@ public class CraftingTreeNode
|
|||||||
|
|
||||||
IAEItemStack request( final MECraftingInventory inv, long l, final IActionSource src ) throws CraftBranchFailure, InterruptedException
|
IAEItemStack request( final MECraftingInventory inv, long l, final IActionSource src ) throws CraftBranchFailure, InterruptedException
|
||||||
{
|
{
|
||||||
this.job.handlePausing();
|
|
||||||
final List<IAEItemStack> thingsUsed = new ArrayList<>();
|
final List<IAEItemStack> thingsUsed = new ArrayList<>();
|
||||||
|
|
||||||
this.what.setStackSize( l );
|
this.what.setStackSize( l );
|
||||||
IAEItemStack available = inv.extractItems( this.what, Actionable.MODULATE, src );
|
if( this.getSlot() >= 0 && this.parent != null && this.parent.details.isCraftable() )
|
||||||
|
|
||||||
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 Collection<IAEItemStack> itemList;
|
||||||
final IItemList<IAEItemStack> inventoryList = inv.getItemList();
|
final IItemList<IAEItemStack> inventoryList = inv.getItemList();
|
||||||
|
|
||||||
if( this.parent.details.canSubstitute() )
|
if( this.parent.details.canSubstitute() )
|
||||||
{
|
{
|
||||||
final List<IAEItemStack> substitutes = this.parent.details.getSubstituteInputs( this.slot );
|
final List<IAEItemStack> substitutes = this.parent.details.getSubstituteInputs(this.slot);
|
||||||
itemList = new ArrayList<>( substitutes.size() );
|
itemList = new ArrayList<>(substitutes.size());
|
||||||
|
|
||||||
for( IAEItemStack stack : substitutes )
|
for (IAEItemStack stack : substitutes) {
|
||||||
{
|
itemList.addAll(inventoryList.findFuzzy(stack, FuzzyMode.IGNORE_ALL));
|
||||||
itemList.addAll( inventoryList.findFuzzy( stack, FuzzyMode.IGNORE_ALL ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -182,7 +156,7 @@ public class CraftingTreeNode
|
|||||||
fuzz = fuzz.copy();
|
fuzz = fuzz.copy();
|
||||||
fuzz.setStackSize( l );
|
fuzz.setStackSize( l );
|
||||||
|
|
||||||
available = inv.extractItems( fuzz, Actionable.MODULATE, src );
|
final IAEItemStack available = inv.extractItems( fuzz, Actionable.MODULATE, src );
|
||||||
|
|
||||||
if( available != null )
|
if( available != null )
|
||||||
{
|
{
|
||||||
@@ -208,6 +182,32 @@ 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 )
|
if( this.canEmit )
|
||||||
{
|
{
|
||||||
@@ -226,7 +226,7 @@ public class CraftingTreeNode
|
|||||||
{
|
{
|
||||||
final CraftingTreeProcess pro = this.nodes.get( 0 );
|
final CraftingTreeProcess pro = this.nodes.get( 0 );
|
||||||
|
|
||||||
while ( pro.possible && l > 0 )
|
while( pro.possible && l > 0 )
|
||||||
{
|
{
|
||||||
final IAEItemStack madeWhat = pro.getAmountCrafted( this.what );
|
final IAEItemStack madeWhat = pro.getAmountCrafted( this.what );
|
||||||
|
|
||||||
@@ -234,7 +234,7 @@ public class CraftingTreeNode
|
|||||||
|
|
||||||
madeWhat.setStackSize( l );
|
madeWhat.setStackSize( l );
|
||||||
|
|
||||||
available = inv.extractItems( madeWhat, Actionable.MODULATE, src );
|
final IAEItemStack available = inv.extractItems( madeWhat, Actionable.MODULATE, src );
|
||||||
|
|
||||||
if( available != null )
|
if( available != null )
|
||||||
{
|
{
|
||||||
@@ -258,13 +258,13 @@ public class CraftingTreeNode
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
while ( pro.possible && l > 0 )
|
while( pro.possible && l > 0 )
|
||||||
{
|
{
|
||||||
final MECraftingInventory subInv = new MECraftingInventory( inv, true, true, true );
|
final MECraftingInventory subInv = new MECraftingInventory( inv, true, true, true );
|
||||||
pro.request( subInv, 1, src );
|
pro.request( subInv, 1, src );
|
||||||
|
|
||||||
this.what.setStackSize( l );
|
this.what.setStackSize( l );
|
||||||
available = subInv.extractItems( this.what, Actionable.MODULATE, src );
|
final IAEItemStack available = subInv.extractItems( this.what, Actionable.MODULATE, src );
|
||||||
|
|
||||||
if( available != null )
|
if( available != null )
|
||||||
{
|
{
|
||||||
@@ -321,7 +321,7 @@ public class CraftingTreeNode
|
|||||||
}
|
}
|
||||||
// missing = 0;
|
// missing = 0;
|
||||||
|
|
||||||
job.addBytes( this.bytes );
|
job.addBytes( 8 + this.bytes );
|
||||||
|
|
||||||
for( final CraftingTreeProcess pro : this.nodes )
|
for( final CraftingTreeProcess pro : this.nodes )
|
||||||
{
|
{
|
||||||
@@ -358,10 +358,6 @@ public class CraftingTreeNode
|
|||||||
|
|
||||||
if( ex == null || ex.getStackSize() != i.getStackSize() )
|
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() );
|
throw new CraftBranchFailure( i, i.getStackSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ public class CraftingTreeProcess
|
|||||||
|
|
||||||
void request( final MECraftingInventory inv, final long i, final IActionSource src ) throws CraftBranchFailure, InterruptedException
|
void request( final MECraftingInventory inv, final long i, final IActionSource src ) throws CraftBranchFailure, InterruptedException
|
||||||
{
|
{
|
||||||
this.job.handlePausing();
|
|
||||||
if( this.fullSimulation )
|
if( this.fullSimulation )
|
||||||
{
|
{
|
||||||
final InventoryCrafting ic = new InventoryCrafting( new ContainerNull(), 3, 3 );
|
final InventoryCrafting ic = new InventoryCrafting( new ContainerNull(), 3, 3 );
|
||||||
@@ -241,6 +241,7 @@ public class CraftingTreeProcess
|
|||||||
o.setStackSize( o.getStackSize() * i );
|
o.setStackSize( o.getStackSize() * i );
|
||||||
inv.injectItems( o, Actionable.MODULATE, src );
|
inv.injectItems( o, Actionable.MODULATE, src );
|
||||||
}
|
}
|
||||||
|
|
||||||
this.crafts += i;
|
this.crafts += i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,7 +253,7 @@ public class CraftingTreeProcess
|
|||||||
pro.dive( job );
|
pro.dive( job );
|
||||||
}
|
}
|
||||||
|
|
||||||
job.addBytes( this.crafts + 8 + this.bytes );
|
job.addBytes( 8 + this.crafts + this.bytes );
|
||||||
}
|
}
|
||||||
|
|
||||||
IAEItemStack getAmountCrafted( IAEItemStack what2 )
|
IAEItemStack getAmountCrafted( IAEItemStack what2 )
|
||||||
@@ -304,7 +305,7 @@ public class CraftingTreeProcess
|
|||||||
|
|
||||||
void getPlan( final IItemList<IAEItemStack> plan )
|
void getPlan( final IItemList<IAEItemStack> plan )
|
||||||
{
|
{
|
||||||
for( IAEItemStack i : this.details.getOutputs() )
|
for( IAEItemStack i : this.details.getCondensedOutputs() )
|
||||||
{
|
{
|
||||||
i = i.copy();
|
i = i.copy();
|
||||||
i.setCountRequestable( i.getStackSize() * this.crafts );
|
i.setCountRequestable( i.getStackSize() * this.crafts );
|
||||||
|
|||||||
@@ -312,13 +312,9 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack>
|
|||||||
if( src.player().isPresent() )
|
if( src.player().isPresent() )
|
||||||
{
|
{
|
||||||
if( result == null )
|
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
|
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;
|
failed = true;
|
||||||
if( !src.player().isPresent() ) break;
|
if( !src.player().isPresent() ) break;
|
||||||
|
|||||||
@@ -21,9 +21,6 @@ package appeng.fluids.client.gui;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import appeng.api.util.IConfigManager;
|
|
||||||
import appeng.client.gui.widgets.GuiCustomSlot;
|
|
||||||
import appeng.util.IConfigManagerHost;
|
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
|
||||||
@@ -41,12 +38,11 @@ import appeng.fluids.helper.IFluidInterfaceHost;
|
|||||||
import appeng.fluids.util.IAEFluidTank;
|
import appeng.fluids.util.IAEFluidTank;
|
||||||
|
|
||||||
|
|
||||||
public class GuiFluidInterface extends GuiUpgradeable implements IConfigManagerHost
|
public class GuiFluidInterface extends GuiUpgradeable
|
||||||
{
|
{
|
||||||
public final static int ID_BUTTON_TANK = 222;
|
public final static int ID_BUTTON_TANK = 222;
|
||||||
|
|
||||||
private final IFluidInterfaceHost host;
|
private final IFluidInterfaceHost host;
|
||||||
private final ContainerFluidInterface container;
|
|
||||||
private GuiTabButton priority;
|
private GuiTabButton priority;
|
||||||
|
|
||||||
public GuiFluidInterface( final InventoryPlayer ip, final IFluidInterfaceHost te )
|
public GuiFluidInterface( final InventoryPlayer ip, final IFluidInterfaceHost te )
|
||||||
@@ -54,8 +50,6 @@ public class GuiFluidInterface extends GuiUpgradeable implements IConfigManagerH
|
|||||||
super( new ContainerFluidInterface( ip, te ) );
|
super( new ContainerFluidInterface( ip, te ) );
|
||||||
this.ySize = 231;
|
this.ySize = 231;
|
||||||
this.host = te;
|
this.host = te;
|
||||||
( this.container = (ContainerFluidInterface) this.inventorySlots ).setGui( this );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -68,7 +62,9 @@ public class GuiFluidInterface extends GuiUpgradeable implements IConfigManagerH
|
|||||||
|
|
||||||
for( int i = 0; i < DualityFluidInterface.NUMBER_OF_TANKS; ++i )
|
for( int i = 0; i < DualityFluidInterface.NUMBER_OF_TANKS; ++i )
|
||||||
{
|
{
|
||||||
this.guiSlots.add( new GuiFluidTank( fluidTank, i, DualityFluidInterface.NUMBER_OF_TANKS + i, 36 + 18 * i, 53, 16, 68 ) );
|
final GuiFluidTank guiTank = new GuiFluidTank( fluidTank, i, DualityFluidInterface.NUMBER_OF_TANKS + i, this.getGuiLeft() + 35 + 18 * i, this
|
||||||
|
.getGuiTop() + 53, 16, 68 );
|
||||||
|
this.buttonList.add( guiTank );
|
||||||
this.guiSlots.add( new GuiFluidSlot( configFluids, i, i, 35 + 18 * i, 35 ) );
|
this.guiSlots.add( new GuiFluidSlot( configFluids, i, i, 35 + 18 * i, 35 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,33 +104,9 @@ public class GuiFluidInterface extends GuiUpgradeable implements IConfigManagerH
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void mouseClicked( int xCoord, int yCoord, int btn ) throws IOException
|
|
||||||
{
|
|
||||||
for( GuiCustomSlot slot : this.guiSlots )
|
|
||||||
{
|
|
||||||
if( slot instanceof GuiFluidTank )
|
|
||||||
{
|
|
||||||
if( this.isPointInRegion( slot.xPos(), slot.yPos(), slot.getWidth(), slot.getHeight(), xCoord, yCoord ) && slot.canClick( this.mc.player ) )
|
|
||||||
{
|
|
||||||
this.container.setTargetStack( ( (GuiFluidTank) slot ).getFluidStack() );
|
|
||||||
slot.slotClicked( this.mc.player.inventory.getItemStack(), btn );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
super.mouseClicked( xCoord, yCoord, btn );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean drawUpgrades()
|
protected boolean drawUpgrades()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,50 +19,42 @@
|
|||||||
package appeng.fluids.client.gui.widgets;
|
package appeng.fluids.client.gui.widgets;
|
||||||
|
|
||||||
|
|
||||||
import appeng.client.gui.widgets.GuiCustomSlot;
|
|
||||||
import appeng.core.sync.network.NetworkHandler;
|
|
||||||
import appeng.core.sync.packets.PacketInventoryAction;
|
|
||||||
import appeng.helpers.InventoryAction;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
import net.minecraft.client.renderer.texture.TextureMap;
|
import net.minecraft.client.renderer.texture.TextureMap;
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
import appeng.api.storage.data.IAEFluidStack;
|
import appeng.api.storage.data.IAEFluidStack;
|
||||||
|
import appeng.api.util.AEColor;
|
||||||
import appeng.client.gui.widgets.ITooltip;
|
import appeng.client.gui.widgets.ITooltip;
|
||||||
import appeng.fluids.util.IAEFluidTank;
|
import appeng.fluids.util.IAEFluidTank;
|
||||||
|
|
||||||
|
|
||||||
@SideOnly( Side.CLIENT )
|
@SideOnly( Side.CLIENT )
|
||||||
public class GuiFluidTank extends GuiCustomSlot implements ITooltip
|
public class GuiFluidTank extends GuiButton implements ITooltip
|
||||||
{
|
{
|
||||||
private final IAEFluidTank tank;
|
private final IAEFluidTank tank;
|
||||||
private final int slot;
|
private final int slot;
|
||||||
private final int width;
|
|
||||||
private final int height;
|
|
||||||
|
|
||||||
public GuiFluidTank( IAEFluidTank tank, int slot, int id, int x, int y, int w, int h )
|
public GuiFluidTank( IAEFluidTank tank, int slot, int id, int x, int y, int w, int h )
|
||||||
{
|
{
|
||||||
super( id, x, y );
|
super( id, x, y, w, h, "" );
|
||||||
this.tank = tank;
|
this.tank = tank;
|
||||||
this.slot = slot;
|
this.slot = slot;
|
||||||
this.width = w;
|
|
||||||
this.height = h;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawContent( Minecraft mc, int mouseX, int mouseY, float partialTicks )
|
public void drawButton( final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks )
|
||||||
{
|
{
|
||||||
final IAEFluidStack fs = this.getFluidStack();
|
if( this.visible )
|
||||||
if( fs != null )
|
|
||||||
{
|
{
|
||||||
GlStateManager.disableBlend();
|
GlStateManager.disableBlend();
|
||||||
GlStateManager.disableLighting();
|
GlStateManager.disableLighting();
|
||||||
|
|
||||||
//drawRect( this.x, this.y, this.x + this.width, this.y + this.height, AEColor.GRAY.blackVariant | 0xFF000000 );
|
drawRect( this.x, this.y, this.x + this.width, this.y + this.height, AEColor.GRAY.blackVariant | 0xFF000000 );
|
||||||
|
|
||||||
final IAEFluidStack fluid = this.tank.getFluidInSlot( this.slot );
|
final IAEFluidStack fluid = this.tank.getFluidInSlot( this.slot );
|
||||||
if( fluid != null && fluid.getStackSize() > 0 )
|
if( fluid != null && fluid.getStackSize() > 0 )
|
||||||
@@ -77,16 +69,17 @@ public class GuiFluidTank extends GuiCustomSlot implements ITooltip
|
|||||||
TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite( fluid.getFluid().getStill().toString() );
|
TextureAtlasSprite sprite = mc.getTextureMapBlocks().getAtlasSprite( fluid.getFluid().getStill().toString() );
|
||||||
final int scaledHeight = (int) ( this.height * ( (float) fluid.getStackSize() / this.tank.getTankProperties()[this.slot].getCapacity() ) );
|
final int scaledHeight = (int) ( this.height * ( (float) fluid.getStackSize() / this.tank.getTankProperties()[this.slot].getCapacity() ) );
|
||||||
|
|
||||||
int iconHeightRemainder = scaledHeight % this.getHeight();
|
int iconHeightRemainder = scaledHeight % 16;
|
||||||
if( iconHeightRemainder > 0 )
|
if( iconHeightRemainder > 0 )
|
||||||
{
|
{
|
||||||
this.drawTexturedModalRect( this.xPos(), this.yPos() + this.getHeight() - iconHeightRemainder, sprite, this.getWidth(), iconHeightRemainder );
|
this.drawTexturedModalRect( this.x, this.y + this.height - iconHeightRemainder, sprite, 16, iconHeightRemainder );
|
||||||
}
|
}
|
||||||
for( int i = 0; i < scaledHeight / this.getHeight(); i++ )
|
for( int i = 0; i < scaledHeight / 16; i++ )
|
||||||
{
|
{
|
||||||
this.drawTexturedModalRect( this.xPos(), this.yPos() + this.getHeight() - iconHeightRemainder - ( i + 1 ) * 16, sprite, this.getWidth(), this.getHeight() );
|
this.drawTexturedModalRect( this.x, this.y + this.height - iconHeightRemainder - ( i + 1 ) * 16, sprite, 16, 16 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,25 +100,25 @@ public class GuiFluidTank extends GuiCustomSlot implements ITooltip
|
|||||||
@Override
|
@Override
|
||||||
public int xPos()
|
public int xPos()
|
||||||
{
|
{
|
||||||
return this.x - 1;
|
return this.x - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int yPos()
|
public int yPos()
|
||||||
{
|
{
|
||||||
return this.y - 1;
|
return this.y - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getWidth()
|
public int getWidth()
|
||||||
{
|
{
|
||||||
return this.width;
|
return this.width + 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHeight()
|
public int getHeight()
|
||||||
{
|
{
|
||||||
return this.height + 1;
|
return this.height + 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -134,24 +127,4 @@ public class GuiFluidTank extends GuiCustomSlot implements ITooltip
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IAEFluidStack getFluidStack()
|
|
||||||
{
|
|
||||||
return this.tank.getFluidInSlot( this.slot );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void slotClicked( ItemStack clickStack, final int mouseButton )
|
|
||||||
{
|
|
||||||
|
|
||||||
if( getFluidStack() != null )
|
|
||||||
{
|
|
||||||
NetworkHandler.instance().sendToServer( new PacketInventoryAction( InventoryAction.FILL_ITEM, slot, 0 ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NetworkHandler.instance().sendToServer( new PacketInventoryAction( InventoryAction.EMPTY_ITEM, slot, 0 ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,17 +19,9 @@
|
|||||||
package appeng.fluids.container;
|
package appeng.fluids.container;
|
||||||
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import appeng.core.sync.network.NetworkHandler;
|
|
||||||
import appeng.core.sync.packets.PacketTargetFluidStack;
|
|
||||||
import appeng.fluids.util.AEFluidStack;
|
|
||||||
import appeng.helpers.InventoryAction;
|
|
||||||
import appeng.util.IConfigManagerHost;
|
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.inventory.IContainerListener;
|
import net.minecraft.inventory.IContainerListener;
|
||||||
|
|
||||||
@@ -41,19 +33,12 @@ import appeng.fluids.helper.FluidSyncHelper;
|
|||||||
import appeng.fluids.helper.IFluidInterfaceHost;
|
import appeng.fluids.helper.IFluidInterfaceHost;
|
||||||
import appeng.fluids.util.IAEFluidTank;
|
import appeng.fluids.util.IAEFluidTank;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
import net.minecraftforge.fluids.FluidUtil;
|
|
||||||
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
|
||||||
|
|
||||||
|
|
||||||
public class ContainerFluidInterface extends ContainerFluidConfigurable implements IConfigManagerHost
|
public class ContainerFluidInterface extends ContainerFluidConfigurable
|
||||||
{
|
{
|
||||||
private final DualityFluidInterface myDuality;
|
private final DualityFluidInterface myDuality;
|
||||||
private final FluidSyncHelper tankSync;
|
private final FluidSyncHelper tankSync;
|
||||||
private IConfigManagerHost gui;
|
|
||||||
// Holds the fluid the client wishes to extract, or null for insert
|
|
||||||
private IAEFluidStack clientRequestedTargetFluid = null;
|
|
||||||
|
|
||||||
public ContainerFluidInterface( final InventoryPlayer ip, final IFluidInterfaceHost te )
|
public ContainerFluidInterface( final InventoryPlayer ip, final IFluidInterfaceHost te )
|
||||||
{
|
{
|
||||||
@@ -75,15 +60,6 @@ public class ContainerFluidInterface extends ContainerFluidConfigurable implemen
|
|||||||
return this.myDuality.getConfig();
|
return this.myDuality.getConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue )
|
|
||||||
{
|
|
||||||
if( this.getGui() != null )
|
|
||||||
{
|
|
||||||
this.getGui().updateSetting( manager, settingName, newValue );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void detectAndSendChanges()
|
public void detectAndSendChanges()
|
||||||
{
|
{
|
||||||
@@ -121,126 +97,6 @@ public class ContainerFluidInterface extends ContainerFluidConfigurable implemen
|
|||||||
this.tankSync.readPacket( fluids );
|
this.tankSync.readPacket( fluids );
|
||||||
}
|
}
|
||||||
|
|
||||||
private IConfigManagerHost getGui()
|
|
||||||
{
|
|
||||||
return this.gui;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGui( @Nonnull final IConfigManagerHost gui )
|
|
||||||
{
|
|
||||||
this.gui = gui;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void doAction( EntityPlayerMP player, InventoryAction action, int slot, long id )
|
|
||||||
{
|
|
||||||
if( action != InventoryAction.FILL_ITEM && action != InventoryAction.EMPTY_ITEM )
|
|
||||||
{
|
|
||||||
super.doAction( player, action, slot, id );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final ItemStack held = player.inventory.getItemStack();
|
|
||||||
ItemStack heldCopy = held.copy();
|
|
||||||
heldCopy.setCount( 1 );
|
|
||||||
IFluidHandlerItem fh = FluidUtil.getFluidHandler( heldCopy );
|
|
||||||
if( fh == null )
|
|
||||||
{
|
|
||||||
// only fluid handlers items
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( action == InventoryAction.FILL_ITEM && this.clientRequestedTargetFluid != null )
|
|
||||||
{
|
|
||||||
final IAEFluidStack stack = this.clientRequestedTargetFluid.copy();
|
|
||||||
|
|
||||||
// Check how much we can store in the item
|
|
||||||
stack.setStackSize( Integer.MAX_VALUE );
|
|
||||||
int amountAllowed = fh.fill( stack.getFluidStack(), false );
|
|
||||||
int heldAmount = held.getCount();
|
|
||||||
for( int i = 0; i < heldAmount; i++ )
|
|
||||||
{
|
|
||||||
ItemStack copiedFluidContainer = held.copy();
|
|
||||||
copiedFluidContainer.setCount( 1 );
|
|
||||||
fh = FluidUtil.getFluidHandler( copiedFluidContainer );
|
|
||||||
|
|
||||||
FluidStack extractableFluid = this.myDuality.getTanks().drain( stack.setStackSize( amountAllowed ).getFluidStack(), false );
|
|
||||||
if( extractableFluid == null || extractableFluid.amount == 0 )
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
int fillableAmount = fh.fill( extractableFluid, false );
|
|
||||||
if( fillableAmount > 0 )
|
|
||||||
{
|
|
||||||
FluidStack extractedFluid = this.myDuality.getTanks().drain( extractableFluid, true );
|
|
||||||
fh.fill( extractedFluid, true );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( held.getCount() == 1 )
|
|
||||||
{
|
|
||||||
player.inventory.setItemStack( fh.getContainer() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.inventory.getItemStack().shrink( 1 );
|
|
||||||
if( !player.inventory.addItemStackToInventory( fh.getContainer() ) )
|
|
||||||
{
|
|
||||||
player.dropItem( fh.getContainer(), false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( action == InventoryAction.EMPTY_ITEM )
|
|
||||||
{
|
|
||||||
int heldAmount = held.getCount();
|
|
||||||
for( int i = 0; i < heldAmount; i++ )
|
|
||||||
{
|
|
||||||
ItemStack copiedFluidContainer = held.copy();
|
|
||||||
copiedFluidContainer.setCount( 1 );
|
|
||||||
fh = FluidUtil.getFluidHandler( copiedFluidContainer );
|
|
||||||
|
|
||||||
FluidStack drainable = fh.drain( this.myDuality.getTanks().getTankProperties()[slot].getCapacity(), false );
|
|
||||||
if( drainable != null )
|
|
||||||
{
|
|
||||||
fh.drain( drainable, true );
|
|
||||||
this.myDuality.getTanks().fill( drainable, true );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( held.getCount() == 1 )
|
|
||||||
{
|
|
||||||
player.inventory.setItemStack( fh.getContainer() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.inventory.getItemStack().shrink( 1 );
|
|
||||||
if( !player.inventory.addItemStackToInventory( fh.getContainer() ) )
|
|
||||||
{
|
|
||||||
player.dropItem( fh.getContainer(), false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.updateHeld( player );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTargetStack( final IAEFluidStack stack )
|
|
||||||
{
|
|
||||||
if( Platform.isClient() )
|
|
||||||
{
|
|
||||||
if( stack == null && this.clientRequestedTargetFluid == null )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if( stack != null && this.clientRequestedTargetFluid != null && stack.getFluidStack().isFluidEqual( this.clientRequestedTargetFluid.getFluidStack() ) )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
NetworkHandler.instance().sendToServer( new PacketTargetFluidStack( (AEFluidStack) stack ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
this.clientRequestedTargetFluid = stack == null ? null : stack.copy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean supportCapacity()
|
protected boolean supportCapacity()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ package appeng.fluids.parts;
|
|||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -45,7 +44,6 @@ import appeng.api.storage.channels.IFluidStorageChannel;
|
|||||||
import appeng.api.storage.data.IAEFluidStack;
|
import appeng.api.storage.data.IAEFluidStack;
|
||||||
import appeng.api.storage.data.IItemList;
|
import appeng.api.storage.data.IItemList;
|
||||||
import appeng.fluids.util.AEFluidStack;
|
import appeng.fluids.util.AEFluidStack;
|
||||||
import appeng.me.GridAccessException;
|
|
||||||
import appeng.me.helpers.IGridProxyable;
|
import appeng.me.helpers.IGridProxyable;
|
||||||
import appeng.me.storage.ITickingMonitor;
|
import appeng.me.storage.ITickingMonitor;
|
||||||
|
|
||||||
@@ -94,14 +92,9 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
|
|||||||
|
|
||||||
if( type == Actionable.MODULATE )
|
if( type == Actionable.MODULATE )
|
||||||
{
|
{
|
||||||
try
|
this.cache
|
||||||
{
|
.currentlyCached
|
||||||
this.proxyable.getProxy().getTick().alertDevice( this.proxyable.getProxy().getNode() );
|
.add( input.copy().setStackSize( wasFillled ));
|
||||||
}
|
|
||||||
catch( GridAccessException ignore )
|
|
||||||
{
|
|
||||||
// meh
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fluidStack.amount = remaining;
|
fluidStack.amount = remaining;
|
||||||
@@ -123,18 +116,16 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IAEFluidStack gatheredAEFluidstack = AEFluidStack.fromFluidStack( gathered );
|
||||||
if( mode == Actionable.MODULATE )
|
if( mode == Actionable.MODULATE )
|
||||||
{
|
{
|
||||||
try
|
IAEFluidStack e = this.cache.currentlyCached.findPrecise( gatheredAEFluidstack );
|
||||||
|
if (e != null)
|
||||||
{
|
{
|
||||||
this.proxyable.getProxy().getTick().alertDevice( this.proxyable.getProxy().getNode() );
|
e.decStackSize( gathered.amount );
|
||||||
}
|
|
||||||
catch( GridAccessException ignore )
|
|
||||||
{
|
|
||||||
// meh
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return AEFluidStack.fromFluidStack( gathered );
|
return gatheredAEFluidstack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -202,9 +193,10 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
|
|||||||
|
|
||||||
private static class InventoryCache
|
private static class InventoryCache
|
||||||
{
|
{
|
||||||
private IAEFluidStack[] cachedAeStacks = new IAEFluidStack[0];
|
|
||||||
private final IFluidHandler fluidHandler;
|
private final IFluidHandler fluidHandler;
|
||||||
private final StorageFilter mode;
|
private final StorageFilter mode;
|
||||||
|
IItemList<IAEFluidStack> currentlyCached = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList();
|
||||||
|
|
||||||
|
|
||||||
public InventoryCache( IFluidHandler fluidHandler, StorageFilter mode )
|
public InventoryCache( IFluidHandler fluidHandler, StorageFilter mode )
|
||||||
{
|
{
|
||||||
@@ -216,19 +208,12 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
|
|||||||
{
|
{
|
||||||
final List<IAEFluidStack> changes = new ArrayList<>();
|
final List<IAEFluidStack> changes = new ArrayList<>();
|
||||||
final IFluidTankProperties[] tankProperties = this.fluidHandler.getTankProperties();
|
final IFluidTankProperties[] tankProperties = this.fluidHandler.getTankProperties();
|
||||||
final int slots = tankProperties.length;
|
|
||||||
|
|
||||||
// Make room for new slots
|
IItemList<IAEFluidStack> currentlyOnStorage = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList();
|
||||||
if( slots > this.cachedAeStacks.length )
|
|
||||||
{
|
|
||||||
this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots );
|
|
||||||
}
|
|
||||||
|
|
||||||
for( int slot = 0; slot < slots; slot++ )
|
for( IFluidTankProperties tankProperty : tankProperties )
|
||||||
{
|
{
|
||||||
// Save the old stuff
|
FluidStack newFS = tankProperty.getContents();
|
||||||
final IAEFluidStack oldAEFS = this.cachedAeStacks[slot];
|
|
||||||
FluidStack newFS = tankProperties[slot].getContents();
|
|
||||||
if( this.mode == StorageFilter.EXTRACTABLE_ONLY && newFS != null )
|
if( this.mode == StorageFilter.EXTRACTABLE_ONLY && newFS != null )
|
||||||
{
|
{
|
||||||
if( this.fluidHandler.drain( 1, false ) == null )
|
if( this.fluidHandler.drain( 1, false ) == null )
|
||||||
@@ -236,82 +221,40 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
|
|||||||
newFS = null;
|
newFS = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.handlePossibleSlotChanges( slot, oldAEFS, newFS, changes );
|
if( newFS != null )
|
||||||
}
|
|
||||||
|
|
||||||
// Handle cases where the number of slots actually is lower now than before
|
|
||||||
if( slots < this.cachedAeStacks.length )
|
|
||||||
{
|
|
||||||
for( int slot = slots; slot < this.cachedAeStacks.length; slot++ )
|
|
||||||
{
|
{
|
||||||
final IAEFluidStack aeStack = this.cachedAeStacks[slot];
|
currentlyOnStorage.add( AEFluidStack.fromFluidStack( newFS ) );
|
||||||
|
|
||||||
if( aeStack != null )
|
|
||||||
{
|
|
||||||
final IAEFluidStack a = aeStack.copy();
|
|
||||||
a.setStackSize( -a.getStackSize() );
|
|
||||||
changes.add( a );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for ( final IAEFluidStack is : currentlyCached )
|
||||||
|
{
|
||||||
|
is.setStackSize( -is.getStackSize() );
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( final IAEFluidStack is : currentlyOnStorage )
|
||||||
|
{
|
||||||
|
currentlyCached.add( is );
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( final IAEFluidStack is : currentlyCached )
|
||||||
|
{
|
||||||
|
if( is.getStackSize() != 0 )
|
||||||
|
{
|
||||||
|
changes.add( is );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
currentlyCached = currentlyOnStorage;
|
||||||
|
|
||||||
return changes;
|
return changes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IItemList<IAEFluidStack> getAvailableItems( IItemList<IAEFluidStack> out )
|
public IItemList<IAEFluidStack> getAvailableItems( IItemList<IAEFluidStack> out )
|
||||||
{
|
{
|
||||||
Arrays.stream( this.cachedAeStacks ).forEach( out::add );
|
currentlyCached.iterator().forEachRemaining( out::add );
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handlePossibleSlotChanges( int slot, IAEFluidStack oldAeFS, FluidStack newFS, List<IAEFluidStack> changes )
|
|
||||||
{
|
|
||||||
if( oldAeFS != null && oldAeFS.getFluidStack().isFluidEqual( newFS ) )
|
|
||||||
{
|
|
||||||
this.handleStackSizeChanged( slot, oldAeFS, newFS, changes );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.handleFluidChanged( slot, oldAeFS, newFS, changes );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleStackSizeChanged( int slot, IAEFluidStack oldAeFS, FluidStack newFS, List<IAEFluidStack> changes )
|
|
||||||
{
|
|
||||||
// Still the same fluid, but amount might have changed
|
|
||||||
final long diff = newFS.amount - oldAeFS.getStackSize();
|
|
||||||
|
|
||||||
if( diff != 0 )
|
|
||||||
{
|
|
||||||
final IAEFluidStack stack = oldAeFS.copy();
|
|
||||||
stack.setStackSize( newFS.amount );
|
|
||||||
|
|
||||||
this.cachedAeStacks[slot] = stack;
|
|
||||||
|
|
||||||
final IAEFluidStack a = stack.copy();
|
|
||||||
a.setStackSize( diff );
|
|
||||||
changes.add( a );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleFluidChanged( int slot, IAEFluidStack oldAeFS, FluidStack newFS, List<IAEFluidStack> changes )
|
|
||||||
{
|
|
||||||
// Completely different fluid
|
|
||||||
this.cachedAeStacks[slot] = AEFluidStack.fromFluidStack( newFS );
|
|
||||||
|
|
||||||
// If we had a stack previously in this slot, notify the network about its disappearance
|
|
||||||
if( oldAeFS != null )
|
|
||||||
{
|
|
||||||
oldAeFS.setStackSize( -oldAeFS.getStackSize() );
|
|
||||||
changes.add( oldAeFS );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Notify the network about the new stack. Note that this is null if newFS was null
|
|
||||||
if( this.cachedAeStacks[slot] != null )
|
|
||||||
{
|
|
||||||
changes.add( this.cachedAeStacks[slot] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ package appeng.fluids.parts;
|
|||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import appeng.api.networking.events.MENetworkChannelChanged;
|
||||||
import appeng.fluids.helper.IConfigurableFluidInventory;
|
import appeng.fluids.helper.IConfigurableFluidInventory;
|
||||||
|
import appeng.me.cache.NetworkMonitor;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
@@ -34,7 +36,6 @@ import appeng.api.storage.IStorageChannel;
|
|||||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||||
import appeng.api.storage.data.IAEFluidStack;
|
import appeng.api.storage.data.IAEFluidStack;
|
||||||
import appeng.api.storage.data.IAEStack;
|
import appeng.api.storage.data.IAEStack;
|
||||||
import appeng.api.storage.data.IItemList;
|
|
||||||
import appeng.api.util.AECableType;
|
import appeng.api.util.AECableType;
|
||||||
import appeng.api.util.AEPartLocation;
|
import appeng.api.util.AEPartLocation;
|
||||||
import appeng.api.util.IConfigManager;
|
import appeng.api.util.IConfigManager;
|
||||||
@@ -112,11 +113,11 @@ public class PartFluidLevelEmitter extends PartUpgradeable implements IStackWatc
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStackChange( IItemList<?> o, IAEStack<?> fullStack, IAEStack<?> diffStack, IActionSource src, IStorageChannel<?> chan )
|
public void onStackChange( IAEStack<?> diffStack, IStorageChannel<?> chan )
|
||||||
{
|
{
|
||||||
if( chan == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) && fullStack.equals( this.config.getFluidInSlot( 0 ) ) )
|
if( chan == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) && diffStack.equals( this.config.getFluidInSlot( 0 ) ) )
|
||||||
{
|
{
|
||||||
this.lastReportedValue = fullStack.getStackSize();
|
this.lastReportedValue += diffStack.getStackSize();
|
||||||
this.updateState();
|
this.updateState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,14 +129,22 @@ public class PartFluidLevelEmitter extends PartUpgradeable implements IStackWatc
|
|||||||
}
|
}
|
||||||
|
|
||||||
@MENetworkEventSubscribe
|
@MENetworkEventSubscribe
|
||||||
public void channelChanged( final MENetworkChannelsChanged c )
|
public void powerStatusChange( final MENetworkPowerStatusChange powerEvent )
|
||||||
{
|
{
|
||||||
|
if (this.getProxy().isActive())
|
||||||
|
{
|
||||||
|
onListUpdate();
|
||||||
|
}
|
||||||
this.updateState();
|
this.updateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@MENetworkEventSubscribe
|
@MENetworkEventSubscribe
|
||||||
public void powerChanged( final MENetworkPowerStatusChange c )
|
public void channelChanged( final MENetworkChannelsChanged c )
|
||||||
{
|
{
|
||||||
|
if (this.getProxy().isActive())
|
||||||
|
{
|
||||||
|
onListUpdate();
|
||||||
|
}
|
||||||
this.updateState();
|
this.updateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,10 +256,9 @@ public class PartFluidLevelEmitter extends PartUpgradeable implements IStackWatc
|
|||||||
|
|
||||||
if( myStack == null )
|
if( myStack == null )
|
||||||
{
|
{
|
||||||
this.lastReportedValue = 0;
|
if( monitor instanceof NetworkMonitor )
|
||||||
for( final IAEFluidStack st : monitor.getStorageList() )
|
|
||||||
{
|
{
|
||||||
this.lastReportedValue += st.getStackSize();
|
this.lastReportedValue = ( (NetworkMonitor<IAEFluidStack>) monitor ).getGridCurrentCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -25,9 +25,7 @@ import java.util.Objects;
|
|||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import appeng.api.networking.storage.IStorageGrid;
|
|
||||||
import appeng.fluids.helper.IConfigurableFluidInventory;
|
import appeng.fluids.helper.IConfigurableFluidInventory;
|
||||||
import appeng.me.cache.GridStorageCache;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
@@ -209,7 +207,7 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
|||||||
{
|
{
|
||||||
this.resetCacheLogic = 2;
|
this.resetCacheLogic = 2;
|
||||||
}
|
}
|
||||||
else if( resetCacheLogic < 2 )
|
else
|
||||||
{
|
{
|
||||||
this.resetCacheLogic = 1;
|
this.resetCacheLogic = 1;
|
||||||
}
|
}
|
||||||
@@ -266,20 +264,17 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
|||||||
@Override
|
@Override
|
||||||
public void postChange( final IBaseMonitor<IAEFluidStack> monitor, final Iterable<IAEFluidStack> change, final IActionSource source )
|
public void postChange( final IBaseMonitor<IAEFluidStack> monitor, final Iterable<IAEFluidStack> change, final IActionSource source )
|
||||||
{
|
{
|
||||||
if( source == this.source || source.machine().map( machine -> machine == this ).orElse( false ) )
|
try
|
||||||
{
|
{
|
||||||
try
|
if( this.getProxy().isActive() )
|
||||||
{
|
{
|
||||||
if( this.getProxy().isActive() )
|
this.getProxy().getStorage().postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ), change, this.source );
|
||||||
{
|
|
||||||
this.getProxy().getStorage().postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ), change, this.source );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch( final GridAccessException e )
|
|
||||||
{
|
|
||||||
// :(
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch( final GridAccessException e )
|
||||||
|
{
|
||||||
|
// :(
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MEInventoryHandler<IAEFluidStack> getInternalHandler()
|
public MEInventoryHandler<IAEFluidStack> getInternalHandler()
|
||||||
@@ -376,7 +371,7 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// force grid to update handlers...
|
// force grid to update handlers...
|
||||||
(( GridStorageCache ) this.getProxy().getGrid().getCache( IStorageGrid.class )).cellUpdate( null );
|
this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||||
}
|
}
|
||||||
catch( final GridAccessException ignore )
|
catch( final GridAccessException ignore )
|
||||||
{
|
{
|
||||||
@@ -417,7 +412,7 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
|||||||
{
|
{
|
||||||
if( channel == this.getStorageChannel() )
|
if( channel == this.getStorageChannel() )
|
||||||
{
|
{
|
||||||
final IMEInventoryHandler<IAEFluidStack> out = this.getProxy().isActive() ? this.getInternalHandler() : null;
|
final IMEInventoryHandler<IAEFluidStack> out = this.getInternalHandler();
|
||||||
if( out != null )
|
if( out != null )
|
||||||
{
|
{
|
||||||
return Collections.singletonList( out );
|
return Collections.singletonList( out );
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final int outputLength = out.size();
|
final int outputLength = this.isCrafting ? CRAFTING_OUTPUT_LIMIT : PROCESSING_OUTPUT_LIMIT;
|
||||||
|
|
||||||
this.inputs = in.toArray(new IAEItemStack[ALL_INPUT_LIMIT]);
|
this.inputs = in.toArray(new IAEItemStack[ALL_INPUT_LIMIT]);
|
||||||
this.outputs = out.toArray(new IAEItemStack[outputLength]);
|
this.outputs = out.toArray(new IAEItemStack[outputLength]);
|
||||||
|
|||||||
@@ -187,15 +187,20 @@ public class TickHandler
|
|||||||
if( ev.type == Type.WORLD && ev.phase == Phase.END )
|
if( ev.type == Type.WORLD && ev.phase == Phase.END )
|
||||||
{
|
{
|
||||||
final WorldTickEvent wte = (WorldTickEvent) ev;
|
final WorldTickEvent wte = (WorldTickEvent) ev;
|
||||||
synchronized ( this.craftingJobs )
|
synchronized( this.craftingJobs )
|
||||||
{
|
{
|
||||||
final Collection<CraftingJob> jobSet = this.craftingJobs.get( wte.world );
|
final Collection<CraftingJob> jobSet = this.craftingJobs.get( wte.world );
|
||||||
if (!jobSet.isEmpty()) {
|
if( !jobSet.isEmpty() )
|
||||||
final int jobSize = jobSet.size();
|
{
|
||||||
final int microSecondsPerTick = AEConfig.instance().getCraftingCalculationTimePerTick() * 1000;
|
final Iterator<CraftingJob> i = jobSet.iterator();
|
||||||
final int simTime = Math.max(1, microSecondsPerTick / jobSize);
|
while( i.hasNext() )
|
||||||
|
{
|
||||||
jobSet.removeIf( cj -> !cj.simulateFor( simTime ) );
|
final CraftingJob cj = i.next();
|
||||||
|
if( !cj.simulateFor() )
|
||||||
|
{
|
||||||
|
i.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
|
|||||||
|
|
||||||
final ICraftingPatternDetails details = this.getPatternForItem( item, w );
|
final ICraftingPatternDetails details = this.getPatternForItem( item, w );
|
||||||
|
|
||||||
out = details != null ? details.getOutputs()[0].createItemStack() : ItemStack.EMPTY;
|
out = details != null ? details.getCondensedOutputs()[0].createItemStack() : ItemStack.EMPTY;
|
||||||
|
|
||||||
SIMPLE_CACHE.put( item, out );
|
SIMPLE_CACHE.put( item, out );
|
||||||
return out;
|
return out;
|
||||||
|
|||||||
@@ -403,7 +403,7 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<
|
|||||||
}
|
}
|
||||||
else if( pos.entityHit.attackEntityFrom( dmgSrc, dmg ) )
|
else if( pos.entityHit.attackEntityFrom( dmgSrc, dmg ) )
|
||||||
{
|
{
|
||||||
hasDestroyed = pos.entityHit.isEntityAlive();
|
hasDestroyed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( pos.typeOfHit == RayTraceResult.Type.BLOCK )
|
else if( pos.typeOfHit == RayTraceResult.Type.BLOCK )
|
||||||
|
|||||||
+1
-1
@@ -296,7 +296,7 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
|||||||
// new craftables!
|
// new craftables!
|
||||||
for( final ICraftingPatternDetails details : this.craftingMethods.keySet() )
|
for( final ICraftingPatternDetails details : this.craftingMethods.keySet() )
|
||||||
{
|
{
|
||||||
for( IAEItemStack out : details.getOutputs() )
|
for( IAEItemStack out : details.getCondensedOutputs() )
|
||||||
{
|
{
|
||||||
out = out.copy();
|
out = out.copy();
|
||||||
out.reset();
|
out.reset();
|
||||||
|
|||||||
+62
-87
@@ -65,9 +65,11 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
{
|
{
|
||||||
|
|
||||||
private static final double MAX_BUFFER_STORAGE = 800;
|
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 percent1 = ( o1.getProviderStoredEnergy() + 1 ) / ( o1.getProviderMaxEnergy() + 1 );
|
||||||
final double percent2 = ( o2.getProviderStoredEnergy() + 1 ) / ( o2.getProviderMaxEnergy() + 1 );
|
final double percent2 = ( o2.getProviderStoredEnergy() + 1 ) / ( o2.getProviderMaxEnergy() + 1 );
|
||||||
|
|
||||||
@@ -161,33 +163,34 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
{
|
{
|
||||||
if( ev.storage.isAEPublicPowerStorage() )
|
if( ev.storage.isAEPublicPowerStorage() )
|
||||||
{
|
{
|
||||||
if( ev.type == PowerEventType.PROVIDE_POWER )
|
switch ( ev.type )
|
||||||
{
|
{
|
||||||
if( ev.storage.getPowerFlow() != AccessRestriction.WRITE )
|
case PROVIDE_POWER:
|
||||||
{
|
if( ev.storage.getPowerFlow() != AccessRestriction.WRITE )
|
||||||
if( !ongoingExtractOperation )
|
|
||||||
{
|
{
|
||||||
addProvider( ev.storage );
|
if( !ongoingExtractOperation )
|
||||||
|
{
|
||||||
|
addProvider( ev.storage );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.providersToAdd.add( ev.storage );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
break;
|
||||||
|
case REQUEST_POWER:
|
||||||
|
if( ev.storage.getPowerFlow() != AccessRestriction.READ )
|
||||||
{
|
{
|
||||||
this.providersToAdd.add( ev.storage );
|
if( !ongoingInjectOperation )
|
||||||
|
{
|
||||||
|
addRequester( ev.storage );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.requesterToAdd.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
|
else
|
||||||
@@ -228,7 +231,7 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
if( this.drainPerTick > 0.0001 )
|
if( this.drainPerTick > 0.0001 )
|
||||||
{
|
{
|
||||||
final double drained = this.extractAEPower( this.getIdlePowerUsage(), Actionable.MODULATE, PowerMultiplier.CONFIG );
|
final double drained = this.extractAEPower( this.getIdlePowerUsage(), Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||||
currentlyHasPower = drained >= this.drainPerTick - 0.001;
|
currentlyHasPower = drained >= this.drainPerTick - 0.001 && this.getStoredPower() > 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -334,55 +337,30 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
|
|
||||||
this.providers.addAll( providersToAdd );
|
this.providers.addAll( providersToAdd );
|
||||||
providersToAdd.clear();
|
providersToAdd.clear();
|
||||||
providers.removeIf( providerToRemove::contains );
|
|
||||||
this.providerToRemove.clear();
|
|
||||||
|
|
||||||
final Iterator<IAEPowerStorage> it = this.providers.iterator();
|
final Iterator<IAEPowerStorage> it = this.providers.iterator();
|
||||||
|
|
||||||
ongoingExtractOperation = true;
|
ongoingExtractOperation = true;
|
||||||
boolean ls = false;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
while ( extractedPower < amt && it.hasNext() )
|
while ( extractedPower < amt && it.hasNext() )
|
||||||
{
|
{
|
||||||
final IAEPowerStorage node = it.next();
|
final IAEPowerStorage node = it.next();
|
||||||
if( node != null )
|
|
||||||
{
|
|
||||||
if( node == localStorage && mode == Actionable.MODULATE )
|
|
||||||
{
|
|
||||||
ls = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
final double req = amt - extractedPower;
|
final double req = amt - extractedPower;
|
||||||
final double newPower = node.extractAEPower( req, mode, PowerMultiplier.ONE );
|
final double newPower = node.extractAEPower( req, mode, PowerMultiplier.ONE );
|
||||||
extractedPower += newPower;
|
extractedPower += newPower;
|
||||||
|
|
||||||
if( newPower < req && mode == Actionable.MODULATE )
|
if( newPower < req && mode == Actionable.MODULATE )
|
||||||
{
|
|
||||||
it.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally
|
} finally
|
||||||
{
|
{
|
||||||
|
providers.removeIf( p -> providerToRemove.contains( p ) );
|
||||||
|
this.providerToRemove.clear();
|
||||||
ongoingExtractOperation = false;
|
ongoingExtractOperation = false;
|
||||||
if( ls && extractedPower < amt )
|
|
||||||
{
|
|
||||||
final double req = amt - extractedPower;
|
|
||||||
final double newPower = localStorage.extractAEPower( req, mode, PowerMultiplier.ONE );
|
|
||||||
|
|
||||||
extractedPower += newPower;
|
|
||||||
|
|
||||||
if( newPower < req )
|
|
||||||
{
|
|
||||||
providers.remove( localStorage );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final double result = Math.min( extractedPower, amt );
|
final double result = Math.min( extractedPower, amt );
|
||||||
@@ -408,8 +386,6 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
|
|
||||||
this.requesters.addAll( requesterToAdd );
|
this.requesters.addAll( requesterToAdd );
|
||||||
requesterToAdd.clear();
|
requesterToAdd.clear();
|
||||||
requesters.removeIf( requesterToRemove::contains );
|
|
||||||
this.requesterToRemove.clear();
|
|
||||||
|
|
||||||
final Iterator<IAEPowerStorage> it = this.requesters.iterator();
|
final Iterator<IAEPowerStorage> it = this.requesters.iterator();
|
||||||
|
|
||||||
@@ -420,22 +396,17 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
{
|
{
|
||||||
final IAEPowerStorage node = it.next();
|
final IAEPowerStorage node = it.next();
|
||||||
|
|
||||||
if( node != null )
|
amt = node.injectAEPower( amt, mode );
|
||||||
{
|
|
||||||
amt = node.injectAEPower( amt, mode );
|
|
||||||
|
|
||||||
if( amt > 0 && mode == Actionable.MODULATE )
|
if( amt > 0 && mode == Actionable.MODULATE )
|
||||||
{
|
|
||||||
it.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally
|
} finally
|
||||||
{
|
{
|
||||||
|
requesters.removeIf( r -> requesterToRemove.contains( r ) );
|
||||||
|
this.requesterToRemove.clear();
|
||||||
ongoingInjectOperation = false;
|
ongoingInjectOperation = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -455,7 +426,7 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
double required = 0;
|
double required = 0;
|
||||||
|
|
||||||
final Iterator<IAEPowerStorage> it = this.requesters.iterator();
|
final Iterator<IAEPowerStorage> it = this.requesters.iterator();
|
||||||
while ( required < maxRequired && it.hasNext() )
|
while( required < maxRequired && it.hasNext() )
|
||||||
{
|
{
|
||||||
final IAEPowerStorage node = it.next();
|
final IAEPowerStorage node = it.next();
|
||||||
if( node.getPowerFlow() != AccessRestriction.READ )
|
if( node.getPowerFlow() != AccessRestriction.READ )
|
||||||
@@ -620,28 +591,28 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addRequester( IAEPowerStorage requester )
|
private void addRequester(IAEPowerStorage requester) {
|
||||||
{
|
Preconditions.checkState(!ongoingInjectOperation,
|
||||||
Preconditions.checkState( !ongoingInjectOperation, "Cannot modify energy requesters while energy is being injected." );
|
"Cannot modify energy requesters while energy is being injected.");
|
||||||
this.requesters.add( requester );
|
this.requesters.add(requester);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeRequester( IAEPowerStorage requester )
|
private void removeRequester(IAEPowerStorage requester) {
|
||||||
{
|
Preconditions.checkState(!ongoingInjectOperation,
|
||||||
Preconditions.checkState( !ongoingInjectOperation, "Cannot modify energy requesters while energy is being injected." );
|
"Cannot modify energy requesters while energy is being injected.");
|
||||||
this.requesters.remove( requester );
|
this.requesters.remove(requester);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addProvider( IAEPowerStorage provider )
|
private void addProvider(IAEPowerStorage provider) {
|
||||||
{
|
Preconditions.checkState(!ongoingExtractOperation,
|
||||||
Preconditions.checkState( !ongoingExtractOperation, "Cannot modify energy providers while energy is being extracted." );
|
"Cannot modify energy providers while energy is being extracted.");
|
||||||
this.providers.add( provider );
|
this.providers.add(provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeProvider( IAEPowerStorage provider )
|
private void removeProvider(IAEPowerStorage provider) {
|
||||||
{
|
Preconditions.checkState(!ongoingExtractOperation,
|
||||||
Preconditions.checkState( !ongoingExtractOperation, "Cannot modify energy providers while energy is being extracted." );
|
"Cannot modify energy providers while energy is being extracted.");
|
||||||
this.providers.remove( provider );
|
this.providers.remove(provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -817,9 +788,13 @@ public class EnergyGridCache implements IEnergyGrid
|
|||||||
|
|
||||||
if( this.stored < 0.01 )
|
if( this.stored < 0.01 )
|
||||||
{
|
{
|
||||||
EnergyGridCache.this.ticksSinceHasPowerChange = 0;
|
refreshPower();
|
||||||
EnergyGridCache.this.publicPowerState( false, EnergyGridCache.this.myGrid );
|
if (globalAvailablePower < MAX_BUFFER_STORAGE - 0.001)
|
||||||
|
{
|
||||||
|
EnergyGridCache.this.ticksSinceHasPowerChange = 0;
|
||||||
|
EnergyGridCache.this.publicPowerState( false, EnergyGridCache.this.myGrid );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -94,7 +94,7 @@ public class GridStorageCache implements IStorageGrid
|
|||||||
|
|
||||||
this.removeCellProvider( cc, tracker );
|
this.removeCellProvider( cc, tracker );
|
||||||
this.inactiveCellProviders.remove( cc );
|
this.inactiveCellProviders.remove( cc );
|
||||||
cellUpdate( null );
|
this.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||||
|
|
||||||
tracker.applyChanges();
|
tracker.applyChanges();
|
||||||
}
|
}
|
||||||
@@ -119,7 +119,7 @@ public class GridStorageCache implements IStorageGrid
|
|||||||
final ICellContainer cc = (ICellContainer) machine;
|
final ICellContainer cc = (ICellContainer) machine;
|
||||||
this.inactiveCellProviders.add( cc );
|
this.inactiveCellProviders.add( cc );
|
||||||
|
|
||||||
cellUpdate( null );
|
this.getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||||
|
|
||||||
if( node.isActive() )
|
if( node.isActive() )
|
||||||
{
|
{
|
||||||
@@ -170,7 +170,7 @@ public class GridStorageCache implements IStorageGrid
|
|||||||
|
|
||||||
private CellChangeTracker addCellProvider( final ICellProvider cc, final CellChangeTracker tracker )
|
private CellChangeTracker addCellProvider( final ICellProvider cc, final CellChangeTracker tracker )
|
||||||
{
|
{
|
||||||
if( this.inactiveCellProviders.contains( cc ) && !this.activeCellProviders.contains( cc ))
|
if( this.inactiveCellProviders.contains( cc ) )
|
||||||
{
|
{
|
||||||
this.inactiveCellProviders.remove( cc );
|
this.inactiveCellProviders.remove( cc );
|
||||||
this.activeCellProviders.add( cc );
|
this.activeCellProviders.add( cc );
|
||||||
|
|||||||
+63
-16
@@ -19,17 +19,21 @@
|
|||||||
package appeng.me.cache;
|
package appeng.me.cache;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Deque;
|
import java.util.Deque;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import javax.annotation.Nonnegative;
|
import javax.annotation.Nonnegative;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import appeng.api.AEApi;
|
||||||
|
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||||
|
import appeng.api.storage.channels.IItemStorageChannel;
|
||||||
|
import appeng.api.storage.data.IAEFluidStack;
|
||||||
|
import appeng.api.storage.data.IAEItemStack;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Queues;
|
import com.google.common.collect.Queues;
|
||||||
|
|
||||||
@@ -66,6 +70,8 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
|||||||
private boolean hasChanged = false;
|
private boolean hasChanged = false;
|
||||||
@Nonnegative
|
@Nonnegative
|
||||||
private int localDepthSemaphore = 0;
|
private int localDepthSemaphore = 0;
|
||||||
|
private long gridItemCount;
|
||||||
|
private long gridFluidCount;
|
||||||
|
|
||||||
public NetworkMonitor( final GridStorageCache cache, final IStorageChannel<T> chan )
|
public NetworkMonitor( final GridStorageCache cache, final IStorageChannel<T> chan )
|
||||||
{
|
{
|
||||||
@@ -137,6 +143,32 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
|||||||
return this.getHandler().getSlot();
|
return this.getHandler().getSlot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getGridCurrentCount()
|
||||||
|
{
|
||||||
|
if( myChannel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
|
||||||
|
{
|
||||||
|
return gridItemCount;
|
||||||
|
}
|
||||||
|
else if( myChannel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
|
||||||
|
{
|
||||||
|
return gridFluidCount;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long incGridCurrentCount(long count)
|
||||||
|
{
|
||||||
|
if( myChannel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
|
||||||
|
{
|
||||||
|
return gridItemCount += count;
|
||||||
|
}
|
||||||
|
else if( myChannel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
|
||||||
|
{
|
||||||
|
return gridFluidCount += count;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public IItemList<T> getStorageList()
|
public IItemList<T> getStorageList()
|
||||||
@@ -230,7 +262,7 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
|||||||
{
|
{
|
||||||
final Entry<IMEMonitorHandlerReceiver<T>, Object> o = i.next();
|
final Entry<IMEMonitorHandlerReceiver<T>, Object> o = i.next();
|
||||||
final IMEMonitorHandlerReceiver<T> receiver = o.getKey();
|
final IMEMonitorHandlerReceiver<T> receiver = o.getKey();
|
||||||
if( receiver.isValid( o.getValue() ) )
|
if( receiver.isValid( o.getValue() ) && receiver.hasListeners() )
|
||||||
{
|
{
|
||||||
receiver.postChange( this, diff, src );
|
receiver.postChange( this, diff, src );
|
||||||
}
|
}
|
||||||
@@ -258,9 +290,7 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
|||||||
|
|
||||||
this.sendEvent = true;
|
this.sendEvent = true;
|
||||||
|
|
||||||
this.notifyListenersOfChange( changes, src );
|
for ( final T changedItem : changes )
|
||||||
|
|
||||||
for( final T changedItem : changes )
|
|
||||||
{
|
{
|
||||||
T difference = changedItem;
|
T difference = changedItem;
|
||||||
|
|
||||||
@@ -270,25 +300,20 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
|||||||
difference.setStackSize( -changedItem.getStackSize() );
|
difference.setStackSize( -changedItem.getStackSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
incGridCurrentCount( difference.getStackSize() );
|
||||||
|
this.cachedList.add( difference );
|
||||||
|
|
||||||
if( this.myGridCache.getInterestManager().containsKey( changedItem ) )
|
if( this.myGridCache.getInterestManager().containsKey( changedItem ) )
|
||||||
{
|
{
|
||||||
final Collection<ItemWatcher> list = this.myGridCache.getInterestManager().get( changedItem );
|
final Collection<ItemWatcher> list = this.myGridCache.getInterestManager().get( changedItem );
|
||||||
|
|
||||||
if( !list.isEmpty() )
|
if( !list.isEmpty() )
|
||||||
{
|
{
|
||||||
IAEStack<T> fullStack = this.getStorageList().findPrecise( changedItem );
|
|
||||||
|
|
||||||
if( fullStack == null )
|
|
||||||
{
|
|
||||||
fullStack = changedItem.copy();
|
|
||||||
fullStack.setStackSize( 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
this.myGridCache.getInterestManager().enableTransactions();
|
this.myGridCache.getInterestManager().enableTransactions();
|
||||||
|
|
||||||
for( final ItemWatcher iw : list )
|
for( final ItemWatcher iw : list )
|
||||||
{
|
{
|
||||||
iw.getHost().onStackChange( this.getStorageList(), fullStack, difference, src, this.getChannel() );
|
iw.getHost().onStackChange( difference, this.getChannel() );
|
||||||
}
|
}
|
||||||
|
|
||||||
this.myGridCache.getInterestManager().disableTransactions();
|
this.myGridCache.getInterestManager().disableTransactions();
|
||||||
@@ -296,6 +321,8 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.notifyListenersOfChange( changes, src );
|
||||||
|
|
||||||
final NetworkMonitor<?> last = GLOBAL_DEPTH.pop();
|
final NetworkMonitor<?> last = GLOBAL_DEPTH.pop();
|
||||||
this.localDepthSemaphore--;
|
this.localDepthSemaphore--;
|
||||||
|
|
||||||
@@ -308,9 +335,28 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
|||||||
void forceUpdate()
|
void forceUpdate()
|
||||||
{
|
{
|
||||||
this.hasChanged = true;
|
this.hasChanged = true;
|
||||||
|
//when the grid comes back online, reset the count to 0 so
|
||||||
|
//it reflects the correct amount after the changes are accounted for
|
||||||
|
|
||||||
|
if( myChannel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
|
||||||
|
{
|
||||||
|
gridItemCount = 0;
|
||||||
|
for( IAEItemStack iaeItemStack : (Iterable<IAEItemStack>) getStorageList() )
|
||||||
|
{
|
||||||
|
gridItemCount += iaeItemStack.getStackSize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( myChannel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
|
||||||
|
{
|
||||||
|
gridFluidCount = 0;
|
||||||
|
for( IAEFluidStack iaeFluidStack : (Iterable<IAEFluidStack>) getStorageList() )
|
||||||
|
{
|
||||||
|
gridFluidCount += iaeFluidStack.getStackSize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final Iterator<Entry<IMEMonitorHandlerReceiver<T>, Object>> i = this.getListeners();
|
final Iterator<Entry<IMEMonitorHandlerReceiver<T>, Object>> i = this.getListeners();
|
||||||
while( i.hasNext() )
|
while ( i.hasNext() )
|
||||||
{
|
{
|
||||||
final Entry<IMEMonitorHandlerReceiver<T>, Object> o = i.next();
|
final Entry<IMEMonitorHandlerReceiver<T>, Object> o = i.next();
|
||||||
final IMEMonitorHandlerReceiver<T> receiver = o.getKey();
|
final IMEMonitorHandlerReceiver<T> receiver = o.getKey();
|
||||||
@@ -333,5 +379,6 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
|||||||
this.sendEvent = false;
|
this.sendEvent = false;
|
||||||
this.myGridCache.getGrid().postEvent( new MENetworkStorageEvent( this, this.myChannel ) );
|
this.myGridCache.getGrid().postEvent( new MENetworkStorageEvent( this, this.myChannel ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,7 +138,6 @@ public class TickManagerCache implements ITickManager
|
|||||||
tt.addEntityCrashInfo( crashreportcategory );
|
tt.addEntityCrashInfo( crashreportcategory );
|
||||||
throw new ReportedException( crashreport );
|
throw new ReportedException( crashreport );
|
||||||
}
|
}
|
||||||
PartLevelEmitter.wipeCache();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addToQueue( final TickTracker tt )
|
private void addToQueue( final TickTracker tt )
|
||||||
|
|||||||
@@ -23,9 +23,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.collect.Multimap;
|
import appeng.api.config.FuzzyMode;
|
||||||
|
|
||||||
import appeng.api.storage.data.IAEStack;
|
import appeng.api.storage.data.IAEStack;
|
||||||
|
import appeng.util.item.AEItemStack;
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
|
|
||||||
|
|
||||||
public class GenericInterestManager<T>
|
public class GenericInterestManager<T>
|
||||||
@@ -101,12 +102,30 @@ public class GenericInterestManager<T>
|
|||||||
|
|
||||||
public boolean containsKey( final IAEStack stack )
|
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 );
|
return this.container.containsKey( stack );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<T> get( final IAEStack stack )
|
public Collection<T> get( final IAEStack stack )
|
||||||
{
|
{
|
||||||
return this.container.get( 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SavedTransactions
|
private class SavedTransactions
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
|
|||||||
final IItemList<T> after = this.getInternal() == null ? this.getWrappedChannel().createList() : this.getInternal()
|
final IItemList<T> after = this.getInternal() == null ? this.getWrappedChannel().createList() : this.getInternal()
|
||||||
.getAvailableItems( new ItemListIgnoreCrafting( this.getWrappedChannel().createList() ) );
|
.getAvailableItems( new ItemListIgnoreCrafting( this.getWrappedChannel().createList() ) );
|
||||||
|
|
||||||
if( this.monitor != null && this.listeners.size() > 0 )
|
if( this.monitor != null )
|
||||||
{
|
{
|
||||||
this.monitor.addListener( this, this.monitor );
|
this.monitor.addListener( this, this.monitor );
|
||||||
}
|
}
|
||||||
@@ -90,6 +90,13 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
|
|||||||
@Override
|
@Override
|
||||||
public void addListener( final IMEMonitorHandlerReceiver<T> l, final Object verificationToken )
|
public void addListener( final IMEMonitorHandlerReceiver<T> l, final Object verificationToken )
|
||||||
{
|
{
|
||||||
|
if( this.listeners.size() == 0 )
|
||||||
|
{
|
||||||
|
if( this.monitor != null )
|
||||||
|
{
|
||||||
|
this.monitor.addListener( this, this.monitor );
|
||||||
|
}
|
||||||
|
}
|
||||||
this.listeners.put( l, verificationToken );
|
this.listeners.put( l, verificationToken );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,6 +124,12 @@ public class MEMonitorPassThrough<T extends IAEStack<T>> extends MEPassThrough<T
|
|||||||
return verificationToken == this.monitor;
|
return verificationToken == this.monitor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasListeners()
|
||||||
|
{
|
||||||
|
return this.listeners.size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postChange( final IBaseMonitor<T> monitor, final Iterable<T> change, final IActionSource source )
|
public void postChange( final IBaseMonitor<T> monitor, final Iterable<T> change, final IActionSource source )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -180,10 +180,7 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( inv.getStorageList().findPrecise( ais ) != null )
|
this.pushItemIntoTarget( destination, energy, inv, ais );
|
||||||
{
|
|
||||||
this.pushItemIntoTarget( destination, energy, inv, ais );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( this.itemToSend == before && this.isCraftingEnabled() )
|
if( this.itemToSend == before && this.isCraftingEnabled() )
|
||||||
|
|||||||
@@ -283,12 +283,12 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
|||||||
final ItemStack simResult;
|
final ItemStack simResult;
|
||||||
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||||
{
|
{
|
||||||
simResult = myAdaptor.simulateSimilarRemove( toSend, itemStackToImport, fzMode, null );
|
simResult = myAdaptor.simulateSimilarRemove( toSend, itemStackToImport, fzMode, this );
|
||||||
itemAmountNotStorable = inv.injectItems( AEItemStack.fromItemStack( simResult ), Actionable.SIMULATE, this.source );
|
itemAmountNotStorable = inv.injectItems( AEItemStack.fromItemStack( simResult ), Actionable.SIMULATE, this.source );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
simResult = myAdaptor.simulateRemove( toSend, itemStackToImport, null );
|
simResult = myAdaptor.simulateRemove( toSend, itemStackToImport, this );
|
||||||
itemAmountNotStorable = inv.injectItems( AEItemStack.fromItemStack( simResult ), Actionable.SIMULATE, this.source );
|
itemAmountNotStorable = inv.injectItems( AEItemStack.fromItemStack( simResult ), Actionable.SIMULATE, this.source );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,11 +19,17 @@
|
|||||||
package appeng.parts.automation;
|
package appeng.parts.automation;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import appeng.api.networking.events.*;
|
||||||
import appeng.me.Grid;
|
import appeng.me.Grid;
|
||||||
import appeng.me.GridNode;
|
import appeng.me.GridNode;
|
||||||
|
import appeng.me.cache.NetworkMonitor;
|
||||||
import appeng.util.item.AEItemStack;
|
import appeng.util.item.AEItemStack;
|
||||||
|
import appeng.util.item.OreHelper;
|
||||||
|
import appeng.util.item.OreReference;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2LongMap;
|
import it.unimi.dsi.fastutil.objects.Object2LongMap;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
@@ -56,10 +62,6 @@ import appeng.api.networking.crafting.ICraftingWatcherHost;
|
|||||||
import appeng.api.networking.energy.IEnergyGrid;
|
import appeng.api.networking.energy.IEnergyGrid;
|
||||||
import appeng.api.networking.energy.IEnergyWatcher;
|
import appeng.api.networking.energy.IEnergyWatcher;
|
||||||
import appeng.api.networking.energy.IEnergyWatcherHost;
|
import appeng.api.networking.energy.IEnergyWatcherHost;
|
||||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
|
||||||
import appeng.api.networking.events.MENetworkCraftingPatternChange;
|
|
||||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
|
||||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
|
||||||
import appeng.api.networking.security.IActionSource;
|
import appeng.api.networking.security.IActionSource;
|
||||||
import appeng.api.networking.storage.IBaseMonitor;
|
import appeng.api.networking.storage.IBaseMonitor;
|
||||||
import appeng.api.networking.storage.IStackWatcher;
|
import appeng.api.networking.storage.IStackWatcher;
|
||||||
@@ -72,7 +74,6 @@ import appeng.api.storage.IStorageChannel;
|
|||||||
import appeng.api.storage.channels.IItemStorageChannel;
|
import appeng.api.storage.channels.IItemStorageChannel;
|
||||||
import appeng.api.storage.data.IAEItemStack;
|
import appeng.api.storage.data.IAEItemStack;
|
||||||
import appeng.api.storage.data.IAEStack;
|
import appeng.api.storage.data.IAEStack;
|
||||||
import appeng.api.storage.data.IItemList;
|
|
||||||
import appeng.api.util.AECableType;
|
import appeng.api.util.AECableType;
|
||||||
import appeng.api.util.AEPartLocation;
|
import appeng.api.util.AEPartLocation;
|
||||||
import appeng.api.util.IConfigManager;
|
import appeng.api.util.IConfigManager;
|
||||||
@@ -123,9 +124,6 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
|||||||
private double centerX;
|
private double centerX;
|
||||||
private double centerY;
|
private double centerY;
|
||||||
private double centerZ;
|
private double centerZ;
|
||||||
static Object2LongMap<Grid> gridItemCount = new Object2LongOpenHashMap<>();
|
|
||||||
static Object2ObjectOpenHashMap<Grid, Object2LongMap<AEItemStack>> fuzzyAEItemStackCount = new Object2ObjectOpenHashMap<>();
|
|
||||||
static Object2ObjectOpenHashMap<Grid, Object2LongMap<AEItemStack>> preciseAEItemStackCount = new Object2ObjectOpenHashMap<>();
|
|
||||||
|
|
||||||
@Reflected
|
@Reflected
|
||||||
public PartLevelEmitter( final ItemStack is )
|
public PartLevelEmitter( final ItemStack is )
|
||||||
@@ -156,12 +154,6 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@MENetworkEventSubscribe
|
|
||||||
public void powerChanged( final MENetworkPowerStatusChange c )
|
|
||||||
{
|
|
||||||
this.updateState();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateState()
|
private void updateState()
|
||||||
{
|
{
|
||||||
final boolean isOn = this.isLevelEmitterOn();
|
final boolean isOn = this.isLevelEmitterOn();
|
||||||
@@ -206,9 +198,23 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
|||||||
return flipState ? this.reportingValue >= this.lastReportedValue + 1 : this.reportingValue < this.lastReportedValue + 1;
|
return flipState ? this.reportingValue >= this.lastReportedValue + 1 : this.reportingValue < this.lastReportedValue + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MENetworkEventSubscribe
|
||||||
|
public void powerStatusChange( final MENetworkPowerStatusChange powerEvent )
|
||||||
|
{
|
||||||
|
if (this.getProxy().isActive())
|
||||||
|
{
|
||||||
|
onListUpdate();
|
||||||
|
}
|
||||||
|
this.updateState();
|
||||||
|
}
|
||||||
|
|
||||||
@MENetworkEventSubscribe
|
@MENetworkEventSubscribe
|
||||||
public void channelChanged( final MENetworkChannelsChanged c )
|
public void channelChanged( final MENetworkChannelsChanged c )
|
||||||
{
|
{
|
||||||
|
if (this.getProxy().isActive())
|
||||||
|
{
|
||||||
|
onListUpdate();
|
||||||
|
}
|
||||||
this.updateState();
|
this.updateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,24 +302,37 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 || myStack == null )
|
|
||||||
|
if( myStack == null )
|
||||||
{
|
{
|
||||||
this.getProxy()
|
this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ).addListener( this, this.getProxy().getGrid() );
|
||||||
.getStorage()
|
|
||||||
.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
|
|
||||||
.addListener( this,
|
|
||||||
this.getProxy().getGrid() );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ).removeListener( this );
|
this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ).removeListener( this );
|
||||||
|
|
||||||
if( this.myWatcher != null )
|
if( this.myWatcher != null )
|
||||||
{
|
{
|
||||||
this.myWatcher.add( myStack );
|
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.updateReportingValue( this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) );
|
this.updateReportingValue( this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) );
|
||||||
}
|
}
|
||||||
catch( final GridAccessException e )
|
catch( final GridAccessException e )
|
||||||
@@ -323,90 +342,29 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateReportingValue( final IMEMonitor<IAEItemStack> monitor )
|
private void updateReportingValue( final IMEMonitor<IAEItemStack> monitor )
|
||||||
{
|
|
||||||
updateReportingValue( monitor,null );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateReportingValue( final IMEMonitor<IAEItemStack> monitor, Iterable<IAEItemStack> change )
|
|
||||||
{
|
{
|
||||||
final IAEItemStack myStack = this.config.getAEStackInSlot( 0 );
|
final IAEItemStack myStack = this.config.getAEStackInSlot( 0 );
|
||||||
|
|
||||||
GridNode node = (GridNode) (this.getGridNode());
|
if( myStack == null )
|
||||||
|
|
||||||
if( node != null )
|
|
||||||
{
|
{
|
||||||
|
if( monitor instanceof NetworkMonitor )
|
||||||
final Grid g = node.getInternalGrid();
|
|
||||||
|
|
||||||
if( myStack == null )
|
|
||||||
{
|
{
|
||||||
if( change != null )
|
this.lastReportedValue = ( (NetworkMonitor<IAEItemStack>) monitor ).getGridCurrentCount();
|
||||||
{
|
|
||||||
if( gridItemCount.containsKey( g ) )
|
|
||||||
{
|
|
||||||
change.forEach( iaeItemStack -> lastReportedValue += iaeItemStack.getStackSize() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
gridItemCount.computeIfAbsent( g, ( aLong ) -> {
|
|
||||||
this.lastReportedValue = 0;
|
|
||||||
monitor.getStorageList().forEach( iaeItemStack -> lastReportedValue += iaeItemStack.getStackSize() );
|
|
||||||
return ( lastReportedValue );
|
|
||||||
} );
|
|
||||||
this.lastReportedValue = gridItemCount.get( g );
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
else if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||||
{
|
{
|
||||||
final FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE );
|
final FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE );
|
||||||
if( change != null )
|
|
||||||
{
|
|
||||||
if( fuzzyAEItemStackCount.containsKey( g ) )
|
|
||||||
{
|
|
||||||
change.forEach( iaeItemStack -> {
|
|
||||||
if( iaeItemStack.sameOre( myStack ) ) lastReportedValue += iaeItemStack.getStackSize();
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fuzzyAEItemStackCount.computeIfAbsent( g, ( grid -> new Object2LongOpenHashMap<>() ) );
|
this.lastReportedValue = 0;
|
||||||
fuzzyAEItemStackCount.get( g ).computeIfAbsent( (AEItemStack) myStack, ( aLong -> {
|
monitor.getStorageList().findFuzzy( myStack, fzMode ).forEach( iaeItemStack -> lastReportedValue += iaeItemStack.getStackSize() );
|
||||||
this.lastReportedValue = 0;
|
}
|
||||||
monitor.getStorageList().findFuzzy( myStack, fzMode ).forEach( iaeItemStack -> lastReportedValue += iaeItemStack.getStackSize() );
|
else
|
||||||
return ( lastReportedValue );
|
{
|
||||||
} ) );
|
this.lastReportedValue = 0;
|
||||||
|
IAEItemStack precise = monitor.getStorageList().findPrecise( myStack );
|
||||||
this.lastReportedValue = fuzzyAEItemStackCount.get( g ).get( myStack );
|
if( precise != null ) lastReportedValue = precise.getStackSize();
|
||||||
if( this.lastReportedValue == 0 )
|
|
||||||
{
|
|
||||||
fuzzyAEItemStackCount.get( g ).remove( myStack );
|
|
||||||
fuzzyAEItemStackCount.trim();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( change != null )
|
|
||||||
{
|
|
||||||
if( preciseAEItemStackCount.containsKey( g ) )
|
|
||||||
{
|
|
||||||
change.forEach( iaeItemStack -> {
|
|
||||||
if( iaeItemStack.isSameType( myStack ) ) lastReportedValue += iaeItemStack.getStackSize();
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
preciseAEItemStackCount.computeIfAbsent( g, ( grid -> new Object2LongOpenHashMap<>() ) );
|
|
||||||
preciseAEItemStackCount.get( g ).computeIfAbsent( (AEItemStack) myStack, ( aLong -> {
|
|
||||||
this.lastReportedValue = 0;
|
|
||||||
IAEItemStack precise = monitor.getStorageList().findPrecise( myStack );
|
|
||||||
if( precise != null ) lastReportedValue = precise.getStackSize();
|
|
||||||
return ( lastReportedValue );
|
|
||||||
} ) );
|
|
||||||
this.lastReportedValue = preciseAEItemStackCount.get( g ).get( myStack );
|
|
||||||
if( this.lastReportedValue == 0 )
|
|
||||||
{
|
|
||||||
preciseAEItemStackCount.get( g ).remove( myStack );
|
|
||||||
preciseAEItemStackCount.trim();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.updateState();
|
this.updateState();
|
||||||
}
|
}
|
||||||
@@ -419,12 +377,23 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStackChange( final IItemList o, final IAEStack fullStack, final IAEStack diffStack, final IActionSource src, final IStorageChannel chan )
|
public void onStackChange( final IAEStack diffStack, final IStorageChannel chan )
|
||||||
{
|
{
|
||||||
if( chan == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) && fullStack.equals( this.config.getAEStackInSlot( 0 ) ) && this
|
if( chan == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
|
||||||
.getInstalledUpgrades( Upgrades.FUZZY ) == 0 )
|
|
||||||
{
|
{
|
||||||
this.lastReportedValue = fullStack.getStackSize();
|
IAEItemStack myStack = this.config.getAEStackInSlot( 0 );
|
||||||
|
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||||
|
{
|
||||||
|
final FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE );
|
||||||
|
if( Platform.itemComparisons().isFuzzyEqualItem( myStack.getDefinition(), ( (IAEItemStack) diffStack ).getDefinition(), fzMode ) )
|
||||||
|
{
|
||||||
|
this.lastReportedValue += diffStack.getStackSize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( diffStack.equals( myStack ) )
|
||||||
|
{
|
||||||
|
this.lastReportedValue += diffStack.getStackSize();
|
||||||
|
}
|
||||||
this.updateState();
|
this.updateState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -459,7 +428,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
|||||||
@Override
|
@Override
|
||||||
public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final IActionSource actionSource )
|
public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final IActionSource actionSource )
|
||||||
{
|
{
|
||||||
this.updateReportingValue( (IMEMonitor<IAEItemStack>) monitor, change );
|
this.updateReportingValue( (IMEMonitor<IAEItemStack>) monitor );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -636,9 +605,4 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void wipeCache(){
|
|
||||||
fuzzyAEItemStackCount.clear();
|
|
||||||
preciseAEItemStackCount.clear();
|
|
||||||
gridItemCount.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import appeng.api.storage.channels.IItemStorageChannel;
|
|||||||
import appeng.api.storage.data.IAEItemStack;
|
import appeng.api.storage.data.IAEItemStack;
|
||||||
import appeng.api.storage.data.IItemList;
|
import appeng.api.storage.data.IItemList;
|
||||||
import appeng.core.AELog;
|
import appeng.core.AELog;
|
||||||
import appeng.me.GridAccessException;
|
|
||||||
import appeng.me.helpers.IGridProxyable;
|
import appeng.me.helpers.IGridProxyable;
|
||||||
import appeng.me.storage.ITickingMonitor;
|
import appeng.me.storage.ITickingMonitor;
|
||||||
import appeng.util.inv.ItemHandlerIterator;
|
import appeng.util.inv.ItemHandlerIterator;
|
||||||
@@ -44,7 +43,6 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
|||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -83,6 +81,8 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
|||||||
stackCache = null;
|
stackCache = null;
|
||||||
|
|
||||||
ItemStack orgInput;
|
ItemStack orgInput;
|
||||||
|
int slotCount = this.itemHandler.getSlots();
|
||||||
|
|
||||||
if( currentCached != null && iox.isSameType( currentCached ) )
|
if( currentCached != null && iox.isSameType( currentCached ) )
|
||||||
{
|
{
|
||||||
// Cache is suitable, just update the count
|
// Cache is suitable, just update the count
|
||||||
@@ -94,10 +94,16 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
|||||||
// We need a new stack :-(
|
// We need a new stack :-(
|
||||||
orgInput = iox.createItemStack();
|
orgInput = iox.createItemStack();
|
||||||
}
|
}
|
||||||
ItemStack remaining = ItemHandlerHelper.insertItem( this.itemHandler, orgInput, type == Actionable.SIMULATE );
|
|
||||||
|
ItemStack remaining = orgInput;
|
||||||
|
|
||||||
|
for ( int i = 0; i < slotCount && !remaining.isEmpty(); i++ )
|
||||||
|
{
|
||||||
|
remaining = this.itemHandler.insertItem( i, remaining, type == Actionable.SIMULATE );
|
||||||
|
}
|
||||||
|
|
||||||
// Store the stack in the cache for next time.
|
// Store the stack in the cache for next time.
|
||||||
if (!remaining.isEmpty() && remaining != orgInput)
|
if( !remaining.isEmpty() && remaining != orgInput )
|
||||||
{
|
{
|
||||||
stackCache = remaining;
|
stackCache = remaining;
|
||||||
}
|
}
|
||||||
@@ -111,15 +117,9 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
|||||||
|
|
||||||
if( type == Actionable.MODULATE )
|
if( type == Actionable.MODULATE )
|
||||||
{
|
{
|
||||||
try
|
this.cache
|
||||||
{
|
.currentlyCached
|
||||||
this.proxyable.getProxy().getTick().alertDevice( this.proxyable.getProxy().getNode() );
|
.add( AEItemStack.fromItemStack( orgInput ).setStackSize( orgInput.getCount() - remaining.getCount() ) );
|
||||||
}
|
|
||||||
catch( GridAccessException ex )
|
|
||||||
{
|
|
||||||
// meh
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return AEItemStack.fromItemStack( remaining );
|
return AEItemStack.fromItemStack( remaining );
|
||||||
@@ -128,18 +128,17 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
|||||||
@Override
|
@Override
|
||||||
public IAEItemStack extractItems( IAEItemStack request, Actionable mode, IActionSource src )
|
public IAEItemStack extractItems( IAEItemStack request, Actionable mode, IActionSource src )
|
||||||
{
|
{
|
||||||
int remainingSize = Ints.saturatedCast(request.getStackSize());
|
int remainingSize = Ints.saturatedCast( request.getStackSize() );
|
||||||
|
|
||||||
// Use this to gather the requested items
|
// Use this to gather the requested items
|
||||||
ItemStack gathered = ItemStack.EMPTY;
|
ItemStack gathered = ItemStack.EMPTY;
|
||||||
|
|
||||||
final boolean simulate = ( mode == Actionable.SIMULATE );
|
final boolean simulate = ( mode == Actionable.SIMULATE );
|
||||||
|
for ( int i = 0; i < this.itemHandler.getSlots(); i++ )
|
||||||
for( int i = 0; i < this.itemHandler.getSlots(); i++ )
|
|
||||||
{
|
{
|
||||||
ItemStack stackInInventorySlot = this.itemHandler.getStackInSlot( i );
|
ItemStack stackInInventorySlot = this.itemHandler.getStackInSlot( i );
|
||||||
|
|
||||||
if (!request.isSameType(stackInInventorySlot))
|
if( !request.isSameType( stackInInventorySlot ) )
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -191,19 +190,17 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
|||||||
|
|
||||||
if( !gathered.isEmpty() )
|
if( !gathered.isEmpty() )
|
||||||
{
|
{
|
||||||
|
IAEItemStack gatheredAEItemStack = AEItemStack.fromItemStack( gathered );
|
||||||
if( mode == Actionable.MODULATE )
|
if( mode == Actionable.MODULATE )
|
||||||
{
|
{
|
||||||
try
|
IAEItemStack e = this.cache.currentlyCached.findPrecise( gatheredAEItemStack );
|
||||||
|
if (e != null)
|
||||||
{
|
{
|
||||||
this.proxyable.getProxy().getTick().alertDevice( this.proxyable.getProxy().getNode() );
|
e.decStackSize( gathered.getCount() );
|
||||||
}
|
|
||||||
catch( GridAccessException ex )
|
|
||||||
{
|
|
||||||
// meh
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return AEItemStack.fromItemStack( gathered );
|
return gatheredAEItemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -274,9 +271,10 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
|||||||
|
|
||||||
private static class InventoryCache implements Iterable<ItemSlot>
|
private static class InventoryCache implements Iterable<ItemSlot>
|
||||||
{
|
{
|
||||||
private IAEItemStack[] cachedAeStacks = new IAEItemStack[0];
|
|
||||||
private final IItemHandler itemHandler;
|
private final IItemHandler itemHandler;
|
||||||
private final StorageFilter mode;
|
private final StorageFilter mode;
|
||||||
|
IItemList<IAEItemStack> currentlyCached = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||||
|
|
||||||
|
|
||||||
public InventoryCache( IItemHandler itemHandler, StorageFilter mode )
|
public InventoryCache( IItemHandler itemHandler, StorageFilter mode )
|
||||||
{
|
{
|
||||||
@@ -286,7 +284,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
|||||||
|
|
||||||
public IItemList<IAEItemStack> getAvailableItems( IItemList<IAEItemStack> out )
|
public IItemList<IAEItemStack> getAvailableItems( IItemList<IAEItemStack> out )
|
||||||
{
|
{
|
||||||
Arrays.stream( this.cachedAeStacks ).forEach( out::add );
|
currentlyCached.iterator().forEachRemaining( out::add );
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,93 +296,41 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
|||||||
public List<IAEItemStack> update()
|
public List<IAEItemStack> update()
|
||||||
{
|
{
|
||||||
final List<IAEItemStack> changes = new ArrayList<>();
|
final List<IAEItemStack> changes = new ArrayList<>();
|
||||||
final int slots = this.itemHandler.getSlots();
|
|
||||||
|
|
||||||
// Make room for new slots
|
IItemList<IAEItemStack> currentlyOnStorage = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||||
if( slots > this.cachedAeStacks.length )
|
|
||||||
{
|
|
||||||
this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots );
|
|
||||||
}
|
|
||||||
|
|
||||||
for( final ItemSlot is : this )
|
for ( final ItemSlot is : this )
|
||||||
{
|
{
|
||||||
// Save the old stuff
|
|
||||||
final IAEItemStack oldAeIS = this.cachedAeStacks[is.getSlot()];
|
|
||||||
final ItemStack newIS = !is.isExtractable() && this.getMode() == StorageFilter.EXTRACTABLE_ONLY ? ItemStack.EMPTY : is.getItemStack();
|
final ItemStack newIS = !is.isExtractable() && this.getMode() == StorageFilter.EXTRACTABLE_ONLY ? ItemStack.EMPTY : is.getItemStack();
|
||||||
|
if( !newIS.isEmpty() )
|
||||||
this.handlePossibleSlotChanges( is.getSlot(), oldAeIS, newIS, changes );
|
|
||||||
}
|
|
||||||
// Handle cases where the number of slots actually is lower now than before
|
|
||||||
if( slots < this.cachedAeStacks.length )
|
|
||||||
{
|
|
||||||
for( int slot = slots; slot < this.cachedAeStacks.length; slot++ )
|
|
||||||
{
|
{
|
||||||
final IAEItemStack aeStack = this.cachedAeStacks[slot];
|
currentlyOnStorage.add( is.getAEItemStack() );
|
||||||
|
|
||||||
if( aeStack != null )
|
|
||||||
{
|
|
||||||
final IAEItemStack a = aeStack.copy();
|
|
||||||
a.setStackSize( -a.getStackSize() );
|
|
||||||
changes.add( a );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reduce the cache size
|
|
||||||
this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for ( final IAEItemStack is : currentlyCached )
|
||||||
|
{
|
||||||
|
is.setStackSize( -is.getStackSize() );
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( final IAEItemStack is : currentlyOnStorage )
|
||||||
|
{
|
||||||
|
currentlyCached.add( is );
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( final IAEItemStack is : currentlyCached )
|
||||||
|
{
|
||||||
|
if( is.getStackSize() != 0 )
|
||||||
|
{
|
||||||
|
changes.add( is );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
currentlyCached = currentlyOnStorage;
|
||||||
|
|
||||||
return changes;
|
return changes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handlePossibleSlotChanges( int slot, IAEItemStack oldAeIS, ItemStack newIS, List<IAEItemStack> changes )
|
|
||||||
{
|
|
||||||
if( oldAeIS != null && oldAeIS.isSameType( newIS ) )
|
|
||||||
{
|
|
||||||
this.handleStackSizeChanged( slot, oldAeIS, newIS, changes );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.handleItemChanged( slot, oldAeIS, newIS, changes );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleStackSizeChanged( int slot, IAEItemStack oldAeIS, ItemStack newIS, List<IAEItemStack> changes )
|
|
||||||
{
|
|
||||||
// Still the same item, but amount might have changed
|
|
||||||
final long diff = newIS.getCount() - oldAeIS.getStackSize();
|
|
||||||
|
|
||||||
if( diff != 0 )
|
|
||||||
{
|
|
||||||
final IAEItemStack stack = oldAeIS.copy();
|
|
||||||
stack.setStackSize( newIS.getCount() );
|
|
||||||
|
|
||||||
this.cachedAeStacks[slot] = stack;
|
|
||||||
|
|
||||||
final IAEItemStack a = stack.copy();
|
|
||||||
a.setStackSize( diff );
|
|
||||||
changes.add( a );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleItemChanged( int slot, IAEItemStack oldAeIS, ItemStack newIS, List<IAEItemStack> changes )
|
|
||||||
{
|
|
||||||
// Completely different item
|
|
||||||
this.cachedAeStacks[slot] = AEItemStack.fromItemStack( newIS );
|
|
||||||
|
|
||||||
// If we had a stack previously in this slot, notify the network about its disappearance
|
|
||||||
if( oldAeIS != null )
|
|
||||||
{
|
|
||||||
oldAeIS.setStackSize( -oldAeIS.getStackSize() );
|
|
||||||
changes.add( oldAeIS );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Notify the network about the new stack. Note that this is null if newIS was null
|
|
||||||
if( this.cachedAeStacks[slot] != null )
|
|
||||||
{
|
|
||||||
changes.add( this.cachedAeStacks[slot] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<ItemSlot> iterator()
|
public Iterator<ItemSlot> iterator()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import appeng.api.storage.channels.IItemStorageChannel;
|
|||||||
import appeng.api.storage.data.IAEItemStack;
|
import appeng.api.storage.data.IAEItemStack;
|
||||||
import appeng.api.storage.data.IItemList;
|
import appeng.api.storage.data.IItemList;
|
||||||
import appeng.core.AELog;
|
import appeng.core.AELog;
|
||||||
import appeng.me.GridAccessException;
|
|
||||||
import appeng.me.helpers.IGridProxyable;
|
import appeng.me.helpers.IGridProxyable;
|
||||||
import appeng.me.storage.ITickingMonitor;
|
import appeng.me.storage.ITickingMonitor;
|
||||||
import appeng.util.item.AEItemStack;
|
import appeng.util.item.AEItemStack;
|
||||||
@@ -24,7 +23,6 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,14 +83,9 @@ class ItemRepositoryAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<
|
|||||||
|
|
||||||
if( type == Actionable.MODULATE )
|
if( type == Actionable.MODULATE )
|
||||||
{
|
{
|
||||||
try
|
this.cache
|
||||||
{
|
.currentlyCached
|
||||||
this.proxyable.getProxy().getTick().alertDevice( this.proxyable.getProxy().getNode() );
|
.add( AEItemStack.fromItemStack( orgInput ).setStackSize( orgInput.getCount() - remaining.getCount() ) );
|
||||||
}
|
|
||||||
catch( GridAccessException ex )
|
|
||||||
{
|
|
||||||
// meh
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return AEItemStack.fromItemStack( remaining );
|
return AEItemStack.fromItemStack( remaining );
|
||||||
@@ -102,7 +95,7 @@ class ItemRepositoryAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<
|
|||||||
@Override
|
@Override
|
||||||
public IAEItemStack extractItems( IAEItemStack request, Actionable mode, IActionSource src )
|
public IAEItemStack extractItems( IAEItemStack request, Actionable mode, IActionSource src )
|
||||||
{
|
{
|
||||||
int remainingSize = Ints.saturatedCast(request.getStackSize());
|
int remainingSize = Ints.saturatedCast( request.getStackSize() );
|
||||||
|
|
||||||
final boolean simulate = ( mode == Actionable.SIMULATE );
|
final boolean simulate = ( mode == Actionable.SIMULATE );
|
||||||
|
|
||||||
@@ -112,25 +105,22 @@ class ItemRepositoryAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<
|
|||||||
{
|
{
|
||||||
// Something broke. It should never return more than we requested...
|
// Something broke. It should never return more than we requested...
|
||||||
// We're going to silently eat the remainder
|
// We're going to silently eat the remainder
|
||||||
AELog.warn( "Mod that provided item handler %s is broken. Returned %s items while only requesting %d.",
|
AELog.warn( "Mod that provided item handler %s is broken. Returned %s items while only requesting %d.", this.itemRepository.getClass().getName(), extracted.toString(), remainingSize );
|
||||||
this.itemRepository.getClass().getName(), extracted.toString(), remainingSize );
|
|
||||||
extracted.setCount( remainingSize );
|
extracted.setCount( remainingSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !extracted.isEmpty() )
|
if( !extracted.isEmpty() )
|
||||||
{
|
{
|
||||||
|
IAEItemStack extractedAEItemStack = AEItemStack.fromItemStack( extracted );
|
||||||
if( mode == Actionable.MODULATE )
|
if( mode == Actionable.MODULATE )
|
||||||
{
|
{
|
||||||
try
|
IAEItemStack e = this.cache.currentlyCached.findPrecise( extractedAEItemStack );
|
||||||
|
if (e != null)
|
||||||
{
|
{
|
||||||
this.proxyable.getProxy().getTick().alertDevice( this.proxyable.getProxy().getNode() );
|
e.decStackSize( extracted.getCount() );
|
||||||
}
|
|
||||||
catch( GridAccessException ex )
|
|
||||||
{
|
|
||||||
// meh
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return AEItemStack.fromItemStack( extracted );
|
return extractedAEItemStack;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -202,7 +192,7 @@ class ItemRepositoryAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<
|
|||||||
|
|
||||||
private static class InventoryCache
|
private static class InventoryCache
|
||||||
{
|
{
|
||||||
private IAEItemStack[] cachedAeStacks = new IAEItemStack[0];
|
private IItemList<IAEItemStack> currentlyCached = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||||
private final IItemRepository iItemRepository;
|
private final IItemRepository iItemRepository;
|
||||||
|
|
||||||
public InventoryCache( IItemRepository iItemRepository )
|
public InventoryCache( IItemRepository iItemRepository )
|
||||||
@@ -212,7 +202,7 @@ class ItemRepositoryAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<
|
|||||||
|
|
||||||
public IItemList<IAEItemStack> getAvailableItems( IItemList<IAEItemStack> out )
|
public IItemList<IAEItemStack> getAvailableItems( IItemList<IAEItemStack> out )
|
||||||
{
|
{
|
||||||
Arrays.stream( this.cachedAeStacks ).forEach( out::add );
|
currentlyCached.iterator().forEachRemaining( out::add );
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,95 +210,31 @@ class ItemRepositoryAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<
|
|||||||
{
|
{
|
||||||
final List<IAEItemStack> changes = new ArrayList<>();
|
final List<IAEItemStack> changes = new ArrayList<>();
|
||||||
|
|
||||||
List<IAEItemStack> out = this.iItemRepository.getAllItems().stream().map( s -> AEItemStack.fromItemStack( s.itemPrototype ).setStackSize( s.count ) ).collect( Collectors.toList() );
|
IItemList<IAEItemStack> currentlyOnStorage = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
|
||||||
|
this.iItemRepository.getAllItems().stream().map( s -> AEItemStack.fromItemStack( s.itemPrototype ).setStackSize( s.count ) ).forEach( currentlyOnStorage::add );
|
||||||
|
|
||||||
final int size = out.size();
|
for ( final IAEItemStack is : currentlyCached )
|
||||||
|
|
||||||
// Make room for new slots
|
|
||||||
if( size > this.cachedAeStacks.length )
|
|
||||||
{
|
{
|
||||||
this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, size );
|
is.setStackSize( -is.getStackSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( int x = 0; x < size; x++ )
|
for ( final IAEItemStack is : currentlyOnStorage )
|
||||||
{
|
{
|
||||||
// Save the old stuff
|
currentlyCached.add( is );
|
||||||
final IAEItemStack oldAeIS = this.cachedAeStacks[x];
|
|
||||||
final IAEItemStack newIS = out.get( x );
|
|
||||||
|
|
||||||
this.handlePossibleSlotChanges( x, oldAeIS, newIS, changes );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle cases where the number of slots actually is lower now than before
|
for ( final IAEItemStack is : currentlyCached )
|
||||||
if( size < this.cachedAeStacks.length )
|
|
||||||
{
|
{
|
||||||
for( int x = 0; x < this.cachedAeStacks.length; x++ )
|
if( is.getStackSize() != 0 )
|
||||||
{
|
{
|
||||||
final IAEItemStack aeStack = this.cachedAeStacks[x];
|
changes.add( is );
|
||||||
|
|
||||||
if( aeStack != null )
|
|
||||||
{
|
|
||||||
final IAEItemStack a = aeStack.copy();
|
|
||||||
a.setStackSize( -a.getStackSize() );
|
|
||||||
changes.add( a );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reduce the cache size
|
|
||||||
this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, size );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentlyCached = currentlyOnStorage;
|
||||||
|
|
||||||
return changes;
|
return changes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handlePossibleSlotChanges( int slot, IAEItemStack oldAeIS, IAEItemStack newIS, List<IAEItemStack> changes )
|
|
||||||
{
|
|
||||||
if( oldAeIS != null && oldAeIS.isSameType( newIS ) )
|
|
||||||
{
|
|
||||||
this.handleStackSizeChanged( slot, oldAeIS, newIS, changes );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.handleItemChanged( slot, oldAeIS, newIS, changes );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleStackSizeChanged( int slot, IAEItemStack oldAeIS, IAEItemStack newIS, List<IAEItemStack> changes )
|
|
||||||
{
|
|
||||||
// Still the same item, but amount might have changed
|
|
||||||
final long diff = newIS.getStackSize() - oldAeIS.getStackSize();
|
|
||||||
|
|
||||||
if( diff != 0 )
|
|
||||||
{
|
|
||||||
final IAEItemStack stack = oldAeIS.copy();
|
|
||||||
stack.setStackSize( newIS.getStackSize() );
|
|
||||||
|
|
||||||
this.cachedAeStacks[slot] = stack;
|
|
||||||
|
|
||||||
final IAEItemStack a = stack.copy();
|
|
||||||
a.setStackSize( diff );
|
|
||||||
changes.add( a );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleItemChanged( int slot, IAEItemStack oldAeIS, IAEItemStack newIS, List<IAEItemStack> changes )
|
|
||||||
{
|
|
||||||
// Completely different item
|
|
||||||
this.cachedAeStacks[slot] = newIS ;
|
|
||||||
|
|
||||||
// If we had a stack previously in this slot, notify the network about its disappearance
|
|
||||||
if( oldAeIS != null )
|
|
||||||
{
|
|
||||||
oldAeIS.setStackSize( -oldAeIS.getStackSize() );
|
|
||||||
changes.add( oldAeIS );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Notify the network about the new stack. Note that this is null if newIS was null
|
|
||||||
if( this.cachedAeStacks[slot] != null )
|
|
||||||
{
|
|
||||||
changes.add( this.cachedAeStacks[slot] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,12 +22,8 @@ package appeng.parts.misc;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import appeng.fluids.parts.PartFluidInterface;
|
|
||||||
import appeng.fluids.tile.TileFluidInterface;
|
|
||||||
import appeng.tile.networking.TileCableBus;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
|
||||||
@@ -157,24 +153,7 @@ public abstract class PartSharedStorageBus extends PartUpgradeable implements IG
|
|||||||
@Override
|
@Override
|
||||||
public void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor )
|
public void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor )
|
||||||
{
|
{
|
||||||
|
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 instanceof TileCableBus )
|
|
||||||
{
|
|
||||||
if( ( (TileCableBus) te ).getPart( this.getSide().getOpposite() ) instanceof PartFluidInterface )
|
|
||||||
{
|
|
||||||
this.resetCache( true );
|
|
||||||
this.resetCache();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if( te == null || te instanceof TileFluidInterface )
|
|
||||||
{
|
|
||||||
this.resetCache( true );
|
|
||||||
this.resetCache();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
this.resetCache( false );
|
this.resetCache( false );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,10 +23,6 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import appeng.api.networking.storage.IStorageGrid;
|
|
||||||
import appeng.me.cache.GridStorageCache;
|
|
||||||
import appeng.tile.misc.TileInterface;
|
|
||||||
import appeng.tile.networking.TileCableBus;
|
|
||||||
import com.jaquadro.minecraft.storagedrawers.api.capabilities.IItemRepository;
|
import com.jaquadro.minecraft.storagedrawers.api.capabilities.IItemRepository;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
@@ -238,7 +234,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
|||||||
{
|
{
|
||||||
this.resetCacheLogic = 2;
|
this.resetCacheLogic = 2;
|
||||||
}
|
}
|
||||||
else if( resetCacheLogic < 2 )
|
else
|
||||||
{
|
{
|
||||||
this.resetCacheLogic = 1;
|
this.resetCacheLogic = 1;
|
||||||
}
|
}
|
||||||
@@ -262,20 +258,17 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
|||||||
@Override
|
@Override
|
||||||
public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final IActionSource source )
|
public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final IActionSource source )
|
||||||
{
|
{
|
||||||
if( source == this.mySrc || source.machine().map( machine -> machine == this ).orElse( false ) )
|
try
|
||||||
{
|
{
|
||||||
try
|
if( this.getProxy().isActive() )
|
||||||
{
|
{
|
||||||
if( this.getProxy().isActive() )
|
this.getProxy().getStorage().postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ), change, this.mySrc );
|
||||||
{
|
|
||||||
this.getProxy().getStorage().postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ), change, this.mySrc );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch( final GridAccessException e )
|
|
||||||
{
|
|
||||||
// :(
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch( final GridAccessException e )
|
||||||
|
{
|
||||||
|
// :(
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -300,15 +293,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
|||||||
final TileEntity te = w.getTileEntity( neighbor );
|
final TileEntity te = w.getTileEntity( neighbor );
|
||||||
|
|
||||||
// In case the TE was destroyed, we have to do a full reset immediately.
|
// In case the TE was destroyed, we have to do a full reset immediately.
|
||||||
if( te instanceof TileCableBus )
|
if( te == null )
|
||||||
{
|
|
||||||
if( ( (TileCableBus) te ).getPart( this.getSide().getOpposite() ) instanceof PartInterface )
|
|
||||||
{
|
|
||||||
this.resetCache( true );
|
|
||||||
this.resetCache();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if( te == null || te instanceof TileInterface )
|
|
||||||
{
|
{
|
||||||
this.resetCache( true );
|
this.resetCache( true );
|
||||||
this.resetCache();
|
this.resetCache();
|
||||||
@@ -446,6 +431,16 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
|||||||
return Objects.hash( target, target.getCapability( Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide ) );
|
return Objects.hash( target, target.getCapability( Capabilities.STORAGE_MONITORABLE_ACCESSOR, targetSide ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ITEM_REPOSITORY_CAPABILITY != null && target.hasCapability( ITEM_REPOSITORY_CAPABILITY, targetSide ))
|
||||||
|
{
|
||||||
|
final IItemRepository handlerRepo = target.getCapability( ITEM_REPOSITORY_CAPABILITY, targetSide );
|
||||||
|
|
||||||
|
if( handlerRepo != null )
|
||||||
|
{
|
||||||
|
return Objects.hash( target, handlerRepo, handlerRepo.getAllItems().size() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final IItemHandler itemHandler = target.getCapability( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, targetSide );
|
final IItemHandler itemHandler = target.getCapability( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, targetSide );
|
||||||
|
|
||||||
if( itemHandler != null )
|
if( itemHandler != null )
|
||||||
@@ -559,7 +554,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// force grid to update handlers...
|
// force grid to update handlers...
|
||||||
(( GridStorageCache ) this.getProxy().getGrid().getCache( IStorageGrid.class )).cellUpdate( null );
|
this.getProxy().getGrid().postEvent( new MENetworkCellArrayUpdate() );
|
||||||
}
|
}
|
||||||
catch( final GridAccessException e )
|
catch( final GridAccessException e )
|
||||||
{
|
{
|
||||||
@@ -600,7 +595,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
|||||||
{
|
{
|
||||||
if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
|
if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
|
||||||
{
|
{
|
||||||
final IMEInventoryHandler<IAEItemStack> out = this.getProxy().isActive() ? this.getInternalHandler() : null;
|
final IMEInventoryHandler<IAEItemStack> out = this.getInternalHandler();
|
||||||
if( out != null )
|
if( out != null )
|
||||||
{
|
{
|
||||||
return Collections.singletonList( out );
|
return Collections.singletonList( out );
|
||||||
|
|||||||
@@ -21,10 +21,12 @@ package appeng.parts.reporting;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||||
|
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||||
|
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||||
import appeng.api.storage.data.IAEFluidStack;
|
import appeng.api.storage.data.IAEFluidStack;
|
||||||
import appeng.fluids.util.AEFluidStack;
|
import appeng.fluids.util.AEFluidStack;
|
||||||
import appeng.util.item.AEStack;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
@@ -43,7 +45,6 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||||||
|
|
||||||
import appeng.api.AEApi;
|
import appeng.api.AEApi;
|
||||||
import appeng.api.implementations.parts.IPartStorageMonitor;
|
import appeng.api.implementations.parts.IPartStorageMonitor;
|
||||||
import appeng.api.networking.security.IActionSource;
|
|
||||||
import appeng.api.networking.storage.IStackWatcher;
|
import appeng.api.networking.storage.IStackWatcher;
|
||||||
import appeng.api.networking.storage.IStackWatcherHost;
|
import appeng.api.networking.storage.IStackWatcherHost;
|
||||||
import appeng.api.parts.IPartModel;
|
import appeng.api.parts.IPartModel;
|
||||||
@@ -52,7 +53,6 @@ import appeng.api.storage.IStorageChannel;
|
|||||||
import appeng.api.storage.channels.IItemStorageChannel;
|
import appeng.api.storage.channels.IItemStorageChannel;
|
||||||
import appeng.api.storage.data.IAEItemStack;
|
import appeng.api.storage.data.IAEItemStack;
|
||||||
import appeng.api.storage.data.IAEStack;
|
import appeng.api.storage.data.IAEStack;
|
||||||
import appeng.api.storage.data.IItemList;
|
|
||||||
import appeng.client.render.TesrRenderHelper;
|
import appeng.client.render.TesrRenderHelper;
|
||||||
import appeng.core.localization.PlayerMessages;
|
import appeng.core.localization.PlayerMessages;
|
||||||
import appeng.helpers.Reflected;
|
import appeng.helpers.Reflected;
|
||||||
@@ -206,17 +206,10 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
|
|||||||
fluidInTank = fluidHandlerItem.drain( Integer.MAX_VALUE, false );
|
fluidInTank = fluidHandlerItem.drain( Integer.MAX_VALUE, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( fluidInTank == null )
|
if (fluidInTank == null)
|
||||||
{
|
{
|
||||||
this.configuredFluid = null;
|
this.configuredFluid = null;
|
||||||
if( !eq.isEmpty() )
|
this.configuredItem = AEItemStack.fromItemStack( eq );
|
||||||
{
|
|
||||||
this.configuredItem = AEItemStack.fromItemStack( eq ).setStackSize( 0 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.configuredItem = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if( fluidInTank.amount > 0 )
|
else if( fluidInTank.amount > 0 )
|
||||||
{
|
{
|
||||||
@@ -392,19 +385,87 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
|
|||||||
this.configureWatchers();
|
this.configureWatchers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MENetworkEventSubscribe
|
||||||
|
public void powerStatusChange( final MENetworkPowerStatusChange ev )
|
||||||
|
{
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@MENetworkEventSubscribe
|
||||||
|
public void channelChanged( final MENetworkChannelsChanged c )
|
||||||
|
{
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStackChange( final IItemList o, final IAEStack fullStack, final IAEStack diffStack, final IActionSource src, final IStorageChannel chan )
|
public void onStackChange( final IAEStack diffStack, final IStorageChannel chan )
|
||||||
{
|
{
|
||||||
if( this.configuredItem != null )
|
if( this.configuredItem != null )
|
||||||
{
|
{
|
||||||
if( fullStack == null )
|
long diff = this.configuredItem.getStackSize() + diffStack.getStackSize();
|
||||||
{
|
this.configuredItem.setStackSize( diff >= 0 ? this.configuredItem.getStackSize() + diffStack.getStackSize() : 0 );
|
||||||
this.configuredItem.setStackSize( 0 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.configuredItem.setStackSize( fullStack.getStackSize() );
|
|
||||||
}
|
|
||||||
|
|
||||||
final long stackSize = this.configuredItem.getStackSize();
|
final long stackSize = this.configuredItem.getStackSize();
|
||||||
final String humanReadableText = NUMBER_CONVERTER.toWideReadableForm( stackSize );
|
final String humanReadableText = NUMBER_CONVERTER.toWideReadableForm( stackSize );
|
||||||
@@ -417,14 +478,8 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
|
|||||||
}
|
}
|
||||||
else if( this.configuredFluid != null )
|
else if( this.configuredFluid != null )
|
||||||
{
|
{
|
||||||
if( fullStack == null )
|
long diff = this.configuredFluid.getStackSize() + diffStack.getStackSize();
|
||||||
{
|
this.configuredFluid.setStackSize( diff >= 0 ? this.configuredFluid.getStackSize() + diffStack.getStackSize() : 0 );
|
||||||
this.configuredFluid.setStackSize( 0 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.configuredFluid.setStackSize( fullStack.getStackSize() );
|
|
||||||
}
|
|
||||||
|
|
||||||
final long stackSize = this.configuredFluid.getStackSize() / 1000;
|
final long stackSize = this.configuredFluid.getStackSize() / 1000;
|
||||||
final String humanReadableText = NUMBER_CONVERTER.toWideReadableForm( stackSize ) + "B";
|
final String humanReadableText = NUMBER_CONVERTER.toWideReadableForm( stackSize ) + "B";
|
||||||
|
|||||||
@@ -170,7 +170,8 @@ public class PartConversionMonitor extends AbstractPartMonitor
|
|||||||
this.insertItem( player, hand, false );
|
this.insertItem( player, hand, false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.onPartActivate( player, hand, pos );
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( this.internalCurrentPower < 0.01 && amt > 0 )
|
if( this.internalCurrentPower < 0.01 && amt > 0.01 )
|
||||||
{
|
{
|
||||||
this.getProxy().getNode().getGrid().postEvent( new MENetworkPowerStorage( this, PowerEventType.PROVIDE_POWER ) );
|
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;
|
final boolean wasFull = this.internalCurrentPower >= this.getInternalMaxPower() - 0.001;
|
||||||
|
|
||||||
if( wasFull && amt > 0 )
|
if( wasFull && amt > 0.001 )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class OreReference
|
|||||||
return this.otherOptions;
|
return this.otherOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<IAEItemStack> getAEEquivalents()
|
public List<IAEItemStack> getAEEquivalents()
|
||||||
{
|
{
|
||||||
if( this.aeOtherOptions == null )
|
if( this.aeOtherOptions == null )
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user