ME Tunnel + Network Tool
This commit is contained in:
parent
1b77755dd6
commit
dfbc8a6c79
2
api
2
api
|
@ -1 +1 @@
|
|||
Subproject commit bda364035f2fcae422eff6d2250354207f15a93f
|
||||
Subproject commit 573265e8d674511b455a24862a6da6710e945e58
|
|
@ -152,6 +152,7 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
|||
|
||||
protected void setTileEntiy(Class<? extends TileEntity> c)
|
||||
{
|
||||
AEBaseTile.registerTileItem( c, new ItemStack( this ) );
|
||||
GameRegistry.registerTileEntity( tileEntityType = c, FeatureFullname );
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package appeng.client.gui;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -319,9 +320,41 @@ public abstract class AEBaseGui extends GuiContainer
|
|||
int ox = guiLeft; // (width - xSize) / 2;
|
||||
int oy = guiTop; // (height - ySize) / 2;
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
drawFG( ox, oy, x, y );
|
||||
|
||||
if ( myScrollBar != null )
|
||||
myScrollBar.draw( this );
|
||||
|
||||
drawFG( ox, oy, x, y );
|
||||
}
|
||||
|
||||
protected Slot getSlot(int mousex, int mousey)
|
||||
{
|
||||
for (int j1 = 0; j1 < this.inventorySlots.inventorySlots.size(); ++j1)
|
||||
{
|
||||
Slot slot = (Slot) this.inventorySlots.inventorySlots.get( j1 );
|
||||
if ( isPointInRegion( slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, mousex, mousey ) )
|
||||
{
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected static String join(Collection<?> s, String delimiter)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
Iterator iter = s.iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
builder.append( iter.next() );
|
||||
if ( !iter.hasNext() )
|
||||
{
|
||||
break;
|
||||
}
|
||||
builder.append( delimiter );
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package appeng.client.gui;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
|
@ -117,36 +115,6 @@ public abstract class AEBaseMEGui extends AEBaseGui
|
|||
super.drawItemStackTooltip( stack, x, y );
|
||||
}
|
||||
|
||||
static String join(Collection<?> s, String delimiter)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
Iterator iter = s.iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
builder.append( iter.next() );
|
||||
if ( !iter.hasNext() )
|
||||
{
|
||||
break;
|
||||
}
|
||||
builder.append( delimiter );
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private Slot getSlot(int mousex, int mousey)
|
||||
{
|
||||
for (int j1 = 0; j1 < this.inventorySlots.inventorySlots.size(); ++j1)
|
||||
{
|
||||
Slot slot = (Slot) this.inventorySlots.inventorySlots.get( j1 );
|
||||
if ( isPointInRegion( slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, mousex, mousey ) )
|
||||
{
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void safeDrawSlot(Slot s)
|
||||
{
|
||||
try
|
||||
|
@ -175,7 +143,7 @@ public abstract class AEBaseMEGui extends AEBaseGui
|
|||
this.zLevel = 100.0F;
|
||||
itemRenderer.zLevel = 100.0F;
|
||||
|
||||
if ( ! isPowered() )
|
||||
if ( !isPowered() )
|
||||
{
|
||||
GL11.glDisable( GL11.GL_LIGHTING );
|
||||
super.drawRect( s.xDisplayPosition, s.yDisplayPosition, 16 + s.xDisplayPosition, 16 + s.yDisplayPosition, 0x66111111 );
|
||||
|
@ -308,7 +276,8 @@ public abstract class AEBaseMEGui extends AEBaseGui
|
|||
safeDrawSlot( s );
|
||||
}
|
||||
|
||||
private boolean isPowered() {
|
||||
private boolean isPowered()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,6 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
|||
int NEI = 0;
|
||||
int top = 4;
|
||||
int extraSpace = height - 114 - NEI - top;
|
||||
int moveDown = 0;
|
||||
|
||||
rows = (int) Math.floor( extraSpace / 18 );
|
||||
if ( rows > maxRows )
|
||||
|
|
|
@ -1,17 +1,54 @@
|
|||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.me.ItemRepo;
|
||||
import appeng.client.me.SlotME;
|
||||
import appeng.container.implementations.ContainerNetworkStatus;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.helpers.INetworkTool;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class GuiNetworkStatus extends AEBaseGui
|
||||
{
|
||||
|
||||
public GuiNetworkStatus(InventoryPlayer inventoryPlayer, TileEntity te) {
|
||||
super( new ContainerNetworkStatus( inventoryPlayer, (TileEntity) te ) );
|
||||
this.ySize = 199;
|
||||
ItemRepo repo;
|
||||
|
||||
int rows = 4;
|
||||
|
||||
public GuiNetworkStatus(InventoryPlayer inventoryPlayer, INetworkTool te) {
|
||||
super( new ContainerNetworkStatus( inventoryPlayer, te ) );
|
||||
this.ySize = 125;
|
||||
this.xSize = 195;
|
||||
myScrollBar = new GuiScrollbar();
|
||||
repo = new ItemRepo( myScrollBar );
|
||||
}
|
||||
|
||||
public void postUpdate(List<IAEItemStack> list)
|
||||
{
|
||||
repo.clear();
|
||||
|
||||
for (IAEItemStack is : list)
|
||||
repo.postUpdate( is );
|
||||
|
||||
repo.updateView();
|
||||
setScrollBar();
|
||||
}
|
||||
|
||||
private void setScrollBar()
|
||||
{
|
||||
myScrollBar.setTop( 39 ).setLeft( 175 ).setHeight( 78 );
|
||||
myScrollBar.setRange( 0, (repo.size() + 8) / 5 - rows, 2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,11 +58,195 @@ public class GuiNetworkStatus extends AEBaseGui
|
|||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
int tooltip = -1;
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouse_x, int mouse_y, float btn)
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
int gx = (width - xSize) / 2;
|
||||
int gy = (height - ySize) / 2;
|
||||
|
||||
tooltip = -1;
|
||||
|
||||
for (int z = 0; z <= 4 * 5; z++)
|
||||
{
|
||||
int minX = gx + 14 + x * 31;
|
||||
int minY = gy + 41 + y * 22;
|
||||
|
||||
if ( minX < mouse_x && minX + 28 > mouse_x )
|
||||
{
|
||||
if ( minY < mouse_y && minY + 20 > mouse_y )
|
||||
{
|
||||
tooltip = z;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
x++;
|
||||
|
||||
if ( x > 4 )
|
||||
{
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
super.drawScreen( mouse_x, mouse_y, btn );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
ContainerNetworkStatus ns = (ContainerNetworkStatus) inventorySlots;
|
||||
|
||||
fontRenderer.drawString( GuiText.NetworkDetails.getLocal(), 8, 6, 4210752 );
|
||||
fontRenderer.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
|
||||
fontRenderer.drawString( GuiText.PowerInputRate.getLocal() + ": " + formatPowerLong( ns.avgAddition ), 8, 16, 4210752 );
|
||||
fontRenderer.drawString( GuiText.PowerUsageRate.getLocal() + ": " + formatPowerLong( ns.powerUsage ), 8, 26, 4210752 );
|
||||
|
||||
int sectionLength = 30;
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int xo = 0 + 12;
|
||||
int yo = 0 + 42;
|
||||
int viewStart = myScrollBar.getCurrentScroll() * 5;
|
||||
int viewEnd = viewStart + 5 * 4;
|
||||
|
||||
int pn = repo.size();
|
||||
int rows = pn / 5 + ((pn % 5) > 0 ? 1 : 0);
|
||||
// updateScrollRegion( rows - 4 > 0 ? rows - 4 : 0 );
|
||||
|
||||
for (int z = viewStart; z < Math.min( viewEnd, repo.size() ); z++)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled( 0.5, 0.5, 0.5 );
|
||||
|
||||
IAEItemStack refStack = repo.getRefrenceItem( z );
|
||||
|
||||
String str = Long.toString( refStack.getStackSize() );
|
||||
if ( repo.getRefrenceItem( z ).getStackSize() >= 10000 )
|
||||
str = Long.toString( refStack.getStackSize() / 1000 ) + StatCollector.translateToLocal( "AppEng.Sizes.1000" );
|
||||
|
||||
int w = fontRenderer.getStringWidth( str );
|
||||
fontRenderer
|
||||
.drawString( str, (int) ((x * sectionLength + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * 18 + yo + 6) * 2), 4210752 );
|
||||
GL11.glPopMatrix();
|
||||
|
||||
int posX = x * sectionLength + xo + sectionLength - 18;
|
||||
int posY = y * 18 + yo;
|
||||
|
||||
drawItem( posX, posY, repo.getItem( z ) );
|
||||
|
||||
x++;
|
||||
|
||||
if ( x > 4 )
|
||||
{
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
x = 0;
|
||||
y = 0;
|
||||
for (int z = viewStart; z < Math.min( viewEnd, repo.size() ); z++)
|
||||
{
|
||||
if ( tooltip == z - viewStart )
|
||||
{
|
||||
IAEItemStack refStack = repo.getRefrenceItem( z );
|
||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
String out = Platform.getItemDisplayName( repo.getItem( z ) );
|
||||
|
||||
out = out + ("\n" + GuiText.Installed.getLocal() + ": " + (refStack.getStackSize()));
|
||||
out = out + ("\n" + GuiText.EnergyDrain.getLocal() + ": " + formatPowerLong( refStack.getCountRequestable() ));
|
||||
|
||||
int posX = x * sectionLength + xo + sectionLength - 8;
|
||||
int posY = y * 18 + yo;
|
||||
|
||||
drawTooltip( posX, posY + 10, 0, out );
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
x++;
|
||||
|
||||
if ( x > 4 )
|
||||
{
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String formatPowerLong(long n)
|
||||
{
|
||||
double p = ((double) n) / 100;
|
||||
return Double.toString( p ) + " ae/t";
|
||||
}
|
||||
|
||||
// @Override - NEI
|
||||
public List<String> handleItemTooltip(ItemStack stack, int mousex, int mousey, List<String> currenttip)
|
||||
{
|
||||
if ( stack != null )
|
||||
{
|
||||
Slot s = getSlot( mousex, mousey );
|
||||
if ( s instanceof SlotME )
|
||||
{
|
||||
IAEItemStack myStack = null;
|
||||
|
||||
try
|
||||
{
|
||||
SlotME theSlotField = (SlotME) s;
|
||||
myStack = theSlotField.getAEStack();
|
||||
}
|
||||
catch (Throwable _)
|
||||
{
|
||||
}
|
||||
|
||||
if ( myStack != null )
|
||||
{
|
||||
while (currenttip.size() > 1)
|
||||
currenttip.remove( 1 );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
// Vanillia version...
|
||||
@Override
|
||||
protected void drawItemStackTooltip(ItemStack stack, int x, int y)
|
||||
{
|
||||
Slot s = getSlot( x, y );
|
||||
if ( s instanceof SlotME && stack != null )
|
||||
{
|
||||
IAEItemStack myStack = null;
|
||||
|
||||
try
|
||||
{
|
||||
SlotME theSlotField = (SlotME) s;
|
||||
myStack = theSlotField.getAEStack();
|
||||
}
|
||||
catch (Throwable _)
|
||||
{
|
||||
}
|
||||
|
||||
if ( myStack != null )
|
||||
{
|
||||
List currenttip = stack.getTooltip( this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips );
|
||||
|
||||
while (currenttip.size() > 1)
|
||||
currenttip.remove( 1 );
|
||||
|
||||
currenttip.add( GuiText.Installed.getLocal() + ": " + (myStack.getStackSize()) );
|
||||
currenttip.add( GuiText.EnergyDrain.getLocal() + ": " + formatPowerLong( myStack.getCountRequestable() ) );
|
||||
|
||||
drawTooltip( x, y, 0, join( currenttip, "\n" ) );
|
||||
}
|
||||
}
|
||||
super.drawItemStackTooltip( stack, x, y );
|
||||
}
|
||||
}
|
||||
|
|
31
client/gui/implementations/GuiNetworkTool.java
Normal file
31
client/gui/implementations/GuiNetworkTool.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.container.implementations.ContainerNetworkTool;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.helpers.INetworkTool;
|
||||
|
||||
public class GuiNetworkTool extends AEBaseGui
|
||||
{
|
||||
|
||||
public GuiNetworkTool(InventoryPlayer inventoryPlayer, INetworkTool te) {
|
||||
super( new ContainerNetworkTool( inventoryPlayer, te ) );
|
||||
this.ySize = 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/toolbox.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRenderer.drawString( GuiText.NetworkTool.getLocal(), 8, 6, 4210752 );
|
||||
fontRenderer.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
|
||||
}
|
|
@ -110,7 +110,7 @@ public class GuiUpgradeable extends AEBaseGui
|
|||
bindTexture( getBackground() );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, 211 - 34, ySize );
|
||||
if ( drawUpgrades() )
|
||||
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 10 + cvb.availableUpgrades() * 18 );
|
||||
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 14 + cvb.availableUpgrades() * 18 );
|
||||
if ( hasToolbox() )
|
||||
this.drawTexturedModalRect( offsetX + 178, offsetY + ySize - 90, 178, ySize - 90, 68, 68 );
|
||||
}
|
||||
|
|
|
@ -145,4 +145,9 @@ public class ItemRepo
|
|||
{
|
||||
return view.size();
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
list.resetStatus();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package appeng.container;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -44,6 +45,12 @@ public abstract class AEBaseContainer extends Container
|
|||
|
||||
protected IMEInventoryHandler<IAEItemStack> cellInv;
|
||||
protected IEnergySource powerSrc;
|
||||
protected HashSet<Integer> locked = new HashSet();
|
||||
|
||||
public void lockPlayerInventorySlot(int idx)
|
||||
{
|
||||
locked.add( idx );
|
||||
}
|
||||
|
||||
public Object getTarget()
|
||||
{
|
||||
|
@ -336,13 +343,19 @@ public abstract class AEBaseContainer extends Container
|
|||
{
|
||||
for (int j = 0; j < 9; j++)
|
||||
{
|
||||
addSlotToContainer( new SlotPlayerInv( inventoryPlayer, j + i * 9 + 9, 8 + j * 18 + offset_x, offset_y + i * 18 ) );
|
||||
if ( locked.contains( j + i * 9 + 9 ) )
|
||||
addSlotToContainer( new SlotDisabled( inventoryPlayer, j + i * 9 + 9, 8 + j * 18 + offset_x, offset_y + i * 18 ) );
|
||||
else
|
||||
addSlotToContainer( new SlotPlayerInv( inventoryPlayer, j + i * 9 + 9, 8 + j * 18 + offset_x, offset_y + i * 18 ) );
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
addSlotToContainer( new SlotPlayerHotBar( inventoryPlayer, i, 8 + i * 18 + offset_x, 58 + offset_y ) );
|
||||
if ( locked.contains( i ) )
|
||||
addSlotToContainer( new SlotDisabled( inventoryPlayer, i, 8 + i * 18 + offset_x, 58 + offset_y ) );
|
||||
else
|
||||
addSlotToContainer( new SlotPlayerHotBar( inventoryPlayer, i, 8 + i * 18 + offset_x, 58 + offset_y ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,10 +34,10 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IMEMonito
|
|||
final IMEMonitor<IAEItemStack> monitor;
|
||||
final IItemList<IAEItemStack> items = new ItemList<IAEItemStack>();
|
||||
|
||||
public ContainerMEMonitorable(InventoryPlayer ip, IStorageMonitorable montiorable) {
|
||||
protected ContainerMEMonitorable(InventoryPlayer ip, IStorageMonitorable montiorable, boolean isServer) {
|
||||
super( ip, montiorable instanceof TileEntity ? (TileEntity) montiorable : null, montiorable instanceof IPart ? (IPart) montiorable : null );
|
||||
|
||||
if ( Platform.isServer() )
|
||||
if ( isServer )
|
||||
{
|
||||
monitor = montiorable.getItemInventory();
|
||||
monitor.addListener( this, null );
|
||||
|
@ -61,7 +61,10 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IMEMonito
|
|||
}
|
||||
else
|
||||
monitor = null;
|
||||
}
|
||||
|
||||
public ContainerMEMonitorable(InventoryPlayer ip, IStorageMonitorable montiorable) {
|
||||
this( ip, montiorable, Platform.isServer() );
|
||||
bindPlayerInventory( ip, 0, 0 );
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,8 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable
|
|||
ICellItemViewer civ;
|
||||
|
||||
public ContainerMEPortableCell(InventoryPlayer ip, ICellItemViewer montiorable) {
|
||||
super( ip, (IStorageMonitorable) montiorable );
|
||||
super( ip, (IStorageMonitorable) montiorable, Platform.isServer() );
|
||||
lockPlayerInventorySlot( ip.currentItem );
|
||||
civ = montiorable;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,24 +1,160 @@
|
|||
package appeng.container.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridBlock;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.packets.PacketMEInventoryUpdate;
|
||||
import appeng.helpers.INetworkTool;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ContainerNetworkStatus extends AEBaseContainer
|
||||
{
|
||||
|
||||
TileEntity myte;
|
||||
IGrid network;
|
||||
|
||||
public ContainerNetworkStatus(InventoryPlayer ip, TileEntity te) {
|
||||
super( ip, te, null );
|
||||
myte = te;
|
||||
public ContainerNetworkStatus(InventoryPlayer ip, INetworkTool te) {
|
||||
super( ip, null, null );
|
||||
IGridHost host = te.getGridHost();
|
||||
|
||||
// addSlotToContainer( new SlotRestrictedInput(
|
||||
// PlaceableItemType.WIRELESS_TERMINAL, te, 0, 71, 14 ) );
|
||||
// addSlotToContainer( new SlotOutput( te, 1, 71, 14,
|
||||
// PlaceableItemType.WIRELESS_TERMINAL.icon ) );
|
||||
if ( host != null )
|
||||
{
|
||||
findNode( host, ForgeDirection.UNKNOWN );
|
||||
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS)
|
||||
findNode( host, d );
|
||||
}
|
||||
|
||||
bindPlayerInventory( ip, 0, 199 - /* height of playerinventory */82 );
|
||||
if ( network == null )
|
||||
ip.player.closeScreen();
|
||||
}
|
||||
|
||||
private void findNode(IGridHost host, ForgeDirection d)
|
||||
{
|
||||
if ( network == null )
|
||||
{
|
||||
IGridNode node = host.getGridNode( d );
|
||||
if ( node != null )
|
||||
network = node.getGrid();
|
||||
}
|
||||
}
|
||||
|
||||
int delay = 0;
|
||||
|
||||
public long avgAddition;
|
||||
public long powerUsage;
|
||||
|
||||
int lo_avgAddition, hi_avgAddition;
|
||||
int lo_powerUsage, hi_powerUsage;
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void updateProgressBar(int idx, int value)
|
||||
{
|
||||
switch (idx)
|
||||
{
|
||||
case 0:
|
||||
lo_avgAddition = value;
|
||||
break;
|
||||
case 1:
|
||||
hi_avgAddition = value;
|
||||
break;
|
||||
case 2:
|
||||
lo_powerUsage = value;
|
||||
break;
|
||||
case 3:
|
||||
hi_powerUsage = value;
|
||||
break;
|
||||
}
|
||||
|
||||
avgAddition = ((long) hi_avgAddition) << 32 | lo_avgAddition;
|
||||
powerUsage = ((long) hi_powerUsage) << 32 | lo_powerUsage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
delay++;
|
||||
if ( Platform.isServer() && delay > 1 && network != null )
|
||||
{
|
||||
delay = 0;
|
||||
|
||||
IEnergyGrid eg = network.getCache( IEnergyGrid.class );
|
||||
if ( eg != null )
|
||||
{
|
||||
avgAddition = (long) (100.0 * eg.getAvgPowerInjection());
|
||||
powerUsage = (long) (100.0 * eg.getAvgPowerUsage());
|
||||
|
||||
lo_avgAddition = (int) (avgAddition & 0xffffffffL);
|
||||
hi_avgAddition = (int) (avgAddition >> 32L);
|
||||
|
||||
lo_powerUsage = (int) (powerUsage & 0xffffffffL);
|
||||
hi_powerUsage = (int) (powerUsage >> 32L);
|
||||
|
||||
for (Object c : this.crafters)
|
||||
{
|
||||
ICrafting icrafting = (ICrafting) c;
|
||||
icrafting.sendProgressBarUpdate( this, 0, (int) lo_avgAddition );
|
||||
icrafting.sendProgressBarUpdate( this, 1, (int) hi_avgAddition );
|
||||
icrafting.sendProgressBarUpdate( this, 2, (int) lo_powerUsage );
|
||||
icrafting.sendProgressBarUpdate( this, 3, (int) hi_powerUsage );
|
||||
}
|
||||
}
|
||||
|
||||
PacketMEInventoryUpdate piu;
|
||||
try
|
||||
{
|
||||
piu = new PacketMEInventoryUpdate();
|
||||
|
||||
for (Class<? extends IGridHost> machineClass : network.getMachinesClasses())
|
||||
{
|
||||
IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
|
||||
for (IGridNode machine : network.getMachines( machineClass ))
|
||||
{
|
||||
IGridBlock blk = machine.getGridBlock();
|
||||
ItemStack is = blk.getMachineRepresentation();
|
||||
if ( is != null )
|
||||
{
|
||||
IAEItemStack ais = AEItemStack.create( is );
|
||||
ais.setStackSize( 1 );
|
||||
ais.setCountRequestable( (long) (blk.getIdlePowerUsage() * 100.0) );
|
||||
list.add( ais );
|
||||
}
|
||||
}
|
||||
|
||||
for (IAEItemStack ais : list)
|
||||
piu.appendItem( ais );
|
||||
}
|
||||
|
||||
Packet p = piu.getPacket();
|
||||
for (Object c : this.crafters)
|
||||
{
|
||||
if ( c instanceof Player )
|
||||
PacketDispatcher.sendPacketToPlayer( p, (Player) c );
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
|
|
49
container/implementations/ContainerNetworkTool.java
Normal file
49
container/implementations/ContainerNetworkTool.java
Normal file
|
@ -0,0 +1,49 @@
|
|||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
|
||||
import appeng.helpers.INetworkTool;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerNetworkTool extends AEBaseContainer
|
||||
{
|
||||
|
||||
INetworkTool toolInv;
|
||||
|
||||
public ContainerNetworkTool(InventoryPlayer ip, INetworkTool te) {
|
||||
super( ip, null, null );
|
||||
toolInv = te;
|
||||
|
||||
lockPlayerInventorySlot( ip.currentItem );
|
||||
|
||||
for (int y = 0; y < 3; y++)
|
||||
for (int x = 0; x < 3; x++)
|
||||
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, te, y * 3 + x, 80 - 18 + x * 18, 37 - 18 + y * 18 )) );
|
||||
|
||||
bindPlayerInventory( ip, 0, 166 - /* height of playerinventory */82 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
ItemStack currentItem = getPlayerInv().getCurrentItem();
|
||||
|
||||
if ( currentItem != toolInv.getItemStack() )
|
||||
{
|
||||
if ( currentItem != null )
|
||||
{
|
||||
if ( Platform.isSameItem( toolInv.getItemStack(), currentItem ) )
|
||||
getPlayerInv().setInventorySlotContents( getPlayerInv().currentItem, toolInv.getItemStack() );
|
||||
else
|
||||
getPlayerInv().player.closeScreen();
|
||||
}
|
||||
else
|
||||
getPlayerInv().player.closeScreen();
|
||||
}
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
}
|
|
@ -3,7 +3,9 @@ package appeng.container.implementations;
|
|||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.Settings;
|
||||
|
@ -17,7 +19,8 @@ import appeng.container.slot.OptionalSlotFakeTypeOnly;
|
|||
import appeng.container.slot.SlotFakeTypeOnly;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.helpers.NetworkToolInv;
|
||||
import appeng.items.tools.ToolNetworkTool;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
@ -26,17 +29,54 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
|
|||
{
|
||||
|
||||
IBusCommon myte;
|
||||
IInventory toolbox = new AppEngInternalInventory( null, 9 );
|
||||
|
||||
int tbslot;
|
||||
NetworkToolInv tbinv;
|
||||
|
||||
public ContainerUpgradeable(InventoryPlayer ip, IBusCommon te) {
|
||||
super( ip, (TileEntity) (te instanceof TileEntity ? te : null), (IPart) (te instanceof IPart ? te : null) );
|
||||
myte = te;
|
||||
|
||||
World w = null;
|
||||
int xCoor = 0, yCoor = 0, zCoor = 0;
|
||||
|
||||
if ( te instanceof TileEntity )
|
||||
{
|
||||
TileEntity myTile = (TileEntity) te;
|
||||
w = myTile.getWorldObj();
|
||||
xCoor = myTile.xCoord;
|
||||
yCoor = myTile.yCoord;
|
||||
zCoor = myTile.zCoord;
|
||||
}
|
||||
|
||||
if ( te instanceof IPart )
|
||||
{
|
||||
IBusCommon myTile = (IBusCommon) te;
|
||||
TileEntity mk = myTile.getTile();
|
||||
w = mk.getWorldObj();
|
||||
xCoor = mk.xCoord;
|
||||
yCoor = mk.yCoord;
|
||||
zCoor = mk.zCoord;
|
||||
}
|
||||
|
||||
IInventory pi = getPlayerInv();
|
||||
for (int x = 0; x < pi.getSizeInventory(); x++)
|
||||
{
|
||||
ItemStack pii = pi.getStackInSlot( x );
|
||||
if ( pii != null && pii.getItem() instanceof ToolNetworkTool )
|
||||
{
|
||||
lockPlayerInventorySlot( x );
|
||||
tbslot = x;
|
||||
tbinv = (NetworkToolInv) ((ToolNetworkTool) pii.getItem()).getGuiObject( pii, w, xCoor, yCoor, zCoor );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( hasToolbox() )
|
||||
{
|
||||
for (int v = 0; v < 3; v++)
|
||||
for (int u = 0; u < 3; u++)
|
||||
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, toolbox, u + v * 3, 186 + u * 18, getHeight() - 82 + v * 18 ))
|
||||
addSlotToContainer( (new SlotRestrictedInput( PlaceableItemType.UPGRADES, tbinv, u + v * 3, 186 + u * 18, getHeight() - 82 + v * 18 ))
|
||||
.setPlayerSide() );
|
||||
}
|
||||
|
||||
|
@ -95,6 +135,27 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
|
|||
public RedstoneMode rsMode = RedstoneMode.IGNORE;
|
||||
public FuzzyMode fzMode = FuzzyMode.IGNORE_ALL;
|
||||
|
||||
public void checkToolbox()
|
||||
{
|
||||
if ( hasToolbox() )
|
||||
{
|
||||
ItemStack currentItem = getPlayerInv().getStackInSlot( tbslot );
|
||||
|
||||
if ( currentItem != tbinv.getItemStack() )
|
||||
{
|
||||
if ( currentItem != null )
|
||||
{
|
||||
if ( Platform.isSameItem( tbinv.getItemStack(), currentItem ) )
|
||||
getPlayerInv().setInventorySlotContents( tbslot, tbinv.getItemStack() );
|
||||
else
|
||||
getPlayerInv().player.closeScreen();
|
||||
}
|
||||
else
|
||||
getPlayerInv().player.closeScreen();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
|
@ -119,6 +180,8 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
|
|||
this.rsMode = (RedstoneMode) this.myte.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
|
||||
}
|
||||
|
||||
checkToolbox();
|
||||
|
||||
for (Object o : inventorySlots)
|
||||
{
|
||||
if ( o instanceof OptionalSlotFake )
|
||||
|
@ -152,8 +215,7 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
|
|||
|
||||
public boolean hasToolbox()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
return tbinv != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -91,10 +91,10 @@ import appeng.items.storage.ItemBasicStorageCell;
|
|||
import appeng.items.storage.ItemCreativeStorageCell;
|
||||
import appeng.items.storage.ItemSpatialStorageCell;
|
||||
import appeng.items.tools.ToolMemoryCard;
|
||||
import appeng.items.tools.ToolNetworkTool;
|
||||
import appeng.items.tools.powered.ToolChargedStaff;
|
||||
import appeng.items.tools.powered.ToolEntropyManipulator;
|
||||
import appeng.items.tools.powered.ToolMassCannon;
|
||||
import appeng.items.tools.powered.ToolNetworkTool;
|
||||
import appeng.items.tools.powered.ToolPortableCell;
|
||||
import appeng.items.tools.powered.ToolWirelessTerminal;
|
||||
import appeng.items.tools.quartz.ToolQuartzAxe;
|
||||
|
|
|
@ -7,7 +7,17 @@ public enum GuiText
|
|||
{
|
||||
inventory("container"), // mc's default Inventory localization.
|
||||
|
||||
Chest, StoredEnergy, Of, Condenser, Drive, GrindStone, VibrationChamber, SpatialIOPort, LevelEmitter, Terminal, Interface, Config, StoredItems, Patterns, ImportBus, ExportBus, CellWorkbench, NetworkDetails, StorageCells, IOBuses, IOPort, BytesUsed, Types, QuantumLinkChamber, PortableCell;
|
||||
Chest, StoredEnergy, Of, Condenser, Drive, GrindStone,
|
||||
|
||||
VibrationChamber, SpatialIOPort, LevelEmitter, Terminal,
|
||||
|
||||
Interface, Config, StoredItems, Patterns, ImportBus, ExportBus,
|
||||
|
||||
CellWorkbench, NetworkDetails, StorageCells, IOBuses,
|
||||
|
||||
IOPort, BytesUsed, Types, QuantumLinkChamber, PortableCell,
|
||||
|
||||
NetworkTool, PowerUsageRate, PowerInputRate, Installed, EnergyDrain;
|
||||
|
||||
String root;
|
||||
|
||||
|
|
|
@ -25,12 +25,15 @@ import appeng.container.implementations.ContainerInterface;
|
|||
import appeng.container.implementations.ContainerLevelEmitter;
|
||||
import appeng.container.implementations.ContainerMEMonitorable;
|
||||
import appeng.container.implementations.ContainerMEPortableCell;
|
||||
import appeng.container.implementations.ContainerNetworkStatus;
|
||||
import appeng.container.implementations.ContainerNetworkTool;
|
||||
import appeng.container.implementations.ContainerQNB;
|
||||
import appeng.container.implementations.ContainerUpgradeable;
|
||||
import appeng.container.implementations.ContainerVibrationChamber;
|
||||
import appeng.helpers.ICellItemViewer;
|
||||
import appeng.helpers.IGuiItem;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.helpers.INetworkTool;
|
||||
import appeng.parts.automation.PartLevelEmitter;
|
||||
import appeng.tile.grindstone.TileGrinder;
|
||||
import appeng.tile.misc.TileCellWorkbench;
|
||||
|
@ -58,6 +61,10 @@ public enum GuiBridge implements IGuiHandler
|
|||
|
||||
GUI_PORTABLE_CELL(ContainerMEPortableCell.class, ICellItemViewer.class, true),
|
||||
|
||||
GUI_NETWORK_STATUS(ContainerNetworkStatus.class, INetworkTool.class, true),
|
||||
|
||||
GUI_NETWORK_TOOL(ContainerNetworkTool.class, INetworkTool.class, true),
|
||||
|
||||
GUI_DRIVE(ContainerDrive.class, TileDrive.class, false),
|
||||
|
||||
GUI_VIBRATIONCHAMBER(ContainerVibrationChamber.class, TileVibrationChamber.class, false),
|
||||
|
@ -166,7 +173,7 @@ public enum GuiBridge implements IGuiHandler
|
|||
ItemStack it = player.inventory.getCurrentItem();
|
||||
if ( it != null && it.getItem() instanceof IGuiItem )
|
||||
{
|
||||
Object myItem = ((IGuiItem) it.getItem()).getGuiObject( it );
|
||||
Object myItem = ((IGuiItem) it.getItem()).getGuiObject( it, w, x, y, z );
|
||||
if ( ID.CorrectTileOrPart( myItem ) )
|
||||
return ID.ConstructContainer( player.inventory, side, myItem );
|
||||
}
|
||||
|
@ -191,7 +198,7 @@ public enum GuiBridge implements IGuiHandler
|
|||
return new ContainerNull();
|
||||
}
|
||||
|
||||
private boolean isItem()
|
||||
public boolean isItem()
|
||||
{
|
||||
return isItem;
|
||||
}
|
||||
|
@ -207,7 +214,7 @@ public enum GuiBridge implements IGuiHandler
|
|||
ItemStack it = player.inventory.getCurrentItem();
|
||||
if ( it != null && it.getItem() instanceof IGuiItem )
|
||||
{
|
||||
Object myItem = ((IGuiItem) it.getItem()).getGuiObject( it );
|
||||
Object myItem = ((IGuiItem) it.getItem()).getGuiObject( it, w, x, y, z );
|
||||
if ( ID.CorrectTileOrPart( myItem ) )
|
||||
return ID.ConstructGui( player.inventory, side, myItem );
|
||||
}
|
||||
|
|
|
@ -36,8 +36,11 @@ public class PacketInventoryAction extends AppEngPacket
|
|||
public void serverPacketData(INetworkManager manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
EntityPlayerMP sender = (EntityPlayerMP) player;
|
||||
AEBaseContainer aebc = (AEBaseContainer) sender.openContainer;
|
||||
aebc.doAction( sender, action, slot, slotItem );
|
||||
if ( sender.openContainer instanceof AEBaseContainer )
|
||||
{
|
||||
AEBaseContainer aebc = (AEBaseContainer) sender.openContainer;
|
||||
aebc.doAction( sender, action, slot, slotItem );
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
|
|
|
@ -14,6 +14,7 @@ import net.minecraft.network.INetworkManager;
|
|||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.implementations.GuiMEMonitorable;
|
||||
import appeng.client.gui.implementations.GuiNetworkStatus;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
@ -45,10 +46,13 @@ public class PacketMEInventoryUpdate extends AppEngPacket
|
|||
public void clientPacketData(INetworkManager network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
|
||||
if ( gs instanceof GuiMEMonitorable )
|
||||
{
|
||||
((GuiMEMonitorable) gs).postUpdate( list );
|
||||
}
|
||||
|
||||
if ( gs instanceof GuiNetworkStatus )
|
||||
((GuiNetworkStatus) gs).postUpdate( list );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -51,22 +51,15 @@ public class ToolDebugCard extends AEBaseItem
|
|||
{
|
||||
int grids = 0;
|
||||
int totalNodes = 0;
|
||||
long totalOver5Ticks = 0;
|
||||
|
||||
for (Grid g : TickHandler.instance.getGridList())
|
||||
{
|
||||
TickManagerCache tmc = (TickManagerCache) g.getCache( ITickManager.class );
|
||||
|
||||
grids++;
|
||||
for (IGridNode n : g.getNodes())
|
||||
{
|
||||
totalOver5Ticks += tmc.getAvgNanoTime( n );
|
||||
totalNodes++;
|
||||
}
|
||||
totalNodes += g.getNodes().size();
|
||||
}
|
||||
|
||||
outputMsg( player, "Grids: " + grids );
|
||||
outputMsg( player, "Total Nodes: " + totalNodes );
|
||||
// outputMsg( player, "Average Time Used: " + " - " + timeMeasurement( totalOver5Ticks / 5 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package appeng.helpers;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IGuiItem
|
||||
{
|
||||
|
||||
Object getGuiObject(ItemStack is);
|
||||
Object getGuiObject(ItemStack is, World world, int x, int y, int z);
|
||||
|
||||
}
|
||||
|
|
14
helpers/INetworkTool.java
Normal file
14
helpers/INetworkTool.java
Normal file
|
@ -0,0 +1,14 @@
|
|||
package appeng.helpers;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.networking.IGridHost;
|
||||
|
||||
public interface INetworkTool extends IInventory
|
||||
{
|
||||
|
||||
IGridHost getGridHost(); // null for most purposes.
|
||||
|
||||
public ItemStack getItemStack();
|
||||
|
||||
}
|
116
helpers/NetworkToolInv.java
Normal file
116
helpers/NetworkToolInv.java
Normal file
|
@ -0,0 +1,116 @@
|
|||
package appeng.helpers;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.implementations.IUpgradeModule;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class NetworkToolInv implements INetworkTool
|
||||
{
|
||||
|
||||
final AppEngInternalInventory inv;
|
||||
final ItemStack is;
|
||||
final IGridHost gh;
|
||||
|
||||
public NetworkToolInv(ItemStack is, IGridHost gHost) {
|
||||
this.is = is;
|
||||
gh = gHost;
|
||||
inv = new AppEngInternalInventory( null, 9 );
|
||||
inv.readFromNBT( Platform.openNbtData( is ), "inv" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return inv.getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i)
|
||||
{
|
||||
return inv.getStackInSlot( i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j)
|
||||
{
|
||||
return inv.decrStackSize( i, j );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i)
|
||||
{
|
||||
return inv.getStackInSlotOnClosing( i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack)
|
||||
{
|
||||
inv.setInventorySlotContents( i, itemstack );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName()
|
||||
{
|
||||
return inv.getInvName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvNameLocalized()
|
||||
{
|
||||
return inv.isInvNameLocalized();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return inv.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryChanged()
|
||||
{
|
||||
inv.onInventoryChanged();
|
||||
inv.writeToNBT( Platform.openNbtData( is ), "inv" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer)
|
||||
{
|
||||
return inv.isUseableByPlayer( entityplayer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChest()
|
||||
{
|
||||
inv.openChest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeChest()
|
||||
{
|
||||
inv.closeChest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
{
|
||||
return inv.isItemValidForSlot( i, itemstack ) && itemstack.getItem() instanceof IUpgradeModule
|
||||
&& ((IUpgradeModule) itemstack.getItem()).getType( itemstack ) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridHost getGridHost()
|
||||
{
|
||||
return gh;
|
||||
}
|
||||
|
||||
}
|
|
@ -102,6 +102,9 @@ public class PartPlacement
|
|||
host.getFacadeContainer().removeFacade( host, sp.side );
|
||||
}
|
||||
|
||||
if ( host.isEmpty() )
|
||||
world.setBlock( x, y, z, 0 );
|
||||
|
||||
if ( is != null && !is.isEmpty() )
|
||||
{
|
||||
Platform.spawnDrops( world, x, y, z, is );
|
||||
|
@ -120,6 +123,7 @@ public class PartPlacement
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
100
items/tools/ToolNetworkTool.java
Normal file
100
items/tools/ToolNetworkTool.java
Normal file
|
@ -0,0 +1,100 @@
|
|||
package appeng.items.tools;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.implementations.IAEWrench;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.IGuiItem;
|
||||
import appeng.helpers.NetworkToolInv;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import cpw.mods.fml.common.Optional.Interface;
|
||||
|
||||
@Interface(iface = "buildcraft.api.tools.IToolWrench", modid = "BuildCraftAPI|core")
|
||||
public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench, IToolWrench
|
||||
{
|
||||
|
||||
public ToolNetworkTool() {
|
||||
super( ToolNetworkTool.class, null );
|
||||
setfeature( EnumSet.of( AEFeature.NetworkTool ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGuiObject(ItemStack is, World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity te = world.getBlockTileEntity( x, y, z );
|
||||
return new NetworkToolInv( is, (IGridHost) (te instanceof IGridHost ? te : null) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
int id = world.getBlockId( x, y, z );
|
||||
if ( id > 0 )
|
||||
{
|
||||
Block b = Block.blocksList[id];
|
||||
TileEntity te = world.getBlockTileEntity( x, y, z );
|
||||
if ( b != null && !(te instanceof IGridHost) )
|
||||
{
|
||||
if ( b.rotateBlock( world, x, y, z, ForgeDirection.getOrientation( side ) ) )
|
||||
{
|
||||
player.swingItem();
|
||||
return !world.isRemote;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack is, EntityPlayer p, World w, int x, int y, int z, int side, float hitx, float hity, float hitz)
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return false;
|
||||
|
||||
if ( !p.isSneaking() )
|
||||
{
|
||||
TileEntity te = w.getBlockTileEntity( x, y, z );
|
||||
if ( te instanceof IGridHost )
|
||||
Platform.openGUI( p, te, ForgeDirection.getOrientation( side ), GuiBridge.GUI_NETWORK_STATUS );
|
||||
else
|
||||
Platform.openGUI( p, null, ForgeDirection.UNKNOWN, GuiBridge.GUI_NETWORK_TOOL );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldPassSneakingClickToBlock(World w, int x, int y, int z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWrench(ItemStack is, EntityPlayer player, int x, int y, int z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWrench(EntityPlayer player, int x, int y, int z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wrenchUsed(EntityPlayer player, int x, int y, int z)
|
||||
{
|
||||
player.swingItem();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package appeng.items.tools.powered;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.helpers.IGuiItem;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
|
||||
public class ToolNetworkTool extends AEBasePoweredItem implements IGuiItem
|
||||
{
|
||||
|
||||
public ToolNetworkTool() {
|
||||
super( ToolNetworkTool.class, null );
|
||||
setfeature( EnumSet.of( AEFeature.NetworkTool, AEFeature.PoweredTools ) );
|
||||
maxStoredPower = 100000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getGuiObject(ItemStack is)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -147,7 +147,7 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell,
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object getGuiObject(ItemStack is)
|
||||
public Object getGuiObject(ItemStack is, World w, int x, int y, int z)
|
||||
{
|
||||
return new CellItemViewer( is );
|
||||
}
|
||||
|
|
|
@ -11,7 +11,9 @@ import appeng.api.implementations.IAEWrench;
|
|||
import appeng.core.features.AEFeature;
|
||||
import appeng.items.AEBaseItem;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import cpw.mods.fml.common.Optional.Interface;
|
||||
|
||||
@Interface(iface = "buildcraft.api.tools.IToolWrench", modid = "BuildCraftAPI|core")
|
||||
public class ToolQuartzWrench extends AEBaseItem implements IAEWrench, IToolWrench
|
||||
{
|
||||
|
||||
|
@ -22,8 +24,7 @@ public class ToolQuartzWrench extends AEBaseItem implements IAEWrench, IToolWren
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX,
|
||||
float hitY, float hitZ)
|
||||
public boolean onItemUseFirst(ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
int id = world.getBlockId( x, y, z );
|
||||
if ( id > 0 )
|
||||
|
|
|
@ -26,8 +26,6 @@ public class Grid implements IGrid
|
|||
HashMap<Class<? extends IGridHost>, Set> Machines = new HashMap<Class<? extends IGridHost>, Set>();
|
||||
HashMap<Class<? extends IGridCache>, GridCacheWrapper> caches = new HashMap<Class<? extends IGridCache>, GridCacheWrapper>();
|
||||
|
||||
long LastFiveRemoveTime = 0;
|
||||
long LastFiveAddNode = 0;
|
||||
GridNode pivot;
|
||||
|
||||
public Grid(GridNode center) {
|
||||
|
|
|
@ -5,19 +5,16 @@ import appeng.api.networking.IGridCache;
|
|||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.IGridStorage;
|
||||
import appeng.me.cache.TickManagerCache;
|
||||
|
||||
public class GridCacheWrapper implements IGridCache
|
||||
{
|
||||
|
||||
final public boolean isTickHandler;
|
||||
final IGridCache myCache;
|
||||
final String name;
|
||||
|
||||
public GridCacheWrapper(final IGridCache gc) {
|
||||
myCache = gc;
|
||||
name = myCache.getClass().getName();
|
||||
isTickHandler = myCache instanceof TickManagerCache;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
16
me/cache/helpers/TunnelConnection.java
vendored
Normal file
16
me/cache/helpers/TunnelConnection.java
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
package appeng.me.cache.helpers;
|
||||
|
||||
import appeng.api.networking.IGridConnection;
|
||||
import appeng.parts.p2p.PartP2PTunnelME;
|
||||
|
||||
public class TunnelConnection
|
||||
{
|
||||
|
||||
final public PartP2PTunnelME tunnel;
|
||||
final public IGridConnection c;
|
||||
|
||||
public TunnelConnection(PartP2PTunnelME t, IGridConnection con) {
|
||||
tunnel = t;
|
||||
c = con;
|
||||
}
|
||||
}
|
|
@ -135,8 +135,7 @@ public class QuantumCluster implements ILocatable, IAECluster
|
|||
return;
|
||||
}
|
||||
|
||||
ConnectionWrapper ql = sideA.connection = sideB.connection = new ConnectionWrapper( AEApi.instance().createGridConnection( sideA.getNode(),
|
||||
sideB.getNode() ) );
|
||||
sideA.connection = sideB.connection = new ConnectionWrapper( AEApi.instance().createGridConnection( sideA.getNode(), sideB.getNode() ) );
|
||||
}
|
||||
else
|
||||
shutdown = true;
|
||||
|
|
|
@ -2,6 +2,7 @@ package appeng.me.helpers;
|
|||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
|
@ -32,6 +33,8 @@ public class AENetworkProxy implements IGridBlock
|
|||
final private IGridProxyable gp;
|
||||
final private boolean worldNode;
|
||||
|
||||
final private ItemStack myRepInstance;
|
||||
|
||||
private boolean isReady = false;
|
||||
private IGridNode node = null;
|
||||
|
||||
|
@ -44,10 +47,17 @@ public class AENetworkProxy implements IGridBlock
|
|||
final private String nbtName; // name
|
||||
NBTTagCompound data = null; // input
|
||||
|
||||
public AENetworkProxy(IGridProxyable te, String nbtName, boolean inWorld) {
|
||||
@Override
|
||||
public ItemStack getMachineRepresentation()
|
||||
{
|
||||
return myRepInstance;
|
||||
}
|
||||
|
||||
public AENetworkProxy(IGridProxyable te, String nbtName, ItemStack visual, boolean inWorld) {
|
||||
this.gp = te;
|
||||
this.nbtName = nbtName;
|
||||
worldNode = inWorld;
|
||||
myRepInstance = visual;
|
||||
validSides = EnumSet.allOf( ForgeDirection.class );
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ public class AENetworkProxyMultiblock extends AENetworkProxy implements IGridMul
|
|||
}
|
||||
|
||||
public AENetworkProxyMultiblock(IGridProxyable te, String nbtName, boolean inWorld) {
|
||||
super( te, nbtName, inWorld );
|
||||
super( te, nbtName, null, inWorld );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -38,7 +38,7 @@ import appeng.parts.networking.PartCable;
|
|||
public class AEBasePart implements IPart, IGridProxyable, IGridHost, IBusCommon
|
||||
{
|
||||
|
||||
protected AENetworkProxy proxy = new AENetworkProxy( this, "part", this instanceof PartCable );
|
||||
protected AENetworkProxy proxy;
|
||||
protected TileEntity tile = null;
|
||||
protected IPartHost host = null;
|
||||
protected ForgeDirection side = null;
|
||||
|
@ -47,6 +47,7 @@ public class AEBasePart implements IPart, IGridProxyable, IGridHost, IBusCommon
|
|||
|
||||
public AEBasePart(Class c, ItemStack is) {
|
||||
this.is = is;
|
||||
proxy = new AENetworkProxy( this, "part", is, this instanceof PartCable );
|
||||
proxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
}
|
||||
|
||||
|
@ -279,4 +280,10 @@ public class AEBasePart implements IPart, IGridProxyable, IGridHost, IBusCommon
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTile()
|
||||
{
|
||||
return tile;
|
||||
}
|
||||
|
||||
}
|
|
@ -24,7 +24,7 @@ import appeng.parts.PartBasicState;
|
|||
public class PartToggleBus extends PartBasicState
|
||||
{
|
||||
|
||||
AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", true );
|
||||
AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", proxy.getMachineRepresentation(), true );
|
||||
IGridConnection connection;
|
||||
|
||||
protected final int REDSTONE_FLAG = 4;
|
||||
|
|
|
@ -28,7 +28,7 @@ import appeng.parts.AEBasePart;
|
|||
public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider
|
||||
{
|
||||
|
||||
AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", true );
|
||||
AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", proxy.getMachineRepresentation(), true );
|
||||
|
||||
public PartQuartzFiber(ItemStack is) {
|
||||
super( PartQuartzFiber.class, is );
|
||||
|
|
|
@ -26,7 +26,7 @@ import appeng.me.helpers.AENetworkProxy;
|
|||
public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements IGridTickable
|
||||
{
|
||||
|
||||
AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", true );
|
||||
AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", null, true );
|
||||
public Connections connection = new Connections( this );
|
||||
|
||||
public PartP2PTunnelME(ItemStack is) {
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.io.DataOutputStream;
|
|||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -31,6 +32,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile
|
|||
{
|
||||
|
||||
private final EnumMap<TileEventType, List<AETileEventHandler>> handlers = new EnumMap<TileEventType, List<AETileEventHandler>>( TileEventType.class );
|
||||
private final static HashMap<Class, ItemStack> myItem = new HashMap();
|
||||
|
||||
private ForgeDirection forward = ForgeDirection.UNKNOWN;
|
||||
private ForgeDirection up = ForgeDirection.UNKNOWN;
|
||||
|
@ -38,6 +40,21 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile
|
|||
public boolean dropItems = true;
|
||||
public int renderFragment = 0;
|
||||
|
||||
public TileEntity getTile()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
static public void registerTileItem(Class c, ItemStack wat)
|
||||
{
|
||||
myItem.put( c, wat );
|
||||
}
|
||||
|
||||
protected ItemStack getItemFromTile(Object obj)
|
||||
{
|
||||
return myItem.get( obj.getClass() );
|
||||
}
|
||||
|
||||
/**
|
||||
* isRedstonePowerd has already changed.
|
||||
*/
|
||||
|
|
|
@ -10,7 +10,7 @@ import appeng.tile.AEBaseInvTile;
|
|||
public abstract class AENetworkInvTile extends AEBaseInvTile implements IGridHost, IGridProxyable
|
||||
{
|
||||
|
||||
protected AENetworkProxy gridProxy = new AENetworkProxy( this, "proxy", true );
|
||||
protected AENetworkProxy gridProxy = new AENetworkProxy( this, "proxy", getItemFromTile( this ), true );
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode(ForgeDirection dir)
|
||||
|
|
|
@ -12,7 +12,7 @@ import appeng.tile.powersink.AEBasePoweredTile;
|
|||
public abstract class AENetworkPowerTile extends AEBasePoweredTile implements IGridHost, IGridProxyable
|
||||
{
|
||||
|
||||
protected AENetworkProxy gridProxy = new AENetworkProxy( this, "proxy", true );
|
||||
protected AENetworkProxy gridProxy = new AENetworkProxy( this, "proxy", getItemFromTile( this ), true );
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir)
|
||||
|
|
|
@ -16,7 +16,7 @@ public class AENetworkTile extends AEBaseTile implements IGridHost, IGridProxyab
|
|||
|
||||
protected AENetworkProxy createProxy()
|
||||
{
|
||||
return new AENetworkProxy( this, "proxy", true );
|
||||
return new AENetworkProxy( this, "proxy", getItemFromTile( this ), true );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -291,4 +291,10 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
|||
{
|
||||
// never called!
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return cb.isEmpty();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -404,4 +404,5 @@ public class TileIOPort extends AENetworkInvTile implements IBusCommon, IConfigM
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -285,7 +285,7 @@ public class Platform
|
|||
}
|
||||
else
|
||||
{
|
||||
if ( Security.hasPermissions( tile, p, AccessType.BLOCK_ACCESS ) )
|
||||
if ( type.isItem() || Security.hasPermissions( tile, p, AccessType.BLOCK_ACCESS ) )
|
||||
p.openGui( AppEng.instance, type.ordinal() << 3 | (side.ordinal()), tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue