Compare commits

..

4 Commits

8 changed files with 70 additions and 18 deletions
+1
View File
@@ -86,6 +86,7 @@ configurations {
dependencies { dependencies {
deobfCompile "com.jaquadro.minecraft.storagedrawers:StorageDrawers:1.12.2-5.4.2:api" deobfCompile "com.jaquadro.minecraft.storagedrawers:StorageDrawers:1.12.2-5.4.2:api"
deobfCompile "gregtechce:gregtech:1.12.2:1.12.0.662"
// installable runtime dependencies // installable runtime dependencies
mods "mcp.mobius.waila:Hwyla:${hwyla_version}" mods "mcp.mobius.waila:Hwyla:${hwyla_version}"
@@ -291,7 +291,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
for( int x = 0; x < this.craftingSlots.length; x++ ) for( int x = 0; x < this.craftingSlots.length; x++ )
{ {
input[x] = this.craftingSlots[x].getStack(); input[x] = this.craftingSlots[x].getStack();
if( !input[x].isEmpty() && input[x].getCount() * multiple > 64 ) if( !input[x].isEmpty() && input[x].getCount() * multiple > input[x].getMaxStackSize() )
{ {
canMultiplyInputs = false; canMultiplyInputs = false;
} }
@@ -299,7 +299,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
for( final OptionalSlotFake outputSlot : this.outputSlots ) for( final OptionalSlotFake outputSlot : this.outputSlots )
{ {
final ItemStack out = outputSlot.getStack(); final ItemStack out = outputSlot.getStack();
if( !out.isEmpty() && out.getCount() * multiple > 64 ) if( !out.isEmpty() && out.getCount() * multiple > out.getMaxStackSize() )
{ {
canMultiplyOutputs = false; canMultiplyOutputs = false;
} }
@@ -369,7 +369,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
for( int x = 0; x < this.craftingSlots.length; x++ ) for( int x = 0; x < this.craftingSlots.length; x++ )
{ {
input[x] = this.craftingSlots[x].getStack(); input[x] = this.craftingSlots[x].getStack();
if( !input[x].isEmpty() && input[x].getCount() + increase > 64 ) if( !input[x].isEmpty() && input[x].getCount() + increase > input[x].getMaxStackSize() )
{ {
canIncreaseInputs = false; canIncreaseInputs = false;
} }
@@ -377,7 +377,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
for( final OptionalSlotFake outputSlot : this.outputSlots ) for( final OptionalSlotFake outputSlot : this.outputSlots )
{ {
final ItemStack out = outputSlot.getStack(); final ItemStack out = outputSlot.getStack();
if( !out.isEmpty() && out.getCount() + increase > 64 ) if( !out.isEmpty() && out.getCount() + increase > out.getMaxStackSize() )
{ {
canIncreaseOutputs = false; canIncreaseOutputs = false;
} }
@@ -450,11 +450,11 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
for( int x = 0; x < this.craftingSlots.length; x++ ) for( int x = 0; x < this.craftingSlots.length; x++ )
{ {
input[x] = this.craftingSlots[x].getStack(); input[x] = this.craftingSlots[x].getStack();
if( !input[x].isEmpty() && 64 - input[x].getCount() > maxInputStackGrowth ) if( !input[x].isEmpty() && input[x].getMaxStackSize() - input[x].getCount() > maxInputStackGrowth )
{ {
maxInputStackGrowth = 64 - input[x].getCount(); maxInputStackGrowth = input[x].getMaxStackSize() - input[x].getCount();
} }
if( !input[x].isEmpty() && input[x].getCount() + maxInputStackGrowth > 64 ) if( !input[x].isEmpty() && input[x].getCount() + maxInputStackGrowth > input[x].getMaxStackSize() )
{ {
canGrowInputs = false; canGrowInputs = false;
} }
@@ -463,9 +463,9 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
{ {
final ItemStack out = outputSlot.getStack(); final ItemStack out = outputSlot.getStack();
{ {
maxOutputStackGrowth = 64 - out.getCount(); maxOutputStackGrowth = out.getMaxStackSize() - out.getCount();
} }
if( !out.isEmpty() && out.getCount() + maxOutputStackGrowth > 64 ) if( !out.isEmpty() && out.getCount() + maxOutputStackGrowth > out.getMaxStackSize() )
{ {
canGrowOutputs = false; canGrowOutputs = false;
} }
@@ -26,6 +26,9 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import appeng.api.config.Settings;
import appeng.api.config.StorageFilter;
import appeng.parts.misc.PartStorageBus;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.IFluidTankProperties; import net.minecraftforge.fluids.capability.IFluidTankProperties;
@@ -61,12 +64,18 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
private final IFluidHandler fluidHandler; private final IFluidHandler fluidHandler;
private final IGridProxyable proxyable; private final IGridProxyable proxyable;
private final FluidHandlerAdapter.InventoryCache cache; private final FluidHandlerAdapter.InventoryCache cache;
private StorageFilter mode;
FluidHandlerAdapter( IFluidHandler fluidHandler, IGridProxyable proxy ) FluidHandlerAdapter( IFluidHandler fluidHandler, IGridProxyable proxy )
{ {
this.fluidHandler = fluidHandler; this.fluidHandler = fluidHandler;
this.proxyable = proxy; this.proxyable = proxy;
this.cache = new FluidHandlerAdapter.InventoryCache( this.fluidHandler ); if( this.proxyable instanceof PartStorageBus )
{
PartStorageBus partStorageBus = (PartStorageBus) this.proxyable;
this.mode = ( (StorageFilter) partStorageBus.getConfigManager().getSetting( Settings.STORAGE_FILTER ) );
}
this.cache = new FluidHandlerAdapter.InventoryCache( this.fluidHandler, this.mode);
} }
@Override @Override
@@ -195,9 +204,11 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
{ {
private IAEFluidStack[] cachedAeStacks = new IAEFluidStack[0]; private IAEFluidStack[] cachedAeStacks = new IAEFluidStack[0];
private final IFluidHandler fluidHandler; private final IFluidHandler fluidHandler;
private final StorageFilter mode;
public InventoryCache( IFluidHandler fluidHandler ) public InventoryCache( IFluidHandler fluidHandler, StorageFilter mode )
{ {
this.mode = mode;
this.fluidHandler = fluidHandler; this.fluidHandler = fluidHandler;
} }
@@ -217,8 +228,14 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
{ {
// Save the old stuff // Save the old stuff
final IAEFluidStack oldAEFS = this.cachedAeStacks[slot]; final IAEFluidStack oldAEFS = this.cachedAeStacks[slot];
final FluidStack newFS = tankProperties[slot].getContents(); FluidStack newFS = tankProperties[slot].getContents();
if( this.mode == StorageFilter.EXTRACTABLE_ONLY && newFS != null )
{
if( this.fluidHandler.drain( 1, false ) == null )
{
newFS = null;
}
}
this.handlePossibleSlotChanges( slot, oldAEFS, newFS, changes ); this.handlePossibleSlotChanges( slot, oldAEFS, newFS, changes );
} }
@@ -33,6 +33,8 @@ import appeng.integration.modules.gregtech.GTCEInventoryAdaptor;
import appeng.util.*; import appeng.util.*;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import gregtech.api.block.machines.BlockMachine;
import gregtech.api.metatileentity.MetaTileEntity;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Items; import net.minecraft.init.Items;
@@ -48,6 +50,7 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.RangedWrapper; import net.minecraftforge.items.wrapper.RangedWrapper;
@@ -109,6 +112,8 @@ import appeng.util.inv.IInventoryDestination;
import appeng.util.inv.InvOperation; import appeng.util.inv.InvOperation;
import appeng.util.item.AEItemStack; import appeng.util.item.AEItemStack;
import static gregtech.api.block.machines.BlockMachine.getMetaTileEntity;
public class DualityInterface implements IGridTickable, IStorageMonitorable, IInventoryDestination, IAEAppEngInventory, IConfigManagerHost, ICraftingProvider, IUpgradeableHost public class DualityInterface implements IGridTickable, IStorageMonitorable, IInventoryDestination, IAEAppEngInventory, IConfigManagerHost, ICraftingProvider, IUpgradeableHost
{ {
@@ -1235,6 +1240,13 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
final IBlockState directedBlockState = hostWorld.getBlockState( targ ); final IBlockState directedBlockState = hostWorld.getBlockState( targ );
final Block directedBlock = directedBlockState.getBlock(); final Block directedBlock = directedBlockState.getBlock();
ItemStack what = new ItemStack( directedBlock, 1, directedBlock.getMetaFromState( directedBlockState ) ); ItemStack what = new ItemStack( directedBlock, 1, directedBlock.getMetaFromState( directedBlockState ) );
if ( Loader.isModLoaded("gregtech") && directedBlock instanceof BlockMachine )
{
MetaTileEntity metaTileEntity = getMetaTileEntity(hostWorld, targ);
return metaTileEntity.getMetaFullName();
}
try try
{ {
Vec3d from = new Vec3d( hostTile.getPos().getX() + 0.5, hostTile.getPos().getY() + 0.5, hostTile.getPos().getZ() + 0.5 ); Vec3d from = new Vec3d( hostTile.getPos().getX() + 0.5, hostTile.getPos().getY() + 0.5, hostTile.getPos().getZ() + 0.5 );
@@ -19,6 +19,7 @@
package appeng.me.storage; package appeng.me.storage;
import appeng.api.config.StorageFilter;
import appeng.api.networking.security.IActionSource; import appeng.api.networking.security.IActionSource;
import appeng.api.networking.ticking.TickRateModulation; import appeng.api.networking.ticking.TickRateModulation;
@@ -30,4 +31,8 @@ public interface ITickingMonitor
void setActionSource( IActionSource actionSource ); void setActionSource( IActionSource actionSource );
default void setMode( StorageFilter setting )
{
}
} }
@@ -26,6 +26,8 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import appeng.api.config.Settings;
import appeng.api.config.StorageFilter;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
@@ -57,12 +59,18 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
private final IItemHandler itemHandler; private final IItemHandler itemHandler;
private final IGridProxyable proxyable; private final IGridProxyable proxyable;
private final InventoryCache cache; private final InventoryCache cache;
private StorageFilter mode;
ItemHandlerAdapter( IItemHandler itemHandler, IGridProxyable proxy ) ItemHandlerAdapter( IItemHandler itemHandler, IGridProxyable proxy )
{ {
this.itemHandler = itemHandler; this.itemHandler = itemHandler;
this.proxyable = proxy; this.proxyable = proxy;
this.cache = new InventoryCache( this.itemHandler ); if( this.proxyable instanceof PartStorageBus )
{
PartStorageBus partStorageBus = (PartStorageBus) this.proxyable;
this.mode = ( (StorageFilter) partStorageBus.getConfigManager().getSetting( Settings.STORAGE_FILTER ) );
}
this.cache = new InventoryCache( this.itemHandler, this.mode );
} }
@Override @Override
@@ -268,9 +276,11 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
{ {
private IAEItemStack[] cachedAeStacks = new IAEItemStack[0]; private IAEItemStack[] cachedAeStacks = new IAEItemStack[0];
private final IItemHandler itemHandler; private final IItemHandler itemHandler;
private final StorageFilter mode;
public InventoryCache( IItemHandler itemHandler ) public InventoryCache( IItemHandler itemHandler, StorageFilter mode )
{ {
this.mode = mode;
this.itemHandler = itemHandler; this.itemHandler = itemHandler;
} }
@@ -295,8 +305,14 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
{ {
// Save the old stuff // Save the old stuff
final IAEItemStack oldAeIS = this.cachedAeStacks[slot]; final IAEItemStack oldAeIS = this.cachedAeStacks[slot];
final ItemStack newIS = this.itemHandler.getStackInSlot( slot ); ItemStack newIS = this.itemHandler.getStackInSlot( slot );
if( this.mode == StorageFilter.EXTRACTABLE_ONLY && !newIS.isEmpty() )
{
if( this.itemHandler.extractItem( slot, 1, true ).isEmpty() )
{
newIS = ItemStack.EMPTY;
}
}
this.handlePossibleSlotChanges( slot, oldAeIS, newIS, changes ); this.handlePossibleSlotChanges( slot, oldAeIS, newIS, changes );
} }
@@ -484,6 +484,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
{ {
this.monitor = (ITickingMonitor) inv; this.monitor = (ITickingMonitor) inv;
this.monitor.setActionSource( new MachineSource( this ) ); this.monitor.setActionSource( new MachineSource( this ) );
this.monitor.setMode( (StorageFilter) this.getConfigManager().getSetting( Settings.STORAGE_FILTER ) );
} }
if( inv != null ) if( inv != null )
@@ -197,7 +197,7 @@ public class AdaptorItemRepository extends InventoryAdaptor
@Override @Override
public boolean hasSlots() public boolean hasSlots()
{ {
return false; return true;
} }
@Override @Override