It's openContainer, not inventoryContainer. Also fix network update stuff

This commit is contained in:
Christian 2012-11-16 20:24:08 -05:00
parent 42f90b109a
commit dc82c9ace6
7 changed files with 28 additions and 23 deletions

View file

@ -170,7 +170,6 @@ public class TileRefinery extends TileMachine implements ITankContainer, IPowerR
return;
} else if (CoreProxy.proxy.isSimulating(worldObj) && updateNetworkTime.markTimeIfDelay(worldObj, 2 * BuildCraftCore.updateFactor)) {
System.out.printf("Server Anim state: %d %f\n", animationStage, animationSpeed);
sendNetworkUpdate();
}

View file

@ -62,7 +62,7 @@ public class PacketHandlerSilicon implements IPacketHandler {
private void onSelectionUpdate(EntityPlayer player, PacketUpdate packet) {
Container container = player.inventoryContainer;
Container container = player.openContainer;
if (container instanceof ContainerAssemblyTable) {
SelectionMessage message = new SelectionMessage();

View file

@ -31,10 +31,10 @@ public class GuiHandler implements IGuiHandler {
switch (ID) {
case GuiIds.PIPE_DIAMOND:
return new ContainerDiamondPipe(player.inventory, (PipeLogicDiamond)pipe.pipe.logic);
case GuiIds.GATES:
return new ContainerGateInterface(player.inventory, pipe.pipe);
default:
return null;
}
@ -57,10 +57,10 @@ public class GuiHandler implements IGuiHandler {
switch (ID) {
case GuiIds.PIPE_DIAMOND:
return new GuiDiamondPipe(player.inventory, pipe);
case GuiIds.GATES:
return new GuiGateInterface(player.inventory, pipe.pipe);
default:
return null;
}

View file

@ -252,7 +252,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
if (renderState.isDirty()){
worldObj.markBlockForRenderUpdate(this.xCoord, this.yCoord, this.zCoord);
worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
renderState.clean();
}
@ -621,7 +621,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
}
break;
}
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
}
@Override

View file

@ -61,6 +61,8 @@ public class ContainerGateInterface extends BuildCraftContainer {
// Do not attempt to create a list of potential actions and triggers on
// the client.
System.out.printf("Gate gui %s\n", this);
if (!CoreProxy.proxy.isRenderWorld(pipe.worldObj)) {
_potentialActions.addAll(pipe.getActions());
_potentialTriggers.addAll(ActionManager.getPipeTriggers(pipe));
@ -88,6 +90,7 @@ public class ContainerGateInterface extends BuildCraftContainer {
if (!_potentialActions.contains(a))
_potentialActions.add(a);
}
System.out.printf("Action list %s %s\n", _potentialActions, _potentialTriggers);
}
}
@ -108,7 +111,7 @@ public class ContainerGateInterface extends BuildCraftContainer {
/**
* Clears list of potential actions and refills it according to packet.
*
*
* @param packet
*/
public void updateActions(PacketUpdate packet) {
@ -123,7 +126,7 @@ public class ContainerGateInterface extends BuildCraftContainer {
/**
* Clears list of potential triggers and refills it according to packet.
*
*
* @param packet
*/
public void updateTriggers(PacketUpdate packet) {
@ -136,7 +139,7 @@ public class ContainerGateInterface extends BuildCraftContainer {
/**
* Sets the currently selected actions and triggers according to packet.
*
*
* @param packet
*/
public void setSelection(PacketUpdate packet) {
@ -260,7 +263,7 @@ public class ContainerGateInterface extends BuildCraftContainer {
/**
* Sends the list of potential actions to the client
*
*
* @param player
*/
private void sendActions(EntityPlayer player) {
@ -275,13 +278,14 @@ public class ContainerGateInterface extends BuildCraftContainer {
PacketUpdate packet = new PacketUpdate(PacketIds.GATE_ACTIONS, pipe.xCoord, pipe.yCoord, pipe.zCoord, payload);
System.out.printf("Packet to player %s\n", packet);
// Send to player
CoreProxy.proxy.sendToPlayer(player, packet);
}
/**
* Sends the list of potential triggers to the client
*
*
* @param player
*/
private void sendTriggers(EntityPlayer player) {
@ -302,7 +306,7 @@ public class ContainerGateInterface extends BuildCraftContainer {
/**
* Sends the current selection on the gate to the client.
*
*
* @param player
*/
public void sendSelection(EntityPlayer player) {

View file

@ -296,6 +296,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
@Override
protected void mouseClicked(int i, int j, int k) {
System.out.printf("Mouse click %d %d %d\n", i,j,k);
super.mouseClicked(i, j, k);
int cornerX = (width - xSize) / 2;

View file

@ -107,7 +107,7 @@ public class PacketHandlerTransport implements IPacketHandler {
* @param packet
*/
private void onGateActions(EntityPlayer player, PacketUpdate packet) {
Container container = player.inventoryContainer;
Container container = player.openContainer;
if (!(container instanceof ContainerGateInterface))
return;
@ -121,7 +121,7 @@ public class PacketHandlerTransport implements IPacketHandler {
* @param packet
*/
private void onGateTriggers(EntityPlayer player, PacketUpdate packet) {
Container container = player.inventoryContainer;
Container container = player.openContainer;
if (!(container instanceof ContainerGateInterface))
return;
@ -135,7 +135,7 @@ public class PacketHandlerTransport implements IPacketHandler {
* @param packet
*/
private void onGateSelection(EntityPlayer player, PacketUpdate packet) {
Container container = player.inventoryContainer;
Container container = player.openContainer;
if (!(container instanceof ContainerGateInterface))
return;
@ -248,10 +248,10 @@ public class PacketHandlerTransport implements IPacketHandler {
* @param packet
*/
private void onGateSelectionChange(EntityPlayer playerEntity, PacketUpdate packet) {
if (!(playerEntity.inventoryContainer instanceof ContainerGateInterface))
if (!(playerEntity.openContainer instanceof ContainerGateInterface))
return;
((ContainerGateInterface) playerEntity.inventoryContainer).handleSelectionChange(packet);
((ContainerGateInterface) playerEntity.openContainer).handleSelectionChange(packet);
}
/**
@ -261,10 +261,10 @@ public class PacketHandlerTransport implements IPacketHandler {
* @param packet
*/
private void onGateSelectionRequest(EntityPlayer playerEntity, PacketCoordinates packet) {
if (!(playerEntity.inventoryContainer instanceof ContainerGateInterface))
if (!(playerEntity.openContainer instanceof ContainerGateInterface))
return;
((ContainerGateInterface) playerEntity.inventoryContainer).sendSelection(playerEntity);
((ContainerGateInterface) playerEntity.openContainer).sendSelection(playerEntity);
}
/**
@ -274,10 +274,11 @@ public class PacketHandlerTransport implements IPacketHandler {
* @param packet
*/
private void onGateInitRequest(EntityPlayer playerEntity, PacketCoordinates packet) {
if (!(playerEntity.inventoryContainer instanceof ContainerGateInterface))
System.out.printf("gate init %s\n",playerEntity.openContainer);
if (!(playerEntity.openContainer instanceof ContainerGateInterface))
return;
((ContainerGateInterface) playerEntity.inventoryContainer).handleInitRequest(playerEntity);
((ContainerGateInterface) playerEntity.openContainer).handleInitRequest(playerEntity);
}
/**