Compare commits

...

7 Commits

11 changed files with 141 additions and 65 deletions
+1
View File
@@ -86,6 +86,7 @@ configurations {
dependencies {
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
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++ )
{
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;
}
@@ -299,7 +299,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
for( final OptionalSlotFake outputSlot : this.outputSlots )
{
final ItemStack out = outputSlot.getStack();
if( !out.isEmpty() && out.getCount() * multiple > 64 )
if( !out.isEmpty() && out.getCount() * multiple > out.getMaxStackSize() )
{
canMultiplyOutputs = false;
}
@@ -369,7 +369,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
for( int x = 0; x < this.craftingSlots.length; x++ )
{
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;
}
@@ -377,7 +377,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
for( final OptionalSlotFake outputSlot : this.outputSlots )
{
final ItemStack out = outputSlot.getStack();
if( !out.isEmpty() && out.getCount() + increase > 64 )
if( !out.isEmpty() && out.getCount() + increase > out.getMaxStackSize() )
{
canIncreaseOutputs = false;
}
@@ -450,11 +450,11 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
for( int x = 0; x < this.craftingSlots.length; x++ )
{
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;
}
@@ -463,9 +463,9 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
{
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;
}
@@ -237,22 +237,6 @@ public class PacketJEIRecipe extends AppEngPacket
// Fall back using an existing item
out = storage.extractItems( request, Actionable.SIMULATE, cct.getActionSource() );
}
if( out == null )
{
IItemList<IAEItemStack> items = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
Iterator<IAEItemStack> iterator = inv.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ).getAvailableItems( items ).iterator();
while ( iterator.hasNext() )
{
final IAEItemStack o = iterator.next();
if( o.getDefinition().isItemEqual( request.getDefinition() ) && o.isCraftable() )
{
out = o;
break;
}
iterator.remove();
}
}
}
if( out != null )
@@ -274,14 +258,14 @@ public class PacketJEIRecipe extends AppEngPacket
else
{
currentItem = ad.simulateSimilarRemove(recipe[x][y].getCount(), this.recipe[x][y],FuzzyMode.IGNORE_ALL, null );
if( currentItem.isEmpty() )
{
currentItem = this.recipe[x][y].copy();
}
}
}
}
}
if( currentItem.isEmpty() && this.recipe[x] != null)
{
currentItem = this.recipe[x][0].copy();
}
}
ItemHandlerUtil.setStackInSlot( craftMatrix, x, currentItem );
}
@@ -26,6 +26,9 @@ import java.util.Iterator;
import java.util.List;
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.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.IFluidTankProperties;
@@ -61,12 +64,18 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
private final IFluidHandler fluidHandler;
private final IGridProxyable proxyable;
private final FluidHandlerAdapter.InventoryCache cache;
private StorageFilter mode;
FluidHandlerAdapter( IFluidHandler fluidHandler, IGridProxyable proxy )
{
this.fluidHandler = fluidHandler;
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
@@ -195,9 +204,11 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
{
private IAEFluidStack[] cachedAeStacks = new IAEFluidStack[0];
private final IFluidHandler fluidHandler;
private final StorageFilter mode;
public InventoryCache( IFluidHandler fluidHandler )
public InventoryCache( IFluidHandler fluidHandler, StorageFilter mode )
{
this.mode = mode;
this.fluidHandler = fluidHandler;
}
@@ -217,8 +228,14 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
{
// Save the old stuff
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 );
}
@@ -33,6 +33,8 @@ import appeng.integration.modules.gregtech.GTCEInventoryAdaptor;
import appeng.util.*;
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.state.IBlockState;
import net.minecraft.init.Items;
@@ -48,6 +50,7 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.RangedWrapper;
@@ -109,6 +112,8 @@ import appeng.util.inv.IInventoryDestination;
import appeng.util.inv.InvOperation;
import appeng.util.item.AEItemStack;
import static gregtech.api.block.machines.BlockMachine.getMetaTileEntity;
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 Block directedBlock = directedBlockState.getBlock();
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
{
Vec3d from = new Vec3d( hostTile.getPos().getX() + 0.5, hostTile.getPos().getY() + 0.5, hostTile.getPos().getZ() + 0.5 );
+40 -25
View File
@@ -19,9 +19,9 @@
package appeng.me.cache;
import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.*;
import appeng.parts.automation.PartLevelEmitter;
import com.google.common.base.Preconditions;
import net.minecraft.crash.CrashReport;
@@ -46,6 +46,7 @@ public class TickManagerCache implements ITickManager
private final HashMap<IGridNode, TickTracker> alertable = new HashMap<>();
private final HashMap<IGridNode, TickTracker> sleeping = new HashMap<>();
private final HashMap<IGridNode, TickTracker> awake = new HashMap<>();
private final HashMap<IGridNode, TickTracker> laterTicker = new HashMap<>();
private final PriorityQueue<TickTracker> upcomingTicks = new PriorityQueue<>();
private long currentTick = 0;
@@ -86,7 +87,7 @@ public class TickManagerCache implements ITickManager
{
this.currentTick++;
while( !this.upcomingTicks.isEmpty() )
while ( !this.upcomingTicks.isEmpty() )
{
tt = this.upcomingTicks.peek();
@@ -99,36 +100,50 @@ public class TickManagerCache implements ITickManager
this.upcomingTicks.poll();
final int diff = (int) ( this.currentTick - tt.getLastTick() );
final TickRateModulation mod = tt.getGridTickable().tickingRequest( tt.getNode(), diff );
switch( mod )
if( tt.getGridTickable() instanceof PartLevelEmitter )
{
laterTicker.put( tt.getNode(), tt );
} else
{
case FASTER:
tt.setCurrentRate( tt.getCurrentRate() - 2 );
break;
case IDLE:
tt.setCurrentRate( tt.getRequest().maxTickRate );
break;
case SAME:
break;
case SLEEP:
this.sleepDevice( tt.getNode() );
break;
case SLOWER:
tt.setCurrentRate( tt.getCurrentRate() + 1 );
break;
case URGENT:
tt.setCurrentRate( 0 );
break;
default:
break;
}
final TickRateModulation mod = tt.getGridTickable().tickingRequest( tt.getNode(), diff );
switch ( mod )
{
case FASTER:
tt.setCurrentRate( tt.getCurrentRate() - 2 );
break;
case IDLE:
tt.setCurrentRate( tt.getRequest().maxTickRate );
break;
case SAME:
break;
case SLEEP:
this.sleepDevice( tt.getNode() );
break;
case SLOWER:
tt.setCurrentRate( tt.getCurrentRate() + 1 );
break;
case URGENT:
tt.setCurrentRate( 0 );
break;
default:
break;
}
}
if( this.awake.containsKey( tt.getNode() ) )
{
this.addToQueue( tt );
}
}
Iterator<Map.Entry<IGridNode, TickTracker>> ltIterator = laterTicker.entrySet().iterator();
while ( ltIterator.hasNext() )
{
Map.Entry<IGridNode, TickTracker> tickTracker = ltIterator.next();
tickTracker.getValue().getGridTickable().tickingRequest( tickTracker.getKey(), 1 );
ltIterator.remove();
}
}
catch( final Throwable t )
{
@@ -19,6 +19,7 @@
package appeng.me.storage;
import appeng.api.config.StorageFilter;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.ticking.TickRateModulation;
@@ -30,4 +31,8 @@ public interface ITickingMonitor
void setActionSource( IActionSource actionSource );
default void setMode( StorageFilter setting )
{
}
}
@@ -19,9 +19,15 @@
package appeng.parts.automation;
import javax.annotation.Nonnull;
import java.util.Collection;
import java.util.Random;
import appeng.api.networking.IGridNode;
import appeng.api.networking.ticking.IGridTickable;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
@@ -82,7 +88,7 @@ import appeng.util.Platform;
import appeng.util.inv.InvOperation;
public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherHost, IStackWatcherHost, ICraftingWatcherHost, IMEMonitorHandlerReceiver<IAEItemStack>, ICraftingProvider
public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherHost, IStackWatcherHost, ICraftingWatcherHost, IMEMonitorHandlerReceiver<IAEItemStack>, ICraftingProvider, IGridTickable
{
@PartModels
@@ -118,6 +124,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
private double centerX;
private double centerY;
private double centerZ;
private IBaseMonitor<IAEItemStack> changedMonitor;
@Reflected
public PartLevelEmitter( final ItemStack is )
@@ -400,7 +407,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
@Override
public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final IActionSource actionSource )
{
this.updateReportingValue( (IMEMonitor<IAEItemStack>) monitor );
this.changedMonitor = monitor;
}
@Override
@@ -576,4 +583,22 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
return this.isLevelEmitterOn() ? MODEL_ON_OFF : MODEL_OFF_OFF;
}
}
@Nonnull
@Override
public TickingRequest getTickingRequest( @Nonnull IGridNode node )
{
return new TickingRequest( 1,1,false,false );
}
@Nonnull
@Override
public TickRateModulation tickingRequest( @Nonnull IGridNode node, int ticksSinceLastCall )
{
if (this.changedMonitor != null)
{
this.updateReportingValue((IMEMonitor<IAEItemStack>) changedMonitor);
}
return TickRateModulation.URGENT;
}
}
@@ -26,6 +26,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import appeng.api.config.Settings;
import appeng.api.config.StorageFilter;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
@@ -57,12 +59,18 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
private final IItemHandler itemHandler;
private final IGridProxyable proxyable;
private final InventoryCache cache;
private StorageFilter mode;
ItemHandlerAdapter( IItemHandler itemHandler, IGridProxyable proxy )
{
this.itemHandler = itemHandler;
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
@@ -268,9 +276,11 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
{
private IAEItemStack[] cachedAeStacks = new IAEItemStack[0];
private final IItemHandler itemHandler;
private final StorageFilter mode;
public InventoryCache( IItemHandler itemHandler )
public InventoryCache( IItemHandler itemHandler, StorageFilter mode )
{
this.mode = mode;
this.itemHandler = itemHandler;
}
@@ -295,8 +305,14 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
{
// Save the old stuff
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 );
}
@@ -484,6 +484,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
{
this.monitor = (ITickingMonitor) inv;
this.monitor.setActionSource( new MachineSource( this ) );
this.monitor.setMode( (StorageFilter) this.getConfigManager().getSetting( Settings.STORAGE_FILTER ) );
}
if( inv != null )
@@ -197,7 +197,7 @@ public class AdaptorItemRepository extends InventoryAdaptor
@Override
public boolean hasSlots()
{
return false;
return true;
}
@Override