Compare commits

..

1 Commits

Author SHA1 Message Date
Salomão bc2e4c84b9 highlight interfaces from interface terminal. 2021-02-28 15:36:45 -03:00
393 changed files with 1325 additions and 7653 deletions
+1 -2
View File
@@ -85,8 +85,7 @@ configurations {
} }
dependencies { dependencies {
compileOnly "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"
compileOnly "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}"
@@ -26,20 +26,5 @@ package appeng.api.config;
public enum ActionItems public enum ActionItems
{ {
WRENCH, WRENCH, CLOSE, STASH, ENCODE, SUBSTITUTION, MULTIPLY_BY_TWO, MULTIPLY_BY_THREE, INCREASE_BY_ONE, DIVIDE_BY_TWO, DIVIDE_BY_THREE, DECREASE_BY_ONE, MAX_COUNT
CLOSE,
STASH,
ENCODE,
SUBSTITUTION,
MULTIPLY_BY_TWO,
MULTIPLY_BY_THREE,
INCREASE_BY_ONE,
DIVIDE_BY_TWO,
DIVIDE_BY_THREE,
DECREASE_BY_ONE,
MAX_COUNT,
FREE_MOLECULAR_SLOT_SHORTCUT,
TOGGLE_SHOW_FULL_INTERFACES_ON,
TOGGLE_SHOW_FULL_INTERFACES_OFF,
HIGHLIGHT_INTERFACE
} }
+11 -31
View File
@@ -23,38 +23,18 @@
package appeng.api.config; package appeng.api.config;
public enum FuzzyMode {
/**
* Matches any item from undamaged to including 0% durability, but not negative durability (where item damage
* exceeds maxdamage).
*/
IGNORE_ALL(-1),
/**
* Matches items that have less than 100% durability (that is, at least 1 damage point) if a damaged item is used as
* the filter, or undamaged items otherwise.
*/
PERCENT_99(0),
/**
* If an item with less than 75% durability is used as the filter, items with less than 75% durability are matched.
* Otherwise items with 75% durability or more are matched.
*/
PERCENT_75(25),
/**
* If an item with less than 50% durability is used as the filter, items with less than 50% durability are matched.
* Otherwise items with 50% durability or more are matched.
*/
PERCENT_50(50),
/**
* If an item with less than 25% durability is used as the filter, items with less than 50% durability are matched.
* Otherwise items with 25% durability or more are matched.
*/
PERCENT_25(75);
public final float breakPoint; public enum FuzzyMode
/** {
* Note this is percentage "damaged". It's the inverse of percentage durability. // Note that percentage damaged, is the inverse of percentage durability.
*/ IGNORE_ALL( -1 ),
public final float percentage; PERCENT_99( 0 ),
PERCENT_75( 25 ),
PERCENT_50( 50 ),
PERCENT_25( 75 );
public final float breakPoint;
public final float percentage;
FuzzyMode( final float p ) FuzzyMode( final float p )
{ {
@@ -112,13 +112,4 @@ public interface IAEItemStack extends IAEStack<IAEItemStack>
* @return definition stack * @return definition stack
*/ */
ItemStack getDefinition(); ItemStack getDefinition();
/**
* Compare this AE item stack to another item stack, but ignores the amount. It checks the item type, NBT and damage
* values.
*
* @param is An item stack
*/
boolean equals(ItemStack is);
} }
@@ -23,24 +23,27 @@
package appeng.api.storage.data; package appeng.api.storage.data;
import java.io.IOException; import java.io.IOException;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
import appeng.api.config.FuzzyMode; import appeng.api.config.FuzzyMode;
import appeng.api.storage.IStorageChannel; import appeng.api.storage.IStorageChannel;
public interface IAEStack<T extends IAEStack<T>> {
public interface IAEStack<T extends IAEStack<T>>
{
/** /**
* add two stacks together * add two stacks together
* *
* @param is added item * @param is added item
*/ */
void add(T is); void add( T is );
/** /**
* number of items in the stack. * number of items in the stack.
@@ -54,7 +57,7 @@ public interface IAEStack<T extends IAEStack<T>> {
* *
* @param stackSize , ItemStack.stackSize = N * @param stackSize , ItemStack.stackSize = N
*/ */
T setStackSize(long stackSize); T setStackSize( long stackSize );
/** /**
* Same as getStackSize, but for requestable items. ( LP ) * Same as getStackSize, but for requestable items. ( LP )
@@ -68,7 +71,7 @@ public interface IAEStack<T extends IAEStack<T>> {
* *
* @return basically itemStack.stackSize = N but for setStackSize items. * @return basically itemStack.stackSize = N but for setStackSize items.
*/ */
T setCountRequestable(long countRequestable); T setCountRequestable( long countRequestable );
/** /**
* true, if the item can be crafted. * true, if the item can be crafted.
@@ -82,7 +85,7 @@ public interface IAEStack<T extends IAEStack<T>> {
* *
* @param isCraftable can item be crafted * @param isCraftable can item be crafted
*/ */
T setCraftable(boolean isCraftable); T setCraftable( boolean isCraftable );
/** /**
* clears, requestable, craftable, and stack sizes. * clears, requestable, craftable, and stack sizes.
@@ -101,33 +104,33 @@ public interface IAEStack<T extends IAEStack<T>> {
* *
* @param i additional stack size * @param i additional stack size
*/ */
void incStackSize(long i); void incStackSize( long i );
/** /**
* removes some from the stack size. * removes some from the stack size.
*/ */
void decStackSize(long i); void decStackSize( long i );
/** /**
* adds items to the requestable * adds items to the requestable
* *
* @param i increased amount of requested items * @param i increased amount of requested items
*/ */
void incCountRequestable(long i); void incCountRequestable( long i );
/** /**
* removes items from the requestable * removes items from the requestable
* *
* @param i decreased amount of requested items * @param i decreased amount of requested items
*/ */
void decCountRequestable(long i); void decCountRequestable( long i );
/** /**
* write to a CompoundNBT. * write to a NBTTagCompound.
* *
* @param i to be written data * @param i to be written data
*/ */
void writeToNBT( NBTTagCompound i); void writeToNBT( NBTTagCompound i );
/** /**
* Compare stacks using precise logic. * Compare stacks using precise logic.
@@ -143,18 +146,17 @@ public interface IAEStack<T extends IAEStack<T>> {
* @return true if they are the same. * @return true if they are the same.
*/ */
@Override @Override
boolean equals(Object obj); boolean equals( Object obj );
/** /**
* Compare the same subtype of {@link IAEStack} with another using a fuzzy * Compare the same subtype of {@link IAEStack} with another using a fuzzy comparison.
* comparison.
* *
* @param other The stack to compare. * @param other The stack to compare.
* @param mode Which {@link FuzzyMode} should be used. * @param mode Which {@link FuzzyMode} should be used.
* *
* @return true if two stacks are equal based on AE Fuzzy Comparison. * @return true if two stacks are equal based on AE Fuzzy Comparison.
*/ */
boolean fuzzyComparison(T other, FuzzyMode mode); boolean fuzzyComparison( T other, FuzzyMode mode );
/** /**
* Slower for disk saving, but smaller/more efficient for packets. * Slower for disk saving, but smaller/more efficient for packets.
@@ -163,7 +165,7 @@ public interface IAEStack<T extends IAEStack<T>> {
* *
* @throws IOException * @throws IOException
*/ */
void writeToPacket( ByteBuf data) throws IOException; void writeToPacket( ByteBuf data ) throws IOException;
/** /**
* Clone the Item / Fluid Stack * Clone the Item / Fluid Stack
@@ -180,7 +182,17 @@ public interface IAEStack<T extends IAEStack<T>> {
T empty(); T empty();
/** /**
* @return The {@link IStorageChannel} backing this stack. * @return true if the stack is a {@link IAEItemStack}
*/
boolean isItem();
/**
* @return true if the stack is a {@link IAEFluidStack}
*/
boolean isFluid();
/**
* @return ITEM or FLUID
*/ */
IStorageChannel<T> getChannel(); IStorageChannel<T> getChannel();
@@ -190,4 +202,4 @@ public interface IAEStack<T extends IAEStack<T>> {
* @return itemstack * @return itemstack
*/ */
ItemStack asItemStackRepresentation(); ItemStack asItemStackRepresentation();
} }
+2 -80
View File
@@ -31,13 +31,11 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import appeng.tile.inventory.AppEngInternalInventory;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.base.Stopwatch; import com.google.common.base.Stopwatch;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.minecraftforge.fml.common.Optional; import net.minecraftforge.fml.common.Optional;
import net.minecraftforge.items.IItemHandler;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse; import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@@ -380,59 +378,6 @@ public abstract class AEBaseGui extends GuiContainer implements IMTModGuiContain
} }
} }
} }
else if( slot instanceof SlotDisconnected )
{
this.drag_click.add( slot );
if( this.drag_click.size() > 1 )
{
if( !itemstack.isEmpty() )
{
Set<IItemHandler> visitedInterfaces = new HashSet<>();
for( final Slot dr : this.drag_click )
{
IItemHandler interfaceHandler = ( (SlotDisconnected) slot ).getSlot().getInventory();
if (visitedInterfaces.contains( interfaceHandler )) break;
visitedInterfaces.add( interfaceHandler );
boolean canInsert = true;
for( int s = 0; s < interfaceHandler.getSlots(); s++ )
{
if( ItemStack.areItemStacksEqual( interfaceHandler.getStackInSlot( s ), itemstack ) )
{
canInsert = false;
break;
}
}
if( canInsert )
{
if( slot.getStack().isEmpty() )
{
InventoryAction action = InventoryAction.SPLIT_OR_PLACE_SINGLE;
final PacketInventoryAction p = new PacketInventoryAction( action, dr.getSlotIndex(), ( (SlotDisconnected) slot ).getSlot().getId() );
NetworkHandler.instance().sendToServer( p );
}
}
}
}
else if( isShiftKeyDown() )
{
for( final Slot dr : this.drag_click )
{
InventoryAction action = null;
if( !slot.getStack().isEmpty() )
{
action = InventoryAction.SHIFT_CLICK;
}
if( action != null )
{
final PacketInventoryAction p = new PacketInventoryAction( action, dr.getSlotIndex(), ( (SlotDisconnected) slot ).getSlot().getId() );
NetworkHandler.instance().sendToServer( p );
}
}
}
}
}
else else
{ {
super.mouseClickMove( x, y, c, d ); super.mouseClickMove( x, y, c, d );
@@ -526,35 +471,12 @@ public abstract class AEBaseGui extends GuiContainer implements IMTModGuiContain
if( slot instanceof SlotDisconnected ) if( slot instanceof SlotDisconnected )
{ {
if( this.drag_click.size() > 1 )
{
return;
}
InventoryAction action = null; InventoryAction action = null;
switch ( clickType ) switch( clickType )
{ {
case PICKUP: // pickup / set-down. case PICKUP: // pickup / set-down.
if( slot.getStack().isEmpty() && !player.inventory.getItemStack().isEmpty() ) action = ( mouseButton == 1 ) ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
{
boolean canInsert = true;
IItemHandler interfaceHandler = ( (SlotDisconnected) slot ).getSlot().getInventory();
for( int s = 0; s < interfaceHandler.getSlots(); s++ )
{
if( ItemStack.areItemStacksEqual( interfaceHandler.getStackInSlot( s ), player.inventory.getItemStack() ) )
{
canInsert = false;
break;
}
}
if( canInsert )
{
action = InventoryAction.SPLIT_OR_PLACE_SINGLE;
}
break;
}
if( !slot.getStack().isEmpty() && player.inventory.getItemStack().getCount() <= 1 ) action = InventoryAction.PICKUP_OR_SET_DOWN;
break; break;
case QUICK_MOVE: case QUICK_MOVE:
action = ( mouseButton == 1 ) ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK; action = ( mouseButton == 1 ) ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
@@ -22,15 +22,17 @@ package appeng.client.gui.implementations;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
import appeng.api.config.ActionItems; import akka.event.Logging;
import appeng.api.config.Settings; import appeng.client.render.BlockPosHighlighter;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.util.BlockPosUtils; import appeng.util.BlockPosUtils;
import com.google.common.collect.HashMultimap; import com.google.common.collect.HashMultimap;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagList;
@@ -48,8 +50,10 @@ import appeng.parts.reporting.PartInterfaceTerminal;
import appeng.util.Platform; 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.ITextComponent;
import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentString;
import org.lwjgl.util.Color;
import org.lwjgl.util.ReadableColor;
import static appeng.client.render.BlockPosHighlighter.hilightBlock; import static appeng.client.render.BlockPosHighlighter.hilightBlock;
@@ -60,7 +64,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
private static final int LINES_ON_PAGE = 6; private static final int LINES_ON_PAGE = 6;
// TODO: copied from GuiMEMonitorable. It looks not changed, maybe unneeded? // TODO: copied from GuiMEMonitorable. It looks not changed, maybe unneeded?
private final int offsetX = 21; private final int offsetX = 9;
private final HashMap<Long, ClientDCInternalInv> byId = new HashMap<>(); private final HashMap<Long, ClientDCInternalInv> byId = new HashMap<>();
private final HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create(); private final HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create();
@@ -74,19 +78,16 @@ public class GuiInterfaceTerminal extends AEBaseGui
private boolean refreshList = false; private boolean refreshList = false;
private MEGuiTextField searchFieldOutputs; private MEGuiTextField searchFieldOutputs;
private MEGuiTextField searchFieldInputs; private MEGuiTextField searchFieldInputs;
private PartInterfaceTerminal partInterfaceTerminal;
private GuiButton guiButtonHide;
private GuiButton guiButtonNextAssembler;
public GuiInterfaceTerminal( final InventoryPlayer inventoryPlayer, final PartInterfaceTerminal te ) public GuiInterfaceTerminal( final InventoryPlayer inventoryPlayer, final PartInterfaceTerminal te )
{ {
super( new ContainerInterfaceTerminal( inventoryPlayer, te ) ); super( new ContainerInterfaceTerminal( inventoryPlayer, te ) );
this.partInterfaceTerminal = te;
final GuiScrollbar scrollbar = new GuiScrollbar(); final GuiScrollbar scrollbar = new GuiScrollbar();
this.setScrollBar( scrollbar ); this.setScrollBar( scrollbar );
this.xSize = 208; this.xSize = 195;
this.ySize = 256; this.ySize = 236;
} }
@Override @Override
@@ -94,41 +95,25 @@ public class GuiInterfaceTerminal extends AEBaseGui
{ {
super.initGui(); super.initGui();
this.getScrollBar().setLeft( 189 ); this.getScrollBar().setLeft( 175 );
this.getScrollBar().setHeight( 106 ); this.getScrollBar().setHeight( 106 );
this.getScrollBar().setTop( 51 ); this.getScrollBar().setTop( 32 );
this.searchFieldInputs = new MEGuiTextField( this.fontRenderer, this.guiLeft + Math.max( 32, this.offsetX ), this.guiTop + 25, 65, 12 ); this.searchFieldInputs = new MEGuiTextField( this.fontRenderer, this.guiLeft + Math.max( 16, this.offsetX ), this.guiTop + 18, 65, 12 );
this.searchFieldInputs.setEnableBackgroundDrawing( false ); this.searchFieldInputs.setEnableBackgroundDrawing( false );
this.searchFieldInputs.setMaxStringLength( 25 ); this.searchFieldInputs.setMaxStringLength( 25 );
this.searchFieldInputs.setTextColor( 0xFFFFFF ); this.searchFieldInputs.setTextColor( 0xFFFFFF );
this.searchFieldInputs.setVisible( true ); this.searchFieldInputs.setVisible( true );
this.searchFieldInputs.setFocused( false ); this.searchFieldInputs.setFocused( false );
this.searchFieldOutputs = new MEGuiTextField( this.fontRenderer, this.guiLeft + Math.max( 32, this.offsetX ), this.guiTop + 38, 65, 12 ); // this.searchFieldOutputs = new MEGuiTextField( this.fontRenderer, this.guiLeft + Math.max( 104, this.offsetX ), this.guiTop + 4, 65, 12 );
this.searchFieldOutputs = new MEGuiTextField( this.fontRenderer, this.guiLeft + Math.max( 94, this.offsetX ), this.guiTop + 18, 65, 12 );
this.searchFieldOutputs.setEnableBackgroundDrawing( false ); this.searchFieldOutputs.setEnableBackgroundDrawing( false );
this.searchFieldOutputs.setMaxStringLength( 25 ); this.searchFieldOutputs.setMaxStringLength( 25 );
this.searchFieldOutputs.setTextColor( 0xFFFFFF ); this.searchFieldOutputs.setTextColor( 0xFFFFFF );
this.searchFieldOutputs.setVisible( true ); this.searchFieldOutputs.setVisible( true );
this.searchFieldOutputs.setFocused( true ); this.searchFieldOutputs.setFocused( true );
this.searchFieldInputs.setText( partInterfaceTerminal.in );
this.searchFieldOutputs.setText( partInterfaceTerminal.out );
}
@Override
public void onGuiClosed()
{
partInterfaceTerminal.saveSearchStrings( this.searchFieldInputs.getText().toLowerCase(), this.searchFieldOutputs.getText().toLowerCase() );
super.onGuiClosed();
}
@Override
protected boolean isPointInRegion( int rectX, int rectY, int rectWidth, int rectHeight, int pointX, int pointY )
{
if( searchFieldInputs.isMouseIn( pointX, pointY ) ) drawTooltip( pointX - guiLeft - offsetX, pointY - guiTop , "Inputs OR names" );
else if( searchFieldOutputs.isMouseIn( pointX, pointY ) ) drawTooltip( pointX - guiLeft - offsetX, pointY - guiTop, "Outputs OR names" );
return super.isPointInRegion( rectX, rectY, rectWidth, rectHeight, pointX, pointY );
} }
@Override @Override
@@ -137,21 +122,20 @@ public class GuiInterfaceTerminal extends AEBaseGui
this.buttonList.clear(); this.buttonList.clear();
this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.InterfaceTerminal.getLocal() ), 8, 6, 4210752 ); this.fontRenderer.drawString( this.getGuiDisplayName( GuiText.InterfaceTerminal.getLocal() ), 8, 6, 4210752 );
this.fontRenderer.drawString( GuiText.inventory.getLocal(), this.offsetX + 2, this.ySize - 96 + 3, 4210752 ); this.fontRenderer.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
final int ex = this.getScrollBar().getCurrentScroll(); final int ex = this.getScrollBar().getCurrentScroll();
this.guiButtonNextAssembler = new GuiImgButton(guiLeft + 123, guiTop + 25,Settings.ACTIONS, ActionItems.FREE_MOLECULAR_SLOT_SHORTCUT); final Iterator<Slot> o = this.inventorySlots.inventorySlots.iterator();
this.buttonList.add( guiButtonNextAssembler ); while( o.hasNext() )
{
if( o.next() instanceof SlotDisconnected )
{
o.remove();
}
}
guiButtonHide = new GuiImgButton( guiLeft + 141, guiTop + 25,Settings.ACTIONS, this.partInterfaceTerminal.onlyInterfacesWithFreeSlots ? int offset = 32;
ActionItems.TOGGLE_SHOW_FULL_INTERFACES_OFF :
ActionItems.TOGGLE_SHOW_FULL_INTERFACES_ON);
this.buttonList.add( guiButtonHide );
this.inventorySlots.inventorySlots.removeIf( slot -> slot instanceof SlotDisconnected );
int offset = 51;
for( int x = 0; x < LINES_ON_PAGE && ex + x < this.lines.size(); x++ ) for( int x = 0; x < LINES_ON_PAGE && ex + x < this.lines.size(); x++ )
{ {
final Object lineObj = this.lines.get( ex + x ); final Object lineObj = this.lines.get( ex + x );
@@ -160,10 +144,9 @@ public class GuiInterfaceTerminal extends AEBaseGui
final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj; final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
for( int z = 0; z < inv.getInventory().getSlots(); z++ ) for( int z = 0; z < inv.getInventory().getSlots(); z++ )
{ {
this.inventorySlots.inventorySlots.add( new SlotDisconnected( inv, z, z * 18 + 22, 1 + offset ) ); this.inventorySlots.inventorySlots.add( new SlotDisconnected( inv, z, z * 18 + 8, 1 + offset ) );
} }
GuiButton guiButton = new GuiButton( x, guiLeft + 1, guiTop + offset + 3, 8, 10, "?" );
GuiButton guiButton = new GuiImgButton(guiLeft + 4, guiTop + offset + 1, Settings.ACTIONS, ActionItems.HIGHLIGHT_INTERFACE);
guiButtonHashMap.put( guiButton , inv); guiButtonHashMap.put( guiButton , inv);
this.buttonList.add( guiButton ); this.buttonList.add( guiButton );
@@ -182,7 +165,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
name = name.substring( 0, name.length() - 1 ); name = name.substring( 0, name.length() - 1 );
} }
this.fontRenderer.drawString( name, this.offsetX + 2, 6 + offset, 4210752 ); this.fontRenderer.drawString( name, 10, 6 + offset, 4210752 );
} }
offset += 18; offset += 18;
} }
@@ -218,30 +201,9 @@ 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();
hilightBlock( blockPos, System.currentTimeMillis() + 500 * BlockPosUtils.getDistance(blockPos, blockPos2) ); hilightBlock( blockPos, System.currentTimeMillis() + 500 * BlockPosUtils.getDistance(blockPos, blockPos2) );
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();
} }
if (btn == guiButtonHide)
{
partInterfaceTerminal.onlyInterfacesWithFreeSlots = !partInterfaceTerminal.onlyInterfacesWithFreeSlots;
this.refreshList();
}
if (btn == guiButtonNextAssembler)
{
// Set Search to "Molecular Assembler" and set "Only Free Interface"
boolean currentOnlyInterfacesWithFreeSlots = this.partInterfaceTerminal.onlyInterfacesWithFreeSlots;
String currentSearchText = this.searchFieldOutputs.getText();
this.partInterfaceTerminal.onlyInterfacesWithFreeSlots = true;
this.searchFieldOutputs.setText("Molecular Assembler");
this.refreshList();
this.partInterfaceTerminal.onlyInterfacesWithFreeSlots = currentOnlyInterfacesWithFreeSlots;
this.searchFieldOutputs.setText(currentSearchText);
}
} }
@Override @Override
@@ -250,7 +212,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
this.bindTexture( "guis/newinterfaceterminal.png" ); this.bindTexture( "guis/newinterfaceterminal.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize ); this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
int offset = 51; int offset = 32;
final int ex = this.getScrollBar().getCurrentScroll(); final int ex = this.getScrollBar().getCurrentScroll();
for( int x = 0; x < LINES_ON_PAGE && ex + x < this.lines.size(); x++ ) for( int x = 0; x < LINES_ON_PAGE && ex + x < this.lines.size(); x++ )
@@ -262,7 +224,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
GlStateManager.color( 1, 1, 1, 1 ); GlStateManager.color( 1, 1, 1, 1 );
final int width = inv.getInventory().getSlots() * 18; final int width = inv.getInventory().getSlots() * 18;
this.drawTexturedModalRect( offsetX + 20, offsetY + offset, 20, 173, width, 18 ); this.drawTexturedModalRect( offsetX + 7, offsetY + offset, 7, 153, width, 18 );
} }
offset += 18; offset += 18;
} }
@@ -362,20 +324,19 @@ public class GuiInterfaceTerminal extends AEBaseGui
final String searchFieldInputs = this.searchFieldInputs.getText().toLowerCase(); final String searchFieldInputs = this.searchFieldInputs.getText().toLowerCase();
final String searchFieldOutputs = this.searchFieldOutputs.getText().toLowerCase(); final String searchFieldOutputs = this.searchFieldOutputs.getText().toLowerCase();
final Set<Object> cachedSearch = this.getCacheForSearchTerm( "IN:" + searchFieldInputs + " OUT:" + searchFieldOutputs + partInterfaceTerminal.onlyInterfacesWithFreeSlots); final Set<Object> cachedSearch = this.getCacheForSearchTerm( "IN:" + searchFieldInputs + " OUT:" + searchFieldOutputs );
final boolean rebuild = cachedSearch.isEmpty(); final boolean rebuild = cachedSearch.isEmpty();
for( final ClientDCInternalInv entry : this.byId.values() ) for( final ClientDCInternalInv entry : this.byId.values() )
{ {
// ignore inventory if not doing a full rebuild and cache already marks it as miss. // ignore inventory if not doing a full rebuild or cache already marks it as miss.
if( !rebuild && !cachedSearch.contains( entry ) ) if( !rebuild && !cachedSearch.contains( entry ) )
{ {
continue; continue;
} }
// Shortcut to skip any filter if search term is ""/empty // Shortcut to skip any filter if search term is ""/empty
boolean found = (searchFieldInputs.isEmpty() && searchFieldOutputs.isEmpty());
boolean found = (searchFieldInputs.isEmpty() && searchFieldOutputs.isEmpty() && !partInterfaceTerminal.onlyInterfacesWithFreeSlots);
// Search if the current inventory holds a pattern containing the search term. // Search if the current inventory holds a pattern containing the search term.
if( !found ) if( !found )
@@ -393,32 +354,13 @@ public class GuiInterfaceTerminal extends AEBaseGui
break; break;
} }
} }
}
// If only Interfaces with empty slots should be shown, check that here
boolean interfaceHasFreeSlots = false;
if (partInterfaceTerminal.onlyInterfacesWithFreeSlots) {
for( final ItemStack itemStack : entry.getInventory() )
{
if(itemStack.isEmpty()){
interfaceHasFreeSlots = true;
break;
}
}
} }
// if found, filter skipped or machine name matching the search term, add it // if found, filter skipped or machine name matching the search term, add it
if( found || (entry.getName().toLowerCase().contains( searchFieldInputs ) && entry.getName().toLowerCase().contains( searchFieldOutputs ))) if( found || (entry.getName().toLowerCase().contains( searchFieldInputs ) && entry.getName().toLowerCase().contains( searchFieldOutputs )))
{ {
if (!partInterfaceTerminal.onlyInterfacesWithFreeSlots) this.byName.put( entry.getName(), entry );
{ cachedSearch.add( entry );
this.byName.put( entry.getName(), entry );
cachedSearch.add( entry );
}
else if ( interfaceHasFreeSlots ){
this.byName.put( entry.getName(), entry );
cachedSearch.add( entry );
}
} }
else else
{ {
@@ -142,11 +142,6 @@ public class GuiImgButton extends GuiButton implements ITooltip
this.registerApp( 11 + 4 * 16, Settings.ACTIONS, ActionItems.DECREASE_BY_ONE, ButtonToolTips.DecreaseByOne, ButtonToolTips.DecreaseByOneDesc ); this.registerApp( 11 + 4 * 16, Settings.ACTIONS, ActionItems.DECREASE_BY_ONE, ButtonToolTips.DecreaseByOne, ButtonToolTips.DecreaseByOneDesc );
this.registerApp( 12 + 4 * 16, Settings.ACTIONS, ActionItems.MAX_COUNT, ButtonToolTips.MaxCount, ButtonToolTips.MaxCountDesc ); this.registerApp( 12 + 4 * 16, Settings.ACTIONS, ActionItems.MAX_COUNT, ButtonToolTips.MaxCount, ButtonToolTips.MaxCountDesc );
this.registerApp( 6 + 5 * 16, Settings.ACTIONS, ActionItems.FREE_MOLECULAR_SLOT_SHORTCUT, ButtonToolTips.FreeMolecularSlotShortcut, ButtonToolTips.FreeMolecularSlotShortcutDesc );
this.registerApp( 7 + 5 * 16, Settings.ACTIONS, ActionItems.TOGGLE_SHOW_FULL_INTERFACES_ON, ButtonToolTips.ToggleShowFullInterfaces, ButtonToolTips.ToggleShowFullInterfacesOnDesc );
this.registerApp( 8 + 5 * 16, Settings.ACTIONS, ActionItems.TOGGLE_SHOW_FULL_INTERFACES_OFF, ButtonToolTips.ToggleShowFullInterfaces, ButtonToolTips.ToggleShowFullInterfacesOffDesc );
this.registerApp( 6 + 6 * 16, Settings.ACTIONS, ActionItems.HIGHLIGHT_INTERFACE, ButtonToolTips.HighlightInterface, "" );
this.registerApp( 8, Settings.ACTIONS, ActionItems.ENCODE, ButtonToolTips.Encode, ButtonToolTips.EncodeDescription ); this.registerApp( 8, Settings.ACTIONS, ActionItems.ENCODE, ButtonToolTips.Encode, ButtonToolTips.EncodeDescription );
this.registerApp( 4 + 3 * 16, Settings.ACTIONS, ItemSubstitution.ENABLED, ButtonToolTips.Substitutions, ButtonToolTips.SubstitutionsDescEnabled ); this.registerApp( 4 + 3 * 16, Settings.ACTIONS, ItemSubstitution.ENABLED, ButtonToolTips.Substitutions, ButtonToolTips.SubstitutionsDescEnabled );
this.registerApp( 7 + 3 * 16, Settings.ACTIONS, ItemSubstitution.DISABLED, ButtonToolTips.Substitutions, ButtonToolTips.SubstitutionsDescDisabled ); this.registerApp( 7 + 3 * 16, Settings.ACTIONS, ItemSubstitution.DISABLED, ButtonToolTips.Substitutions, ButtonToolTips.SubstitutionsDescDisabled );
@@ -37,7 +37,7 @@ public class ClientDCInternalInv implements Comparable<ClientDCInternalInv>
public ClientDCInternalInv( final int size, final long id, final long sortBy, final String unlocalizedName ) public ClientDCInternalInv( final int size, final long id, final long sortBy, final String unlocalizedName )
{ {
this.inventory = new AppEngInternalInventory( null, size, 1 ); this.inventory = new AppEngInternalInventory( null, size );
this.unlocalizedName = unlocalizedName; this.unlocalizedName = unlocalizedName;
this.id = id; this.id = id;
this.sortBy = sortBy; this.sortBy = sortBy;
@@ -80,7 +80,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
this.grid = anchor.getActionableNode().getGrid(); this.grid = anchor.getActionableNode().getGrid();
} }
this.bindPlayerInventory( ip, 14, 256 - /* height of player inventory */82 ); this.bindPlayerInventory( ip, 0, 236 - /* height of player inventory */82 );
} }
@Override @Override
@@ -258,7 +258,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
if( hasItemInHand ) if( hasItemInHand )
{ {
ItemStack extra = playerHand.removeItems( 1, ItemStack.EMPTY, null ); ItemStack extra = playerHand.removeItems( 1, ItemStack.EMPTY, null );
if( !extra.isEmpty() && !interfaceSlot.containsItems()) if( !extra.isEmpty() )
{ {
extra = interfaceSlot.addItems( extra ); extra = interfaceSlot.addItems( extra );
} }
@@ -419,7 +419,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
this.client = new AppEngInternalInventory( null, this.server.getSlots() ); this.client = new AppEngInternalInventory( null, this.server.getSlots() );
this.unlocalizedName = unlocalizedName; this.unlocalizedName = unlocalizedName;
this.sortBy = dual.getSortValue(); this.sortBy = dual.getSortValue();
this.pos = dual.getLocation().getPos(); this.pos = dual.getTile().getPos();
} }
} }
@@ -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 > input[x].getMaxStackSize() ) if( !input[x].isEmpty() && input[x].getCount() * multiple > 64 )
{ {
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 > out.getMaxStackSize() ) if( !out.isEmpty() && out.getCount() * multiple > 64 )
{ {
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 > input[x].getMaxStackSize() ) if( !input[x].isEmpty() && input[x].getCount() + increase > 64 )
{ {
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 > out.getMaxStackSize() ) if( !out.isEmpty() && out.getCount() + increase > 64 )
{ {
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() && input[x].getMaxStackSize() - input[x].getCount() > maxInputStackGrowth ) if( !input[x].isEmpty() && 64 - input[x].getCount() > maxInputStackGrowth )
{ {
maxInputStackGrowth = input[x].getMaxStackSize() - input[x].getCount(); maxInputStackGrowth = 64 - input[x].getCount();
} }
if( !input[x].isEmpty() && input[x].getCount() + maxInputStackGrowth > input[x].getMaxStackSize() ) if( !input[x].isEmpty() && input[x].getCount() + maxInputStackGrowth > 64 )
{ {
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 = out.getMaxStackSize() - out.getCount(); maxOutputStackGrowth = 64 - out.getCount();
} }
if( !out.isEmpty() && out.getCount() + maxOutputStackGrowth > out.getMaxStackSize() ) if( !out.isEmpty() && out.getCount() + maxOutputStackGrowth > 64 )
{ {
canGrowOutputs = false; canGrowOutputs = false;
} }
@@ -616,12 +616,7 @@ public final class ApiBlocks implements IBlocks
private static IBlockDefinition makeStairs( String registryName, FeatureFactory registry, IBlockDefinition block ) private static IBlockDefinition makeStairs( String registryName, FeatureFactory registry, IBlockDefinition block )
{ {
if( !block.maybeBlock().isPresent() ) return registry.block( registryName, () -> new BlockStairCommon( block.maybeBlock().get(), block.identifier() ) )
{
return new BlockDefinition( registryName, null, null );
}
IBlockDefinition stairs = registry.block( registryName, () -> new BlockStairCommon( block.maybeBlock().get(), block.identifier() ) )
.features( AEFeature.DECORATIVE_BLOCKS ) .features( AEFeature.DECORATIVE_BLOCKS )
.rendering( new BlockRenderingCustomizer() .rendering( new BlockRenderingCustomizer()
{ {
@@ -634,10 +629,6 @@ public final class ApiBlocks implements IBlocks
} }
} ) } )
.build(); .build();
Verify.verify(stairs.maybeBlock().isPresent());
return stairs;
} }
@Override @Override
@@ -19,7 +19,6 @@
package appeng.core.localization; package appeng.core.localization;
import appeng.api.config.SchedulingMode;
import net.minecraft.util.text.translation.I18n; import net.minecraft.util.text.translation.I18n;
@@ -152,13 +151,6 @@ public enum ButtonToolTips
DecreaseByOneDesc, DecreaseByOneDesc,
MaxCount, MaxCount,
MaxCountDesc, MaxCountDesc,
FreeMolecularSlotShortcut,
FreeMolecularSlotShortcutDesc,
ToggleShowFullInterfaces,
ToggleShowFullInterfacesOnDesc,
ToggleShowFullInterfacesOffDesc,
HighlightInterface,
HighlightInterfaceDesc,
// Used in the tooltips of the items in the terminal, when moused over // Used in the tooltips of the items in the terminal, when moused over
ItemsStored, ItemsStored,
@@ -171,11 +171,6 @@ public class PacketJEIRecipe extends AppEngPacket
// already the correct item? // already the correct item?
ItemStack newItem = this.canUseInSlot( x, currentItem ); ItemStack newItem = this.canUseInSlot( x, currentItem );
if ( !cct.useRealItems() && this.recipe[x] != null ) {
if (this.recipe[x].length > 0 )
currentItem.setCount( recipe[x][0].getCount() );
}
// put away old item // put away old item
if( newItem != currentItem && security.hasPermission( player, SecurityPermissions.INJECT ) ) if( newItem != currentItem && security.hasPermission( player, SecurityPermissions.INJECT ) )
{ {
@@ -215,7 +210,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() )
{ {
@@ -242,6 +237,22 @@ public class PacketJEIRecipe extends AppEngPacket
// Fall back using an existing item // Fall back using an existing item
out = storage.extractItems( request, Actionable.SIMULATE, cct.getActionSource() ); 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 ) if( out != null )
@@ -263,17 +274,14 @@ public class PacketJEIRecipe extends AppEngPacket
else else
{ {
currentItem = ad.simulateSimilarRemove(recipe[x][y].getCount(), this.recipe[x][y],FuzzyMode.IGNORE_ALL, null ); 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 (!cct.useRealItems())
{
if( currentItem.isEmpty() && this.recipe[x] != null )
{
currentItem = this.recipe[x][0].copy();
}
}
} }
ItemHandlerUtil.setStackInSlot( craftMatrix, x, currentItem ); ItemHandlerUtil.setStackInSlot( craftMatrix, x, currentItem );
} }
@@ -26,9 +26,7 @@ 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 net.minecraft.item.ItemStack;
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;
@@ -64,18 +62,12 @@ 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;
if( this.proxyable instanceof PartStorageBus ) this.cache = new FluidHandlerAdapter.InventoryCache( this.fluidHandler );
{
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
@@ -204,12 +196,13 @@ 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; private ArrayList<Integer> skipSlots;
public InventoryCache( IFluidHandler fluidHandler, StorageFilter mode )
public InventoryCache( IFluidHandler fluidHandler )
{ {
this.mode = mode;
this.fluidHandler = fluidHandler; this.fluidHandler = fluidHandler;
this.skipSlots = new ArrayList<>(this.fluidHandler.getTankProperties().length);
} }
public List<IAEFluidStack> update() public List<IAEFluidStack> update()
@@ -222,20 +215,23 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
if( slots > this.cachedAeStacks.length ) if( slots > this.cachedAeStacks.length )
{ {
this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots ); this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots );
this.skipSlots = new ArrayList<>(this.fluidHandler.getTankProperties().length);
} }
for( int slot = 0; slot < slots; slot++ ) for( int slot = 0; slot < slots; slot++ )
{ {
if (skipSlots.contains( slot ))
continue;
// Save the old stuff // Save the old stuff
final IAEFluidStack oldAEFS = this.cachedAeStacks[slot]; final IAEFluidStack oldAEFS = this.cachedAeStacks[slot];
FluidStack newFS = tankProperties[slot].getContents(); FluidStack newFS = tankProperties[slot].getContents();
if( this.mode == StorageFilter.EXTRACTABLE_ONLY && newFS != null ) if (newFS != null) {
{ if (this.fluidHandler.drain( 1, false ) == null){
if( this.fluidHandler.drain( 1, false ) == null )
{
newFS = null; newFS = null;
skipSlots.add( slot );
} }
} }
this.handlePossibleSlotChanges( slot, oldAEFS, newFS, changes ); this.handlePossibleSlotChanges( slot, oldAEFS, newFS, changes );
} }
@@ -255,6 +251,7 @@ public class FluidHandlerAdapter implements IMEInventory<IAEFluidStack>, IBaseMo
} }
this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots ); this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots );
this.skipSlots = new ArrayList<>( this.fluidHandler.getTankProperties().length );
} }
return changes; return changes;
} }
@@ -32,7 +32,6 @@ import io.netty.buffer.ByteBuf;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
@@ -217,6 +216,18 @@ public final class AEFluidStack extends AEStack<IAEFluidStack> implements IAEFlu
return dup; return dup;
} }
@Override
public boolean isItem()
{
return false;
}
@Override
public boolean isFluid()
{
return true;
}
@Override @Override
public IStorageChannel<IAEFluidStack> getChannel() public IStorageChannel<IAEFluidStack> getChannel()
{ {
@@ -307,17 +318,17 @@ public final class AEFluidStack extends AEStack<IAEFluidStack> implements IAEFlu
} }
@Override @Override
public void writeToPacket( final ByteBuf i ) throws IOException public void writeToPacket( final ByteBuf buffer ) throws IOException
{ {
final byte mask = (byte) ( ( this.getType( this.getStackSize() ) << 2 ) | ( this final byte mask = (byte) ( ( this.getType( this.getStackSize() ) << 2 ) | ( this
.getType( this.getCountRequestable() ) << 4 ) | ( (byte) ( this.isCraftable() ? 1 : 0 ) << 6 ) | ( this.hasTagCompound() ? 1 : 0 ) << 7 ); .getType( this.getCountRequestable() ) << 4 ) | ( (byte) ( this.isCraftable() ? 1 : 0 ) << 6 ) | ( this.hasTagCompound() ? 1 : 0 ) << 7 );
i.writeByte( mask ); buffer.writeByte( mask );
this.writeToStream( i ); this.writeToStream( buffer );
this.putPacketValue( i, this.getStackSize() ); this.putPacketValue( buffer, this.getStackSize() );
this.putPacketValue( i, this.getCountRequestable() ); this.putPacketValue( buffer, this.getCountRequestable() );
} }
private void writeToStream( final ByteBuf buffer ) throws IOException private void writeToStream( final ByteBuf buffer ) throws IOException
@@ -33,8 +33,6 @@ 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;
@@ -50,7 +48,6 @@ 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;
@@ -112,8 +109,6 @@ 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
{ {
@@ -1240,13 +1235,6 @@ 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 );
+4 -6
View File
@@ -19,9 +19,9 @@
package appeng.me.cache; package appeng.me.cache;
import java.util.*; import java.util.HashMap;
import java.util.PriorityQueue;
import appeng.parts.automation.PartLevelEmitter;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import net.minecraft.crash.CrashReport; import net.minecraft.crash.CrashReport;
@@ -46,7 +46,6 @@ public class TickManagerCache implements ITickManager
private final HashMap<IGridNode, TickTracker> alertable = new HashMap<>(); private final HashMap<IGridNode, TickTracker> alertable = new HashMap<>();
private final HashMap<IGridNode, TickTracker> sleeping = new HashMap<>(); private final HashMap<IGridNode, TickTracker> sleeping = new HashMap<>();
private final HashMap<IGridNode, TickTracker> awake = 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 final PriorityQueue<TickTracker> upcomingTicks = new PriorityQueue<>();
private long currentTick = 0; private long currentTick = 0;
@@ -87,7 +86,7 @@ public class TickManagerCache implements ITickManager
{ {
this.currentTick++; this.currentTick++;
while ( !this.upcomingTicks.isEmpty() ) while( !this.upcomingTicks.isEmpty() )
{ {
tt = this.upcomingTicks.peek(); tt = this.upcomingTicks.peek();
@@ -102,7 +101,7 @@ public class TickManagerCache implements ITickManager
final int diff = (int) ( this.currentTick - tt.getLastTick() ); final int diff = (int) ( this.currentTick - tt.getLastTick() );
final TickRateModulation mod = tt.getGridTickable().tickingRequest( tt.getNode(), diff ); final TickRateModulation mod = tt.getGridTickable().tickingRequest( tt.getNode(), diff );
switch ( mod ) switch( mod )
{ {
case FASTER: case FASTER:
tt.setCurrentRate( tt.getCurrentRate() - 2 ); tt.setCurrentRate( tt.getCurrentRate() - 2 );
@@ -138,7 +137,6 @@ public class TickManagerCache implements ITickManager
tt.addEntityCrashInfo( crashreportcategory ); tt.addEntityCrashInfo( crashreportcategory );
throw new ReportedException( crashreport ); throw new ReportedException( crashreport );
} }
PartLevelEmitter.wipeCache();
} }
private void addToQueue( final TickTracker tt ) private void addToQueue( final TickTracker tt )
@@ -19,7 +19,6 @@
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;
@@ -31,8 +30,4 @@ public interface ITickingMonitor
void setActionSource( IActionSource actionSource ); void setActionSource( IActionSource actionSource );
default void setMode( StorageFilter setting )
{
}
} }
@@ -19,14 +19,9 @@
package appeng.parts.automation; package appeng.parts.automation;
import java.util.Collection;
import java.util.Random; import java.util.Random;
import appeng.me.Grid;
import appeng.me.GridNode;
import appeng.util.item.AEItemStack;
import it.unimi.dsi.fastutil.objects.Object2LongMap;
import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -123,9 +118,6 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
private double centerX; private double centerX;
private double centerY; private double centerY;
private double centerZ; private double centerZ;
static Object2LongMap<Grid> gridItemCount = new Object2LongOpenHashMap<>();
static Object2ObjectOpenHashMap<Grid, Object2LongMap<AEItemStack>> fuzzyAEItemStackCount = new Object2ObjectOpenHashMap<>();
static Object2ObjectOpenHashMap<Grid, Object2LongMap<AEItemStack>> preciseAEItemStackCount = new Object2ObjectOpenHashMap<>();
@Reflected @Reflected
public PartLevelEmitter( final ItemStack is ) public PartLevelEmitter( final ItemStack is )
@@ -323,91 +315,40 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
} }
private void updateReportingValue( final IMEMonitor<IAEItemStack> monitor ) private void updateReportingValue( final IMEMonitor<IAEItemStack> monitor )
{
updateReportingValue( monitor,null );
}
private void updateReportingValue( final IMEMonitor<IAEItemStack> monitor, Iterable<IAEItemStack> change )
{ {
final IAEItemStack myStack = this.config.getAEStackInSlot( 0 ); final IAEItemStack myStack = this.config.getAEStackInSlot( 0 );
GridNode node = (GridNode) (this.getGridNode()); if( myStack == null )
if( node != null )
{ {
this.lastReportedValue = 0;
final Grid g = node.getInternalGrid(); for( final IAEItemStack st : monitor.getStorageList() )
if( myStack == null )
{ {
if( change != null ) this.lastReportedValue += st.getStackSize();
{
if( gridItemCount.containsKey( g ) )
{
change.forEach( iaeItemStack -> lastReportedValue += iaeItemStack.getStackSize() );
}
}
gridItemCount.computeIfAbsent( g, ( aLong ) -> {
this.lastReportedValue = 0;
monitor.getStorageList().forEach( iaeItemStack -> lastReportedValue += iaeItemStack.getStackSize() );
return ( lastReportedValue );
} );
this.lastReportedValue = gridItemCount.get( g );
} }
}
else if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ) else if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
{
this.lastReportedValue = 0;
final FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE );
final Collection<IAEItemStack> fuzzyList = monitor.getStorageList().findFuzzy( myStack, fzMode );
for( final IAEItemStack st : fuzzyList )
{ {
final FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ); this.lastReportedValue += st.getStackSize();
if( change != null ) }
{ }
if( fuzzyAEItemStackCount.containsKey( g ) ) else
{ {
change.forEach( iaeItemStack -> { final IAEItemStack r = monitor.getStorageList().findPrecise( myStack );
if( iaeItemStack.sameOre( myStack ) ) lastReportedValue += iaeItemStack.getStackSize(); if( r == null )
} ); {
} this.lastReportedValue = 0;
}
fuzzyAEItemStackCount.computeIfAbsent( g, ( grid -> new Object2LongOpenHashMap<>() ) );
fuzzyAEItemStackCount.get( g ).computeIfAbsent( (AEItemStack) myStack, ( aLong -> {
this.lastReportedValue = 0;
monitor.getStorageList().findFuzzy( myStack, fzMode ).forEach( iaeItemStack -> lastReportedValue += iaeItemStack.getStackSize() );
return ( lastReportedValue );
} ) );
this.lastReportedValue = fuzzyAEItemStackCount.get( g ).get( myStack );
if( this.lastReportedValue == 0 )
{
fuzzyAEItemStackCount.get( g ).remove( myStack );
fuzzyAEItemStackCount.trim();
}
} }
else else
{ {
if( change != null ) this.lastReportedValue = r.getStackSize();
{
if( preciseAEItemStackCount.containsKey( g ) )
{
change.forEach( iaeItemStack -> {
if( iaeItemStack.isSameType( myStack ) ) lastReportedValue += iaeItemStack.getStackSize();
} );
}
}
preciseAEItemStackCount.computeIfAbsent( g, ( grid -> new Object2LongOpenHashMap<>() ) );
preciseAEItemStackCount.get( g ).computeIfAbsent( (AEItemStack) myStack, ( aLong -> {
this.lastReportedValue = 0;
IAEItemStack precise = monitor.getStorageList().findPrecise( myStack );
if( precise != null ) lastReportedValue = precise.getStackSize();
return ( lastReportedValue );
} ) );
this.lastReportedValue = preciseAEItemStackCount.get( g ).get( myStack );
if( this.lastReportedValue == 0 )
{
preciseAEItemStackCount.get( g ).remove( myStack );
preciseAEItemStackCount.trim();
}
} }
} }
this.updateState(); this.updateState();
} }
@@ -459,7 +400,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
@Override @Override
public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final IActionSource actionSource ) public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final IActionSource actionSource )
{ {
this.updateReportingValue( (IMEMonitor<IAEItemStack>) monitor, change ); this.updateReportingValue( (IMEMonitor<IAEItemStack>) monitor );
} }
@Override @Override
@@ -635,10 +576,4 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
return this.isLevelEmitterOn() ? MODEL_ON_OFF : MODEL_OFF_OFF; return this.isLevelEmitterOn() ? MODEL_ON_OFF : MODEL_OFF_OFF;
} }
} }
public static void wipeCache(){
fuzzyAEItemStackCount.clear();
preciseAEItemStackCount.clear();
gridItemCount.clear();
}
} }
@@ -26,9 +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 it.unimi.dsi.fastutil.ints.IntList;
import appeng.api.config.StorageFilter;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import appeng.api.AEApi; import appeng.api.AEApi;
@@ -59,18 +59,12 @@ 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;
if( this.proxyable instanceof PartStorageBus ) this.cache = new InventoryCache( this.itemHandler );
{
PartStorageBus partStorageBus = (PartStorageBus) this.proxyable;
this.mode = ( (StorageFilter) partStorageBus.getConfigManager().getSetting( Settings.STORAGE_FILTER ) );
}
this.cache = new InventoryCache( this.itemHandler, this.mode );
} }
@Override @Override
@@ -276,12 +270,12 @@ 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; private ArrayList<Integer> skipSlots;
public InventoryCache( IItemHandler itemHandler, StorageFilter mode ) public InventoryCache( IItemHandler itemHandler )
{ {
this.mode = mode;
this.itemHandler = itemHandler; this.itemHandler = itemHandler;
this.skipSlots = new ArrayList<>(this.itemHandler.getSlots());
} }
public IItemList<IAEItemStack> getAvailableItems( IItemList<IAEItemStack> out ) public IItemList<IAEItemStack> getAvailableItems( IItemList<IAEItemStack> out )
@@ -299,18 +293,20 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
if( slots > this.cachedAeStacks.length ) if( slots > this.cachedAeStacks.length )
{ {
this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots ); this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots );
this.skipSlots = new ArrayList<>(this.itemHandler.getSlots());
} }
for( int slot = 0; slot < slots; slot++ ) for( int slot = 0; slot < slots; slot++ )
{ {
if (skipSlots.contains( slot ))
continue;
// Save the old stuff // Save the old stuff
final IAEItemStack oldAeIS = this.cachedAeStacks[slot]; final IAEItemStack oldAeIS = this.cachedAeStacks[slot];
ItemStack newIS = this.itemHandler.getStackInSlot( slot ); ItemStack newIS = this.itemHandler.getStackInSlot( slot );
if( this.mode == StorageFilter.EXTRACTABLE_ONLY && !newIS.isEmpty() ) if (!newIS.isEmpty()) {
{ if (this.itemHandler.extractItem( slot,1,true ).isEmpty()){
if( this.itemHandler.extractItem( slot, 1, true ).isEmpty() )
{
newIS = ItemStack.EMPTY; newIS = ItemStack.EMPTY;
skipSlots.add( slot );
} }
} }
this.handlePossibleSlotChanges( slot, oldAeIS, newIS, changes ); this.handlePossibleSlotChanges( slot, oldAeIS, newIS, changes );
@@ -333,6 +329,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
// Reduce the cache size // Reduce the cache size
this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots ); this.cachedAeStacks = Arrays.copyOf( this.cachedAeStacks, slots );
this.skipSlots = new ArrayList<>(this.itemHandler.getSlots());
} }
return changes; return changes;
@@ -484,7 +484,6 @@ 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 )
@@ -44,9 +44,6 @@ public class PartInterfaceTerminal extends AbstractPartDisplay
public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF ); public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF );
public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_ON ); public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_ON );
public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL ); public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL );
public String in = "";
public String out = "";
public boolean onlyInterfacesWithFreeSlots = false;
public PartInterfaceTerminal( final ItemStack is ) public PartInterfaceTerminal( final ItemStack is )
{ {
@@ -72,8 +69,4 @@ public class PartInterfaceTerminal extends AbstractPartDisplay
return this.selectModel( MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL ); return this.selectModel( MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL );
} }
public void saveSearchStrings(String in, String out){
this.in = in;
this.out = out;
}
} }
@@ -1,36 +0,0 @@
package appeng.recipes.factories.conditions;
import appeng.core.Api;
import appeng.core.AppEng;
import com.google.gson.JsonObject;
import net.minecraft.util.JsonUtils;
import net.minecraftforge.common.crafting.IConditionFactory;
import net.minecraftforge.common.crafting.JsonContext;
import java.util.function.BooleanSupplier;
public class PartExists implements IConditionFactory {
private static final String JSON_MATERIAL_KEY = "part";
@Override
public BooleanSupplier parse(JsonContext jsonContext, JsonObject jsonObject )
{
final boolean result;
if( JsonUtils.isString( jsonObject, JSON_MATERIAL_KEY ) )
{
final String part = JsonUtils.getString( jsonObject, JSON_MATERIAL_KEY );
final Object item = Api.INSTANCE.registries().recipes().resolveItem( AppEng.MOD_ID, part );
result = item != null;
}
else
{
result = false;
}
return () -> result;
}
}
+1 -1
View File
@@ -48,4 +48,4 @@ public final class UUIDMatcher
{ {
return PATTERN.matcher( potential ).matches(); return PATTERN.matcher( potential ).matches();
} }
} }
@@ -197,7 +197,7 @@ public class AdaptorItemRepository extends InventoryAdaptor
@Override @Override
public boolean hasSlots() public boolean hasSlots()
{ {
return true; return false;
} }
@Override @Override
+284 -222
View File
@@ -1,6 +1,6 @@
/* /*
* This file is part of Applied Energistics 2. * This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2020, AlgorithmX2, All rights reserved. * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
* *
* Applied Energistics 2 is free software: you can redistribute it and/or modify * Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
@@ -18,6 +18,7 @@
package appeng.util.item; package appeng.util.item;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Optional; import java.util.Optional;
@@ -25,287 +26,348 @@ import java.util.Optional;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import appeng.api.AEApi;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.network.ByteBufUtils; import net.minecraftforge.fml.common.network.ByteBufUtils;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemHandlerHelper;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode; import appeng.api.config.FuzzyMode;
import appeng.api.storage.IStorageChannel; import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.util.Platform; import appeng.util.Platform;
public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemStack {
private final AESharedItemStack sharedStack; public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemStack
private Optional<OreReference> oreReference; {
private AESharedItemStack sharedStack;
private Optional<OreReference> oreReference;
@SideOnly( Side.CLIENT ) @SideOnly( Side.CLIENT )
private String displayName; private String displayName;
@SideOnly( Side.CLIENT ) @SideOnly( Side.CLIENT )
private List<String> tooltip; private List<String> tooltip;
@SideOnly( Side.CLIENT )
private ResourceLocation uniqueID;
private AEItemStack(final AEItemStack is) { private AEItemStack( final AEItemStack is )
this.setStackSize(is.getStackSize()); {
this.setCraftable(is.isCraftable()); this.setStackSize( is.getStackSize() );
this.setCountRequestable(is.getCountRequestable()); this.setCraftable( is.isCraftable() );
this.sharedStack = is.sharedStack; this.setCountRequestable( is.getCountRequestable() );
this.oreReference = is.oreReference; this.sharedStack = is.sharedStack;
} this.oreReference = is.oreReference;
}
private AEItemStack(final AESharedItemStack is, long size) { private AEItemStack( final AESharedItemStack is, long size )
this.sharedStack = is; {
this.setStackSize(size); this.sharedStack = is;
this.setCraftable(false); this.setStackSize( size );
this.setCountRequestable(0); this.setCraftable( false );
this.oreReference = OreHelper.INSTANCE.getOre( is.getDefinition() ); this.setCountRequestable( 0 );
} this.oreReference = OreHelper.INSTANCE.getOre( is.getDefinition() );
}
@Nullable @Nullable
public static AEItemStack fromItemStack(@Nonnull final ItemStack stack) { public static AEItemStack fromItemStack( @Nonnull final ItemStack stack )
if (stack.isEmpty()) { {
return null; if( stack.isEmpty() )
} {
return null;
}
return new AEItemStack(AEItemStackRegistry.getRegisteredStack(stack), stack.getCount()); return new AEItemStack( AEItemStackRegistry.getRegisteredStack( stack ), stack.getCount() );
} }
public static IAEItemStack fromNBT( final NBTTagCompound i ) public static IAEItemStack fromNBT( final NBTTagCompound i )
{ {
if( i == null ) if( i == null )
{ {
return null; return null;
} }
final ItemStack itemstack = new ItemStack( i ); final ItemStack itemstack = new ItemStack( i );
if( itemstack.isEmpty() ) if( itemstack.isEmpty() )
{ {
return null; return null;
} }
final AEItemStack item = AEItemStack.fromItemStack( itemstack ); final AEItemStack item = AEItemStack.fromItemStack( itemstack );
item.setStackSize( i.getLong( "Cnt" ) ); item.setStackSize( i.getLong( "Cnt" ) );
item.setCountRequestable( i.getLong( "Req" ) ); item.setCountRequestable( i.getLong( "Req" ) );
item.setCraftable( i.getBoolean( "Craft" ) ); item.setCraftable( i.getBoolean( "Craft" ) );
return item; return item;
} }
@Override @Override
public void writeToNBT( final NBTTagCompound i ) public void writeToNBT( final NBTTagCompound i )
{ {
this.getDefinition().writeToNBT( i ); this.getDefinition().writeToNBT( i );
i.setLong( "Cnt", this.getStackSize() ); i.setLong( "Cnt", this.getStackSize() );
i.setLong( "Req", this.getCountRequestable() ); i.setLong( "Req", this.getCountRequestable() );
i.setBoolean( "Craft", this.isCraftable() ); i.setBoolean( "Craft", this.isCraftable() );
} }
public static AEItemStack fromPacket( final ByteBuf data ) public static AEItemStack fromPacket( final ByteBuf data )
{ {
final byte mask = data.readByte(); final byte mask = data.readByte();
final byte stackType = (byte) ( ( mask & 0x0C ) >> 2 ); final byte stackType = (byte) ( ( mask & 0x0C ) >> 2 );
final byte countReqType = (byte) ( ( mask & 0x30 ) >> 4 ); final byte countReqType = (byte) ( ( mask & 0x30 ) >> 4 );
final boolean isCraftable = ( mask & 0x40 ) > 0; final boolean isCraftable = ( mask & 0x40 ) > 0;
final ItemStack itemstack = new ItemStack( ByteBufUtils.readTag( data ) ); final ItemStack itemstack = new ItemStack( ByteBufUtils.readTag( data ) );
final long stackSize = getPacketValue( stackType, data ); final long stackSize = getPacketValue( stackType, data );
final long countRequestable = getPacketValue( countReqType, data ); final long countRequestable = getPacketValue( countReqType, data );
if( itemstack.isEmpty() ) if( itemstack.isEmpty() )
{ {
return null; return null;
} }
final AEItemStack item = new AEItemStack( AEItemStackRegistry.getRegisteredStack( itemstack ), stackSize ); final AEItemStack item = new AEItemStack( AEItemStackRegistry.getRegisteredStack( itemstack ), stackSize );
item.setCountRequestable( countRequestable ); item.setCountRequestable( countRequestable );
item.setCraftable( isCraftable ); item.setCraftable( isCraftable );
return item; return item;
} }
@Override @Override
public void writeToPacket( final ByteBuf i ) public void writeToPacket( final ByteBuf i )
{ {
final byte mask = (byte) ( ( this.getType( this.getStackSize() ) << 2 ) | ( this final byte mask = (byte) ( ( this.getType( this.getStackSize() ) << 2 ) | ( this
.getType( this.getCountRequestable() ) << 4 ) | ( (byte) ( this.isCraftable() ? 1 : 0 ) << 6 ) | ( this.hasTagCompound() ? 1 : 0 ) << 7 ); .getType( this.getCountRequestable() ) << 4 ) | ( (byte) ( this.isCraftable() ? 1 : 0 ) << 6 ) | ( this.hasTagCompound() ? 1 : 0 ) << 7 );
i.writeByte( mask ); i.writeByte( mask );
ByteBufUtils.writeTag( i, this.getDefinition().serializeNBT() ); ByteBufUtils.writeTag( i, this.getDefinition().serializeNBT() );
this.putPacketValue( i, this.getStackSize() ); this.putPacketValue( i, this.getStackSize() );
this.putPacketValue( i, this.getCountRequestable() ); this.putPacketValue( i, this.getCountRequestable() );
} }
/** @Override
* We're assuming that using capNBT here is safe, because {@link #getDefinition()} should have been created by public void add( final IAEItemStack option )
* {@link ItemStack#copy()}, and then never mutated. Copying an item stack will automatically serialize the {
* capabilities of the source stack and initialize the target stacks capNBT field using that tag, which we are then if( option == null )
* reusing here. {
*/ return;
}
@Override this.incStackSize( option.getStackSize() );
public void add(final IAEItemStack option) { this.setCountRequestable( this.getCountRequestable() + option.getCountRequestable() );
if (option == null) { this.setCraftable( this.isCraftable() || option.isCraftable() );
return; }
}
this.incStackSize(option.getStackSize()); @Override
this.setCountRequestable(this.getCountRequestable() + option.getCountRequestable()); public boolean fuzzyComparison( final IAEItemStack other, final FuzzyMode mode )
this.setCraftable(this.isCraftable() || option.isCraftable()); {
} if( mode == FuzzyMode.IGNORE_ALL && OreHelper.INSTANCE.sameOre( this, other ) )
{
return true;
}
@Override final ItemStack itemStack = this.getDefinition();
public boolean fuzzyComparison(final IAEItemStack other, final FuzzyMode mode) { final ItemStack otherStack = other.getDefinition();
final ItemStack itemStack = this.getDefinition();
final ItemStack otherStack = other.getDefinition();
return this.fuzzyItemStackComparison(itemStack, otherStack, mode); return this.fuzzyItemStackComparison( itemStack, otherStack, mode );
} }
@Override @Override
public IAEItemStack copy() { public IAEItemStack copy()
return new AEItemStack(this); {
} return new AEItemStack( this );
}
@Override @Override
public IStorageChannel<IAEItemStack> getChannel() { public boolean isItem()
return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); {
} return true;
}
@Override @Override
public ItemStack createItemStack() { public boolean isFluid()
return ItemHandlerHelper.copyStackWithSize(this.getDefinition(), {
(int) Math.min(Integer.MAX_VALUE, this.getStackSize())); return false;
} }
@Override @Override
public Item getItem() { public IStorageChannel<IAEItemStack> getChannel()
return this.getDefinition().getItem(); {
} return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
}
@Override @Override
public int getItemDamage() { public ItemStack createItemStack()
return this.sharedStack.getItemDamage(); {
} return ItemHandlerHelper.copyStackWithSize( this.getDefinition(), (int) Math.min( Integer.MAX_VALUE, this.getStackSize() ) );
}
public Optional<OreReference> getOre() @Override
{ public Item getItem()
return this.oreReference; {
} return this.getDefinition().getItem();
}
@Override @Override
public boolean sameOre( final IAEItemStack is ) public int getItemDamage()
{ {
return OreHelper.INSTANCE.sameOre( this, is ); return this.sharedStack.getItemDamage();
} }
@Override @Override
public boolean isSameType(final IAEItemStack otherStack) { public boolean sameOre( final IAEItemStack is )
if (otherStack == null) { {
return false; return OreHelper.INSTANCE.sameOre( this, is );
} }
return Objects.equals(this.sharedStack, ((AEItemStack) otherStack).sharedStack); @Override
} public boolean isSameType( final IAEItemStack otherStack )
{
if( otherStack == null )
{
return false;
}
@Override return Objects.equals( this.sharedStack, ( (AEItemStack) otherStack ).sharedStack );
public boolean isSameType(final ItemStack otherStack) { }
if (otherStack.isEmpty()) {
return false;
}
int oldSize = otherStack.getCount();
otherStack.setCount(1); @Override
boolean ret = ItemStack.areItemStacksEqual(this.getDefinition(), otherStack); public boolean isSameType( final ItemStack otherStack )
otherStack.setCount(oldSize); {
if( otherStack.isEmpty() )
{
return false;
}
int oldSize = otherStack.getCount();
return ret; otherStack.setCount( 1 );
} boolean ret = ItemStack.areItemStacksEqual( this.getDefinition(), otherStack );
otherStack.setCount( oldSize );
@Override return ret;
public int hashCode() { }
return this.sharedStack.hashCode();
}
@Override @Override
public boolean equals(final Object ia) { public int hashCode()
if (ia instanceof AEItemStack) { {
return this.isSameType((AEItemStack) ia); return this.sharedStack.hashCode();
} else if (ia instanceof ItemStack) { }
// this actually breaks the equals contract (being equals to unrelated classes)
return equals((ItemStack) ia);
}
return false;
}
@Override @Override
public String toString() { public boolean equals( final Object ia )
return this.getStackSize() + "x" + this.getDefinition().getItem().getRegistryName(); {
} if( ia instanceof AEItemStack )
{
return this.isSameType( (AEItemStack) ia );
}
else if( ia instanceof ItemStack )
{
return this.isSameType( (ItemStack) ia );
}
return false;
}
@SideOnly( Side.CLIENT ) @Override
public List<String> getToolTip() { public String toString()
if (this.tooltip == null) { {
this.tooltip = Platform.getTooltip(this.asItemStackRepresentation()); return this.getStackSize() + "x" + this.getDefinition().getItem().getUnlocalizedName() + "@" + this.getDefinition().getItemDamage();
} }
return this.tooltip;
}
@SideOnly( Side.CLIENT ) @SideOnly( Side.CLIENT )
public String getDisplayName() { public List<String> getToolTip()
if (this.displayName == null) { {
this.displayName = Platform.getItemDisplayName(this.asItemStackRepresentation()); if( this.tooltip == null )
} {
return this.displayName; this.tooltip = Platform.getTooltip( this.asItemStackRepresentation() );
} }
return this.tooltip;
}
@SideOnly( Side.CLIENT ) @SideOnly( Side.CLIENT )
public String getModID() { public String getDisplayName()
return this.getDefinition().getItem().getRegistryName().getResourceDomain(); {
} if( this.displayName == null )
{
this.displayName = Platform.getItemDisplayName( this.asItemStackRepresentation() );
}
return this.displayName;
}
@Override @SideOnly( Side.CLIENT )
public boolean hasTagCompound() { public String getModID()
return this.getDefinition().hasTagCompound(); {
} if( this.uniqueID == null )
{
this.uniqueID = Item.REGISTRY.getNameForObject( this.getDefinition().getItem() );
}
@Override if( this.uniqueID == null )
public ItemStack asItemStackRepresentation() { {
return this.getDefinition().copy(); return "** Null";
} }
@Override return this.uniqueID.getResourceDomain() == null ? "** Null" : this.uniqueID.getResourceDomain();
public ItemStack getDefinition() { }
return this.sharedStack.getDefinition();
}
public boolean equals(final ItemStack is) { public Optional<OreReference> getOre()
return this.isSameType(is); {
} return this.oreReference;
}
AESharedItemStack getSharedStack() { @Override
return this.sharedStack; public boolean hasTagCompound()
} {
return this.getDefinition().hasTagCompound();
}
private boolean fuzzyItemStackComparison(ItemStack a, ItemStack b, FuzzyMode mode) { @Override
if (a.getItem() == b.getItem()) { public ItemStack asItemStackRepresentation()
if (a.getItem().isDamageable()) { {
if (mode == FuzzyMode.IGNORE_ALL) { return this.getDefinition().copy();
return true; }
} else if (mode == FuzzyMode.PERCENT_99) {
return (a.getItemDamage() > 1) == (b.getItemDamage() > 1);
} else {
final float percentDamageOfA = (float) a.getItemDamage() / a.getMaxDamage();
final float percentDamageOfB = (float) b.getItemDamage() / b.getMaxDamage();
return (percentDamageOfA > mode.breakPoint) == (percentDamageOfB > mode.breakPoint); @Override
} public ItemStack getDefinition()
} {
} return this.sharedStack.getDefinition();
}
AESharedItemStack getSharedStack()
{
return this.sharedStack;
}
private boolean fuzzyItemStackComparison( ItemStack a, ItemStack b, FuzzyMode mode )
{
if( a.getItem() == b.getItem() )
{
if( a.getItem().isDamageable() )
{
if( mode == FuzzyMode.IGNORE_ALL )
{
return true;
}
else if( mode == FuzzyMode.PERCENT_99 )
{
return ( a.getItemDamage() > 1 ) == ( b.getItemDamage() > 1 );
}
else
{
final float percentDamageOfA = (float) a.getItemDamage() / (float) a.getMaxDamage();
final float percentDamageOfB = (float) b.getItemDamage() / (float) b.getMaxDamage();
return ( percentDamageOfA > mode.breakPoint ) == ( percentDamageOfB > mode.breakPoint );
}
}
return a.getMetadata() == b.getMetadata();
}
return false;
}
return false;
}
} }
@@ -23,6 +23,7 @@
package appeng.util.item; package appeng.util.item;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.WeakHashMap; import java.util.WeakHashMap;
@@ -30,34 +31,56 @@ import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public final class AEItemStackRegistry { import appeng.util.Platform;
private static final WeakHashMap<AESharedItemStack, WeakReference<AESharedItemStack>> REGISTRY = new WeakHashMap<>();
private AEItemStackRegistry() {
}
static synchronized AESharedItemStack getRegisteredStack(final @Nonnull ItemStack itemStack) { public final class AEItemStackRegistry
if (itemStack.isEmpty()) { {
throw new IllegalArgumentException("stack cannot be empty"); private static final WeakHashMap<AESharedItemStack, WeakReference<AESharedItemStack>> SERVER_REGISTRY = new WeakHashMap<>();
} private static final WeakHashMap<AESharedItemStack, WeakReference<AESharedItemStack>> CLIENT_REGISTRY = new WeakHashMap<>();
int oldStackSize = itemStack.getCount(); private AEItemStackRegistry()
itemStack.setCount(1); {
}
AESharedItemStack search = new AESharedItemStack(itemStack); private static WeakHashMap<AESharedItemStack, WeakReference<AESharedItemStack>> registry()
WeakReference<AESharedItemStack> weak = REGISTRY.get(search); {
AESharedItemStack ret = null; if( Platform.isClient() )
{
return CLIENT_REGISTRY;
}
else
{
return SERVER_REGISTRY;
}
}
if (weak != null) { static synchronized AESharedItemStack getRegisteredStack( final @Nonnull ItemStack itemStack )
ret = weak.get(); {
} if( itemStack.isEmpty() )
{
throw new IllegalArgumentException( "stack cannot be empty" );
}
if (ret == null) { int oldStackSize = itemStack.getCount();
ret = new AESharedItemStack(itemStack.copy()); itemStack.setCount( 1 );
REGISTRY.put(ret, new WeakReference<>(ret));
}
itemStack.setCount(oldStackSize);
return ret; AESharedItemStack search = new AESharedItemStack( itemStack );
} WeakReference<AESharedItemStack> weak = registry().get( search );
AESharedItemStack ret = null;
if( weak != null )
{
ret = weak.get();
}
if( ret == null )
{
ret = new AESharedItemStack( itemStack.copy() );
registry().put( ret, new WeakReference<>( ret ) );
}
itemStack.setCount( oldStackSize );
return ret;
}
} }
@@ -18,76 +18,263 @@
package appeng.util.item; package appeng.util.item;
import java.util.Objects; import java.util.Objects;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
final class AESharedItemStack { import appeng.api.config.FuzzyMode;
private final ItemStack itemStack;
private final int itemId;
private final int itemDamage;
private final int hashCode;
public AESharedItemStack(final ItemStack itemStack) { final class AESharedItemStack implements Comparable<AESharedItemStack>
this(itemStack, itemStack.getItemDamage()); {
} private static final NBTTagCompound LOW_TAG = new NBTTagCompound();
private static final NBTTagCompound HIGH_TAG = new NBTTagCompound();
/** private final ItemStack itemStack;
* A constructor to explicitly set the damage value and not fetch it from the {@link ItemStack} private final int itemId;
* private final int itemDamage;
* @param itemStack The {@link ItemStack} to filter private final int hashCode;
* @param damage The damage of the item
*/
private AESharedItemStack(ItemStack itemStack, int damage) {
this.itemStack = itemStack;
this.itemId = Item.getIdFromItem(itemStack.getItem());
this.itemDamage = damage;
// Ensure this is always called last. public AESharedItemStack( final ItemStack itemStack )
this.hashCode = this.makeHashCode(); {
} this.itemStack = itemStack;
this.itemId = Item.getIdFromItem( itemStack.getItem() );
this.itemDamage = itemStack.getItemDamage();
this.hashCode = this.makeHashCode();
}
ItemStack getDefinition() { Bounds getBounds( final FuzzyMode fuzzy, final boolean ignoreMeta )
return this.itemStack; {
} return new Bounds( this.itemStack, fuzzy, ignoreMeta );
}
int getItemDamage() { ItemStack getDefinition()
return this.itemDamage; {
} return this.itemStack;
}
@Override int getItemDamage()
public int hashCode() { {
return this.hashCode; return this.itemDamage;
} }
@Override int getItemID()
public boolean equals(final Object obj) { {
if (this == obj) { return this.itemId;
return true; }
}
if (!(obj instanceof AESharedItemStack)) {
return false;
}
final AESharedItemStack other = (AESharedItemStack) obj; @Override
Preconditions.checkState(this.itemStack.getCount() == 1, "ItemStack#getCount() has to be 1"); public int hashCode()
Preconditions.checkArgument(other.getDefinition().getCount() == 1, "ItemStack#getCount() has to be 1"); {
return this.hashCode;
}
if (this.itemStack == other.itemStack) { @Override
return true; public boolean equals( final Object obj )
} {
return ItemStack.areItemStacksEqual(this.itemStack, other.itemStack); if( obj instanceof AESharedItemStack )
} {
final AESharedItemStack other = (AESharedItemStack) obj;
private int makeHashCode() { Preconditions.checkState( this.itemStack.getCount() == 1, "ItemStack#getCount() has to be 1" );
return Objects.hash( Preconditions.checkArgument( other.getDefinition().getCount() == 1, "ItemStack#getCount() has to be 1" );
this.itemId,
this.itemDamage,
this.itemStack.hasTagCompound() ? this.itemStack.getTagCompound() : 0);
}
if( this.itemStack == other.itemStack )
{
return true;
}
return ItemStack.areItemStacksEqual( this.itemStack, other.itemStack );
}
return false;
}
@Override
public int compareTo( final AESharedItemStack b )
{
Preconditions.checkState( this.itemStack.getCount() == 1, "ItemStack#getCount() has to be 1" );
Preconditions.checkArgument( b.getDefinition().getCount() == 1, "ItemStack#getCount() has to be 1" );
if( this.itemStack == b.getDefinition() )
{
return 0;
}
final int id = this.itemId - b.itemId;
if( id != 0 )
{
return id;
}
final int damageValue = this.itemDamage - b.itemDamage;
if( damageValue != 0 )
{
return damageValue;
}
final int nbt = this.compareNBT( b.getDefinition() );
if( nbt != 0 )
{
return nbt;
}
if( !this.itemStack.areCapsCompatible( b.getDefinition() ) )
{
return System.identityHashCode( this.itemStack ) - System.identityHashCode( b.getDefinition() );
}
return 0;
}
private int compareNBT( final ItemStack b )
{
if( this.itemStack.getTagCompound() == b.getTagCompound() )
{
return 0;
}
if( this.itemStack.getTagCompound() == LOW_TAG || b.getTagCompound() == HIGH_TAG )
{
return -1;
}
if( this.itemStack.getTagCompound() == HIGH_TAG || b.getTagCompound() == LOW_TAG )
{
return 1;
}
return System.identityHashCode( this.itemStack.getTagCompound() ) - System.identityHashCode( b.getTagCompound() );
}
private int makeHashCode()
{
return Objects.hash( this.itemId, this.itemDamage, this.itemStack.hasTagCompound() ? this.itemStack.getTagCompound() : 0 );
}
/**
* Creates the lower and upper bounds for a specific shared itemstack.
*/
public static final class Bounds
{
/**
* Bounds enforced by {@link ItemStack#isEmpty()}
*/
private static final int MIN_DAMAGE_VALUE = 0;
private static final int MAX_DAMAGE_VALUE = 65535;
private final AESharedItemStack lower;
private final AESharedItemStack upper;
public Bounds( final ItemStack stack, final FuzzyMode fuzzy, final boolean ignoreMeta )
{
Preconditions.checkState( !stack.isEmpty(), "ItemStack#isEmpty() has to be false" );
Preconditions.checkState( stack.getCount() == 1, "ItemStack#getCount() has to be 1" );
final NBTTagCompound tag = stack.hasTagCompound() ? stack.getTagCompound() : null;
this.lower = this.makeLowerBound( stack, tag, fuzzy, ignoreMeta );
this.upper = this.makeUpperBound( stack, tag, fuzzy, ignoreMeta );
}
public AESharedItemStack lower()
{
return this.lower;
}
public AESharedItemStack upper()
{
return this.upper;
}
private AESharedItemStack makeLowerBound( final ItemStack itemStack, final NBTTagCompound tag, final FuzzyMode fuzzy, final boolean ignoreMeta )
{
final ItemStack newDef = itemStack.copy();
if( ignoreMeta )
{
newDef.setItemDamage( MIN_DAMAGE_VALUE );
newDef.setTagCompound( tag );
}
else
{
if( newDef.getItem().isDamageable() )
{
if (itemStack.getMaxDamage() == 0)
{
newDef.setItemDamage(itemStack.getItemDamage() );
}
else if ( fuzzy == FuzzyMode.IGNORE_ALL )
{
newDef.setItemDamage( MIN_DAMAGE_VALUE );
}
else if( fuzzy == FuzzyMode.PERCENT_99 )
{
if( itemStack.getItemDamage() == MIN_DAMAGE_VALUE )
{
newDef.setItemDamage( MIN_DAMAGE_VALUE );
}
else
{
newDef.setItemDamage( MIN_DAMAGE_VALUE + 1 );
}
}
else
{
final int breakpoint = fuzzy.calculateBreakPoint( itemStack.getMaxDamage() );
final int damage = breakpoint <= itemStack.getItemDamage() ? breakpoint : 0;
newDef.setItemDamage( damage );
}
}
newDef.setTagCompound( LOW_TAG );
}
return new AESharedItemStack( newDef );
}
private AESharedItemStack makeUpperBound( final ItemStack itemStack, final NBTTagCompound tag, final FuzzyMode fuzzy, final boolean ignoreMeta )
{
final ItemStack newDef = itemStack.copy();
if( ignoreMeta )
{
newDef.setItemDamage( MAX_DAMAGE_VALUE );
newDef.setTagCompound( tag );
}
else
{
if( newDef.getItem().isDamageable() )
{
if (itemStack.getMaxDamage() == 0)
{
newDef.setItemDamage(itemStack.getItemDamage() );
}
else if ( fuzzy == FuzzyMode.IGNORE_ALL )
{
newDef.setItemDamage( itemStack.getMaxDamage() + 1 );
}
else if( fuzzy == FuzzyMode.PERCENT_99 )
{
if( itemStack.getItemDamage() == MIN_DAMAGE_VALUE )
{
newDef.setItemDamage( MIN_DAMAGE_VALUE );
}
else
{
newDef.setItemDamage( itemStack.getMaxDamage() + 1 );
}
}
else
{
final int breakpoint = fuzzy.calculateBreakPoint( itemStack.getMaxDamage() );
final int damage = itemStack.getItemDamage() < breakpoint ? breakpoint - 1 : itemStack.getMaxDamage() + 1;
newDef.setItemDamage( damage );
}
}
newDef.setTagCompound( HIGH_TAG );
}
return new AESharedItemStack( newDef );
}
}
} }
+143 -126
View File
@@ -18,152 +18,169 @@
package appeng.util.item; package appeng.util.item;
import appeng.api.storage.data.IAEStack;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import appeng.api.storage.data.IAEStack;
public abstract class AEStack<T extends IAEStack<T>> implements IAEStack<T> {
private boolean isCraftable; public abstract class AEStack<StackType extends IAEStack<StackType>> implements IAEStack<StackType>
private long stackSize; {
private long countRequestable;
@Override private boolean isCraftable;
public long getStackSize() { private long stackSize;
return this.stackSize; private long countRequestable;
}
@Override protected static long getPacketValue( final byte type, final ByteBuf tag )
public T setStackSize(final long ss) { {
this.stackSize = ss; if( type == 0 )
return (T) this; {
} long l = tag.readByte();
l -= Byte.MIN_VALUE;
return l;
}
else if( type == 1 )
{
long l = tag.readShort();
l -= Short.MIN_VALUE;
return l;
}
else if( type == 2 )
{
long l = tag.readInt();
l -= Integer.MIN_VALUE;
return l;
}
@Override return tag.readLong();
public long getCountRequestable() { }
return this.countRequestable;
}
@Override @Override
public T setCountRequestable(final long countRequestable) { public long getStackSize()
this.countRequestable = countRequestable; {
return (T) this; return this.stackSize;
} }
@Override @Override
public boolean isCraftable() { public StackType setStackSize( final long ss )
return this.isCraftable; {
} this.stackSize = ss;
return (StackType) this;
}
@Override @Override
public T setCraftable(final boolean isCraftable) { public long getCountRequestable()
this.isCraftable = isCraftable; {
return (T) this; return this.countRequestable;
} }
@Override @Override
public T reset() { public StackType setCountRequestable( final long countRequestable )
this.stackSize = 0; {
this.setCountRequestable(0); this.countRequestable = countRequestable;
this.setCraftable(false); return (StackType) this;
return (T) this; }
}
@Override @Override
public T empty() { public boolean isCraftable()
final T dup = this.copy(); {
dup.reset(); return this.isCraftable;
return dup; }
}
@Override @Override
public boolean isMeaningful() { public StackType setCraftable( final boolean isCraftable )
return this.stackSize != 0 || this.countRequestable > 0 || this.isCraftable; {
} this.isCraftable = isCraftable;
return (StackType) this;
}
@Override @Override
public void incStackSize(final long i) { public StackType reset()
this.stackSize += i; {
} this.stackSize = 0;
// priority = Integer.MIN_VALUE;
this.setCountRequestable( 0 );
this.setCraftable( false );
return (StackType) this;
}
@Override @Override
public void decStackSize(final long i) { public StackType empty()
this.stackSize -= i; {
} final StackType dup = this.copy();
dup.reset();
return dup;
}
@Override @Override
public void incCountRequestable(final long i) { public boolean isMeaningful()
this.countRequestable += i; {
} return this.stackSize != 0 || this.countRequestable > 0 || this.isCraftable;
}
@Override @Override
public void decCountRequestable(final long i) { public void incStackSize( final long i )
this.countRequestable -= i; {
} this.stackSize += i;
}
protected abstract boolean hasTagCompound(); @Override
public void decStackSize( final long i )
{
this.stackSize -= i;
}
protected static long getPacketValue( final byte type, final ByteBuf tag ) @Override
{ public void incCountRequestable( final long i )
if( type == 0 ) {
{ this.countRequestable += i;
long l = tag.readByte(); }
l -= Byte.MIN_VALUE;
return l;
}
else if( type == 1 )
{
long l = tag.readShort();
l -= Short.MIN_VALUE;
return l;
}
else if( type == 2 )
{
long l = tag.readInt();
l -= Integer.MIN_VALUE;
return l;
}
return tag.readLong(); @Override
} public void decCountRequestable( final long i )
{
this.countRequestable -= i;
}
protected void putPacketValue( final ByteBuf tag, final long num ) protected byte getType( final long num )
{ {
if( num <= 255 ) if( num <= 255 )
{ {
tag.writeByte( (byte) ( num + Byte.MIN_VALUE ) ); return 0;
} }
else if( num <= 65535 ) else if( num <= 65535 )
{ {
tag.writeShort( (short) ( num + Short.MIN_VALUE ) ); return 1;
} }
else if( num <= 4294967295L ) else if( num <= 4294967295L )
{ {
tag.writeInt( (int) ( num + Integer.MIN_VALUE ) ); return 2;
} }
else else
{ {
tag.writeLong( num ); return 3;
} }
} }
protected byte getType( final long num ) protected abstract boolean hasTagCompound();
{
if( num <= 255 ) protected void putPacketValue( final ByteBuf tag, final long num )
{ {
return 0; if( num <= 255 )
} {
else if( num <= 65535 ) tag.writeByte( (byte) ( num + Byte.MIN_VALUE ) );
{ }
return 1; else if( num <= 65535 )
} {
else if( num <= 4294967295L ) tag.writeShort( (short) ( num + Short.MIN_VALUE ) );
{ }
return 2; else if( num <= 4294967295L )
} {
else tag.writeInt( (int) ( num + Integer.MIN_VALUE ) );
{ }
return 3; else
} {
} tag.writeLong( num );
}
}
} }
@@ -1,179 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2021, TeamAppliedEnergistics, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.util.item;
import java.util.Collection;
import java.util.Comparator;
import java.util.Map;
import com.google.common.base.Preconditions;
import net.minecraft.item.ItemStack;
import it.unimi.dsi.fastutil.objects.Object2ObjectAVLTreeMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectSortedMap;
import appeng.api.config.FuzzyMode;
import appeng.api.storage.data.IAEItemStack;
/**
* This variant list is optimized for damageable items, and supports selecting durability ranges with
* {@link #findFuzzy(IAEItemStack, FuzzyMode)}.
*/
class FuzzyItemVariantList extends ItemVariantList {
static final SharedStackComparator COMPARATOR = new SharedStackComparator();
// NOTE: We only use Object as they key here so we can pass our special DamageBounds to the subMap method.
// We NEVER put any keys in this map that are not AESharedItemStacks.
private final Object2ObjectSortedMap<Object, IAEItemStack> records = new Object2ObjectAVLTreeMap<>(COMPARATOR);
@Override
public Collection<IAEItemStack> findFuzzy(final IAEItemStack filter, final FuzzyMode fuzzy) {
ItemStack itemStack = filter.getDefinition();
ItemDamageBound lowerBound = makeLowerBound(itemStack, fuzzy);
ItemDamageBound upperBound = makeUpperBound(itemStack, fuzzy);
Preconditions.checkState(lowerBound.itemDamage > upperBound.itemDamage);
return this.records.subMap(lowerBound, upperBound).values();
}
@SuppressWarnings("unchecked")
@Override
Map<AESharedItemStack, IAEItemStack> getRecords() {
// We ensure on our end that we NEVER use anything but AESharedItemStack as the key in this map
return (Map<AESharedItemStack, IAEItemStack>) (Object) this.records;
}
static class ItemDamageBound {
final int itemDamage;
public ItemDamageBound(int itemDamage) {
this.itemDamage = itemDamage;
}
}
/**
* This comparator creates a strict and total ordering over all {@link AESharedItemStack} of the same item. To
* support selecting ranges of durability, it is defined for type {@link Object} and also accepts
* {@link ItemDamageBound} as an argument to compare against.
*/
static class SharedStackComparator implements Comparator<Object> {
@Override
public int compare(Object a, Object b) {
// Either argument can either be a damage bound or a shared item stack
// Since we never put damage bounds into the map as keys, only one
// of the two arguments can possibly be a bound
ItemDamageBound boundA = null;
AESharedItemStack stackA = null;
int itemDamageA;
if (a instanceof ItemDamageBound) {
boundA = (ItemDamageBound) a;
itemDamageA = boundA.itemDamage;
} else {
stackA = (AESharedItemStack) a;
itemDamageA = stackA.getItemDamage();
}
ItemDamageBound boundB = null;
AESharedItemStack stackB = null;
int itemDamageB;
if (b instanceof ItemDamageBound) {
boundB = (ItemDamageBound) b;
itemDamageB = boundB.itemDamage;
} else {
stackB = (AESharedItemStack) b;
itemDamageB = stackB.getItemDamage();
}
// When either argument is a damage bound, we just compare the damage values because it is used
// only to get a certain damage range out of the map.
if (boundA != null || boundB != null) {
return Integer.compare(itemDamageB, itemDamageA);
}
ItemStack itemStackA = stackA.getDefinition();
ItemStack itemStackB = stackB.getDefinition();
Preconditions.checkState(itemStackA.getCount() == 1, "ItemStack#getCount() has to be 1");
Preconditions.checkArgument(itemStackB.getCount() == 1, "ItemStack#getCount() has to be 1");
if (itemStackA == itemStackB) {
return 0;
}
// Damaged items are sorted before undamaged items
final int damageValue = Integer.compare(itemDamageB, itemDamageA);
if (damageValue != 0) {
return damageValue;
}
// As a final tie breaker, order by the object identity of the item stack
// While this will order seemingly at random, we only need the order of
// damage values to be predictable, while still having to satisfy the
// complete order requirements of the sorted map
return Long.compare(System.identityHashCode(itemStackA), System.identityHashCode(itemStackB));
}
}
/**
* Minecraft reverses the damage values. So anything with a damage of 0 is undamaged and increases the more damaged
* the item is.
* <p>
* Further the used subMap follows [MAX_DAMAGE, MIN_DAMAGE), so to include undamaged items, we have to start with a
* lower damage value than 0, while it is fine to use {@link ItemStack#getMaxDamage()} for the upper bound.
*/
private static final int MIN_DAMAGE_VALUE = -1;
/*
* Keep in mind that the stack order is from most damaged to least damaged, so this lower bound will actually be a
* higher number than the upper bound.
*/
static ItemDamageBound makeLowerBound(final ItemStack stack, final FuzzyMode fuzzy) {
Preconditions.checkState(((stack.getMaxDamage() == 0 && stack.getItemDamage() > 0 ) || stack.isItemStackDamageable()), "ItemStack#isDamageable() has to be true");
int damage;
if (fuzzy == FuzzyMode.IGNORE_ALL) {
damage = stack.getMaxDamage();
} else {
final int breakpoint = fuzzy.calculateBreakPoint(stack.getMaxDamage());
damage = stack.getItemDamage() <= breakpoint ? breakpoint : stack.getMaxDamage();
}
return new ItemDamageBound(damage);
}
/*
* Keep in mind that the stack order is from most damaged to least damaged, so this upper bound will actually be a
* lower number than the lower bound. It also is exclusive.
*/
static ItemDamageBound makeUpperBound(final ItemStack stack, final FuzzyMode fuzzy) {
Preconditions.checkState(((stack.getMaxDamage() == 0 && stack.getItemDamage() > 0 ) || stack.isItemStackDamageable()), "ItemStack#isDamageable() has to be true");
int damage;
if (fuzzy == FuzzyMode.IGNORE_ALL) {
damage = MIN_DAMAGE_VALUE;
} else {
final int breakpoint = fuzzy.calculateBreakPoint(stack.getMaxDamage());
damage = stack.getItemDamage() <= breakpoint ? MIN_DAMAGE_VALUE : breakpoint;
}
return new ItemDamageBound(damage);
}
}
+164 -148
View File
@@ -1,6 +1,6 @@
/* /*
* This file is part of Applied Energistics 2. * This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2020, AlgorithmX2, All rights reserved. * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
* *
* Applied Energistics 2 is free software: you can redistribute it and/or modify * Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
@@ -18,196 +18,212 @@
package appeng.util.item; package appeng.util.item;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.ConcurrentModificationException;
import java.util.Iterator; import java.util.Iterator;
import java.util.NoSuchElementException; import java.util.NavigableMap;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.ConcurrentSkipListMap;
import net.minecraft.item.Item; import net.minecraftforge.oredict.OreDictionary;
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
import appeng.api.config.FuzzyMode; import appeng.api.config.FuzzyMode;
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.util.item.AESharedItemStack.Bounds;
public final class ItemList implements IItemList<IAEItemStack> {
private final Reference2ObjectMap<Item, ItemVariantList> records = new Reference2ObjectOpenHashMap<>(); public final class ItemList implements IItemList<IAEItemStack>
/** {
* We increment this version field everytime an attempt to mutate this item list (or potentially one of its
* sub-lists) is made. Iterators will copy the version when they are created and compare it against the current
* version whenever they advance to trigger a {@link ConcurrentModificationException}.
*/
private final AtomicInteger version = new AtomicInteger(0);
@Override private final NavigableMap<AESharedItemStack, IAEItemStack> records = new ConcurrentSkipListMap<>();
public IAEItemStack findPrecise(final IAEItemStack itemStack) {
if (itemStack == null) {
return null;
}
ItemVariantList record = this.records.get(itemStack.getItem()); @Override
return record != null ? record.findPrecise(itemStack) : null; public void add( final IAEItemStack option )
} {
if( option == null )
{
return;
}
@Override final IAEItemStack st = this.records.get( ( (AEItemStack) option ).getSharedStack() );
public Collection<IAEItemStack> findFuzzy(final IAEItemStack filter, final FuzzyMode fuzzy) {
if (filter == null) {
return Collections.emptyList();
}
ItemVariantList record = this.records.get(filter.getItem()); if( st != null )
return record != null ? record.findFuzzy(filter, fuzzy) : Collections.emptyList(); {
} st.add( option );
return;
}
@Override final IAEItemStack opt = option.copy();
public boolean isEmpty() {
return !this.iterator().hasNext();
}
@Override this.putItemRecord( opt );
public void add(final IAEItemStack itemStack) { }
version.incrementAndGet();
if (itemStack == null) { @Override
return; public IAEItemStack findPrecise( final IAEItemStack itemStack )
} {
if( itemStack == null )
{
return null;
}
this.getOrCreateRecord(itemStack.getItem()).add(itemStack); return this.records.get( ( (AEItemStack) itemStack ).getSharedStack() );
} }
@Override @Override
public void addStorage(final IAEItemStack itemStack) { public Collection<IAEItemStack> findFuzzy( final IAEItemStack filter, final FuzzyMode fuzzy )
version.incrementAndGet(); {
if( filter == null )
{
return Collections.emptyList();
}
if (itemStack == null) { final AEItemStack ais = (AEItemStack) filter;
return;
}
this.getOrCreateRecord(itemStack.getItem()).addStorage(itemStack); return ais.getOre().map( or ->
} {
if( or.getAEEquivalents().size() == 1 )
{
final IAEItemStack is = or.getAEEquivalents().get( 0 );
@Override return this.findFuzzyDamage( is, fuzzy, is.getItemDamage() == OreDictionary.WILDCARD_VALUE );
public void addCrafting(final IAEItemStack itemStack) { }
version.incrementAndGet(); else
{
final Collection<IAEItemStack> output = new ArrayList<>();
if (itemStack == null) { for( final IAEItemStack is : or.getAEEquivalents() )
return; {
} output.addAll( this.findFuzzyDamage( is, fuzzy, is.getItemDamage() == OreDictionary.WILDCARD_VALUE ) );
}
this.getOrCreateRecord(itemStack.getItem()).addCrafting(itemStack); return output;
} }
} ).orElse( this.findFuzzyDamage( ais, fuzzy, false ) );
}
@Override @Override
public void addRequestable(final IAEItemStack itemStack) { public boolean isEmpty()
version.incrementAndGet(); {
return !this.iterator().hasNext();
}
if (itemStack == null) { @Override
return; public void addStorage( final IAEItemStack option )
} {
if( option == null )
{
return;
}
this.getOrCreateRecord(itemStack.getItem()).addRequestable(itemStack); final IAEItemStack st = this.records.get( ( (AEItemStack) option ).getSharedStack() );
}
@Override if( st != null )
public IAEItemStack getFirstItem() { {
for (final IAEItemStack stackType : this) { st.incStackSize( option.getStackSize() );
return stackType; return;
} }
return null; final IAEItemStack opt = option.copy();
}
@Override this.putItemRecord( opt );
public int size() { }
int size = 0;
for (ItemVariantList entry : records.values()) {
size += entry.size();
}
return size; /*
} * public void clean() { Iterator<StackType> i = iterator(); while (i.hasNext()) { StackType AEI =
* i.next(); if ( !AEI.isMeaningful() ) i.remove(); } }
*/
@Override @Override
public Iterator<IAEItemStack> iterator() { public void addCrafting( final IAEItemStack option )
return new ChainedIterator(this.records.values().iterator(), version); {
} if( option == null )
{
return;
}
@Override final IAEItemStack st = this.records.get( ( (AEItemStack) option ).getSharedStack() );
public void resetStatus() {
for (final IAEItemStack i : this) {
i.reset();
}
}
private ItemVariantList getOrCreateRecord(Item item) { if( st != null )
return this.records.computeIfAbsent(item, this::makeRecordMap); {
} st.setCraftable( true );
return;
}
private ItemVariantList makeRecordMap(Item item) { final IAEItemStack opt = option.copy();
if (item.isDamageable()) { opt.setStackSize( 0 );
return new FuzzyItemVariantList(); opt.setCraftable( true );
} else {
return new NormalItemVariantList();
}
}
/** this.putItemRecord( opt );
* Iterates over multiple item lists as if they were one list. }
*/
private static class ChainedIterator implements Iterator<IAEItemStack> {
private final AtomicInteger parentVersion; @Override
private final int version; public void addRequestable( final IAEItemStack option )
private final Iterator<ItemVariantList> parent; {
private Iterator<IAEItemStack> next; if( option == null )
{
return;
}
public ChainedIterator(Iterator<ItemVariantList> iterator, AtomicInteger parentVersion) { final IAEItemStack st = this.records.get( ( (AEItemStack) option ).getSharedStack() );
this.parent = iterator;
this.parentVersion = parentVersion;
this.version = parentVersion.get();
this.ensureItems();
}
@Override if( st != null )
public boolean hasNext() { {
return next != null && next.hasNext(); st.setCountRequestable( st.getCountRequestable() + option.getCountRequestable() );
} return;
}
@Override final IAEItemStack opt = option.copy();
public IAEItemStack next() { opt.setStackSize( 0 );
if (this.next == null) { opt.setCraftable( false );
throw new NoSuchElementException(); opt.setCountRequestable( option.getCountRequestable() );
}
if (this.version != this.parentVersion.get()) {
throw new ConcurrentModificationException();
}
IAEItemStack result = this.next.next(); this.putItemRecord( opt );
this.ensureItems(); }
return result;
}
private void ensureItems() { @Override
if (hasNext()) { public IAEItemStack getFirstItem()
return; // Still items left in the current one {
} for( final IAEItemStack stackType : this )
{
return stackType;
}
// Find the next iterator willing to return some items... return null;
while (this.parent.hasNext()) { }
this.next = this.parent.next().iterator();
if (this.next.hasNext()) { @Override
return; // Found one! public int size()
} {
} return this.records.size();
}
// No more items @Override
this.next = null; public Iterator<IAEItemStack> iterator()
} {
} return new MeaningfulItemIterator<>( this.records.values().iterator() );
}
@Override
public void resetStatus()
{
for( final IAEItemStack i : this )
{
i.reset();
}
}
private IAEItemStack putItemRecord( final IAEItemStack itemStack )
{
return this.records.put( ( (AEItemStack) itemStack ).getSharedStack(), itemStack );
}
private Collection<IAEItemStack> findFuzzyDamage( final IAEItemStack filter, final FuzzyMode fuzzy, final boolean ignoreMeta )
{
final AEItemStack itemStack = (AEItemStack) filter;
final Bounds bounds = itemStack.getSharedStack().getBounds( fuzzy, ignoreMeta );
return this.records.subMap( bounds.lower(), true, bounds.upper(), true ).descendingMap().values();
}
} }
@@ -0,0 +1,87 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.util.item;
import java.util.Collection;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemContainer;
public class ItemModList implements IItemContainer<IAEItemStack>
{
private final IItemContainer<IAEItemStack> backingStore;
private final IItemContainer<IAEItemStack> overrides = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList();
public ItemModList( final IItemContainer<IAEItemStack> backend )
{
this.backingStore = backend;
}
@Override
public void add( final IAEItemStack option )
{
IAEItemStack over = this.overrides.findPrecise( option );
if( over == null )
{
over = this.backingStore.findPrecise( option );
if( over == null )
{
this.overrides.add( option );
}
else
{
option.add( over );
this.overrides.add( option );
}
}
else
{
this.overrides.add( option );
}
}
@Override
public IAEItemStack findPrecise( final IAEItemStack i )
{
final IAEItemStack over = this.overrides.findPrecise( i );
if( over == null )
{
return this.backingStore.findPrecise( i );
}
return over;
}
@Override
public Collection<IAEItemStack> findFuzzy( final IAEItemStack input, final FuzzyMode fuzzy )
{
return this.overrides.findFuzzy( input, fuzzy );
}
@Override
public boolean isEmpty()
{
return this.overrides.isEmpty() && this.backingStore.isEmpty();
}
}
@@ -1,118 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2021, TeamAppliedEnergistics, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.util.item;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import appeng.api.config.FuzzyMode;
import appeng.api.storage.data.IAEItemStack;
/**
* Stores variants of a single type of {@link net.minecraft.item.Item}, i.e. versions with different durability, or
* different NBT or capabilities.
*/
abstract class ItemVariantList {
public void add(final IAEItemStack option) {
final IAEItemStack st = this.getRecords().get(((AEItemStack) option).getSharedStack());
if (st != null) {
st.add(option);
return;
}
final IAEItemStack opt = option.copy();
this.putItemRecord(opt);
}
public IAEItemStack findPrecise(final IAEItemStack itemStack) {
return this.getRecords().get(((AEItemStack) itemStack).getSharedStack());
}
public void addStorage(final IAEItemStack option) {
final IAEItemStack st = this.getRecords().get(((AEItemStack) option).getSharedStack());
if (st != null) {
st.incStackSize(option.getStackSize());
return;
}
final IAEItemStack opt = option.copy();
this.putItemRecord(opt);
}
public void addCrafting(final IAEItemStack option) {
final IAEItemStack st = this.getRecords().get(((AEItemStack) option).getSharedStack());
if (st != null) {
st.setCraftable(true);
return;
}
final IAEItemStack opt = option.copy();
opt.setStackSize(0);
opt.setCraftable(true);
this.putItemRecord(opt);
}
public void addRequestable(final IAEItemStack option) {
final IAEItemStack st = this.getRecords().get(((AEItemStack) option).getSharedStack());
if (st != null) {
st.setCountRequestable(st.getCountRequestable() + option.getCountRequestable());
return;
}
final IAEItemStack opt = option.copy();
opt.setStackSize(0);
opt.setCraftable(false);
opt.setCountRequestable(option.getCountRequestable());
this.putItemRecord(opt);
}
public int size() {
int size = 0;
for (IAEItemStack entry : getRecords().values()) {
if (entry.isMeaningful()) {
size++;
}
}
return size;
}
public Iterator<IAEItemStack> iterator() {
return new MeaningfulItemIterator<>(this.getRecords().values());
}
private void putItemRecord(final IAEItemStack itemStack) {
this.getRecords().put(((AEItemStack) itemStack).getSharedStack(), itemStack);
}
abstract Map<AESharedItemStack, IAEItemStack> getRecords();
public abstract Collection<IAEItemStack> findFuzzy(final IAEItemStack filter, final FuzzyMode fuzzy);
}
@@ -1,6 +1,6 @@
/* /*
* This file is part of Applied Energistics 2. * This file is part of Applied Energistics 2.
* Copyright (c) 2021, TeamAppliedEnergistics, All rights reserved. * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
* *
* Applied Energistics 2 is free software: you can redistribute it and/or modify * Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
@@ -18,53 +18,59 @@
package appeng.util.item; package appeng.util.item;
import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
/**
* This iterator will only return items from a collection that are meaningful (w.r.t.
* {@link IAEItemStack#isMeaningful()}. Items that are not meaningful are automatically removed from the collection as
* it is being iterated.
*/
public class MeaningfulItemIterator<T extends IAEItemStack> implements Iterator<T> {
private final Iterator<T> parent;
private T next;
public MeaningfulItemIterator(final Collection<T> collection) { public class MeaningfulItemIterator<T extends IAEItemStack> implements Iterator<T>
this.parent = collection.iterator(); {
this.next = seekNext();
}
@Override private final Iterator<T> parent;
public boolean hasNext() { private T next;
return this.next != null;
}
@Override public MeaningfulItemIterator( final Iterator<T> iterator )
public T next() { {
if (this.next == null) { this.parent = iterator;
throw new NoSuchElementException(); }
}
T result = this.next; @Override
this.next = this.seekNext(); public boolean hasNext()
return result; {
} while( this.parent.hasNext() )
{
this.next = this.parent.next();
private T seekNext() { if( this.next.isMeaningful() )
while (this.parent.hasNext()) { {
T item = this.parent.next(); return true;
}
else
{
this.parent.remove(); // self cleaning :3
}
}
if (item.isMeaningful()) { this.next = null;
return item; return false;
} else { }
this.parent.remove();
}
}
return null; @Override
} public T next()
{
if( this.next == null )
{
throw new NoSuchElementException();
}
return this.next;
}
@Override
public void remove()
{
this.parent.remove();
}
} }
@@ -1,51 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2021, TeamAppliedEnergistics, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.util.item;
import java.util.Collection;
import java.util.Map;
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
import appeng.api.config.FuzzyMode;
import appeng.api.storage.data.IAEItemStack;
/**
* This variant list is optimized for items that cannot be damaged and thus do not support querying durability ranges
* via {@link #findFuzzy(IAEItemStack, FuzzyMode)}.
*/
class NormalItemVariantList extends ItemVariantList {
private final Reference2ObjectMap<AESharedItemStack, IAEItemStack> records = new Reference2ObjectOpenHashMap<>();
@Override
Map<AESharedItemStack, IAEItemStack> getRecords() {
return this.records;
}
/**
* For items that do not support durability, we just return all variants to a fuzzy search.
*/
@Override
public Collection<IAEItemStack> findFuzzy(IAEItemStack filter, FuzzyMode fuzzy) {
return this.getRecords().values();
}
}
@@ -1,25 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:charger"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 7
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:part",
"data": 16
}
]
}
],
"display": { "display": {
"icon": { "icon": {
"item": "appliedenergistics2:part", "item": "appliedenergistics2:part",
@@ -46,4 +25,4 @@
} }
} }
} }
} }
@@ -1,11 +1,4 @@
{ {
"conditions": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 1
}
],
"display": { "display": {
"icon": { "icon": {
"item": "appliedenergistics2:material", "item": "appliedenergistics2:material",
@@ -32,4 +25,4 @@
} }
} }
} }
} }
@@ -1,20 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:charger"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 1
}
]
}
],
"display": { "display": {
"icon": { "icon": {
"item": "appliedenergistics2:charger" "item": "appliedenergistics2:charger"
@@ -39,4 +23,4 @@
} }
} }
} }
} }
@@ -1,10 +1,4 @@
{ {
"conditions": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:sky_compass"
}
],
"display": { "display": {
"icon": { "icon": {
"item": "appliedenergistics2:sky_compass" "item": "appliedenergistics2:sky_compass"
@@ -29,4 +23,4 @@
} }
} }
} }
} }
@@ -1,35 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 13
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 14
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 15
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 19
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:controller"
}
]
}
],
"display": { "display": {
"icon": { "icon": {
"item": "appliedenergistics2:controller" "item": "appliedenergistics2:controller"
@@ -54,4 +23,4 @@
} }
} }
} }
} }
@@ -1,61 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:crafting_storage_1k"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:crafting_storage_4k"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:crafting_storage_16k"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:crafting_storage_64k"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 13
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 14
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 15
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 19
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:controller"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:part",
"data": 360
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:part",
"data": 340
}
]
}
],
"display": { "display": {
"icon": { "icon": {
"item": "appliedenergistics2:crafting_storage_64k" "item": "appliedenergistics2:crafting_storage_64k"
@@ -118,4 +61,4 @@
"c64k" "c64k"
] ]
] ]
} }
@@ -1,40 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 13
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 14
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 15
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 19
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:controller"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:part",
"data": 360
}
]
}
],
"display": { "display": {
"icon": { "icon": {
"item": "appliedenergistics2:part", "item": "appliedenergistics2:part",
@@ -61,4 +25,4 @@
} }
} }
} }
} }
@@ -1,33 +1,7 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:charger"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 7
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:part",
"data": 16
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:facade"
}
]
}
],
"display": { "display": {
"icon": { "icon": {
"item": "appliedenergistics2:facade", "item": "appliedenergistics2:facade"
"nbt": "{item:\"minecraft:stone\"}"
}, },
"title": { "title": {
"translate": "achievement.ae2.Facade" "translate": "achievement.ae2.Facade"
@@ -49,4 +23,4 @@
} }
} }
} }
} }
@@ -1,20 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:charger"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 7
}
]
}
],
"display": { "display": {
"icon": { "icon": {
"item": "appliedenergistics2:material", "item": "appliedenergistics2:material",
@@ -41,4 +25,4 @@
} }
} }
} }
} }
@@ -1,24 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:charger"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 7
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:quartz_growth_accelerator"
}
]
}
],
"display": { "display": {
"icon": { "icon": {
"item": "appliedenergistics2:quartz_growth_accelerator" "item": "appliedenergistics2:quartz_growth_accelerator"
@@ -43,4 +23,4 @@
} }
} }
} }
} }
@@ -1,29 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:charger"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 7
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:part",
"data": 16
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:interface"
}
]
}
],
"display": { "display": {
"icon": { "icon": {
"item": "appliedenergistics2:interface" "item": "appliedenergistics2:interface"
@@ -48,4 +23,4 @@
} }
} }
} }
} }
@@ -1,50 +1,4 @@
{ {
"conditions": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:storage_cell_1k"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:storage_cell_4k"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:storage_cell_16k"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:storage_cell_64k"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 13
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 14
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 15
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 19
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:controller"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:io_port"
}
],
"display": { "display": {
"icon": { "icon": {
"item": "appliedenergistics2:io_port" "item": "appliedenergistics2:io_port"
@@ -69,4 +23,4 @@
} }
} }
} }
} }
@@ -1,25 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:charger"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 7
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:part",
"data": 16
}
]
}
],
"display": { "display": {
"icon": { "icon": {
"item": "appliedenergistics2:part", "item": "appliedenergistics2:part",
@@ -38,4 +17,4 @@
"trigger": "appliedenergistics2:network_apprentice" "trigger": "appliedenergistics2:network_apprentice"
} }
} }
} }
@@ -1,25 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:charger"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 7
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:part",
"data": 16
}
]
}
],
"display": { "display": {
"icon": { "icon": {
"item": "appliedenergistics2:part", "item": "appliedenergistics2:part",
@@ -38,4 +17,4 @@
"trigger": "appliedenergistics2:network_engineer" "trigger": "appliedenergistics2:network_engineer"
} }
} }
} }
@@ -1,25 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:charger"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 7
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:part",
"data": 16
}
]
}
],
"display": { "display": {
"icon": { "icon": {
"item": "appliedenergistics2:part", "item": "appliedenergistics2:part",
@@ -38,4 +17,4 @@
"trigger": "appliedenergistics2:network_admin" "trigger": "appliedenergistics2:network_admin"
} }
} }
} }
@@ -1,39 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 13
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 14
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 15
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 19
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:controller"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:network_tool"
}
]
}
],
"display": { "display": {
"icon": { "icon": {
"item": "appliedenergistics2:network_tool" "item": "appliedenergistics2:network_tool"
@@ -58,4 +23,4 @@
} }
} }
} }
} }
@@ -1,30 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:charger"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 7
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:part",
"data": 16
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:part",
"data": 460
}
]
}
],
"display": { "display": {
"icon": { "icon": {
"item": "appliedenergistics2:part", "item": "appliedenergistics2:part",
@@ -44,11 +18,11 @@
"conditions": { "conditions": {
"items": [ "items": [
{ {
"item": "appliedenergistics2:part", "type": "appliedenergistics2:part",
"data": 460 "part": "P2P_TUNNEL_ME"
} }
] ]
} }
} }
} }
} }
@@ -1,45 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 13
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 14
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 15
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 19
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:controller"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:part",
"data": 360
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:part",
"data": 340
}
]
}
],
"display": { "display": {
"icon": { "icon": {
"item": "appliedenergistics2:part", "item": "appliedenergistics2:part",
@@ -66,4 +25,4 @@
} }
} }
} }
} }
@@ -1,55 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:storage_cell_1k"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:storage_cell_4k"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:storage_cell_16k"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:storage_cell_64k"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 13
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 14
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 15
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 19
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:controller"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:portable_cell"
}
]
}
],
"display": { "display": {
"icon": { "icon": {
"item": "appliedenergistics2:portable_cell" "item": "appliedenergistics2:portable_cell"
@@ -74,4 +23,4 @@
} }
} }
} }
} }
@@ -1,31 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 13
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 14
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 15
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 19
}
]
}
],
"display": { "display": {
"icon": { "icon": {
"item": "appliedenergistics2:material", "item": "appliedenergistics2:material",
@@ -93,4 +66,4 @@
"silicon" "silicon"
] ]
] ]
} }
@@ -1,34 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:charger"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 7
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:part",
"data": 16
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:part",
"data": 460
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:quantum_link"
}
]
}
],
"display": { "display": {
"icon": { "icon": {
"item": "appliedenergistics2:quantum_link" "item": "appliedenergistics2:quantum_link"
@@ -53,4 +23,4 @@
} }
} }
} }
} }
@@ -27,4 +27,4 @@
} }
} }
} }
} }
@@ -1,59 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:storage_cell_1k"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:storage_cell_4k"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:storage_cell_16k"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:storage_cell_64k"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 13
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 14
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 15
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 19
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:controller"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:io_port"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:spatial_io_port"
}
]
}
],
"display": { "display": {
"icon": { "icon": {
"item": "appliedenergistics2:spatial_storage_cell_128_cubed" "item": "appliedenergistics2:spatial_storage_cell_128_cubed"
@@ -71,4 +16,4 @@
"trigger": "appliedenergistics2:spatial_explorer" "trigger": "appliedenergistics2:spatial_explorer"
} }
} }
} }
@@ -1,59 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:storage_cell_1k"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:storage_cell_4k"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:storage_cell_16k"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:storage_cell_64k"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 13
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 14
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 15
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 19
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:controller"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:io_port"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:spatial_io_port"
}
]
}
],
"display": { "display": {
"icon": { "icon": {
"item": "appliedenergistics2:spatial_io_port" "item": "appliedenergistics2:spatial_io_port"
@@ -78,4 +23,4 @@
} }
} }
} }
} }
@@ -1,34 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:charger"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 7
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:part",
"data": 16
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:interface"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:part",
"data": 220
}
]
}
],
"display": { "display": {
"icon": { "icon": {
"item": "appliedenergistics2:part", "item": "appliedenergistics2:part",
@@ -55,4 +25,4 @@
} }
} }
} }
} }
@@ -1,51 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:storage_cell_1k"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:storage_cell_4k"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:storage_cell_16k"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:storage_cell_64k"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 13
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 14
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 15
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:material",
"data": 19
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:controller"
}
]
}
],
"display": { "display": {
"icon": { "icon": {
"item": "appliedenergistics2:storage_cell_64k" "item": "appliedenergistics2:storage_cell_64k"
@@ -108,4 +61,4 @@
"c64k" "c64k"
] ]
] ]
} }
@@ -1,10 +1,4 @@
{ {
"conditions": [
{
"type": "appliedenergistics2:material_exists",
"material": "material.fluix_dust"
}
],
"type": "appliedenergistics2:grinder", "type": "appliedenergistics2:grinder",
"input": { "input": {
"type": "forge:ore_dict", "type": "forge:ore_dict",
@@ -1,10 +1,4 @@
{ {
"conditions": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:sky_stone_block"
}
],
"type": "appliedenergistics2:grinder", "type": "appliedenergistics2:grinder",
"input": { "input": {
"item": "appliedenergistics2:sky_stone_block" "item": "appliedenergistics2:sky_stone_block"
@@ -1,23 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "appliedenergistics2:material_exists",
"material": "material.engineering_processor"
},
{
"type": "appliedenergistics2:material_exists",
"material": "material.engineering_processor_print"
},
{
"type": "appliedenergistics2:material_exists",
"material": "material.silicon_print"
}
]
}
],
"type": "appliedenergistics2:inscriber", "type": "appliedenergistics2:inscriber",
"mode": "press", "mode": "press",
"result": { "result": {
@@ -1,10 +1,4 @@
{ {
"conditions": [
{
"type": "appliedenergistics2:material_exists",
"material": "material.calculation_processor_press"
}
],
"type": "appliedenergistics2:inscriber", "type": "appliedenergistics2:inscriber",
"mode": "inscribe", "mode": "inscribe",
"result": { "result": {
@@ -1,23 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "appliedenergistics2:material_exists",
"material": "material.calculation_processor_print"
},
{
"type": "appliedenergistics2:material_exists",
"material": "material.calculation_processor_press"
},
{
"type": "appliedenergistics2:material_exists",
"material": "material.purified_certus_quartz_crystal"
}
]
}
],
"type": "appliedenergistics2:inscriber", "type": "appliedenergistics2:inscriber",
"mode": "inscribe", "mode": "inscribe",
"result": { "result": {
@@ -1,23 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "appliedenergistics2:material_exists",
"material": "material.calculation_processor"
},
{
"type": "appliedenergistics2:material_exists",
"material": "material.calculation_processor_print"
},
{
"type": "appliedenergistics2:material_exists",
"material": "material.silicon_print"
}
]
}
],
"type": "appliedenergistics2:inscriber", "type": "appliedenergistics2:inscriber",
"mode": "press", "mode": "press",
"result": { "result": {
@@ -1,10 +1,4 @@
{ {
"conditions": [
{
"type": "appliedenergistics2:material_exists",
"material": "material.engineering_processor_press"
}
],
"type": "appliedenergistics2:inscriber", "type": "appliedenergistics2:inscriber",
"mode": "inscribe", "mode": "inscribe",
"result": { "result": {
@@ -1,19 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "appliedenergistics2:material_exists",
"material": "material.engineering_processor_print"
},
{
"type": "appliedenergistics2:material_exists",
"material": "material.engineering_processor_press"
}
]
}
],
"type": "appliedenergistics2:inscriber", "type": "appliedenergistics2:inscriber",
"mode": "inscribe", "mode": "inscribe",
"result": { "result": {
@@ -1,23 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "appliedenergistics2:material_exists",
"material": "material.logic_processor"
},
{
"type": "appliedenergistics2:material_exists",
"material": "material.logic_processor_print"
},
{
"type": "appliedenergistics2:material_exists",
"material": "material.silicon_print"
}
]
}
],
"type": "appliedenergistics2:inscriber", "type": "appliedenergistics2:inscriber",
"mode": "press", "mode": "press",
"result": { "result": {
@@ -1,10 +1,4 @@
{ {
"conditions": [
{
"type": "appliedenergistics2:material_exists",
"material": "material.logic_processor_press"
}
],
"type": "appliedenergistics2:inscriber", "type": "appliedenergistics2:inscriber",
"mode": "inscribe", "mode": "inscribe",
"result": { "result": {
@@ -1,19 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "appliedenergistics2:material_exists",
"material": "material.logic_processor_print"
},
{
"type": "appliedenergistics2:material_exists",
"material": "material.logic_processor_press"
}
]
}
],
"type": "appliedenergistics2:inscriber", "type": "appliedenergistics2:inscriber",
"mode": "inscribe", "mode": "inscribe",
"result": { "result": {
@@ -1,10 +1,4 @@
{ {
"conditions": [
{
"type": "appliedenergistics2:material_exists",
"material": "material.silicon_press"
}
],
"type": "appliedenergistics2:inscriber", "type": "appliedenergistics2:inscriber",
"mode": "inscribe", "mode": "inscribe",
"result": { "result": {
@@ -1,19 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "appliedenergistics2:material_exists",
"material": "material.silicon_print"
},
{
"type": "appliedenergistics2:material_exists",
"material": "material.silicon_press"
}
]
}
],
"type": "appliedenergistics2:inscriber", "type": "appliedenergistics2:inscriber",
"mode": "inscribe", "mode": "inscribe",
"result": { "result": {
@@ -1,10 +1,4 @@
{ {
"conditions": [
{
"type": "appliedenergistics2:material_exists",
"material": "material.flour"
}
],
"type": "appliedenergistics2:smelt", "type": "appliedenergistics2:smelt",
"result": { "result": {
"item": "minecraft:bread" "item": "minecraft:bread"
@@ -1,10 +1,4 @@
{ {
"conditions": [
{
"type": "appliedenergistics2:material_exists",
"material": "material.silicon"
}
],
"type": "appliedenergistics2:smelt", "type": "appliedenergistics2:smelt",
"result": { "result": {
"part": "material.silicon" "part": "material.silicon"
@@ -1,19 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:smooth_sky_stone_block"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:sky_stone_block"
}
]
}
],
"type": "appliedenergistics2:smelt", "type": "appliedenergistics2:smelt",
"result": { "result": {
"item": "appliedenergistics2:smooth_sky_stone_block" "item": "appliedenergistics2:smooth_sky_stone_block"
@@ -363,12 +363,6 @@ gui.tooltips.appliedenergistics2.DecreaseByOne=Decrease one
gui.tooltips.appliedenergistics2.DecreaseByOneDesc=Will try to add decrease the items set in the crafting slots by one DOES NOT MAINTAIN INGREDIENT RATIO gui.tooltips.appliedenergistics2.DecreaseByOneDesc=Will try to add decrease the items set in the crafting slots by one DOES NOT MAINTAIN INGREDIENT RATIO
gui.tooltips.appliedenergistics2.MaxCount=Maximize slot count gui.tooltips.appliedenergistics2.MaxCount=Maximize slot count
gui.tooltips.appliedenergistics2.MaxCountDesc=Will maximize the output maintaing the input ratio of the items set in the crafting slots gui.tooltips.appliedenergistics2.MaxCountDesc=Will maximize the output maintaing the input ratio of the items set in the crafting slots
gui.tooltips.appliedenergistics2.FreeMolecularSlotShortcut=Show Crafting interfaces with free slots
gui.tooltips.appliedenergistics2.FreeMolecularSlotShortcutDesc=Shortcut that toggles interfaces with free slots and searches for molecular assemblers
gui.tooltips.appliedenergistics2.ToggleShowFullInterfaces=Toggles showing interfaces with full slots
gui.tooltips.appliedenergistics2.ToggleShowFullInterfacesOnDesc=Showing all interfaces
gui.tooltips.appliedenergistics2.ToggleShowFullInterfacesOffDesc=Showing only interfaces with free slots
gui.tooltips.appliedenergistics2.HighlightInterface=Highlight interface
// Units // Units
gui.appliedenergistics2.units.appliedenergstics=AE gui.appliedenergistics2.units.appliedenergstics=AE
@@ -1,8 +1,7 @@
{ {
"conditions": { "conditions": {
"material_exists": "appeng.recipes.factories.conditions.MaterialExists", "material_exists": "appeng.recipes.factories.conditions.MaterialExists",
"features": "appeng.recipes.factories.conditions.Features", "features": "appeng.recipes.factories.conditions.Features"
"part_exists": "appeng.recipes.factories.conditions.PartExists"
}, },
"ingredients": { "ingredients": {
"part": "appeng.recipes.factories.ingredients.PartIngredientFactory" "part": "appeng.recipes.factories.ingredients.PartIngredientFactory"
@@ -1,10 +1,4 @@
{ {
"conditions": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:quartz_block"
}
],
"result": { "result": {
"item": "appliedenergistics2:quartz_block" "item": "appliedenergistics2:quartz_block"
}, },
@@ -1,19 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:quartz_block"
},
{
"type": "appliedenergistics2:material_exists",
"material": "material.purified_certus_quartz_crystal"
}
]
}
],
"result": { "result": {
"item": "appliedenergistics2:quartz_block" "item": "appliedenergistics2:quartz_block"
}, },
@@ -1,19 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:quartz_pillar"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:quartz_block"
}
]
}
],
"result": { "result": {
"item": "appliedenergistics2:quartz_pillar", "item": "appliedenergistics2:quartz_pillar",
"count": 2 "count": 2
@@ -1,19 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:chiseled_quartz_block"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:quartz_block"
}
]
}
],
"result": { "result": {
"item": "appliedenergistics2:chiseled_quartz_block", "item": "appliedenergistics2:chiseled_quartz_block",
"count": 2 "count": 2
@@ -1,10 +1,4 @@
{ {
"conditions": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:fluix_block"
}
],
"result": { "result": {
"item": "appliedenergistics2:fluix_block" "item": "appliedenergistics2:fluix_block"
}, },
@@ -1,19 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:fluix_block"
},
{
"type": "appliedenergistics2:material_exists",
"material": "material.purified_fluix_crystal"
}
]
}
],
"result": { "result": {
"item": "appliedenergistics2:fluix_block" "item": "appliedenergistics2:fluix_block"
}, },
@@ -1,10 +1,4 @@
{ {
"conditions": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:light_detector"
}
],
"result": { "result": {
"item": "appliedenergistics2:light_detector" "item": "appliedenergistics2:light_detector"
}, },
@@ -1,10 +1,4 @@
{ {
"conditions": [
{
"type": "appliedenergistics2:material_exists",
"material": "material.purified_nether_quartz_crystal"
}
],
"result": { "result": {
"item": "minecraft:quartz_block", "item": "minecraft:quartz_block",
"data": 0 "data": 0
@@ -1,20 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:quartz_fixture"
},
{
"type": "appliedenergistics2:material_exists",
"material": "material.certus_quartz_crystal_charged"
}
]
}
],
"result": { "result": {
"item": "appliedenergistics2:quartz_fixture", "item": "appliedenergistics2:quartz_fixture",
"count": 2 "count": 2
@@ -1,10 +1,4 @@
{ {
"conditions": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:quartz_glass"
}
],
"result": { "result": {
"item": "appliedenergistics2:quartz_glass", "item": "appliedenergistics2:quartz_glass",
"count": 4 "count": 4
@@ -1,19 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:quartz_vibrant_glass"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:quartz_glass"
}
]
}
],
"result": { "result": {
"item": "appliedenergistics2:quartz_vibrant_glass" "item": "appliedenergistics2:quartz_vibrant_glass"
}, },
@@ -1,19 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:sky_stone_brick"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:smooth_sky_stone_block"
}
]
}
],
"result": { "result": {
"item": "appliedenergistics2:sky_stone_brick" "item": "appliedenergistics2:sky_stone_brick"
}, },
@@ -1,19 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:sky_stone_small_brick"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:sky_stone_brick"
}
]
}
],
"result": { "result": {
"item": "appliedenergistics2:sky_stone_small_brick" "item": "appliedenergistics2:sky_stone_small_brick"
}, },
@@ -1,19 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:smooth_sky_stone_block"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:sky_stone_small_brick"
}
]
}
],
"result": { "result": {
"item": "appliedenergistics2:smooth_sky_stone_block" "item": "appliedenergistics2:smooth_sky_stone_block"
}, },
@@ -1,19 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:chiseled_quartz_slab"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:chiseled_quartz_block"
}
]
}
],
"result": { "result": {
"item": "appliedenergistics2:chiseled_quartz_slab", "item": "appliedenergistics2:chiseled_quartz_slab",
"data": 0, "data": 0,
@@ -1,19 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:fluix_slab"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:fluix_block"
}
]
}
],
"result": { "result": {
"item": "appliedenergistics2:fluix_slab", "item": "appliedenergistics2:fluix_slab",
"data": 0, "data": 0,
@@ -1,19 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:quartz_slab"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:quartz_block"
}
]
}
],
"result": { "result": {
"item": "appliedenergistics2:quartz_slab", "item": "appliedenergistics2:quartz_slab",
"data": 0, "data": 0,
@@ -1,19 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:quartz_pillar_slab"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:quartz_pillar"
}
]
}
],
"result": { "result": {
"item": "appliedenergistics2:quartz_pillar_slab", "item": "appliedenergistics2:quartz_pillar_slab",
"data": 0, "data": 0,
@@ -1,19 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:sky_stone_slab"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:sky_stone_block"
}
]
}
],
"result": { "result": {
"item": "appliedenergistics2:sky_stone_slab", "item": "appliedenergistics2:sky_stone_slab",
"data": 0, "data": 0,
@@ -1,19 +1,4 @@
{ {
"conditions": [
{
"type": "forge:and",
"values": [
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:sky_stone_brick_slab"
},
{
"type": "minecraft:item_exists",
"item": "appliedenergistics2:sky_stone_brick"
}
]
}
],
"result": { "result": {
"item": "appliedenergistics2:sky_stone_brick_slab", "item": "appliedenergistics2:sky_stone_brick_slab",
"data": 0, "data": 0,

Some files were not shown because too many files have changed in this diff Show More