Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c629b4e0cf | |||
| 65ca607134 | |||
| 898c07ca01 | |||
| 883c267aa8 | |||
| 22cf913708 | |||
| b4ba1af1ec |
@@ -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()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -476,7 +476,10 @@ public abstract class AEBaseGui extends GuiContainer implements IMTModGuiContain
|
|||||||
switch( clickType )
|
switch( clickType )
|
||||||
{
|
{
|
||||||
case PICKUP: // pickup / set-down.
|
case PICKUP: // pickup / set-down.
|
||||||
action = ( mouseButton == 1 ) ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
|
if (slot.getStack().isEmpty() && !player.inventory.getItemStack().isEmpty())
|
||||||
|
action = InventoryAction.SPLIT_OR_PLACE_SINGLE;
|
||||||
|
if (!slot.getStack().isEmpty() && player.inventory.getItemStack().isEmpty())
|
||||||
|
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;
|
||||||
|
|||||||
@@ -19,19 +19,13 @@
|
|||||||
package appeng.client.gui.implementations;
|
package appeng.client.gui.implementations;
|
||||||
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
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 appeng.util.BlockPosUtils;
|
||||||
import com.google.common.collect.HashMultimap;
|
import com.google.common.collect.HashMultimap;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
@@ -50,6 +44,12 @@ 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.TextComponentString;
|
||||||
|
|
||||||
|
|
||||||
|
import static appeng.client.render.BlockPosHighlighter.hilightBlock;
|
||||||
|
|
||||||
|
|
||||||
public class GuiInterfaceTerminal extends AEBaseGui
|
public class GuiInterfaceTerminal extends AEBaseGui
|
||||||
@@ -62,6 +62,8 @@ 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<>();
|
||||||
|
|
||||||
@@ -70,12 +72,15 @@ 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 = 195;
|
this.xSize = 195;
|
||||||
@@ -98,23 +103,41 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
|||||||
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( 104, this.offsetX ), this.guiTop + 4, 65, 12 );
|
// this.searchFieldOutputs = new MEGuiTextField( this.fontRenderer, this.guiLeft + Math.max( 105, 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 = 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
|
@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 );
|
||||||
|
|
||||||
final int ex = this.getScrollBar().getCurrentScroll();
|
final int ex = this.getScrollBar().getCurrentScroll();
|
||||||
|
|
||||||
|
this.guiButtonNextAssembler = new GuiButton( -1, guiLeft + 110, guiTop + 4, 12, 12, "M" );
|
||||||
|
this.buttonList.add( guiButtonNextAssembler );
|
||||||
|
|
||||||
|
this.guiButtonHide = new GuiButton( -1, guiLeft + 128, guiTop + 4, 60, 12, "Hide Full" );
|
||||||
|
this.buttonList.add( guiButtonHide );
|
||||||
|
|
||||||
final Iterator<Slot> o = this.inventorySlots.inventorySlots.iterator();
|
final Iterator<Slot> o = this.inventorySlots.inventorySlots.iterator();
|
||||||
while( o.hasNext() )
|
while( o.hasNext() )
|
||||||
{
|
{
|
||||||
@@ -135,6 +158,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 )
|
||||||
{
|
{
|
||||||
@@ -178,10 +205,44 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
|||||||
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
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 = 32;
|
int offset = 32;
|
||||||
@@ -257,6 +318,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++ )
|
||||||
{
|
{
|
||||||
@@ -290,23 +352,25 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
|||||||
private void refreshList()
|
private void refreshList()
|
||||||
{
|
{
|
||||||
this.byName.clear();
|
this.byName.clear();
|
||||||
|
this.buttonList.clear();
|
||||||
|
|
||||||
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( searchFieldInputs + searchFieldOutputs );
|
final Set<Object> cachedSearch = this.getCacheForSearchTerm( "IN:" + searchFieldInputs + " OUT:" + searchFieldOutputs + partInterfaceTerminal.onlyInterfacesWithFreeSlots);
|
||||||
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 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 ) )
|
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 )
|
||||||
@@ -324,13 +388,32 @@ 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 )))
|
||||||
{
|
{
|
||||||
this.byName.put( entry.getName(), entry );
|
if (!partInterfaceTerminal.onlyInterfacesWithFreeSlots)
|
||||||
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
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
@@ -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.getLocation().getPos();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -44,6 +44,9 @@ 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 )
|
||||||
{
|
{
|
||||||
@@ -69,4 +72,8 @@ 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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: 11 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
Reference in New Issue
Block a user