Compare commits

..

8 Commits

Author SHA1 Message Date
Salomão bc2e4c84b9 highlight interfaces from interface terminal. 2021-02-28 15:36:45 -03:00
Salomão b4ba1af1ec bind BlockPos of the interface on the list 2021-02-28 02:03:00 -03:00
Salomão 892c919ee2 also shrink the fluid skiplist if the tanks change sizes 2021-02-24 18:08:57 -03:00
Salomão a65b3d2ceb fix interface terminal GUI 2021-02-24 13:24:04 -03:00
Salomão c826a3e24f Add second search bar to Interface Terminal 2021-02-23 20:48:45 -03:00
Salomão fc98505f22 even more JEI integration
get ingredient from the crafting calculation GUIs
2021-02-22 22:33:05 -03:00
Salomão ea54ccbcf5 More JEI integration 2021-02-22 18:35:46 -03:00
Salomão 7796c6d4b6 rebuild skipslotlist if the the inventory grows or shrinks 2021-02-22 14:33:06 -03:00
16 changed files with 436 additions and 42 deletions
@@ -25,6 +25,7 @@ import java.util.EnumMap;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import appeng.helpers.HighlighterHandler;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.settings.KeyBinding; import net.minecraft.client.settings.KeyBinding;
@@ -37,6 +38,7 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.client.event.MouseEvent; import net.minecraftforge.client.event.MouseEvent;
import net.minecraftforge.client.event.RenderLivingEvent; import net.minecraftforge.client.event.RenderLivingEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.client.model.ModelLoaderRegistry; import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.common.ForgeModContainer; import net.minecraftforge.common.ForgeModContainer;
@@ -106,6 +108,11 @@ public class ClientHelper extends ServerHelper
} }
} }
@SubscribeEvent
public void renderWorldLastEvent( RenderWorldLastEvent event) {
HighlighterHandler.tick(event);
}
@Override @Override
public World getWorld() public World getWorld()
{ {
@@ -0,0 +1,97 @@
package appeng.client.gui;
import javax.annotation.Nullable;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.implementations.GuiCraftAmount;
import appeng.client.gui.implementations.GuiCraftConfirm;
import appeng.client.gui.implementations.GuiCraftingCPU;
import appeng.client.gui.widgets.GuiCustomSlot;
import appeng.container.implementations.ContainerCraftAmount;
import mezz.jei.api.gui.IAdvancedGuiHandler;
import net.minecraft.client.renderer.RenderItem;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import java.awt.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public class AEGuiHandler implements IAdvancedGuiHandler<AEBaseGui>
{
@Override
public Class<AEBaseGui> getGuiContainerClass()
{
return AEBaseGui.class;
}
@Nullable
@Override
public List<Rectangle> getGuiExtraAreas( AEBaseGui guiContainer )
{
return Collections.emptyList();
}
@Nullable
@Override
public Object getIngredientUnderMouse( AEBaseGui guiContainer, int mouseX, int mouseY )
{
List<IAEItemStack> visual = new ArrayList<>();
int guiSlotIdx = 0;
Object result = null;
if( guiContainer instanceof GuiCraftConfirm )
{
guiSlotIdx = getSlotidx( guiContainer, mouseX, mouseY, ( (GuiCraftConfirm) guiContainer ).getDisplayedRows() );
visual = ( (GuiCraftConfirm) guiContainer ).getVisual();
if( guiSlotIdx < visual.size() && guiSlotIdx != -1 )
{
result = visual.get( guiSlotIdx ).getDefinition();
}
else
{
return null;
}
}
if( guiContainer instanceof GuiCraftingCPU )
{
guiSlotIdx = getSlotidx( guiContainer, mouseX, mouseY, ( (GuiCraftingCPU) guiContainer ).getDisplayedRows() );
visual = ( (GuiCraftingCPU) guiContainer ).getVisual();
if( guiSlotIdx < visual.size() && guiSlotIdx != -1 )
{
result = visual.get( guiSlotIdx ).getDefinition();
}
else
{
return null;
}
}
if( guiContainer instanceof GuiCraftAmount )
{
if( guiContainer.getSlotUnderMouse() != null )
{
result = guiContainer.getSlotUnderMouse().getStack();
}
}
return result;
}
private int getSlotidx(AEBaseGui guiContainer, int mouseX, int mouseY, int rows)
{
int guileft = guiContainer.getGuiLeft();
int guitop = guiContainer.getGuiTop();
int currentScroll = guiContainer.getScrollBar().getCurrentScroll();
final int xo = 9;
final int yo = 19;
int guiSlotx = ( mouseX - guileft - xo ) / 67;
if( guiSlotx > 2 || mouseX < guileft + xo ) return -1;
int guiSloty = ( mouseY - guitop - yo ) / 23;
if( guiSloty > ( rows - 1 ) || mouseY < guitop + yo ) return -1;
return ( guiSloty * 3 ) + guiSlotx + ( currentScroll * 3 );
}
}
@@ -582,4 +582,14 @@ public class GuiCraftConfirm extends AEBaseGui
} }
} }
} }
public List<IAEItemStack> getVisual()
{
return visual;
}
public int getDisplayedRows()
{
return this.rows;
}
} }
@@ -493,4 +493,14 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource
{ {
return ViewItems.ALL; return ViewItems.ALL;
} }
public List<IAEItemStack> getVisual()
{
return visual;
}
public int getDisplayedRows()
{
return DISPLAYED_ROWS;
}
} }
@@ -20,18 +20,17 @@ package appeng.client.gui.implementations;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
import akka.event.Logging;
import appeng.client.render.BlockPosHighlighter;
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.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.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -49,6 +48,14 @@ import appeng.container.implementations.ContainerInterfaceTerminal;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.parts.reporting.PartInterfaceTerminal; import appeng.parts.reporting.PartInterfaceTerminal;
import appeng.util.Platform; import appeng.util.Platform;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import org.lwjgl.util.Color;
import org.lwjgl.util.ReadableColor;
import static appeng.client.render.BlockPosHighlighter.hilightBlock;
public class GuiInterfaceTerminal extends AEBaseGui public class GuiInterfaceTerminal extends AEBaseGui
@@ -61,13 +68,17 @@ public class GuiInterfaceTerminal extends AEBaseGui
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();
private final HashMap<ClientDCInternalInv,BlockPos> blockPosHashMap = new HashMap<>();
private final HashMap<GuiButton,ClientDCInternalInv> guiButtonHashMap = new HashMap<>();
private final ArrayList<String> names = new ArrayList<>(); private final ArrayList<String> names = new ArrayList<>();
private final ArrayList<Object> lines = new ArrayList<>(); private final ArrayList<Object> lines = new ArrayList<>();
private final Map<String, Set<Object>> cachedSearches = new WeakHashMap<>(); private final Map<String, Set<Object>> cachedSearches = new WeakHashMap<>();
private boolean refreshList = false; private boolean refreshList = false;
private MEGuiTextField searchField; private MEGuiTextField searchFieldOutputs;
private MEGuiTextField searchFieldInputs;
public GuiInterfaceTerminal( final InventoryPlayer inventoryPlayer, final PartInterfaceTerminal te ) public GuiInterfaceTerminal( final InventoryPlayer inventoryPlayer, final PartInterfaceTerminal te )
{ {
@@ -76,7 +87,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
final GuiScrollbar scrollbar = new GuiScrollbar(); final GuiScrollbar scrollbar = new GuiScrollbar();
this.setScrollBar( scrollbar ); this.setScrollBar( scrollbar );
this.xSize = 195; this.xSize = 195;
this.ySize = 222; this.ySize = 236;
} }
@Override @Override
@@ -86,19 +97,30 @@ public class GuiInterfaceTerminal extends AEBaseGui
this.getScrollBar().setLeft( 175 ); this.getScrollBar().setLeft( 175 );
this.getScrollBar().setHeight( 106 ); this.getScrollBar().setHeight( 106 );
this.getScrollBar().setTop( 18 ); this.getScrollBar().setTop( 32 );
this.searchFieldInputs = new MEGuiTextField( this.fontRenderer, this.guiLeft + Math.max( 16, this.offsetX ), this.guiTop + 18, 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.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.setMaxStringLength( 25 );
this.searchFieldOutputs.setTextColor( 0xFFFFFF );
this.searchFieldOutputs.setVisible( true );
this.searchFieldOutputs.setFocused( true );
this.searchField = new MEGuiTextField( this.fontRenderer, 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 );
} }
@Override @Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{ {
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(), 8, this.ySize - 96 + 3, 4210752 ); this.fontRenderer.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
@@ -113,7 +135,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
} }
} }
int offset = 17; int offset = 32;
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 );
@@ -124,6 +146,10 @@ public class GuiInterfaceTerminal extends AEBaseGui
{ {
this.inventorySlots.inventorySlots.add( new SlotDisconnected( inv, z, z * 18 + 8, 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, "?" );
guiButtonHashMap.put( guiButton , inv);
this.buttonList.add( guiButton );
} }
else if( lineObj instanceof String ) else if( lineObj instanceof String )
{ {
@@ -148,24 +174,45 @@ public class GuiInterfaceTerminal extends AEBaseGui
@Override @Override
protected void mouseClicked( final int xCoord, final int yCoord, final int btn ) throws IOException protected void mouseClicked( final int xCoord, final int yCoord, final int btn ) throws IOException
{ {
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(); this.refreshList();
} }
super.mouseClicked( xCoord, yCoord, btn ); super.mouseClicked( xCoord, yCoord, btn );
} }
@Override
protected void actionPerformed( final GuiButton btn ) throws IOException
{
if( guiButtonHashMap.containsKey( btn ) )
{
BlockPos blockPos = blockPosHashMap.get( guiButtonHashMap.get( this.selectedButton ) );
BlockPos blockPos2 = mc.player.getPosition();
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.closeScreen();
}
}
@Override @Override
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) 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 ); this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
int offset = 17; 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++ )
@@ -177,14 +224,19 @@ 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 + 7, offsetY + offset, 7, 139, width, 18 ); this.drawTexturedModalRect( offsetX + 7, offsetY + offset, 7, 153, width, 18 );
} }
offset += 18; offset += 18;
} }
if( this.searchField != null ) if( this.searchFieldInputs != null )
{ {
this.searchField.drawTextBox(); this.searchFieldInputs.drawTextBox();
}
if( this.searchFieldOutputs != null )
{
this.searchFieldOutputs.drawTextBox();
} }
} }
@@ -193,15 +245,21 @@ public class GuiInterfaceTerminal extends AEBaseGui
{ {
if( !this.checkHotbarKeys( key ) ) if( !this.checkHotbarKeys( key ) )
{ {
if( character == ' ' && this.searchField.getText().isEmpty() ) if( character == ' ' && this.searchFieldInputs.getText().isEmpty() && this.searchFieldInputs.isFocused() )
{ {
return; 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(); this.refreshList();
} }
else else
{ {
super.keyTyped( character, key ); super.keyTyped( character, key );
@@ -227,6 +285,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
final long id = Long.parseLong( key.substring( 1 ), Character.MAX_RADIX ); final long id = Long.parseLong( key.substring( 1 ), Character.MAX_RADIX );
final NBTTagCompound invData = in.getCompoundTag( key ); final NBTTagCompound invData = in.getCompoundTag( key );
final ClientDCInternalInv current = this.getById( id, invData.getLong( "sortBy" ), invData.getString( "un" ) ); final ClientDCInternalInv current = this.getById( id, invData.getLong( "sortBy" ), invData.getString( "un" ) );
blockPosHashMap.put( current, NBTUtil.getPosFromTag( invData.getCompoundTag( "pos" )) );
for( int x = 0; x < current.getInventory().getSlots(); x++ ) for( int x = 0; x < current.getInventory().getSlots(); x++ )
{ {
@@ -260,10 +319,12 @@ public class GuiInterfaceTerminal extends AEBaseGui
private void refreshList() private void refreshList()
{ {
this.byName.clear(); this.byName.clear();
this.buttonList.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 );
final boolean rebuild = cachedSearch.isEmpty(); final boolean rebuild = cachedSearch.isEmpty();
for( final ClientDCInternalInv entry : this.byId.values() ) for( final ClientDCInternalInv entry : this.byId.values() )
@@ -275,14 +336,19 @@ public class GuiInterfaceTerminal extends AEBaseGui
} }
// Shortcut to skip any filter if search term is ""/empty // Shortcut to skip any filter if search term is ""/empty
boolean found = searchFilterLowerCase.isEmpty(); boolean found = (searchFieldInputs.isEmpty() && searchFieldOutputs.isEmpty());
// 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 && !searchFilterLowerCase.isEmpty() ) if( !found )
{ {
for( final ItemStack itemStack : entry.getInventory() ) for( final ItemStack itemStack : entry.getInventory() )
{ {
found = this.itemStackMatchesSearchTerm( itemStack, searchFilterLowerCase ); if( !searchFieldInputs.isEmpty() && !searchFieldOutputs.isEmpty() )
found = ( this.itemStackMatchesSearchTerm( itemStack, searchFieldInputs, 0 ) || this.itemStackMatchesSearchTerm( itemStack, searchFieldOutputs, 1 ) );
else if( !searchFieldInputs.isEmpty() )
found = ( this.itemStackMatchesSearchTerm( itemStack, searchFieldInputs, 0 ) );
else if( !searchFieldOutputs.isEmpty() )
found = ( this.itemStackMatchesSearchTerm( itemStack, searchFieldOutputs, 1 ) );
if( found ) if( found )
{ {
break; break;
@@ -291,7 +357,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
} }
// 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( searchFilterLowerCase ) ) if( found || (entry.getName().toLowerCase().contains( searchFieldInputs ) && entry.getName().toLowerCase().contains( searchFieldOutputs )))
{ {
this.byName.put( entry.getName(), entry ); this.byName.put( entry.getName(), entry );
cachedSearch.add( entry ); cachedSearch.add( entry );
@@ -324,7 +390,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
this.getScrollBar().setRange( 0, this.lines.size() - LINES_ON_PAGE, 2 ); 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.isEmpty() ) if( itemStack.isEmpty() )
{ {
@@ -338,14 +404,21 @@ public class GuiInterfaceTerminal extends AEBaseGui
return false; return false;
} }
// Potential later use to filter by input NBTTagList tag = new NBTTagList();
// NBTTagList inTag = encodedValue.getTagList( "in", 10 );
final NBTTagList outTag = encodedValue.getTagList( "out", 10 );
for( int i = 0; i < outTag.tagCount(); i++ ) if (pass == 0)
{
tag = encodedValue.getTagList( "in", 10 );
}
else
{
tag = encodedValue.getTagList( "out", 10 );
}
for( int i = 0; i < tag.tagCount(); i++ )
{ {
final ItemStack parsedItemStack = new ItemStack( outTag.getCompoundTagAt( i ) ); final ItemStack parsedItemStack = new ItemStack( tag.getCompoundTagAt( i ) );
if( !parsedItemStack.isEmpty() ) if( !parsedItemStack.isEmpty() )
{ {
final String displayName = Platform final String displayName = Platform
@@ -0,0 +1,25 @@
package appeng.client.render;
import net.minecraft.util.math.BlockPos;
// taken from McJty's McJtyLib
public class BlockPosHighlighter
{
private static BlockPos hilightedBlock;
private static long expireHilight;
public static void hilightBlock( BlockPos c, long expireHilight ) {
hilightedBlock = c;
BlockPosHighlighter.expireHilight = expireHilight;
}
public static BlockPos getHilightedBlock() {
return hilightedBlock;
}
public static long getExpireHilight() {
return expireHilight;
}
}
@@ -51,6 +51,12 @@ public class ContainerCraftAmount extends AEBaseContainer
this.addSlotToContainer( this.getCraftingItem() ); this.addSlotToContainer( this.getCraftingItem() );
} }
@Override
public Slot getSlot( int slotId )
{
return super.getSlot( 0 );
}
@Override @Override
public void detectAndSendChanges() public void detectAndSendChanges()
{ {
@@ -28,6 +28,8 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import appeng.api.config.Settings; import appeng.api.config.Settings;
@@ -78,7 +80,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
this.grid = anchor.getActionableNode().getGrid(); this.grid = anchor.getActionableNode().getGrid();
} }
this.bindPlayerInventory( ip, 0, 222 - /* height of player inventory */82 ); this.bindPlayerInventory( ip, 0, 236 - /* height of player inventory */82 );
} }
@Override @Override
@@ -378,6 +380,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
{ {
tag.setLong( "sortBy", inv.sortBy ); tag.setLong( "sortBy", inv.sortBy );
tag.setString( "un", inv.unlocalizedName ); tag.setString( "un", inv.unlocalizedName );
tag.setTag("pos", NBTUtil.createPosTag( inv.pos ) );
} }
for( int x = 0; x < length; x++ ) for( int x = 0; x < length; x++ )
@@ -408,6 +411,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
private final String unlocalizedName; private final String unlocalizedName;
private final IItemHandler client; private final IItemHandler client;
private final IItemHandler server; private final IItemHandler server;
private final BlockPos pos;
public InvTracker( final DualityInterface dual, final IItemHandler patterns, final String unlocalizedName ) public InvTracker( final DualityInterface dual, final IItemHandler patterns, final String unlocalizedName )
{ {
@@ -415,6 +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.getTile().getPos();
} }
} }
@@ -24,8 +24,10 @@ import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator;
import appeng.api.config.FuzzyMode; import appeng.api.config.FuzzyMode;
import appeng.api.storage.data.IItemList;
import appeng.container.implementations.ContainerPatternTerm; import appeng.container.implementations.ContainerPatternTerm;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
@@ -208,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()) if( !is.isCraftable() )
{ {
if( mostDamaged == null || mostDamaged.getItemDamage() < is.getItemDamage() ) if( mostDamaged == null || mostDamaged.getItemDamage() < is.getItemDamage() )
{ {
@@ -235,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 )
@@ -251,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;
} }
@@ -0,0 +1,96 @@
package appeng.helpers;
import appeng.client.render.BlockPosHighlighter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import org.lwjgl.opengl.GL11;
// taken from McJty's McJtyLib
public class HighlighterHandler
{
public static void tick( RenderWorldLastEvent event ) {
renderHilightedBlock(event);
}
private static void renderHilightedBlock( RenderWorldLastEvent event ) {
BlockPos c = BlockPosHighlighter.getHilightedBlock();
if (c == null) {
return;
}
Minecraft mc = Minecraft.getMinecraft();
long time = System.currentTimeMillis();
if (time > BlockPosHighlighter.getExpireHilight()) {
BlockPosHighlighter.hilightBlock(null, -1);
return;
}
if (((time / 500) & 1) == 0) {
return;
}
EntityPlayerSP p = mc.player;
double doubleX = p.lastTickPosX + (p.posX - p.lastTickPosX) * event.getPartialTicks();
double doubleY = p.lastTickPosY + (p.posY - p.lastTickPosY) * event.getPartialTicks();
double doubleZ = p.lastTickPosZ + (p.posZ - p.lastTickPosZ) * event.getPartialTicks();
GlStateManager.pushMatrix();
GlStateManager.color(1.0f, 0, 0);
GlStateManager.glLineWidth(3);
GlStateManager.translate(-doubleX, -doubleY, -doubleZ);
GlStateManager.disableDepth();
GlStateManager.disableTexture2D();
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
float mx = c.getX();
float my = c.getY();
float mz = c.getZ();
buffer.begin( GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
renderHighLightedBlocksOutline(buffer, mx, my, mz, 1.0f, 0.0f, 0.0f, 1.0f);
tessellator.draw();
GlStateManager.enableTexture2D();
GlStateManager.popMatrix();
}
public static void renderHighLightedBlocksOutline(BufferBuilder buffer, float mx, float my, float mz, float r, float g, float b, float a) {
buffer.pos(mx, my, mz).color(r, g, b, a).endVertex();
buffer.pos(mx + 1, my, mz).color(r, g, b, a).endVertex();
buffer.pos(mx, my, mz).color(r, g, b, a).endVertex();
buffer.pos(mx, my + 1, mz).color(r, g, b, a).endVertex();
buffer.pos(mx, my, mz).color(r, g, b, a).endVertex();
buffer.pos(mx, my, mz + 1).color(r, g, b, a).endVertex();
buffer.pos(mx + 1, my + 1, mz + 1).color(r, g, b, a).endVertex();
buffer.pos(mx, my + 1, mz + 1).color(r, g, b, a).endVertex();
buffer.pos(mx + 1, my + 1, mz + 1).color(r, g, b, a).endVertex();
buffer.pos(mx + 1, my, mz + 1).color(r, g, b, a).endVertex();
buffer.pos(mx + 1, my + 1, mz + 1).color(r, g, b, a).endVertex();
buffer.pos(mx + 1, my + 1, mz).color(r, g, b, a).endVertex();
buffer.pos(mx, my + 1, mz).color(r, g, b, a).endVertex();
buffer.pos(mx, my + 1, mz + 1).color(r, g, b, a).endVertex();
buffer.pos(mx, my + 1, mz).color(r, g, b, a).endVertex();
buffer.pos(mx + 1, my + 1, mz).color(r, g, b, a).endVertex();
buffer.pos(mx + 1, my, mz).color(r, g, b, a).endVertex();
buffer.pos(mx + 1, my, mz + 1).color(r, g, b, a).endVertex();
buffer.pos(mx + 1, my, mz).color(r, g, b, a).endVertex();
buffer.pos(mx + 1, my + 1, mz).color(r, g, b, a).endVertex();
buffer.pos(mx, my, mz + 1).color(r, g, b, a).endVertex();
buffer.pos(mx + 1, my, mz + 1).color(r, g, b, a).endVertex();
buffer.pos(mx, my, mz + 1).color(r, g, b, a).endVertex();
buffer.pos(mx, my + 1, mz + 1).color(r, g, b, a).endVertex();
}
}
@@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import appeng.client.gui.AEGuiHandler;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@@ -93,6 +94,9 @@ public class JEIPlugin implements IModPlugin
registry.getRecipeTransferRegistry() registry.getRecipeTransferRegistry()
.addRecipeTransferHandler( new RecipeTransferHandler<>( ContainerPatternTerm.class ), .addRecipeTransferHandler( new RecipeTransferHandler<>( ContainerPatternTerm.class ),
Constants.UNIVERSAL_RECIPE_TRANSFER_UID ); Constants.UNIVERSAL_RECIPE_TRANSFER_UID );
AEGuiHandler aeGuiHandler = new AEGuiHandler();
registry.addAdvancedGuiHandlers(aeGuiHandler);
} }
private void registerDescriptions( IDefinitions definitions, IModRegistry registry ) private void registerDescriptions( IDefinitions definitions, IModRegistry registry )
@@ -329,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;
@@ -0,0 +1,41 @@
package appeng.util;
import net.minecraft.util.math.BlockPos;
public class BlockPosUtils
{
public static long getDistance( BlockPos blockPos, BlockPos blockPos2 )
{
int x;
if( (blockPos.getX() > 0 && blockPos2.getX() > 0) || (blockPos.getX() < 0 && blockPos2.getX() < 0))
{
x = blockPos.getX() - blockPos2.getX();
}
else
{
x = blockPos.getX() + blockPos2.getX();
}
int y;
if( (blockPos.getY() > 0 && blockPos2.getY() > 0) || (blockPos.getY() < 0 && blockPos2.getY() < 0) )
{
y = blockPos.getY() - blockPos2.getY();
}
else
{
y = blockPos.getY() + blockPos2.getY();
}
int z;
if( (blockPos.getZ() > 0 && blockPos2.getZ() > 0) || (blockPos.getZ() < 0 && blockPos2.getZ() < 0) )
{
z = blockPos.getZ() - blockPos2.getZ();
}
else
{
z = blockPos.getZ() + blockPos2.getZ();
}
return Math.abs( x ) + Math.abs( y ) + Math.abs( z );
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB