Merge pull request #94 from GTNewHorizons/feature/OmniBackport

Backported/reimplemented features from PrototypeTrousers/Omnifactory AE fork
This commit is contained in:
repo-alt authored and GitHub committed 2022-01-17 19:59:40 +03:00
commit b63fc3f7d8
25 files changed
+546 -105

No files matched your search

@@ -26,5 +26,11 @@ package appeng.api.config;
public enum ActionItems
{
WRENCH, CLOSE, STASH, ENCODE, SUBSTITUTION, SLOT_CONFIG, ORE_FILTER, DOUBLE
WRENCH, CLOSE, STASH, ENCODE, SUBSTITUTION, SLOT_CONFIG, ORE_FILTER, DOUBLE,
MOLECULAR_ASSEMBLEERS_ON,
MOLECULAR_ASSEMBLEERS_OFF,
TOGGLE_SHOW_FULL_INTERFACES_ON,
TOGGLE_SHOW_FULL_INTERFACES_OFF,
HIGHLIGHT_INTERFACE
}
@@ -58,6 +58,13 @@ public class DimensionalCoord extends WorldCoord
this.dimId = _w.provider.dimensionId;
}
public DimensionalCoord( final int _x, final int _y, final int _z, final int _dim )
{
super( _x, _y, _z );
this.w = null;
this.dimId = _dim;
}
@Override
public DimensionalCoord copy()
{
@@ -96,4 +103,6 @@ public class DimensionalCoord extends WorldCoord
{
return this.w;
}
public int getDimension() { return dimId; }
}
@@ -137,6 +137,22 @@ public class WorldCoord
return null;
}
public double distanceTo( final WorldCoord c )
{
double dx = c.x - x;
double dy = c.y - y;
double dz = c.z - z;
return Math.sqrt(dx*dx + dy*dy + dz*dz);
}
public static long getTaxicabDistance( WorldCoord blockPos, WorldCoord blockPos2 )
{
long dx = Math.abs(blockPos.x - blockPos2.x);
long dy = Math.abs(blockPos.y - blockPos2.y);
long dz = Math.abs(blockPos.z - blockPos2.z);
return dx + dy + dz;
}
public boolean isEqual( final WorldCoord c )
{
return this.x == c.x && this.y == c.y && this.z == c.z;
@@ -39,6 +39,7 @@ import appeng.entity.EntityFloatingItem;
import appeng.entity.EntityTinyTNTPrimed;
import appeng.entity.RenderFloatingItem;
import appeng.entity.RenderTinyTNTPrimed;
import appeng.helpers.HighlighterHandler;
import appeng.helpers.IMouseWheelItem;
import appeng.hooks.TickHandler;
import appeng.hooks.TickHandler.PlayerColor;
@@ -67,6 +68,7 @@ import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.client.event.MouseEvent;
import net.minecraftforge.client.event.RenderLivingEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.MinecraftForge;
import org.lwjgl.opengl.GL11;
@@ -104,6 +106,11 @@ public class ClientHelper extends ServerHelper
MinecraftForge.EVENT_BUS.register( this );
}
@SubscribeEvent
public void renderWorldLastEvent( RenderWorldLastEvent event) {
HighlighterHandler.tick(event);
}
@Override
public World getWorld()
{
+50 -1
View File
@@ -39,6 +39,7 @@ import appeng.helpers.InventoryAction;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.integration.abstraction.INEI;
import appeng.tile.inventory.AppEngInternalInventory;
import com.google.common.base.Joiner;
import com.google.common.base.Stopwatch;
import cpw.mods.fml.common.ObfuscationReflectionHelper;
@@ -50,6 +51,7 @@ import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
@@ -364,6 +366,42 @@ public abstract class AEBaseGui extends GuiContainer
}
}
}
else if( slot instanceof SlotDisconnected )
{
this.drag_click.add( slot );
if( this.drag_click.size() > 1 )
{
if( itemstack != null )
{
for( final Slot dr : this.drag_click )
{
if( slot.getStack() == null)
{
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() != null )
{
action = InventoryAction.SHIFT_CLICK;
}
if( action != null )
{
final PacketInventoryAction p = new PacketInventoryAction( action, dr.getSlotIndex(), ( (SlotDisconnected) slot ).getSlot().getId() );
NetworkHandler.instance.sendToServer( p );
}
}
}
}
}
else
{
super.mouseClickMove( x, y, c, d );
@@ -456,12 +494,23 @@ public abstract class AEBaseGui extends GuiContainer
if( slot instanceof SlotDisconnected )
{
if( this.drag_click.size() > 1 )
{
return;
}
InventoryAction action = null;
switch( mouseButton )
{
case 0: // pickup / set-down.
action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
{
ItemStack heldStack = player.inventory.getItemStack();
if (slot.getStack() == null && heldStack != null)
action = InventoryAction.SPLIT_OR_PLACE_SINGLE;
else if (slot.getStack() != null && (heldStack == null || heldStack.stackSize <= 1))
action = InventoryAction.PICKUP_OR_SET_DOWN;
}
break;
case 1:
action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
@@ -20,20 +20,31 @@ package appeng.client.gui.implementations;
import appeng.api.AEApi;
import appeng.api.config.ActionItems;
import appeng.api.config.Settings;
import appeng.api.util.DimensionalCoord;
import appeng.api.util.WorldCoord;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.MEGuiTextField;
import appeng.client.me.ClientDCInternalInv;
import appeng.client.me.SlotDisconnected;
import appeng.client.render.BlockPosHighlighter;
import appeng.container.implementations.ContainerInterfaceTerminal;
import appeng.core.localization.ButtonToolTips;
import appeng.core.localization.GuiText;
import appeng.core.localization.PlayerMessages;
import appeng.parts.reporting.PartInterfaceTerminal;
import appeng.util.Platform;
import com.google.common.collect.HashMultimap;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ChatComponentTranslation;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import java.util.*;
@@ -43,19 +54,27 @@ public class GuiInterfaceTerminal extends AEBaseGui
{
private static final int LINES_ON_PAGE = 6;
private static final int offsetX = 21;
// TODO: copied from GuiMEMonitorable. It looks not changed, maybe unneeded?
private final int offsetX = 9;
private final HashMap<Long, ClientDCInternalInv> byId = new HashMap<Long, ClientDCInternalInv>();
private final HashMap<Long, ClientDCInternalInv> byId = new HashMap<>();
private final HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create();
private final ArrayList<String> names = new ArrayList<String>();
private final ArrayList<Object> lines = new ArrayList<Object>();
private final HashMap<ClientDCInternalInv, DimensionalCoord> blockPosHashMap = new HashMap<>();
private final HashMap<GuiButton,ClientDCInternalInv> guiButtonHashMap = new HashMap<>();
private final ArrayList<String> names = new ArrayList<>();
private final ArrayList<Object> lines = new ArrayList<>();
private final Set<Object> matchedStacks = new HashSet<>();
private final Map<String, Set<Object>> cachedSearches = new WeakHashMap<String, Set<Object>>();
private final Map<String, Set<Object>> cachedSearches = new WeakHashMap<>();
private MEGuiTextField searchFieldOutputs;
private MEGuiTextField searchFieldInputs;
private GuiButton guiButtonHideFull;
private GuiButton guiButtonAssemblersOnly;
private boolean refreshList = false;
private MEGuiTextField searchField;
private boolean onlyInterfacesWithFreeSlots = false;
private boolean onlyMolecularAssemblers = false;
private static final String MOLECULAR_ASSEMBLER = "molecular assembler";
public GuiInterfaceTerminal( final InventoryPlayer inventoryPlayer, final PartInterfaceTerminal te )
{
@@ -63,8 +82,8 @@ public class GuiInterfaceTerminal extends AEBaseGui
final GuiScrollbar scrollbar = new GuiScrollbar();
this.setScrollBar( scrollbar );
this.xSize = 195;
this.ySize = 222;
this.xSize = 208;
this.ySize = 255;
}
@Override
@@ -72,36 +91,44 @@ public class GuiInterfaceTerminal extends AEBaseGui
{
super.initGui();
this.getScrollBar().setLeft( 175 );
this.getScrollBar().setLeft( 189 );
this.getScrollBar().setHeight( 106 );
this.getScrollBar().setTop( 18 );
this.getScrollBar().setTop( 51 );
this.searchField = new MEGuiTextField( this.fontRendererObj, this.guiLeft + Math.max( 104, this.offsetX ), this.guiTop + 4, 65, 12 );
this.searchField.setEnableBackgroundDrawing( false );
this.searchField.setMaxStringLength( 25 );
this.searchField.setTextColor( 0xFFFFFF );
this.searchField.setVisible( true );
this.searchField.setFocused( true );
this.searchFieldInputs = new MEGuiTextField( this.fontRendererObj, this.guiLeft + Math.max( 32, this.offsetX ), this.guiTop + 25, 65, 12 );
this.searchFieldInputs.setEnableBackgroundDrawing( false );
this.searchFieldInputs.setMaxStringLength( 25 );
this.searchFieldInputs.setTextColor( 0xFFFFFF );
this.searchFieldInputs.setVisible( true );
this.searchFieldInputs.setFocused( false );
this.searchFieldOutputs = new MEGuiTextField( this.fontRendererObj, this.guiLeft + Math.max( 32, this.offsetX ), this.guiTop + 38, 65, 12 );
this.searchFieldOutputs.setEnableBackgroundDrawing( false );
this.searchFieldOutputs.setMaxStringLength( 25 );
this.searchFieldOutputs.setTextColor( 0xFFFFFF );
this.searchFieldOutputs.setVisible( true );
this.searchFieldOutputs.setFocused( true );
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.buttonList.clear();
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.InterfaceTerminal.getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), this.offsetX + 2, this.ySize - 96 + 3, 4210752 );
final int ex = this.getScrollBar().getCurrentScroll();
final Iterator<Object> o = this.inventorySlots.inventorySlots.iterator();
while( o.hasNext() )
{
if( o.next() instanceof SlotDisconnected )
{
o.remove();
}
}
this.guiButtonAssemblersOnly = new GuiImgButton(guiLeft + 123, guiTop + 25, Settings.ACTIONS, onlyMolecularAssemblers ? ActionItems.MOLECULAR_ASSEMBLEERS_ON : ActionItems.MOLECULAR_ASSEMBLEERS_OFF);
this.buttonList.add(guiButtonAssemblersOnly);
int offset = 17;
guiButtonHideFull = new GuiImgButton( guiLeft + 141, guiTop + 25, Settings.ACTIONS, this.onlyInterfacesWithFreeSlots ? ActionItems.TOGGLE_SHOW_FULL_INTERFACES_OFF : ActionItems.TOGGLE_SHOW_FULL_INTERFACES_ON );
this.buttonList.add(guiButtonHideFull);
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++ )
{
final Object lineObj = this.lines.get( ex + x );
@@ -110,8 +137,13 @@ public class GuiInterfaceTerminal extends AEBaseGui
final ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
for( int z = 0; z < inv.getInventory().getSizeInventory(); z++ )
{
this.inventorySlots.inventorySlots.add( new SlotDisconnected( inv, z, z * 18 + 8, 1 + offset ) );
this.inventorySlots.inventorySlots.add( new SlotDisconnected( inv, z, z * 18 + 22, 1 + offset ) );
if (this.matchedStacks.contains(inv.getInventory().getStackInSlot(z)))
drawRect( z * 18 + 22, 1 + offset, z * 18 + 22 + 16, 1 + offset + 16, 0x2A00FF00 );
}
GuiButton guiButton = new GuiImgButton(guiLeft + 4, guiTop + offset + 1, Settings.ACTIONS, ActionItems.HIGHLIGHT_INTERFACE);
guiButtonHashMap.put( guiButton , inv);
this.buttonList.add( guiButton );
}
else if( lineObj instanceof String )
{
@@ -127,33 +159,78 @@ public class GuiInterfaceTerminal extends AEBaseGui
name = name.substring( 0, name.length() - 1 );
}
this.fontRendererObj.drawString( name, 10, 6 + offset, 4210752 );
this.fontRendererObj.drawString( name, this.offsetX + 2, 6 + offset, 4210752 );
}
offset += 18;
}
if( searchFieldInputs.isMouseIn( mouseX , mouseY ) )
drawTooltip( Mouse.getEventX() * this.width / this.mc.displayWidth - offsetX, mouseY - guiTop, 0, ButtonToolTips.SearchFieldInputs.getLocal() );
else if( searchFieldOutputs.isMouseIn( mouseX, mouseY ) )
drawTooltip( Mouse.getEventX() * this.width / this.mc.displayWidth - offsetX, mouseY - guiTop, 0, ButtonToolTips.SearchFieldOutputs.getLocal() );
}
@Override
protected void mouseClicked( final int xCoord, final int yCoord, final int btn )
{
this.searchField.mouseClicked( xCoord, yCoord, btn );
this.searchFieldInputs.mouseClicked( xCoord, yCoord, btn );
if( btn == 1 && this.searchField.isMouseIn( xCoord, yCoord ) )
if( btn == 1 && this.searchFieldInputs.isMouseIn( xCoord, yCoord ) )
{
this.searchField.setText( "" );
this.searchFieldInputs.setText( "" );
this.refreshList();
}
this.searchFieldOutputs.mouseClicked( xCoord, yCoord, btn );
if( btn == 1 && this.searchFieldOutputs.isMouseIn( xCoord, yCoord ) )
{
this.searchFieldOutputs.setText( "" );
this.refreshList();
}
super.mouseClicked( xCoord, yCoord, btn );
}
@Override
protected void actionPerformed( final GuiButton btn )
{
if( guiButtonHashMap.containsKey( btn ) )
{
DimensionalCoord blockPos = blockPosHashMap.get( guiButtonHashMap.get( btn ) );
WorldCoord blockPos2 = new WorldCoord((int)mc.thePlayer.posX, (int)mc.thePlayer.posY, (int)mc.thePlayer.posZ);
if( mc.theWorld.provider.dimensionId != blockPos.getDimension() )
{
mc.thePlayer.addChatMessage(new ChatComponentTranslation( PlayerMessages.InterfaceInOtherDim.getName(), blockPos.getDimension()));
}
else
{
BlockPosHighlighter.highlightBlock(blockPos, System.currentTimeMillis() + 500 * WorldCoord.getTaxicabDistance(blockPos, blockPos2));
mc.thePlayer.addChatMessage(new ChatComponentTranslation( PlayerMessages.InterfaceHighlighted.getName(), blockPos.x, blockPos.y, blockPos.z));
}
mc.thePlayer.closeScreen();
}
if (btn == guiButtonHideFull)
{
onlyInterfacesWithFreeSlots = !onlyInterfacesWithFreeSlots;
this.refreshList();
}
if (btn == guiButtonAssemblersOnly)
{
onlyMolecularAssemblers = !onlyMolecularAssemblers;
this.refreshList();
}
}
@Override
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.bindTexture( "guis/interfaceterminal.png" );
this.bindTexture( "guis/newinterfaceterminal.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
int offset = 17;
int offset = 51;
final int ex = this.getScrollBar().getCurrentScroll();
for( int x = 0; x < LINES_ON_PAGE && ex + x < this.lines.size(); x++ )
@@ -165,14 +242,19 @@ public class GuiInterfaceTerminal extends AEBaseGui
GL11.glColor4f( 1, 1, 1, 1 );
final int width = inv.getInventory().getSizeInventory() * 18;
this.drawTexturedModalRect( offsetX + 7, offsetY + offset, 7, 139, width, 18 );
this.drawTexturedModalRect( offsetX + 20, offsetY + offset, 20, 173, width, 18 );
}
offset += 18;
}
if( this.searchField != null )
if( this.searchFieldInputs != null )
{
this.searchField.drawTextBox();
this.searchFieldInputs.drawTextBox();
}
if( this.searchFieldOutputs != null )
{
this.searchFieldOutputs.drawTextBox();
}
}
@@ -181,12 +263,17 @@ public class GuiInterfaceTerminal extends AEBaseGui
{
if( !this.checkHotbarKeys( key ) )
{
if( character == ' ' && this.searchField.getText().isEmpty() )
if( character == ' ' && this.searchFieldInputs.getText().isEmpty() && this.searchFieldInputs.isFocused() )
{
return;
}
if( this.searchField.textboxKeyTyped( character, key ) )
if( character == ' ' && this.searchFieldOutputs.getText().isEmpty() && this.searchFieldOutputs.isFocused() )
{
return;
}
if( this.searchFieldInputs.textboxKeyTyped( character, key ) || this.searchFieldOutputs.textboxKeyTyped( character, key ))
{
this.refreshList();
}
@@ -215,6 +302,11 @@ public class GuiInterfaceTerminal extends AEBaseGui
final long id = Long.parseLong( key.substring( 1 ), Character.MAX_RADIX );
final NBTTagCompound invData = in.getCompoundTag( key );
final ClientDCInternalInv current = this.getById( id, invData.getLong( "sortBy" ), invData.getString( "un" ) );
int X = invData.getInteger( "x" );
int Y = invData.getInteger( "y" );
int Z = invData.getInteger( "z" );
int dim = invData.getInteger( "dim" );
blockPosHashMap.put( current, new DimensionalCoord(X,Y,Z,dim));
for( int x = 0; x < current.getInventory().getSizeInventory(); x++ )
{
@@ -236,6 +328,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
this.refreshList = false;
// invalid caches on refresh
this.cachedSearches.clear();
onlyMolecularAssemblers = false;
this.refreshList();
}
}
@@ -248,41 +341,73 @@ public class GuiInterfaceTerminal extends AEBaseGui
private void refreshList()
{
this.byName.clear();
this.buttonList.clear();
this.matchedStacks.clear();
final String searchFilterLowerCase = this.searchField.getText().toLowerCase();
final String searchFieldInputs = this.searchFieldInputs.getText().toLowerCase();
final String searchFieldOutputs = this.searchFieldOutputs.getText().toLowerCase();
final Set<Object> cachedSearch = this.getCacheForSearchTerm( searchFilterLowerCase );
final Set<Object> cachedSearch = this.getCacheForSearchTerm( "IN:" + searchFieldInputs + " OUT:" + searchFieldOutputs + onlyInterfacesWithFreeSlots + this.onlyMolecularAssemblers);
final boolean rebuild = cachedSearch.isEmpty();
for( final ClientDCInternalInv entry : this.byId.values() )
{
// ignore inventory if not doing a full rebuild or cache already marks it as miss.
// ignore inventory if not doing a full rebuild and cache already marks it as miss.
if( !rebuild && !cachedSearch.contains( entry ) )
{
continue;
}
// Shortcut to skip any filter if search term is ""/empty
boolean found = searchFilterLowerCase.isEmpty();
boolean found = (searchFieldInputs.isEmpty() && searchFieldOutputs.isEmpty()) && !onlyInterfacesWithFreeSlots;
boolean interfaceHasFreeSlots = false;
// Search if the current inventory holds a pattern containing the search term.
if( !found && !searchFilterLowerCase.isEmpty() )
if( !found )
{
for( final ItemStack itemStack : entry.getInventory() )
{
found = this.itemStackMatchesSearchTerm( itemStack, searchFilterLowerCase );
if( found )
{
break;
if( !searchFieldInputs.isEmpty() && !searchFieldOutputs.isEmpty() ) {
if (this.itemStackMatchesSearchTerm(itemStack, searchFieldInputs, 0) || this.itemStackMatchesSearchTerm(itemStack, searchFieldOutputs, 1)) {
found = true;
matchedStacks.add(itemStack);
}
}
else if( !searchFieldInputs.isEmpty() ) {
if (this.itemStackMatchesSearchTerm(itemStack, searchFieldInputs, 0)) {
found = true;
matchedStacks.add(itemStack);
}
}
else if( !searchFieldOutputs.isEmpty() ) {
if (this.itemStackMatchesSearchTerm(itemStack, searchFieldOutputs, 1)) {
found = true;
matchedStacks.add(itemStack);
}
}
// If only Interfaces with empty slots should be shown, check that here
if( itemStack == null )
interfaceHasFreeSlots = true;
}
}
// if found, filter skipped or machine name matching the search term, add it
if( found || entry.getName().toLowerCase().contains( searchFilterLowerCase ) )
String name = entry.getName().toLowerCase();
if (onlyMolecularAssemblers) {
if (searchFieldInputs.isEmpty() && searchFieldOutputs.isEmpty())
found = name.equals(MOLECULAR_ASSEMBLER);
else
found &= name.equals(MOLECULAR_ASSEMBLER);
}
else
found |= name.contains( searchFieldInputs ) && name.contains( searchFieldOutputs );
if (found)
{
this.byName.put( entry.getName(), entry );
cachedSearch.add( entry );
if (!onlyInterfacesWithFreeSlots || interfaceHasFreeSlots)
{
this.byName.put(entry.getName(), entry);
cachedSearch.add(entry);
}
}
else
{
@@ -301,10 +426,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
for( final String n : this.names )
{
this.lines.add( n );
final ArrayList<ClientDCInternalInv> clientInventories = new ArrayList<ClientDCInternalInv>();
clientInventories.addAll( this.byName.get( n ) );
final ArrayList<ClientDCInternalInv> clientInventories = new ArrayList<>(this.byName.get(n));
Collections.sort( clientInventories );
this.lines.addAll( clientInventories );
}
@@ -312,7 +434,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
this.getScrollBar().setRange( 0, this.lines.size() - LINES_ON_PAGE, 2 );
}
private boolean itemStackMatchesSearchTerm( final ItemStack itemStack, final String searchTerm )
private boolean itemStackMatchesSearchTerm( final ItemStack itemStack, final String searchTerm, int pass )
{
if( itemStack == null )
{
@@ -326,14 +448,11 @@ public class GuiInterfaceTerminal extends AEBaseGui
return false;
}
// Potential later use to filter by input
// NBTTagList inTag = encodedValue.getTagList( "in", 10 );
final NBTTagList outTag = encodedValue.getTagList( "out", 10 );
NBTTagList tag = encodedValue.getTagList( pass == 0 ? "in" : "out", 10 );
for( int i = 0; i < outTag.tagCount(); i++ )
for( int i = 0; i < tag.tagCount(); i++ )
{
final ItemStack parsedItemStack = ItemStack.loadItemStackFromNBT( outTag.getCompoundTagAt( i ) );
final ItemStack parsedItemStack = ItemStack.loadItemStackFromNBT( tag.getCompoundTagAt( i ) );
if( parsedItemStack != null )
{
final String displayName = Platform.getItemDisplayName( AEApi.instance().storage().createItemStack( parsedItemStack ) ).toLowerCase();
@@ -359,7 +478,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
{
if( !this.cachedSearches.containsKey( searchTerm ) )
{
this.cachedSearches.put( searchTerm, new HashSet<Object>() );
this.cachedSearches.put( searchTerm, new HashSet<>() );
}
final Set<Object> cache = this.cachedSearches.get( searchTerm );
@@ -78,7 +78,7 @@ public class GuiPatternTerm extends GuiMEMonitorable
}
else if( this.encodeBtn == btn )
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PatternTerminal.Encode", "1" ) );
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PatternTerminal.Encode", isShiftKeyDown() ? "2" : "1" ) );
}
else if( this.clearBtn == btn )
{
@@ -47,7 +47,7 @@ public class GuiPatternTermEx extends GuiMEMonitorable {
{
if( this.encodeBtn == btn )
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PatternTerminalEx.Encode", "1" ) );
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PatternTerminalEx.Encode", isShiftKeyDown() ? "2" : "1" ) );
}
else if( this.clearBtn == btn )
{
@@ -154,6 +154,12 @@ public class GuiImgButton extends GuiButton implements ITooltip
this.registerApp( 70, Settings.ACTIONS, ActionItems.ORE_FILTER, ButtonToolTips.OreFilter, ButtonToolTips.OreFilterHint );
this.registerApp( 71, Settings.ACTIONS, ActionItems.DOUBLE, ButtonToolTips.DoublePattern, ButtonToolTips.DoublePatternHint );
this.registerApp( 16 * 14 + 2, Settings.CRAFTING_STATUS, CraftingStatus.BUTTON, ButtonToolTips.CraftingStatus, ButtonToolTips.CraftingStatusDesc );
this.registerApp( 6 + 5 * 16, Settings.ACTIONS, ActionItems.MOLECULAR_ASSEMBLEERS_ON, ButtonToolTips.ToggleMolecularAssemblers, ButtonToolTips.ToggleMolecularAssemblersDescOn );
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( 9 + 5 * 16, Settings.ACTIONS, ActionItems.MOLECULAR_ASSEMBLEERS_OFF, ButtonToolTips.ToggleMolecularAssemblers, ButtonToolTips.ToggleMolecularAssemblersDescOff );
this.registerApp( 6 + 6 * 16, Settings.ACTIONS, ActionItems.HIGHLIGHT_INTERFACE, ButtonToolTips.HighlightInterface, "" );
}
}
@@ -37,7 +37,7 @@ public class ClientDCInternalInv implements Comparable<ClientDCInternalInv>
public ClientDCInternalInv( final int size, final long id, final long sortBy, final String unlocalizedName )
{
this.inventory = new AppEngInternalInventory( null, size );
this.inventory = new AppEngInternalInventory( null, size, 1 );
this.unlocalizedName = unlocalizedName;
this.id = id;
this.sortBy = sortBy;
@@ -0,0 +1,23 @@
package appeng.client.render;
import appeng.api.util.DimensionalCoord;
// taken from McJty's McJtyLib
public class BlockPosHighlighter
{
private static DimensionalCoord highlightedBlock;
private static long expireHighlight;
public static void highlightBlock(DimensionalCoord c, long expireHighlight) {
highlightedBlock = c;
BlockPosHighlighter.expireHighlight = expireHighlight;
}
public static DimensionalCoord getHighlightedBlock() {
return highlightedBlock;
}
public static long getExpireHighlight() {
return expireHighlight;
}
}
@@ -61,7 +61,7 @@ public class ContainerInterface extends ContainerUpgradeable implements IOptiona
for (int x = 0; x < DualityInterface.NUMBER_OF_PATTERN_SLOTS; x++) {
this.addSlotToContainer(new OptionalSlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, this.myDuality.getPatterns(), this,
x + row*DualityInterface.NUMBER_OF_PATTERN_SLOTS, 8 + 18 * x, 108 - row * 18, row, this.getInventoryPlayer()));
x + row*DualityInterface.NUMBER_OF_PATTERN_SLOTS, 8 + 18 * x, 108 - row * 18, row, this.getInventoryPlayer()).setStackLimit( 1 ) );
}
}
@@ -40,6 +40,7 @@ import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.inv.AdaptorIInventory;
import appeng.util.inv.AdaptorPlayerHand;
import appeng.util.inv.ItemSlot;
import appeng.util.inv.WrapperInvSlot;
import com.google.common.collect.HashMultimap;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -74,7 +75,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer {
this.grid = anchor.getActionableNode().getGrid();
}
this.bindPlayerInventory(ip, 0, 222 - /* height of player inventory */82);
this.bindPlayerInventory(ip, 14, 256 - /* height of player inventory */82);
}
@Override
@@ -147,27 +148,42 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer {
final IInventory theSlot = slotInv.getWrapper(slot + inv.offset);
final InventoryAdaptor interfaceSlot = new AdaptorIInventory(theSlot);
IInventory interfaceHandler = inv.server;
boolean canInsert = true;
switch (action) {
case PICKUP_OR_SET_DOWN:
if (hasItemInHand) {
ItemStack inSlot = theSlot.getStackInSlot(0);
if (inSlot == null) {
player.inventory.setItemStack(interfaceSlot.addItems(player.inventory.getItemStack()));
} else {
inSlot = inSlot.copy();
final ItemStack inHand = player.inventory.getItemStack().copy();
theSlot.setInventorySlotContents(0, null);
player.inventory.setItemStack(null);
player.inventory.setItemStack(interfaceSlot.addItems(inHand.copy()));
if (player.inventory.getItemStack() == null) {
player.inventory.setItemStack(inSlot);
if (hasItemInHand)
{
for( int s = 0; s < interfaceHandler.getSizeInventory(); s++ )
{
if( Platform.isSameItemPrecise( interfaceHandler.getStackInSlot( s ), player.inventory.getItemStack() ) )
{
canInsert = false;
break;
}
}
if( canInsert )
{
ItemStack inSlot = theSlot.getStackInSlot(0);
if (inSlot == null) {
player.inventory.setItemStack(interfaceSlot.addItems(player.inventory.getItemStack()));
} else {
player.inventory.setItemStack(inHand);
theSlot.setInventorySlotContents(0, inSlot);
inSlot = inSlot.copy();
final ItemStack inHand = player.inventory.getItemStack().copy();
theSlot.setInventorySlotContents(0, null);
player.inventory.setItemStack(null);
player.inventory.setItemStack(interfaceSlot.addItems(inHand.copy()));
if (player.inventory.getItemStack() == null) {
player.inventory.setItemStack(inSlot);
} else {
player.inventory.setItemStack(inHand);
theSlot.setInventorySlotContents(0, inSlot);
}
}
}
} else {
@@ -179,12 +195,22 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer {
case SPLIT_OR_PLACE_SINGLE:
if (hasItemInHand) {
ItemStack extra = playerHand.removeItems(1, null, null);
if (extra != null) {
extra = interfaceSlot.addItems(extra);
for( int s = 0; s < interfaceHandler.getSizeInventory(); s++ )
{
if( Platform.isSameItemPrecise( interfaceHandler.getStackInSlot( s ), player.inventory.getItemStack() ) )
{
canInsert = false;
break;
}
}
if (extra != null) {
playerHand.addItems(extra);
if( canInsert ) {
ItemStack extra = playerHand.removeItems(1, null, null);
if (extra != null && !interfaceSlot.containsItems()) {
extra = interfaceSlot.addItems(extra);
}
if (extra != null) {
playerHand.addItems(extra);
}
}
} else if (is != null) {
ItemStack extra = interfaceSlot.removeItems((is.stackSize + 1) / 2, null, null);
@@ -201,14 +227,14 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer {
final IInventory mySlot = slotInv.getWrapper(slot + inv.offset);
final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
mySlot.setInventorySlotContents(0, playerInv.addItems(mySlot.getStackInSlot(0)));
mySlot.setInventorySlotContents(0, mergeToPlayerInventory(playerInv, mySlot.getStackInSlot(0)));
break;
case MOVE_REGION:
final InventoryAdaptor playerInvAd = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
for (int x = 0; x < inv.client.getSizeInventory(); x++) {
inv.server.setInventorySlotContents(x + inv.offset, playerInvAd.addItems(inv.server.getStackInSlot(x + inv.offset)));
inv.server.setInventorySlotContents(x + inv.offset, mergeToPlayerInventory(playerInvAd, inv.server.getStackInSlot(x + inv.offset)));
}
break;
@@ -226,7 +252,20 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer {
this.updateHeld(player);
}
}
private ItemStack mergeToPlayerInventory(InventoryAdaptor playerInv, ItemStack stack)
{
if (stack == null)
return null;
for (ItemSlot slot: playerInv) {
if (Platform.isSameItemPrecise(slot.getItemStack(), stack)) {
if (slot.getItemStack().stackSize < slot.getItemStack().getMaxStackSize()) {
++slot.getItemStack().stackSize;
return null;
}
}
}
return playerInv.addItems(stack);
}
private void regenList(final NBTTagCompound data) {
this.byId.clear();
this.diList.clear();
@@ -284,6 +323,10 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer {
if (tag.hasNoTags()) {
tag.setLong("sortBy", inv.sortBy);
tag.setString("un", inv.unlocalizedName);
tag.setInteger("x", inv.X);
tag.setInteger("y", inv.Y);
tag.setInteger("z", inv.Z);
tag.setInteger("dim", inv.dim);
}
for (int x = 0; x < length; x++) {
@@ -312,6 +355,10 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer {
private final IInventory client;
private final IInventory server;
private final int offset;
private final int X;
private final int Y;
private final int Z;
private final int dim;
public InvTracker(final DualityInterface dual, final IInventory patterns, final String unlocalizedName, int offset, int size) {
this.server = patterns;
@@ -319,6 +366,10 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer {
this.unlocalizedName = unlocalizedName;
this.sortBy = dual.getSortValue() + offset << 16;
this.offset = offset;
X = dual.getLocation().x;
Y = dual.getLocation().y;
Z = dual.getLocation().z;
dim = dual.getLocation().getDimension();
}
}
@@ -174,6 +174,19 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
}
public void encodeAndMoveToInventory()
{
encode();
ItemStack output = this.patternSlotOUT.getStack();
if ( output != null )
{
if (!getPlayerInv().addItemStackToInventory( output )){
getPlayerInv().player.entityDropItem(output, 0);
}
this.patternSlotOUT.putStack( null );
}
}
public void encode()
{
ItemStack output = this.patternSlotOUT.getStack();
@@ -69,6 +69,19 @@ public class ContainerPatternTermEx extends ContainerMEMonitorable implements IO
this.bindPlayerInventory( ip, 0, 0 );
}
public void encodeAndMoveToInventory()
{
encode();
ItemStack output = this.patternSlotOUT.getStack();
if ( output != null )
{
if (!getPlayerInv().addItemStackToInventory( output )){
getPlayerInv().player.entityDropItem(output, 0);
}
this.patternSlotOUT.putStack( null );
}
}
public void encode()
{
ItemStack output = this.patternSlotOUT.getStack();
@@ -67,7 +67,19 @@ public enum ButtonToolTips
SchedulingMode, SchedulingModeDefault, SchedulingModeRoundRobin, SchedulingModeRandom, OreFilter, OreFilterHint, DoublePattern, DoublePatternHint,
SaveSearchString, SaveSearchStringYes, SaveSearchStringNo,
CraftingStatus, CraftingStatusDesc;
CraftingStatus, CraftingStatusDesc,
ToggleMolecularAssemblers,
ToggleMolecularAssemblersDescOn,
ToggleMolecularAssemblersDescOff,
ToggleShowFullInterfaces,
ToggleShowFullInterfacesOnDesc,
ToggleShowFullInterfacesOffDesc,
HighlightInterface,
HighlightInterfaceDesc,
SearchFieldInputs,
SearchFieldOutputs
;
private final String root;
@@ -31,7 +31,8 @@ public enum PlayerMessages
AmmoDepleted,
CommunicationError, OutOfRange, DeviceNotPowered, DeviceNotWirelessTerminal, DeviceNotLinked, StationCanNotBeLocated,
SettingCleared,
TunnelNotConnected, TunnelInputIsAt, TunnelHasNoOutputs, TunnelOutputsAreAt
TunnelNotConnected, TunnelInputIsAt, TunnelHasNoOutputs, TunnelOutputsAreAt,
InterfaceInOtherDim, InterfaceHighlighted
;
public IChatComponent get()
@@ -146,7 +146,10 @@ public class PacketValueConfig extends AppEngPacket
}
else if( this.Name.equals( "PatternTerminal.Encode" ) )
{
cpt.encode();
if (this.Value.equals( "2" ))
cpt.encodeAndMoveToInventory();
else
cpt.encode();
}
else if( this.Name.equals( "PatternTerminal.Clear" ) )
{
@@ -166,7 +169,10 @@ public class PacketValueConfig extends AppEngPacket
final ContainerPatternTermEx cpt = (ContainerPatternTermEx) c;
if( this.Name.equals( "PatternTerminalEx.Encode" ) )
{
cpt.encode();
if (this.Value.equals( "2" ))
cpt.encodeAndMoveToInventory();
else
cpt.encode();
}
else if( this.Name.equals( "PatternTerminalEx.Clear" ) )
{
@@ -0,0 +1,94 @@
package appeng.helpers;
import appeng.api.util.DimensionalCoord;
import appeng.client.render.BlockPosHighlighter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import org.lwjgl.opengl.GL11;
// inspired by McJtyLib
public class HighlighterHandler
{
public static void tick( RenderWorldLastEvent event ) {
renderHilightedBlock(event);
}
private static void renderHilightedBlock( RenderWorldLastEvent event ) {
DimensionalCoord c = BlockPosHighlighter.getHighlightedBlock();
if (c == null) {
return;
}
Minecraft mc = Minecraft.getMinecraft();
int dimension = mc.theWorld.provider.dimensionId;
long time = System.currentTimeMillis();
if (time > BlockPosHighlighter.getExpireHighlight() || dimension != BlockPosHighlighter.getHighlightedBlock().getDimension()) {
BlockPosHighlighter.highlightBlock(null, -1);
return;
}
if (((time / 500) & 1) == 0) {
return;
}
EntityPlayerSP p = mc.thePlayer;
double doubleX = p.lastTickPosX + (p.posX - p.lastTickPosX) * event.partialTicks;
double doubleY = p.lastTickPosY + (p.posY - p.lastTickPosY) * event.partialTicks;
double doubleZ = p.lastTickPosZ + (p.posZ - p.lastTickPosZ) * event.partialTicks;
GL11.glPushMatrix();
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
GL11.glLineWidth(3);
GL11.glTranslated(-doubleX, -doubleY, -doubleZ);
GL11.glDisable( GL11.GL_DEPTH_TEST );
GL11.glDisable( GL11.GL_TEXTURE_2D );
GL11.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
renderHighLightedBlocksOutline(c.x, c.y, c.z);
GL11.glPopAttrib();
GL11.glPopMatrix();
}
static void renderHighLightedBlocksOutline(double x, double y, double z)
{
GL11.glBegin(GL11.GL_LINE_STRIP);
GL11.glVertex3d(x, y, z);
GL11.glVertex3d(x, y+1, z);
GL11.glVertex3d(x, y+1, z+1);
GL11.glVertex3d(x, y, z+1);
GL11.glVertex3d(x, y, z);
GL11.glVertex3d(x+1, y, z);
GL11.glVertex3d(x+1, y+1, z);
GL11.glVertex3d(x+1, y+1, z+1);
GL11.glVertex3d(x+1, y, z+1);
GL11.glVertex3d(x+1, y, z);
GL11.glVertex3d(x, y, z);
GL11.glVertex3d(x+1, y, z);
GL11.glVertex3d(x+1, y, z+1);
GL11.glVertex3d(x, y, z+1);
GL11.glVertex3d(x, y+1, z+1);
GL11.glVertex3d(x+1, y+1, z+1);
GL11.glVertex3d(x+1, y+1, z);
GL11.glVertex3d(x+1, y, z);
GL11.glVertex3d(x, y, z);
GL11.glVertex3d(x+1, y, z);
GL11.glVertex3d(x+1, y+1, z);
GL11.glVertex3d(x, y+1, z);
GL11.glVertex3d(x, y+1, z+1);
GL11.glVertex3d(x+1, y+1, z+1);
GL11.glVertex3d(x+1, y, z+1);
GL11.glVertex3d(x, y, z+1);
GL11.glEnd();
}
}
@@ -53,7 +53,7 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
public ItemEncodedPattern()
{
this.setFeature( EnumSet.of( AEFeature.Patterns ) );
this.setMaxStackSize( 1 );
this.setMaxStackSize( 64 );
if( Platform.isClient() )
{
MinecraftForgeClient.registerItemRenderer( this, new ItemEncodedPatternRenderer() );
@@ -42,10 +42,15 @@ public class AppEngInternalInventory implements IInventory, Iterable<ItemStack>
private int maxStack;
public AppEngInternalInventory( final IAEAppEngInventory inventory, final int size )
{
this(inventory, size, 64);
}
public AppEngInternalInventory( final IAEAppEngInventory inventory, final int size, final int maxstack )
{
this.setTileEntity( inventory );
this.size = size;
this.maxStack = 64;
this.maxStack = maxstack;
this.inv = new ItemStack[size];
}
@@ -91,6 +91,8 @@ chat.appliedenergistics2.TunnelNotConnected=Tunnel is not connected.
chat.appliedenergistics2.TunnelInputIsAt=Tunnel input is at (%d, %d, %d)
chat.appliedenergistics2.TunnelHasNoOutputs=Tunnel has no outputs.
chat.appliedenergistics2.TunnelOutputsAreAt=Tunnel outputs are at:
chat.appliedenergistics2.InterfaceInOtherDim=Interface located at dimension: %d and cant be highlighted
chat.appliedenergistics2.InterfaceHighlighted=The interface is now highlighted at %d, %d, %d
# Creative Tabs
itemGroup.appliedenergistics2=Applied Energistics 2
itemGroup.appliedenergistics2.facades=Applied Energistics 2 - Facades
@@ -251,7 +253,7 @@ gui.tooltips.appliedenergistics2.SubstitutionsDescDisabled=Prevent substitutions
gui.tooltips.appliedenergistics2.PatternSlotConfigTitle=Switch Terminal Mode
gui.tooltips.appliedenergistics2.PatternSlotConfigInfo=Switch slot pattern mode beween (16 -> 4) and (4 -> 16)
gui.tooltips.appliedenergistics2.Encode=Encode Pattern
gui.tooltips.appliedenergistics2.EncodeDescription=Write the entered pattern to the current encoded pattern, or to available blank pattern.
gui.tooltips.appliedenergistics2.EncodeDescription=Write the entered pattern to the current encoded pattern, or to available blank pattern. Hold Shift to transfer directly to your inventory
gui.tooltips.appliedenergistics2.FuzzyMode=Fuzzy Comparison
gui.tooltips.appliedenergistics2.FZPercent_25=Split Damage at 25%
gui.tooltips.appliedenergistics2.FZPercent_50=Split Damage at 50%
@@ -345,6 +347,15 @@ gui.tooltips.appliedenergistics2.DoublePattern=Double pattern
gui.tooltips.appliedenergistics2.DoublePatternHint=Double stack sizes of pattern inputs and output(s)
gui.tooltips.appliedenergistics2.CraftingStatus=Crafting Status
gui.tooltips.appliedenergistics2.CraftingStatusDesc=Opens crafting status window
gui.tooltips.appliedenergistics2.ToggleMolecularAssemblers=Toggles showing crafting interfaces only
gui.tooltips.appliedenergistics2.ToggleMolecularAssemblersDescOff=Showing all interfaces
gui.tooltips.appliedenergistics2.ToggleMolecularAssemblersDescOn=Showing only interfaces on 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
gui.tooltips.appliedenergistics2.SearchFieldInputs=Inputs OR names
gui.tooltips.appliedenergistics2.SearchFieldOutputs=Outputs OR names
# Units
gui.appliedenergistics2.units.appliedenergstics=AE
Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 15 KiB

+1 -1
View File
@@ -5,7 +5,7 @@
"description":"A Mod about Matter, Energy and using them to conquer the world..",
"version":"${modVersion}",
"mcversion":"${minecraftVersion}",
"url":"http://ae2.ae-mod.info",
"url":"https://github.com/GTNewHorizons/Applied-Energistics-2-Unofficial",
"updateUrl":"",
"authorList":[
"AlgorithmX2"