Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 33946438bd | |||
| 9372cb2f14 | |||
| 00037ace77 | |||
| e13af643ba | |||
| ffcfd809d8 | |||
| 7c10a6b883 | |||
| c2bddc30c4 | |||
| 024655f84d | |||
| 589e48ac01 | |||
| 43d3a2c1c0 | |||
| c432fa7200 | |||
| cc744ab8b9 | |||
| 8fe4229a8e | |||
| 3f86884965 | |||
| 1319ec79c9 | |||
| 31a3afc18b | |||
| 9d6026635d | |||
| 39038ac935 | |||
| 4f627b234c | |||
| 6180c188e6 | |||
| 7ada6d18ee | |||
| f493767243 | |||
| ba4cdbcb85 | |||
| f3877aa1ec | |||
| 366b31b3aa | |||
| 533fb5c34b | |||
| 62d1d904c6 | |||
| 03fb43db16 | |||
| 9576bec855 | |||
| b5da6730a1 | |||
| 039bab4811 | |||
| 4b5bdf9893 |
+47
@@ -0,0 +1,47 @@
|
|||||||
|
Changes so far :
|
||||||
|
|
||||||
|
Design changes/breakages:
|
||||||
|
- Interfaces no longer spill items of one pattern on other faces
|
||||||
|
- Interfaces now push patterns in round-robin (Interfaces, then sides)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Fixes:
|
||||||
|
|
||||||
|
- Fix gregtech machines appearing with 'unnamed' or 'draconium lens' on the interface terminal on specific situations.
|
||||||
|
- Add memorycard support for fluid interfaces, import/export/storage busses and level emitters ( this fix was upstreamed to AE2 for MC 1.16)
|
||||||
|
- Storage busses now hide/show inaccessible items as configured.
|
||||||
|
- Exclusive Blocking mode for GTCE ( shapes, molds and configured circuits do not block GTCE machines )
|
||||||
|
- Blocking modes default to block on any item in the iventory the entity exposes
|
||||||
|
- Fuzzy includes items that report that they're damageable, but report a maxDamage of 0 ( auto-crafting of basic capacitors -> resonant capacitors is now possible ) <- Broken item implementation.
|
||||||
|
|
||||||
|
Performance:
|
||||||
|
|
||||||
|
- Added @talchas fixes for insane channelless AE networks.
|
||||||
|
- Implemented StorageDrawers slotless itemrepository.
|
||||||
|
- Removed CraftedEvent calls (really bad lag with craftweaker versions before CraftTweaker2-1.12-4.1.20.626)
|
||||||
|
- Count items set in interfaces before queuing crafting for them needlessly
|
||||||
|
- Backported b7ca98d ( Avoid copying items on simulated item extraction )
|
||||||
|
- Cache some level emitters functions
|
||||||
|
|
||||||
|
QOL:
|
||||||
|
|
||||||
|
- added highlight interface button to interface terminal ("?" button on the left of the interface slots)
|
||||||
|
- Added bar on the interface terminal that search by inputs ( The one on the LEFT, also searchs by interface name )
|
||||||
|
- Shortcut to molecular assemblers with free slots on the terminal interface by @Theisyat
|
||||||
|
- Toggle button on interface terminal to hide full interfaces
|
||||||
|
- JEI "U""R" and "A" (Usages/Recipes/Bookmark) now work on the Crafting Status GUI. ( the one that shows the total items to craft, and whats missing)
|
||||||
|
- Patterns can now be made with items currently showing on JEI. ( This is overriden by Just Enough Energistics. )
|
||||||
|
- Added multiplier buttons to processing pattern gui
|
||||||
|
- Switched crafting terminal JEI search to fuzzy mode. If the recipe uses a damageable item, AE will try to grab it ( damaged tools )
|
||||||
|
- Encoded patterns stack up to 64 ( holding shift and clicking the encode arrow will transfer the encoded pattern to the player inventory)
|
||||||
|
- Encoded patterns can be draggred on the interface terminal.
|
||||||
|
- Storage Monitor and Conversion Monitor now also ccepts fluids
|
||||||
|
- Draggable JEI ghost items (also works on bookmarked items. SHIFT + Click will move the hovered item into the first free target slot)
|
||||||
|
-JEI auto switches between crafting and processing patterns
|
||||||
|
|
||||||
|
HOTKEYS:
|
||||||
|
|
||||||
|
- Implemented mousetweaks API. AE2 custom keybinds now work. (Try right clicking and use the scroll-wheel on the terminals)
|
||||||
|
- Holding SHIFT and scrolling UP and DOWN will increase the items set on the configured slots of Interfaces and Pattern Terminal (Processing mode)
|
||||||
@@ -19,11 +19,6 @@
|
|||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
|
|
||||||
maven {
|
|
||||||
name = "storagedrawers"
|
|
||||||
url = "https://dl.bintray.com/jaquadro/dev/"
|
|
||||||
}
|
|
||||||
|
|
||||||
maven {
|
maven {
|
||||||
name "Mobius"
|
name "Mobius"
|
||||||
url "http://mobiusstrip.eu/maven"
|
url "http://mobiusstrip.eu/maven"
|
||||||
@@ -39,6 +34,11 @@ repositories {
|
|||||||
url "http://maven.mcmoddev.com"
|
url "http://maven.mcmoddev.com"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maven {
|
||||||
|
name "Ellpeck"
|
||||||
|
url "https://maven.ellpeck.de"
|
||||||
|
}
|
||||||
|
|
||||||
maven {
|
maven {
|
||||||
name = "IC2 repo"
|
name = "IC2 repo"
|
||||||
url = "http://maven.ic2.player.to"
|
url = "http://maven.ic2.player.to"
|
||||||
@@ -59,11 +59,6 @@ repositories {
|
|||||||
url "http://maven.k-4u.nl/"
|
url "http://maven.k-4u.nl/"
|
||||||
}
|
}
|
||||||
|
|
||||||
maven { // Hwyla
|
|
||||||
name 'tehnut'
|
|
||||||
url "http://tehnut.info/maven"
|
|
||||||
}
|
|
||||||
|
|
||||||
maven { // CraftTweaker
|
maven { // CraftTweaker
|
||||||
name 'jared maven'
|
name 'jared maven'
|
||||||
url "http://maven.blamejared.com/"
|
url "http://maven.blamejared.com/"
|
||||||
@@ -102,6 +97,7 @@ dependencies {
|
|||||||
compileOnly "CraftTweaker2:CraftTweaker2-API:${crafttweaker_version}"
|
compileOnly "CraftTweaker2:CraftTweaker2-API:${crafttweaker_version}"
|
||||||
compileOnly "inventory-tweaks:InventoryTweaks:${inventorytweaks_version}:api"
|
compileOnly "inventory-tweaks:InventoryTweaks:${inventorytweaks_version}:api"
|
||||||
compileOnly "team.chisel.ctm:CTM:${ctm_version}"
|
compileOnly "team.chisel.ctm:CTM:${ctm_version}"
|
||||||
|
compileOnly "de.ellpeck.actuallyadditions:ActuallyAdditions:1.12.2-r152.16:api"
|
||||||
|
|
||||||
// at runtime, use the full JEI jar
|
// at runtime, use the full JEI jar
|
||||||
runtime "mezz.jei:jei_${minecraft_version}:${jei_version}"
|
runtime "mezz.jei:jei_${minecraft_version}:${jei_version}"
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import java.util.*;
|
|||||||
import appeng.api.config.ActionItems;
|
import appeng.api.config.ActionItems;
|
||||||
import appeng.api.config.Settings;
|
import appeng.api.config.Settings;
|
||||||
import appeng.client.gui.widgets.GuiImgButton;
|
import appeng.client.gui.widgets.GuiImgButton;
|
||||||
|
import appeng.core.worlddata.IWorldPlayerMapping;
|
||||||
import appeng.util.BlockPosUtils;
|
import appeng.util.BlockPosUtils;
|
||||||
import com.google.common.collect.HashMultimap;
|
import com.google.common.collect.HashMultimap;
|
||||||
|
|
||||||
@@ -49,6 +50,7 @@ import appeng.util.Platform;
|
|||||||
import net.minecraft.nbt.NBTUtil;
|
import net.minecraft.nbt.NBTUtil;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.text.TextComponentString;
|
import net.minecraft.util.text.TextComponentString;
|
||||||
|
import net.minecraftforge.common.DimensionManager;
|
||||||
import org.lwjgl.input.Mouse;
|
import org.lwjgl.input.Mouse;
|
||||||
|
|
||||||
|
|
||||||
@@ -79,6 +81,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
|||||||
private PartInterfaceTerminal partInterfaceTerminal;
|
private PartInterfaceTerminal partInterfaceTerminal;
|
||||||
private GuiButton guiButtonHide;
|
private GuiButton guiButtonHide;
|
||||||
private GuiButton guiButtonNextAssembler;
|
private GuiButton guiButtonNextAssembler;
|
||||||
|
private HashMap<ClientDCInternalInv,Integer> dimHashMap = new HashMap<>();
|
||||||
|
|
||||||
public GuiInterfaceTerminal( final InventoryPlayer inventoryPlayer, final PartInterfaceTerminal te )
|
public GuiInterfaceTerminal( final InventoryPlayer inventoryPlayer, final PartInterfaceTerminal te )
|
||||||
{
|
{
|
||||||
@@ -217,9 +220,17 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
|||||||
{
|
{
|
||||||
BlockPos blockPos = blockPosHashMap.get( guiButtonHashMap.get( this.selectedButton ) );
|
BlockPos blockPos = blockPosHashMap.get( guiButtonHashMap.get( this.selectedButton ) );
|
||||||
BlockPos blockPos2 = mc.player.getPosition();
|
BlockPos blockPos2 = mc.player.getPosition();
|
||||||
int dimension = mc.world.provider.getDimension();
|
int playerDim = mc.world.provider.getDimension();
|
||||||
hilightBlock( blockPos, System.currentTimeMillis() + 500 * BlockPosUtils.getDistance(blockPos, blockPos2), dimension );
|
int interfaceDim = dimHashMap.get( guiButtonHashMap.get( this.selectedButton ) );
|
||||||
|
if( playerDim != interfaceDim )
|
||||||
|
{
|
||||||
|
mc.player.sendStatusMessage( new TextComponentString( "Interface located at dimension: " + interfaceDim + " [" + DimensionManager.getWorld( interfaceDim ).provider.getDimensionType().getName() + "] and cant be highlighted" ), false );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hilightBlock( blockPos, System.currentTimeMillis() + 500 * BlockPosUtils.getDistance( blockPos, blockPos2 ), playerDim );
|
||||||
mc.player.sendStatusMessage( new TextComponentString( "The interface is now highlighted at " + "X: " + blockPos.getX() + " Y: " + blockPos.getY() + " Z: " + blockPos.getZ() ), false );
|
mc.player.sendStatusMessage( new TextComponentString( "The interface is now highlighted at " + "X: " + blockPos.getX() + " Y: " + blockPos.getY() + " Z: " + blockPos.getZ() ), false );
|
||||||
|
}
|
||||||
mc.player.closeScreen();
|
mc.player.closeScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,6 +336,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
|||||||
final NBTTagCompound invData = in.getCompoundTag( key );
|
final NBTTagCompound invData = in.getCompoundTag( key );
|
||||||
final ClientDCInternalInv current = this.getById( id, invData.getLong( "sortBy" ), invData.getString( "un" ) );
|
final ClientDCInternalInv current = this.getById( id, invData.getLong( "sortBy" ), invData.getString( "un" ) );
|
||||||
blockPosHashMap.put( current, NBTUtil.getPosFromTag( invData.getCompoundTag( "pos" )) );
|
blockPosHashMap.put( current, NBTUtil.getPosFromTag( invData.getCompoundTag( "pos" )) );
|
||||||
|
dimHashMap.put( current, invData.getInteger( "dim" ));
|
||||||
|
|
||||||
for( int x = 0; x < current.getInventory().getSlots(); x++ )
|
for( int x = 0; x < current.getInventory().getSlots(); x++ )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -404,6 +404,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
|
|||||||
tag.setLong( "sortBy", inv.sortBy );
|
tag.setLong( "sortBy", inv.sortBy );
|
||||||
tag.setString( "un", inv.unlocalizedName );
|
tag.setString( "un", inv.unlocalizedName );
|
||||||
tag.setTag( "pos", NBTUtil.createPosTag( inv.pos ) );
|
tag.setTag( "pos", NBTUtil.createPosTag( inv.pos ) );
|
||||||
|
tag.setInteger( "dim", inv.dim );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( int x = 0; x < length; x++ )
|
for( int x = 0; x < length; x++ )
|
||||||
@@ -435,6 +436,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
|
|||||||
private final IItemHandler client;
|
private final IItemHandler client;
|
||||||
private final IItemHandler server;
|
private final IItemHandler server;
|
||||||
private final BlockPos pos;
|
private final BlockPos pos;
|
||||||
|
private final int dim;
|
||||||
|
|
||||||
public InvTracker( final DualityInterface dual, final IItemHandler patterns, final String unlocalizedName )
|
public InvTracker( final DualityInterface dual, final IItemHandler patterns, final String unlocalizedName )
|
||||||
{
|
{
|
||||||
@@ -443,6 +445,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
|
|||||||
this.unlocalizedName = unlocalizedName;
|
this.unlocalizedName = unlocalizedName;
|
||||||
this.sortBy = dual.getSortValue();
|
this.sortBy = dual.getSortValue();
|
||||||
this.pos = dual.getLocation().getPos();
|
this.pos = dual.getLocation().getPos();
|
||||||
|
this.dim = dual.getLocation().getWorld().provider.getDimension();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import appeng.container.slot.*;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
@@ -51,12 +52,6 @@ import appeng.api.storage.data.IAEItemStack;
|
|||||||
import appeng.api.storage.data.IItemList;
|
import appeng.api.storage.data.IItemList;
|
||||||
import appeng.container.ContainerNull;
|
import appeng.container.ContainerNull;
|
||||||
import appeng.container.guisync.GuiSync;
|
import appeng.container.guisync.GuiSync;
|
||||||
import appeng.container.slot.IOptionalSlotHost;
|
|
||||||
import appeng.container.slot.OptionalSlotFake;
|
|
||||||
import appeng.container.slot.SlotFakeCraftingMatrix;
|
|
||||||
import appeng.container.slot.SlotPatternOutputs;
|
|
||||||
import appeng.container.slot.SlotPatternTerm;
|
|
||||||
import appeng.container.slot.SlotRestrictedInput;
|
|
||||||
import appeng.core.sync.packets.PacketPatternSlot;
|
import appeng.core.sync.packets.PacketPatternSlot;
|
||||||
import appeng.helpers.IContainerCraftingPacket;
|
import appeng.helpers.IContainerCraftingPacket;
|
||||||
import appeng.items.storage.ItemViewCell;
|
import appeng.items.storage.ItemViewCell;
|
||||||
@@ -132,6 +127,26 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
|
|||||||
this.updateOrderOfOutputSlots();
|
this.updateOrderOfOutputSlots();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack transferStackInSlot( final EntityPlayer p, final int idx )
|
||||||
|
{
|
||||||
|
if( Platform.isClient() )
|
||||||
|
{
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
final AppEngSlot clickSlot = ( AppEngSlot ) this.inventorySlots.get( idx ); // require AE SLots!
|
||||||
|
ItemStack itemStack = clickSlot.getStack();
|
||||||
|
if( AEApi.instance().definitions().materials().blankPattern().isSameAs( itemStack ) )
|
||||||
|
{
|
||||||
|
IItemHandler patternInv = this.getPatternTerminal().getInventoryByName( "pattern" );
|
||||||
|
ItemStack remainder = patternInv.insertItem( 0, itemStack, false );
|
||||||
|
clickSlot.putStack( remainder );
|
||||||
|
}
|
||||||
|
return super.transferStackInSlot( p, idx );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void updateOrderOfOutputSlots()
|
private void updateOrderOfOutputSlots()
|
||||||
{
|
{
|
||||||
if( !this.isCraftingMode() )
|
if( !this.isCraftingMode() )
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ package appeng.core.sync.packets;
|
|||||||
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
import appeng.api.storage.data.IAEFluidStack;
|
import appeng.api.storage.data.IAEFluidStack;
|
||||||
import appeng.container.slot.IJEITargetSlot;
|
import appeng.container.slot.IJEITargetSlot;
|
||||||
@@ -224,7 +225,9 @@ public class PacketInventoryAction extends AppEngPacket
|
|||||||
IAEFluidStack aefs = AEFluidStack.fromNBT( this.slotItem.getDefinition().getTagCompound() );
|
IAEFluidStack aefs = AEFluidStack.fromNBT( this.slotItem.getDefinition().getTagCompound() );
|
||||||
if( aefs != null )
|
if( aefs != null )
|
||||||
{
|
{
|
||||||
|
aefs.setStackSize( 1000 );
|
||||||
( (ContainerFluidConfigurable) sender.openContainer ).getFluidConfigInventory().setFluidInSlot( this.slot, aefs );
|
( (ContainerFluidConfigurable) sender.openContainer ).getFluidConfigInventory().setFluidInSlot( this.slot, aefs );
|
||||||
|
NetworkHandler.instance().sendToServer( new PacketFluidSlot( Collections.singletonMap( this.slot, aefs ) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ public class PacketJEIRecipe extends AppEngPacket
|
|||||||
IAEItemStack mostDamaged = null;
|
IAEItemStack mostDamaged = null;
|
||||||
for( IAEItemStack is : outList )
|
for( IAEItemStack is : outList )
|
||||||
{
|
{
|
||||||
if( !is.isCraftable() && is.getItem().isDamageable() )
|
if( !is.isCraftable() )
|
||||||
{
|
{
|
||||||
if( mostDamaged == null || mostDamaged.getItemDamage() < is.getItemDamage() )
|
if( mostDamaged == null || mostDamaged.getItemDamage() < is.getItemDamage() )
|
||||||
{
|
{
|
||||||
@@ -285,6 +285,7 @@ public class PacketJEIRecipe extends AppEngPacket
|
|||||||
IItemHandler outputSlots = cct.getInventoryByName( "output" );
|
IItemHandler outputSlots = cct.getInventoryByName( "output" );
|
||||||
for( int i = 0; i < this.output.length; ++i )
|
for( int i = 0; i < this.output.length; ++i )
|
||||||
{
|
{
|
||||||
|
if( this.output[i] == null ) continue;
|
||||||
ItemHandlerUtil.setStackInSlot( outputSlots, i, this.output[i] );
|
ItemHandlerUtil.setStackInSlot( outputSlots, i, this.output[i] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -263,14 +263,14 @@ 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()
|
this.getProxy().getStorage().postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ), change, this.source );
|
||||||
.getStorage()
|
|
||||||
.postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ), change, this.source );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( final GridAccessException e )
|
catch( final GridAccessException e )
|
||||||
@@ -278,6 +278,7 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
|||||||
// :(
|
// :(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public MEInventoryHandler<IAEFluidStack> getInternalHandler()
|
public MEInventoryHandler<IAEFluidStack> getInternalHandler()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,12 +24,17 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import appeng.integration.modules.gregtech.GTCEInventoryAdaptor;
|
||||||
import appeng.util.*;
|
import appeng.util.*;
|
||||||
import appeng.util.inv.*;
|
import appeng.util.inv.*;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.api.tile.IPhantomTile;
|
||||||
import gregtech.api.block.machines.BlockMachine;
|
import gregtech.api.block.machines.BlockMachine;
|
||||||
import gregtech.api.metatileentity.MetaTileEntity;
|
import gregtech.api.metatileentity.MetaTileEntity;
|
||||||
|
import gregtech.api.metatileentity.MetaTileEntityHolder;
|
||||||
|
import gregtech.api.metatileentity.TieredMetaTileEntity;
|
||||||
|
import gregtech.api.metatileentity.WorkableTieredMetaTileEntity;
|
||||||
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;
|
||||||
@@ -106,6 +111,8 @@ 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
|
||||||
{
|
{
|
||||||
|
private int[] failedCraftTriesSlot = {0,0,0,0,0,0,0,0,0};
|
||||||
|
|
||||||
public static final int NUMBER_OF_STORAGE_SLOTS = 9;
|
public static final int NUMBER_OF_STORAGE_SLOTS = 9;
|
||||||
public static final int NUMBER_OF_CONFIG_SLOTS = 9;
|
public static final int NUMBER_OF_CONFIG_SLOTS = 9;
|
||||||
public static final int NUMBER_OF_PATTERN_SLOTS = 9;
|
public static final int NUMBER_OF_PATTERN_SLOTS = 9;
|
||||||
@@ -137,6 +144,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
|||||||
private final Accessor accessor = new Accessor();
|
private final Accessor accessor = new Accessor();
|
||||||
private EnumSet<EnumFacing> visitedFaces = EnumSet.noneOf( EnumFacing.class );
|
private EnumSet<EnumFacing> visitedFaces = EnumSet.noneOf( EnumFacing.class );
|
||||||
private EnumMap<EnumFacing,List<ItemStack>> waitingToSendFacing = new EnumMap<>(EnumFacing.class);
|
private EnumMap<EnumFacing,List<ItemStack>> waitingToSendFacing = new EnumMap<>(EnumFacing.class);
|
||||||
|
private GTCEInventoryAdaptor GTad;
|
||||||
|
|
||||||
public DualityInterface( final AENetworkProxy networkProxy, final IInterfaceHost ih )
|
public DualityInterface( final AENetworkProxy networkProxy, final IInterfaceHost ih )
|
||||||
{
|
{
|
||||||
@@ -726,8 +734,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
|||||||
|
|
||||||
private void pushItemsOut( final EnumFacing s )
|
private void pushItemsOut( final EnumFacing s )
|
||||||
{
|
{
|
||||||
if( this.waitingToSendFacing.get(s) == null || this.waitingToSendFacing.get( s ).isEmpty() )
|
if (!this.waitingToSendFacing.containsKey(s) ||
|
||||||
{
|
(this.waitingToSendFacing.containsKey(s) && this.waitingToSendFacing.get( s ).isEmpty())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -761,7 +769,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
|||||||
|
|
||||||
if( this.waitingToSendFacing.get( s ).isEmpty() )
|
if( this.waitingToSendFacing.get( s ).isEmpty() )
|
||||||
{
|
{
|
||||||
this.waitingToSendFacing.get( s ).clear();
|
this.waitingToSendFacing.remove( s );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -884,8 +892,17 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
|||||||
{
|
{
|
||||||
if( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 && itemStack != null )
|
if( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 && itemStack != null )
|
||||||
{
|
{
|
||||||
return this.craftingTracker.handleCrafting( x, itemStack.getStackSize(), itemStack, d, this.iHost.getTileEntity().getWorld(),
|
if (this.failedCraftTriesSlot[x] <= 0)
|
||||||
|
{
|
||||||
|
boolean crafted = this.craftingTracker.handleCrafting( x, itemStack.getStackSize(), itemStack, d, this.iHost.getTileEntity().getWorld(),
|
||||||
this.gridProxy.getGrid(), this.gridProxy.getCrafting(), this.mySource );
|
this.gridProxy.getGrid(), this.gridProxy.getCrafting(), this.mySource );
|
||||||
|
|
||||||
|
if (crafted) this.failedCraftTriesSlot[x] = 0;
|
||||||
|
else{
|
||||||
|
this.failedCraftTriesSlot[x] += 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.failedCraftTriesSlot[x] -= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( final GridAccessException e )
|
catch( final GridAccessException e )
|
||||||
@@ -1020,20 +1037,12 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
|||||||
|
|
||||||
private boolean invIsBlocked( InventoryAdaptor inv )
|
private boolean invIsBlocked( InventoryAdaptor inv )
|
||||||
{
|
{
|
||||||
final Iterator<ICraftingPatternDetails> i = this.craftingList.iterator();
|
return (inv.containsItems());
|
||||||
ICraftingPatternDetails patt = i.next();
|
}
|
||||||
for ( ItemSlot itemSlot : inv)
|
|
||||||
|
private static boolean invIsBlockedGTCE( GTCEInventoryAdaptor inv )
|
||||||
{
|
{
|
||||||
if (itemSlot.getItemStack().isEmpty()){
|
return ( !inv.canRemoveAllExceptCircuits() );
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for ( IAEItemStack iaeItemStack : patt.getCondensedInputs()){
|
|
||||||
if (iaeItemStack.isSameType( itemSlot.getItemStack() )){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1076,12 +1085,11 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
|||||||
final ICraftingMachine cm = (ICraftingMachine) te;
|
final ICraftingMachine cm = (ICraftingMachine) te;
|
||||||
if( cm.acceptsPlans() )
|
if( cm.acceptsPlans() )
|
||||||
{
|
{
|
||||||
|
visitedFaces.remove( s );
|
||||||
if( cm.pushPattern( patternDetails, table, s.getOpposite() ) )
|
if( cm.pushPattern( patternDetails, table, s.getOpposite() ) )
|
||||||
{
|
{
|
||||||
visitedFaces.remove( s );
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
visitedFaces.remove( s );
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1089,17 +1097,42 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
|||||||
final InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() );
|
final InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() );
|
||||||
if( ad != null )
|
if( ad != null )
|
||||||
{
|
{
|
||||||
boolean isDrawer = te.getBlockType().getRegistryName().getResourceDomain().equals( "storagedrawers" );
|
|
||||||
if( this.isBlocking() )
|
if( this.isBlocking() )
|
||||||
{
|
{
|
||||||
if( invIsBlocked( ad ) )
|
IPhantomTile phantomTE = null;
|
||||||
|
if( Loader.isModLoaded( "actuallyadditions" ) && Loader.isModLoaded( "gregtech" ) && te instanceof IPhantomTile )
|
||||||
{
|
{
|
||||||
|
phantomTE = ( (IPhantomTile) te );
|
||||||
|
if( phantomTE.hasBoundPosition() )
|
||||||
|
{
|
||||||
|
TileEntity phantom = w.getTileEntity( phantomTE.getBoundPosition() );
|
||||||
|
if( phantom instanceof MetaTileEntityHolder && isGTCEblocked( phantom, s ) )
|
||||||
|
{
|
||||||
|
visitedFaces.remove( s );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if( Loader.isModLoaded( "gregtech" ) && te instanceof MetaTileEntityHolder )
|
||||||
|
{
|
||||||
|
if( isGTCEblocked( te, s ) )
|
||||||
|
{
|
||||||
|
visitedFaces.remove( s );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( this.acceptsItems( ad, patternDetails, isDrawer ) )
|
else if( invIsBlocked( ad ) )
|
||||||
{
|
{
|
||||||
|
visitedFaces.remove( s );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( this.acceptsItems( ad, table ) )
|
||||||
|
{
|
||||||
|
visitedFaces.remove( s );
|
||||||
for( int x = 0; x < table.getSizeInventory(); x++ )
|
for( int x = 0; x < table.getSizeInventory(); x++ )
|
||||||
{
|
{
|
||||||
final ItemStack is = table.getStackInSlot( x );
|
final ItemStack is = table.getStackInSlot( x );
|
||||||
@@ -1107,9 +1140,8 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
|||||||
{
|
{
|
||||||
addToSendListFacing( is, s );
|
addToSendListFacing( is, s );
|
||||||
}
|
}
|
||||||
pushItemsOut( s );
|
|
||||||
}
|
}
|
||||||
visitedFaces.remove( s );
|
pushItemsOut( s );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1139,11 +1171,35 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
|||||||
for( final EnumFacing s : possibleDirections )
|
for( final EnumFacing s : possibleDirections )
|
||||||
{
|
{
|
||||||
final TileEntity te = w.getTileEntity( tile.getPos().offset( s ) );
|
final TileEntity te = w.getTileEntity( tile.getPos().offset( s ) );
|
||||||
|
IPhantomTile phantomTE = null;
|
||||||
|
|
||||||
final InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() );
|
final InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() );
|
||||||
if( ad != null )
|
if( ad != null )
|
||||||
{
|
{
|
||||||
if( !invIsBlocked( ad ) )
|
if( Loader.isModLoaded( "actuallyadditions") && Loader.isModLoaded( "gregtech" ) && te instanceof IPhantomTile )
|
||||||
|
{
|
||||||
|
phantomTE = ( (IPhantomTile) te );
|
||||||
|
if( phantomTE.hasBoundPosition() )
|
||||||
|
{
|
||||||
|
TileEntity phantom = w.getTileEntity( phantomTE.getBoundPosition() );
|
||||||
|
if( phantom instanceof MetaTileEntityHolder && !isGTCEblocked( phantom, s ) )
|
||||||
|
{
|
||||||
|
allAreBusy = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if( Loader.isModLoaded( "gregtech" ) && te instanceof MetaTileEntityHolder )
|
||||||
|
{
|
||||||
|
if( !isGTCEblocked( te, s ) )
|
||||||
|
{
|
||||||
|
allAreBusy = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if( !invIsBlocked( ad ) )
|
||||||
{
|
{
|
||||||
allAreBusy = false;
|
allAreBusy = false;
|
||||||
break;
|
break;
|
||||||
@@ -1155,6 +1211,12 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
|||||||
return busy;
|
return busy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isGTCEblocked(TileEntity te, EnumFacing s)
|
||||||
|
{
|
||||||
|
GTad = GTCEInventoryAdaptor.getAdaptor( te, s.getOpposite() );
|
||||||
|
return invIsBlockedGTCE( GTad );
|
||||||
|
}
|
||||||
|
|
||||||
private boolean sameGrid( final IGrid grid ) throws GridAccessException
|
private boolean sameGrid( final IGrid grid ) throws GridAccessException
|
||||||
{
|
{
|
||||||
return grid == this.gridProxy.getGrid();
|
return grid == this.gridProxy.getGrid();
|
||||||
@@ -1165,87 +1227,25 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
|||||||
return this.cm.getSetting( Settings.BLOCK ) == YesNo.YES;
|
return this.cm.getSetting( Settings.BLOCK ) == YesNo.YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean acceptsItems( final InventoryAdaptor ad, final ICraftingPatternDetails patternDetails, boolean isDrawer )
|
private boolean acceptsItems( final InventoryAdaptor ad, final InventoryCrafting table )
|
||||||
{
|
{
|
||||||
List<ItemStack> patternedStacks = Arrays.stream( patternDetails.getCondensedInputs() ).map( IAEItemStack::createItemStack ).collect( Collectors.toList() );
|
for( int x = 0; x < table.getSizeInventory(); x++ )
|
||||||
List<ItemSlot> copiedItemSlots = new ArrayList<>();
|
|
||||||
|
|
||||||
if( patternedStacks.size() == 1 )
|
|
||||||
{
|
{
|
||||||
return ad.simulateAdd( patternedStacks.get( 0 ) ).isEmpty();
|
final ItemStack is = table.getStackInSlot( x );
|
||||||
}
|
if( is.isEmpty() )
|
||||||
else
|
|
||||||
{
|
{
|
||||||
Iterator<ItemSlot> adit = ad.iterator();
|
continue;
|
||||||
while ( adit.hasNext() )
|
|
||||||
{
|
|
||||||
ItemSlot is = adit.next();
|
|
||||||
//skip storage drawers slot 0 to avoid voiding items due to broken itemhandler implementation
|
|
||||||
if( isDrawer && is.getSlot() == 0 ) is = adit.next();
|
|
||||||
|
|
||||||
//some inventory may expose their special slots ( for upgrades, etc )
|
|
||||||
//if its empty AND we cant fit any of the items in the recipes, skip it.
|
|
||||||
if( is.getItemStack().isEmpty() )
|
|
||||||
{
|
|
||||||
boolean validInputSlotForIngredients = false;
|
|
||||||
for( IAEItemStack aeItemStack : patternDetails.getCondensedInputs() )
|
|
||||||
{
|
|
||||||
if( is.insertItem( aeItemStack.getDefinition() ).isEmpty() )
|
|
||||||
{
|
|
||||||
validInputSlotForIngredients = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if( validInputSlotForIngredients )
|
|
||||||
{
|
|
||||||
copiedItemSlots.add( is.copy() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( !is.getItemStack().isEmpty() && is.getItemStack().getCount() < is.getSlotLimit() )
|
|
||||||
{
|
|
||||||
copiedItemSlots.add( is.copy() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Iterator<ItemSlot> copiedItemSlotIterator = copiedItemSlots.iterator();
|
|
||||||
while ( copiedItemSlotIterator.hasNext() )
|
|
||||||
{
|
|
||||||
ItemSlot copiedItemSlot = copiedItemSlotIterator.next();
|
|
||||||
|
|
||||||
Iterator<ItemStack> psi = patternedStacks.iterator();
|
|
||||||
while ( psi.hasNext() )
|
|
||||||
{
|
|
||||||
ItemStack patternedStack = psi.next();
|
|
||||||
ItemStack remainder = copiedItemSlot.insertItem( patternedStack );
|
|
||||||
|
|
||||||
if( !remainder.isEmpty() )
|
|
||||||
{
|
|
||||||
patternedStack.setCount( patternedStack.getCount() - ( patternedStack.getCount() - remainder.getCount() ) );
|
|
||||||
if( copiedItemSlot.getSlotLimit() == copiedItemSlot.getItemStack().getCount() )
|
|
||||||
{
|
|
||||||
copiedItemSlotIterator.remove();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( copiedItemSlot.getSlotLimit() == copiedItemSlot.getItemStack().getCount() )
|
|
||||||
{
|
|
||||||
copiedItemSlotIterator.remove();
|
|
||||||
}
|
|
||||||
psi.remove();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( patternedStacks.size() == 0 )
|
if( !ad.simulateAdd( is.copy() ).isEmpty() )
|
||||||
{
|
{
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void provideCrafting( final ICraftingProviderHelper craftingTracker )
|
public void provideCrafting( final ICraftingProviderHelper craftingTracker )
|
||||||
{
|
{
|
||||||
@@ -1272,6 +1272,20 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( this.waitingToSendFacing != null )
|
||||||
|
{
|
||||||
|
for (List<ItemStack> itemList : waitingToSendFacing.values())
|
||||||
|
{
|
||||||
|
for (final ItemStack is : itemList)
|
||||||
|
{
|
||||||
|
if (!is.isEmpty())
|
||||||
|
{
|
||||||
|
drops.add(is);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for( final ItemStack is : this.upgrades )
|
for( final ItemStack is : this.upgrades )
|
||||||
{
|
{
|
||||||
if( !is.isEmpty() )
|
if( !is.isEmpty() )
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ public class HighlighterHandler
|
|||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
|
|
||||||
GlStateManager.enableTexture2D();
|
GlStateManager.enableTexture2D();
|
||||||
|
GlStateManager.enableDepth();
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package appeng.integration.modules.gregtech;
|
||||||
|
|
||||||
|
import appeng.util.inv.ItemSlot;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
|
public abstract class GTCEInventoryAdaptor implements Iterable<ItemSlot>
|
||||||
|
{
|
||||||
|
public static GTCEInventoryAdaptor getAdaptor(final TileEntity te, final EnumFacing d)
|
||||||
|
{
|
||||||
|
if (te != null && te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, d))
|
||||||
|
{
|
||||||
|
// Attempt getting an IItemHandler for the given side via caps
|
||||||
|
IItemHandler itemHandler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, d);
|
||||||
|
if (itemHandler != null)
|
||||||
|
{
|
||||||
|
return new GTCEItemHandler(itemHandler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract boolean canRemoveAllExceptCircuits();
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package appeng.integration.modules.gregtech;
|
||||||
|
|
||||||
|
import appeng.util.inv.ItemHandlerIterator;
|
||||||
|
import appeng.util.inv.ItemSlot;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
public class GTCEItemHandler extends GTCEInventoryAdaptor
|
||||||
|
{
|
||||||
|
ArrayList<Integer> GTCElenses = new ArrayList<>(Arrays.asList(15085,15214,15092,15111,15113,15219,15218,15243,15244,15209,15117,15206,15216,15331,15212,15213,15154,15122,15157,15190,15247));
|
||||||
|
ArrayList<Integer> GTCEmolds = new ArrayList<>(Arrays.asList(32301,32303,32304,32305,32306,32307,32308,32309,32313,32314,32315,32317,32350,32351,32352,32353,32354,32355,32356,32358,32359,32360,32361,32363,32364,32365,32366,32367,32368,32369,32370,32371,32372,32373));
|
||||||
|
Item smallGearExtruderShape = Item.getByNameOrId("contenttweaker:smallgearextrudershape");
|
||||||
|
Item creativePortableTankMold = Item.getByNameOrId("contenttweaker:creativeportabletankmold");
|
||||||
|
|
||||||
|
protected final IItemHandler itemHandler;
|
||||||
|
|
||||||
|
public GTCEItemHandler(IItemHandler itemHandler)
|
||||||
|
{
|
||||||
|
this.itemHandler = itemHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isBlockableItem(ItemStack stack)
|
||||||
|
{
|
||||||
|
if ( stack.getItem() == Item.getByNameOrId("gregtech:meta_item_1") ) {
|
||||||
|
int metadata = stack.getItemDamage();
|
||||||
|
if ( metadata == 32766 || GTCElenses.contains(metadata) || GTCEmolds.contains(metadata)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( stack.getItem() == smallGearExtruderShape ) return false;
|
||||||
|
if ( stack.getItem() == creativePortableTankMold) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canRemoveAllExceptCircuits()
|
||||||
|
{
|
||||||
|
int slots = this.itemHandler.getSlots();
|
||||||
|
for ( int slot = 0; slot < slots; slot++ ) {
|
||||||
|
ItemStack is = this.itemHandler.getStackInSlot(slot);
|
||||||
|
if ( is.isEmpty() || !isBlockableItem(is) ) continue;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterator<ItemSlot> iterator()
|
||||||
|
{
|
||||||
|
return new ItemHandlerIterator( this.itemHandler );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,6 +27,7 @@ import java.util.Map;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import appeng.container.implementations.ContainerPatternTerm;
|
import appeng.container.implementations.ContainerPatternTerm;
|
||||||
|
import appeng.core.sync.packets.PacketValueConfig;
|
||||||
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
|
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
|
||||||
import mezz.jei.transfer.RecipeTransferErrorInternal;
|
import mezz.jei.transfer.RecipeTransferErrorInternal;
|
||||||
import mezz.jei.transfer.RecipeTransferErrorTooltip;
|
import mezz.jei.transfer.RecipeTransferErrorTooltip;
|
||||||
@@ -73,24 +74,7 @@ class RecipeTransferHandler<T extends Container> implements IRecipeTransferHandl
|
|||||||
{
|
{
|
||||||
final String recipeType = recipeLayout.getRecipeCategory().getUid();
|
final String recipeType = recipeLayout.getRecipeCategory().getUid();
|
||||||
|
|
||||||
if (!recipeType.equals( VanillaRecipeCategoryUid.INFORMATION) && !recipeType.equals(VanillaRecipeCategoryUid.FUEL))
|
if (recipeType.equals( VanillaRecipeCategoryUid.INFORMATION) || recipeType.equals(VanillaRecipeCategoryUid.FUEL))
|
||||||
{
|
|
||||||
if( container instanceof ContainerPatternTerm )
|
|
||||||
{
|
|
||||||
if( !( (ContainerPatternTerm) container ).isCraftingMode() )
|
|
||||||
{
|
|
||||||
if( recipeType.equals( VanillaRecipeCategoryUid.CRAFTING ) )
|
|
||||||
{
|
|
||||||
return new RecipeTransferErrorTooltip( I18n.format( "gui.appliedenergistics2.CraftingPattern" ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( !recipeType.equals( VanillaRecipeCategoryUid.CRAFTING ) )
|
|
||||||
{
|
|
||||||
return new RecipeTransferErrorTooltip( I18n.format( "gui.appliedenergistics2.ProcessingPattern" ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
return RecipeTransferErrorInternal.INSTANCE;
|
return RecipeTransferErrorInternal.INSTANCE;
|
||||||
}
|
}
|
||||||
@@ -100,6 +84,30 @@ class RecipeTransferHandler<T extends Container> implements IRecipeTransferHandl
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( container instanceof ContainerPatternTerm )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if( !( (ContainerPatternTerm) container ).isCraftingMode() )
|
||||||
|
{
|
||||||
|
if( recipeType.equals( VanillaRecipeCategoryUid.CRAFTING ) )
|
||||||
|
{
|
||||||
|
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.CraftMode", "1" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( !recipeType.equals( VanillaRecipeCategoryUid.CRAFTING ) )
|
||||||
|
{
|
||||||
|
|
||||||
|
NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.CraftMode", "0" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch( IOException e )
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Map<Integer, ? extends IGuiIngredient<ItemStack>> ingredients = recipeLayout.getItemStacks().getGuiIngredients();
|
Map<Integer, ? extends IGuiIngredient<ItemStack>> ingredients = recipeLayout.getItemStacks().getGuiIngredients();
|
||||||
|
|
||||||
final NBTTagCompound recipe = new NBTTagCompound();
|
final NBTTagCompound recipe = new NBTTagCompound();
|
||||||
|
|||||||
+4
-2
@@ -44,6 +44,8 @@ import appeng.api.storage.IStorageChannel;
|
|||||||
import appeng.api.storage.data.IAEStack;
|
import appeng.api.storage.data.IAEStack;
|
||||||
import appeng.api.storage.data.IItemList;
|
import appeng.api.storage.data.IItemList;
|
||||||
import appeng.me.storage.ItemWatcher;
|
import appeng.me.storage.ItemWatcher;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
|
|
||||||
|
|
||||||
public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
||||||
@@ -58,7 +60,7 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
private final IItemList<T> cachedList;
|
private final IItemList<T> cachedList;
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private final Map<IMEMonitorHandlerReceiver<T>, Object> listeners;
|
private final Object2ObjectMap<IMEMonitorHandlerReceiver<T>, Object> listeners;
|
||||||
|
|
||||||
private boolean sendEvent = false;
|
private boolean sendEvent = false;
|
||||||
private boolean hasChanged = false;
|
private boolean hasChanged = false;
|
||||||
@@ -70,7 +72,7 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
|||||||
this.myGridCache = cache;
|
this.myGridCache = cache;
|
||||||
this.myChannel = chan;
|
this.myChannel = chan;
|
||||||
this.cachedList = chan.createList();
|
this.cachedList = chan.createList();
|
||||||
this.listeners = new HashMap<>();
|
this.listeners = new Object2ObjectOpenHashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ import appeng.util.item.AEItemStack;
|
|||||||
|
|
||||||
public class PartExportBus extends PartSharedItemBus implements ICraftingRequester
|
public class PartExportBus extends PartSharedItemBus implements ICraftingRequester
|
||||||
{
|
{
|
||||||
|
private final int[] failedCraftTriesSlot = {0,0,0,0,0,0,0,0,0};
|
||||||
|
|
||||||
public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/export_bus_base" );
|
public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/export_bus_base" );
|
||||||
|
|
||||||
@PartModels
|
@PartModels
|
||||||
@@ -140,7 +142,7 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
|||||||
|
|
||||||
if( destination != null )
|
if( destination != null )
|
||||||
{
|
{
|
||||||
int x;
|
int x = 0;
|
||||||
|
|
||||||
for( x = 0; x < this.availableSlots() && this.itemToSend > 0; x++ )
|
for( x = 0; x < this.availableSlots() && this.itemToSend > 0; x++ )
|
||||||
{
|
{
|
||||||
@@ -151,8 +153,16 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
|||||||
if( ais == null || this.itemToSend <= 0 ) continue;
|
if( ais == null || this.itemToSend <= 0 ) continue;
|
||||||
|
|
||||||
if ( this.craftOnly() ) {
|
if ( this.craftOnly() ) {
|
||||||
|
if (this.failedCraftTriesSlot[x] <= 0) {
|
||||||
|
|
||||||
this.didSomething = this.craftingTracker.handleCrafting(slotToExport, this.itemToSend, ais, destination, this.getTile().getWorld(),
|
this.didSomething = this.craftingTracker.handleCrafting(slotToExport, this.itemToSend, ais, destination, this.getTile().getWorld(),
|
||||||
this.getProxy().getGrid(), cg, this.mySrc) || this.didSomething;
|
this.getProxy().getGrid(), cg, this.mySrc) || this.didSomething;
|
||||||
|
|
||||||
|
if (this.didSomething) this.failedCraftTriesSlot[x] = 0;
|
||||||
|
else this.failedCraftTriesSlot[x] += 2;
|
||||||
|
}
|
||||||
|
this.failedCraftTriesSlot[x] -= 1;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final long before = this.itemToSend;
|
final long before = this.itemToSend;
|
||||||
@@ -175,8 +185,15 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest
|
|||||||
|
|
||||||
if( this.itemToSend == before && this.isCraftingEnabled() )
|
if( this.itemToSend == before && this.isCraftingEnabled() )
|
||||||
{
|
{
|
||||||
|
if (this.failedCraftTriesSlot[x] <= 0) {
|
||||||
|
|
||||||
this.didSomething = this.craftingTracker.handleCrafting(slotToExport, this.itemToSend, ais, destination, this.getTile().getWorld(),
|
this.didSomething = this.craftingTracker.handleCrafting(slotToExport, this.itemToSend, ais, destination, this.getTile().getWorld(),
|
||||||
this.getProxy().getGrid(), cg, this.mySrc) || this.didSomething;
|
this.getProxy().getGrid(), cg, this.mySrc) || this.didSomething;
|
||||||
|
|
||||||
|
if (this.didSomething) this.failedCraftTriesSlot[x] = 0;
|
||||||
|
else this.failedCraftTriesSlot[x] += 2;
|
||||||
|
}
|
||||||
|
this.failedCraftTriesSlot[x] -= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -218,6 +218,12 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
|||||||
private boolean importStuff( final InventoryAdaptor myAdaptor, final IAEItemStack whatToImport, final IMEMonitor<IAEItemStack> inv, final IEnergySource energy, final FuzzyMode fzMode )
|
private boolean importStuff( final InventoryAdaptor myAdaptor, final IAEItemStack whatToImport, final IMEMonitor<IAEItemStack> inv, final IEnergySource energy, final FuzzyMode fzMode )
|
||||||
{
|
{
|
||||||
final int toSend = this.calculateMaximumAmountToImport( myAdaptor, whatToImport, inv, fzMode );
|
final int toSend = this.calculateMaximumAmountToImport( myAdaptor, whatToImport, inv, fzMode );
|
||||||
|
|
||||||
|
if( toSend == 0 )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
final ItemStack newItems;
|
final ItemStack newItems;
|
||||||
|
|
||||||
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
|
||||||
@@ -286,8 +292,17 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin
|
|||||||
itemAmountNotStorable = inv.injectItems( AEItemStack.fromItemStack( simResult ), Actionable.SIMULATE, this.source );
|
itemAmountNotStorable = inv.injectItems( AEItemStack.fromItemStack( simResult ), Actionable.SIMULATE, this.source );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( simResult.isEmpty() )
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if( itemAmountNotStorable != null )
|
if( itemAmountNotStorable != null )
|
||||||
{
|
{
|
||||||
|
if( simResult.getCount() == itemAmountNotStorable.getStackSize() )
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return (int) Math.min( simResult.getCount() - itemAmountNotStorable.getStackSize(), toSend );
|
return (int) Math.min( simResult.getCount() - itemAmountNotStorable.getStackSize(), toSend );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,15 +19,12 @@
|
|||||||
package appeng.parts.misc;
|
package appeng.parts.misc;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import appeng.api.config.Settings;
|
import appeng.api.config.Settings;
|
||||||
import appeng.api.config.StorageFilter;
|
import appeng.api.config.StorageFilter;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||||
|
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;
|
||||||
|
|
||||||
@@ -42,11 +39,11 @@ 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.Platform;
|
import appeng.util.Platform;
|
||||||
import appeng.util.item.AEItemStack;
|
import appeng.util.item.AEItemStack;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,7 +51,7 @@ import appeng.util.item.AEItemStack;
|
|||||||
*/
|
*/
|
||||||
class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAEItemStack>, ITickingMonitor
|
class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAEItemStack>, ITickingMonitor
|
||||||
{
|
{
|
||||||
private final Map<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new HashMap<>();
|
private final Object2ObjectMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new Object2ObjectOpenHashMap<>();
|
||||||
private IActionSource mySource;
|
private IActionSource mySource;
|
||||||
private final IItemHandler itemHandler;
|
private final IItemHandler itemHandler;
|
||||||
private final IGridProxyable proxyable;
|
private final IGridProxyable proxyable;
|
||||||
@@ -76,16 +73,28 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
|||||||
@Override
|
@Override
|
||||||
public IAEItemStack injectItems( IAEItemStack iox, Actionable type, IActionSource src )
|
public IAEItemStack injectItems( IAEItemStack iox, Actionable type, IActionSource src )
|
||||||
{
|
{
|
||||||
|
|
||||||
ItemStack orgInput = iox.createItemStack();
|
ItemStack orgInput = iox.createItemStack();
|
||||||
ItemStack remaining = orgInput;
|
ItemStack remaining = orgInput;
|
||||||
|
|
||||||
int slotCount = this.itemHandler.getSlots();
|
int slotCount = this.itemHandler.getSlots();
|
||||||
boolean simulate = ( type == Actionable.SIMULATE );
|
boolean simulate = ( type == Actionable.SIMULATE );
|
||||||
|
List<Pair<Integer, Integer>> injectedList = new ArrayList<>();
|
||||||
// This uses a brute force approach and tries to jam it in every slot the inventory exposes.
|
// This uses a brute force approach and tries to jam it in every slot the inventory exposes.
|
||||||
for( int i = 0; i < slotCount && !remaining.isEmpty(); i++ )
|
for( int i = 0; i < slotCount && !remaining.isEmpty(); i++ )
|
||||||
{
|
{
|
||||||
|
int countPre = remaining.getCount();
|
||||||
remaining = this.itemHandler.insertItem( i, remaining, simulate );
|
remaining = this.itemHandler.insertItem( i, remaining, simulate );
|
||||||
|
int countPos = remaining.getCount();
|
||||||
|
if( remaining.isEmpty() )
|
||||||
|
{
|
||||||
|
injectedList.add( Pair.of( i, countPre ) );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if( countPos < countPre )
|
||||||
|
{
|
||||||
|
injectedList.add( Pair.of( i, countPre - countPos ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// At this point, we still have some items left...
|
// At this point, we still have some items left...
|
||||||
@@ -97,14 +106,30 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
|||||||
|
|
||||||
if( type == Actionable.MODULATE )
|
if( type == Actionable.MODULATE )
|
||||||
{
|
{
|
||||||
try
|
if( this.cache.cachedAeStacks.length == 0 )
|
||||||
{
|
{
|
||||||
this.proxyable.getProxy().getTick().alertDevice( this.proxyable.getProxy().getNode() );
|
this.cache.update();
|
||||||
}
|
}
|
||||||
catch( GridAccessException ex )
|
else
|
||||||
{
|
{
|
||||||
// meh
|
for( Pair<Integer, Integer> pair : injectedList )
|
||||||
|
{
|
||||||
|
if( pair.getKey() >= this.cache.cachedAeStacks.length )
|
||||||
|
{
|
||||||
|
this.cache.update();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
if( this.cache.cachedAeStacks[pair.getKey()] == null )
|
||||||
|
{
|
||||||
|
this.cache.cachedAeStacks[pair.getKey()] = iox.copy().setStackSize( pair.getValue() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.cache.cachedAeStacks[pair.getKey()].incStackSize( pair.getValue() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return AEItemStack.fromItemStack( remaining );
|
return AEItemStack.fromItemStack( remaining );
|
||||||
@@ -113,7 +138,6 @@ 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 )
|
||||||
{
|
{
|
||||||
|
|
||||||
ItemStack requestedItemStack = request.createItemStack();
|
ItemStack requestedItemStack = request.createItemStack();
|
||||||
int remainingSize = requestedItemStack.getCount();
|
int remainingSize = requestedItemStack.getCount();
|
||||||
|
|
||||||
@@ -121,6 +145,8 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
|||||||
ItemStack gathered = ItemStack.EMPTY;
|
ItemStack gathered = ItemStack.EMPTY;
|
||||||
|
|
||||||
final boolean simulate = ( mode == Actionable.SIMULATE );
|
final boolean simulate = ( mode == Actionable.SIMULATE );
|
||||||
|
List<Pair<Integer, Integer>> extractedList = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
for ( int i = 0; i < this.itemHandler.getSlots(); i++ )
|
for ( int i = 0; i < this.itemHandler.getSlots(); i++ )
|
||||||
{
|
{
|
||||||
@@ -140,6 +166,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
extracted = this.itemHandler.extractItem( i, remainingCurrentSlot, simulate );
|
extracted = this.itemHandler.extractItem( i, remainingCurrentSlot, simulate );
|
||||||
|
|
||||||
if( !extracted.isEmpty() )
|
if( !extracted.isEmpty() )
|
||||||
{
|
{
|
||||||
if( extracted.getCount() > remainingCurrentSlot )
|
if( extracted.getCount() > remainingCurrentSlot )
|
||||||
@@ -169,6 +196,11 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
|||||||
|
|
||||||
remainingSize -= stackSizeCurrentSlot - remainingCurrentSlot;
|
remainingSize -= stackSizeCurrentSlot - remainingCurrentSlot;
|
||||||
|
|
||||||
|
if (!gathered.isEmpty())
|
||||||
|
{
|
||||||
|
extractedList.add( Pair.of( i, gathered.getCount() ) );
|
||||||
|
}
|
||||||
|
|
||||||
// Done?
|
// Done?
|
||||||
if( remainingSize <= 0 )
|
if( remainingSize <= 0 )
|
||||||
{
|
{
|
||||||
@@ -180,13 +212,23 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
|
|||||||
{
|
{
|
||||||
if( mode == Actionable.MODULATE )
|
if( mode == Actionable.MODULATE )
|
||||||
{
|
{
|
||||||
try
|
if( this.cache.cachedAeStacks.length == 0 )
|
||||||
{
|
{
|
||||||
this.proxyable.getProxy().getTick().alertDevice( this.proxyable.getProxy().getNode() );
|
this.cache.update();
|
||||||
}
|
}
|
||||||
catch( GridAccessException ex )
|
else
|
||||||
{
|
{
|
||||||
// meh
|
for( Pair<Integer, Integer> pair : extractedList )
|
||||||
|
{
|
||||||
|
if( this.cache.cachedAeStacks[pair.getKey()] != null )
|
||||||
|
{
|
||||||
|
this.cache.cachedAeStacks[pair.getKey()].decStackSize( pair.getValue() );
|
||||||
|
if( this.cache.cachedAeStacks[pair.getKey()].getStackSize() == 0 )
|
||||||
|
{
|
||||||
|
this.cache.cachedAeStacks[pair.getKey()] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,14 @@
|
|||||||
package appeng.parts.misc;
|
package appeng.parts.misc;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import appeng.api.storage.IStorageChannel;
|
import appeng.api.storage.IStorageChannel;
|
||||||
|
|
||||||
import appeng.core.AELog;
|
import appeng.core.AELog;
|
||||||
import com.jaquadro.minecraft.storagedrawers.api.capabilities.IItemRepository;
|
import com.jaquadro.minecraft.storagedrawers.api.capabilities.IItemRepository;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
import appeng.api.AEApi;
|
import appeng.api.AEApi;
|
||||||
@@ -38,7 +35,7 @@ import javax.annotation.Nonnull;
|
|||||||
|
|
||||||
class ItemRepositoryAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAEItemStack>, ITickingMonitor
|
class ItemRepositoryAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAEItemStack>, ITickingMonitor
|
||||||
{
|
{
|
||||||
private final Map<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new HashMap<>();
|
private final Object2ObjectMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new Object2ObjectOpenHashMap<>();
|
||||||
private IActionSource mySource;
|
private IActionSource mySource;
|
||||||
private final IItemRepository itemRepository;
|
private final IItemRepository itemRepository;
|
||||||
private final IGridProxyable proxyable;
|
private final IGridProxyable proxyable;
|
||||||
@@ -88,13 +85,12 @@ 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 )
|
||||||
{
|
{
|
||||||
ItemStack requestedItemStack = request.createItemStack();
|
ItemStack requestedItemStack = request.getDefinition();
|
||||||
int remainingSize = requestedItemStack.getCount();
|
int remainingSize = (int) Math.min( Integer.MAX_VALUE, request.getStackSize());
|
||||||
|
|
||||||
final boolean simulate = ( mode == Actionable.SIMULATE );
|
final boolean simulate = ( mode == Actionable.SIMULATE );
|
||||||
|
|
||||||
ItemStack extracted;
|
ItemStack extracted = this.itemRepository.extractItem( requestedItemStack, remainingSize, simulate );
|
||||||
extracted = this.itemRepository.extractItem( requestedItemStack, remainingSize, simulate );
|
|
||||||
|
|
||||||
if( extracted.getCount() > remainingSize )
|
if( extracted.getCount() > remainingSize )
|
||||||
{
|
{
|
||||||
@@ -118,10 +114,8 @@ class ItemRepositoryAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<
|
|||||||
// meh
|
// meh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return AEItemStack.fromItemStack( extracted );
|
return AEItemStack.fromItemStack( extracted );
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -257,15 +257,14 @@ 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()
|
this.getProxy().getStorage().postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ), change, this.mySrc );
|
||||||
.getStorage()
|
|
||||||
.postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ), change,
|
|
||||||
this.mySrc );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( final GridAccessException e )
|
catch( final GridAccessException e )
|
||||||
@@ -273,6 +272,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
|||||||
// :(
|
// :(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onListUpdate()
|
public void onListUpdate()
|
||||||
|
|||||||
@@ -20,10 +20,13 @@ package appeng.util;
|
|||||||
|
|
||||||
|
|
||||||
import appeng.util.inv.*;
|
import appeng.util.inv.*;
|
||||||
|
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;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
|
import net.minecraftforge.common.capabilities.CapabilityInject;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
@@ -37,12 +40,23 @@ import appeng.api.config.FuzzyMode;
|
|||||||
*/
|
*/
|
||||||
public abstract class InventoryAdaptor implements Iterable<ItemSlot>
|
public abstract class InventoryAdaptor implements Iterable<ItemSlot>
|
||||||
{
|
{
|
||||||
|
@CapabilityInject( IItemRepository.class)
|
||||||
|
public static Capability<IItemRepository> ITEM_REPOSITORY_CAPABILITY = null;
|
||||||
|
|
||||||
public static InventoryAdaptor getAdaptor( final TileEntity te, final EnumFacing d )
|
public static InventoryAdaptor getAdaptor( final TileEntity te, final EnumFacing d )
|
||||||
{
|
{
|
||||||
if( te != null )
|
if( te != null )
|
||||||
{
|
{
|
||||||
if( te.hasCapability( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, d ) )
|
if( ITEM_REPOSITORY_CAPABILITY != null && te.hasCapability( ITEM_REPOSITORY_CAPABILITY, d ) )
|
||||||
{
|
{
|
||||||
|
IItemRepository itemRepository = te.getCapability( ITEM_REPOSITORY_CAPABILITY, d );
|
||||||
|
if (itemRepository != null){
|
||||||
|
return new AdaptorItemRepository( itemRepository );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( te.hasCapability( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, d ) )
|
||||||
|
{
|
||||||
|
|
||||||
// Attempt getting an IItemHandler for the given side via caps
|
// Attempt getting an IItemHandler for the given side via caps
|
||||||
IItemHandler itemHandler = te.getCapability( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, d );
|
IItemHandler itemHandler = te.getCapability( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, d );
|
||||||
if( itemHandler != null )
|
if( itemHandler != null )
|
||||||
|
|||||||
@@ -0,0 +1,209 @@
|
|||||||
|
package appeng.util.inv;
|
||||||
|
|
||||||
|
import appeng.api.config.FuzzyMode;
|
||||||
|
import appeng.util.InventoryAdaptor;
|
||||||
|
|
||||||
|
import appeng.util.Platform;
|
||||||
|
import com.jaquadro.minecraft.storagedrawers.api.capabilities.IItemRepository;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
|
||||||
|
public class AdaptorItemRepository extends InventoryAdaptor
|
||||||
|
{
|
||||||
|
protected final IItemRepository itemRepository;
|
||||||
|
|
||||||
|
public AdaptorItemRepository( IItemRepository itemRepository )
|
||||||
|
{
|
||||||
|
this.itemRepository = itemRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack removeItems( int amount, ItemStack filter, IInventoryDestination destination )
|
||||||
|
{
|
||||||
|
ItemStack rv = ItemStack.EMPTY;
|
||||||
|
ItemStack extracted = ItemStack.EMPTY;
|
||||||
|
|
||||||
|
if( !filter.isEmpty() )
|
||||||
|
{
|
||||||
|
extracted = this.itemRepository.extractItem( filter, amount, true );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for( IItemRepository.ItemRecord record : this.itemRepository.getAllItems() )
|
||||||
|
{
|
||||||
|
extracted = this.itemRepository.extractItem( record.itemPrototype, amount, true );
|
||||||
|
if( !extracted.isEmpty() )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( destination != null )
|
||||||
|
{
|
||||||
|
|
||||||
|
if( extracted.isEmpty() || !destination.canInsert( extracted ) )
|
||||||
|
{
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extracted = this.itemRepository.extractItem( filter, amount, false );
|
||||||
|
|
||||||
|
return extracted;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack simulateRemove( int amount, ItemStack filter, IInventoryDestination destination )
|
||||||
|
{
|
||||||
|
ItemStack rv = ItemStack.EMPTY;
|
||||||
|
ItemStack extracted = ItemStack.EMPTY;
|
||||||
|
|
||||||
|
if( !filter.isEmpty() )
|
||||||
|
{
|
||||||
|
extracted = this.itemRepository.extractItem( filter, amount, true );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for( IItemRepository.ItemRecord record : this.itemRepository.getAllItems() )
|
||||||
|
{
|
||||||
|
extracted = this.itemRepository.extractItem( record.itemPrototype, amount, true );
|
||||||
|
if( !extracted.isEmpty() )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( destination != null )
|
||||||
|
{
|
||||||
|
|
||||||
|
if( extracted.isEmpty() || !destination.canInsert( extracted ) )
|
||||||
|
{
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return extracted;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack removeSimilarItems( int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination )
|
||||||
|
{
|
||||||
|
ItemStack rv = ItemStack.EMPTY;
|
||||||
|
ItemStack extracted = ItemStack.EMPTY;
|
||||||
|
|
||||||
|
for( IItemRepository.ItemRecord record : this.itemRepository.getAllItems() )
|
||||||
|
{
|
||||||
|
if( Platform.itemComparisons().isFuzzyEqualItem( record.itemPrototype, filter, fuzzyMode ) )
|
||||||
|
{
|
||||||
|
extracted = this.itemRepository.extractItem( record.itemPrototype, amount, true );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !extracted.isEmpty() )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( destination != null )
|
||||||
|
{
|
||||||
|
|
||||||
|
if( extracted.isEmpty() || !destination.canInsert( extracted ) )
|
||||||
|
{
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extracted = this.itemRepository.extractItem( extracted, amount, false );
|
||||||
|
|
||||||
|
return extracted;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack simulateSimilarRemove( int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination )
|
||||||
|
{
|
||||||
|
ItemStack rv = ItemStack.EMPTY;
|
||||||
|
ItemStack extracted = ItemStack.EMPTY;
|
||||||
|
|
||||||
|
for( IItemRepository.ItemRecord record : this.itemRepository.getAllItems() )
|
||||||
|
{
|
||||||
|
if( Platform.itemComparisons().isFuzzyEqualItem( record.itemPrototype, filter, fuzzyMode ) )
|
||||||
|
{
|
||||||
|
extracted = this.itemRepository.extractItem( record.itemPrototype, amount, true );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !extracted.isEmpty() )
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( destination != null )
|
||||||
|
{
|
||||||
|
|
||||||
|
if( extracted.isEmpty() || !destination.canInsert( extracted ) )
|
||||||
|
{
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return extracted;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack addItems( ItemStack toBeAdded )
|
||||||
|
{
|
||||||
|
return this.addItems( toBeAdded, false );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ItemStack addItems( final ItemStack itemsToAdd, final boolean simulate )
|
||||||
|
{
|
||||||
|
if( itemsToAdd.isEmpty() )
|
||||||
|
{
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack left = itemsToAdd.copy();
|
||||||
|
|
||||||
|
left = this.itemRepository.insertItem( left, simulate );
|
||||||
|
|
||||||
|
if( left.isEmpty() )
|
||||||
|
{
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
return left;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack simulateAdd( ItemStack toBeSimulated )
|
||||||
|
{
|
||||||
|
return this.addItems( toBeSimulated, true );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean containsItems()
|
||||||
|
{
|
||||||
|
return !this.itemRepository.getAllItems().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasSlots()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterator<ItemSlot> iterator()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ import java.util.NoSuchElementException;
|
|||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
|
|
||||||
class ItemHandlerIterator implements Iterator<ItemSlot>
|
public class ItemHandlerIterator implements Iterator<ItemSlot>
|
||||||
{
|
{
|
||||||
|
|
||||||
private final IItemHandler itemHandler;
|
private final IItemHandler itemHandler;
|
||||||
@@ -34,7 +34,7 @@ class ItemHandlerIterator implements Iterator<ItemSlot>
|
|||||||
|
|
||||||
private int slot = 0;
|
private int slot = 0;
|
||||||
|
|
||||||
ItemHandlerIterator( IItemHandler itemHandler )
|
public ItemHandlerIterator( IItemHandler itemHandler )
|
||||||
{
|
{
|
||||||
this.itemHandler = itemHandler;
|
this.itemHandler = itemHandler;
|
||||||
}
|
}
|
||||||
@@ -55,8 +55,6 @@ class ItemHandlerIterator implements Iterator<ItemSlot>
|
|||||||
this.itemSlot.setExtractable( !this.itemHandler.extractItem( this.slot, 1, true ).isEmpty() );
|
this.itemSlot.setExtractable( !this.itemHandler.extractItem( this.slot, 1, true ).isEmpty() );
|
||||||
this.itemSlot.setItemStack( this.itemHandler.getStackInSlot( this.slot ) );
|
this.itemSlot.setItemStack( this.itemHandler.getStackInSlot( this.slot ) );
|
||||||
this.itemSlot.setSlot( this.slot );
|
this.itemSlot.setSlot( this.slot );
|
||||||
this.itemSlot.setSlotLimit( this.itemHandler.getSlotLimit( this.slot ) );
|
|
||||||
this.itemSlot.setItemHandler( this.itemHandler );
|
|
||||||
this.slot++;
|
this.slot++;
|
||||||
return this.itemSlot;
|
return this.itemSlot;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import net.minecraft.item.ItemStack;
|
|||||||
|
|
||||||
import appeng.api.storage.data.IAEItemStack;
|
import appeng.api.storage.data.IAEItemStack;
|
||||||
import appeng.util.item.AEItemStack;
|
import appeng.util.item.AEItemStack;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
|
||||||
|
|
||||||
|
|
||||||
public class ItemSlot
|
public class ItemSlot
|
||||||
@@ -35,25 +34,6 @@ public class ItemSlot
|
|||||||
private IAEItemStack aeItemStack;
|
private IAEItemStack aeItemStack;
|
||||||
private ItemStack itemStack;
|
private ItemStack itemStack;
|
||||||
|
|
||||||
public void setItemHandler( IItemHandler itemHandler )
|
|
||||||
{
|
|
||||||
this.itemHandler = itemHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IItemHandler itemHandler;
|
|
||||||
|
|
||||||
public int getSlotLimit()
|
|
||||||
{
|
|
||||||
return slotLimit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSlotLimit( int slotLimit )
|
|
||||||
{
|
|
||||||
this.slotLimit = slotLimit;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int slotLimit;
|
|
||||||
|
|
||||||
public ItemStack getItemStack()
|
public ItemStack getItemStack()
|
||||||
{
|
{
|
||||||
return this.itemStack
|
return this.itemStack
|
||||||
@@ -97,19 +77,4 @@ public class ItemSlot
|
|||||||
{
|
{
|
||||||
this.slot = slot;
|
this.slot = slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemSlot copy()
|
|
||||||
{
|
|
||||||
ItemSlot copy = new ItemSlot();
|
|
||||||
copy.setSlot( this.slot );
|
|
||||||
copy.setSlotLimit( this.slotLimit );
|
|
||||||
copy.setItemStack( this.getItemStack() );
|
|
||||||
copy.setExtractable( this.isExtractable );
|
|
||||||
copy.setItemHandler( this.itemHandler );
|
|
||||||
return copy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack insertItem( ItemStack sourceItemStack){
|
|
||||||
return this.itemHandler.insertItem( this.slot, sourceItemStack , true );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -4,8 +4,8 @@
|
|||||||
"type": "forge:and",
|
"type": "forge:and",
|
||||||
"values": [
|
"values": [
|
||||||
{
|
{
|
||||||
"type": "minecraft:item_exists",
|
"type": "appliedenergistics2:part_exists",
|
||||||
"item": "appliedenergistics2:part:part.terminal"
|
"part": "part.terminal"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "appliedenergistics2:material_exists",
|
"type": "appliedenergistics2:material_exists",
|
||||||
|
|||||||
Reference in New Issue
Block a user