Fix Gate GUI

This commit is contained in:
CovertJaguar 2013-07-20 18:06:17 -07:00
parent e0e66f7910
commit 66bc9914ae
3 changed files with 18 additions and 20 deletions

View file

@ -99,8 +99,8 @@ public class ActionTriggerIconProvider implements IIconProvider {
icons[ActionTriggerIconProvider.Trigger_PipeSignal_Green_Inactive] = iconRegister.registerIcon("buildcraft:triggers/trigger_pipesignal_green_inactive"); icons[ActionTriggerIconProvider.Trigger_PipeSignal_Green_Inactive] = iconRegister.registerIcon("buildcraft:triggers/trigger_pipesignal_green_inactive");
icons[ActionTriggerIconProvider.Trigger_PipeSignal_Yellow_Active] = iconRegister.registerIcon("buildcraft:triggers/trigger_pipesignal_yellow_active"); icons[ActionTriggerIconProvider.Trigger_PipeSignal_Yellow_Active] = iconRegister.registerIcon("buildcraft:triggers/trigger_pipesignal_yellow_active");
icons[ActionTriggerIconProvider.Trigger_PipeSignal_Yellow_Inactive] = iconRegister.registerIcon("buildcraft:triggers/trigger_pipesignal_yellow_inactive"); icons[ActionTriggerIconProvider.Trigger_PipeSignal_Yellow_Inactive] = iconRegister.registerIcon("buildcraft:triggers/trigger_pipesignal_yellow_inactive");
// icons[ActionTriggerIconProvider.Trigger_RedstoneInput_Active] = iconRegister.registerIcon("buildcraft:triggers/trigger_redstoneinput_active"); icons[ActionTriggerIconProvider.Trigger_RedstoneInput_Active] = iconRegister.registerIcon("buildcraft:triggers/trigger_redstoneinput_active");
// icons[ActionTriggerIconProvider.Trigger_RedstoneInput_Inactive] = iconRegister.registerIcon("buildcraft:triggers/trigger_redstoneinput_inactive"); icons[ActionTriggerIconProvider.Trigger_RedstoneInput_Inactive] = iconRegister.registerIcon("buildcraft:triggers/trigger_redstoneinput_inactive");
icons[ActionTriggerIconProvider.Trigger_Inventory_Below25] = iconRegister.registerIcon("buildcraft:triggers/trigger_inventory_below25"); icons[ActionTriggerIconProvider.Trigger_Inventory_Below25] = iconRegister.registerIcon("buildcraft:triggers/trigger_inventory_below25");
icons[ActionTriggerIconProvider.Trigger_Inventory_Below50] = iconRegister.registerIcon("buildcraft:triggers/trigger_inventory_below50"); icons[ActionTriggerIconProvider.Trigger_Inventory_Below50] = iconRegister.registerIcon("buildcraft:triggers/trigger_inventory_below50");
icons[ActionTriggerIconProvider.Trigger_Inventory_Below75] = iconRegister.registerIcon("buildcraft:triggers/trigger_inventory_below75"); icons[ActionTriggerIconProvider.Trigger_Inventory_Below75] = iconRegister.registerIcon("buildcraft:triggers/trigger_inventory_below75");

View file

@ -117,7 +117,6 @@ public class ContainerGateInterface extends BuildCraftContainer {
* @param packet * @param packet
*/ */
public void updateActions(PacketUpdate packet) { public void updateActions(PacketUpdate packet) {
_potentialActions.clear(); _potentialActions.clear();
PacketPayloadArrays payload = (PacketPayloadArrays) packet.payload; PacketPayloadArrays payload = (PacketPayloadArrays) packet.payload;
int length = payload.intPayload[0]; int length = payload.intPayload[0];
@ -125,7 +124,6 @@ public class ContainerGateInterface extends BuildCraftContainer {
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
_potentialActions.add(ActionManager.actions.get(payload.stringPayload[i])); _potentialActions.add(ActionManager.actions.get(payload.stringPayload[i]));
} }
} }
/** /**
@ -148,31 +146,31 @@ public class ContainerGateInterface extends BuildCraftContainer {
* *
* @param packet * @param packet
*/ */
public void setSelection(PacketUpdate packet) { public void setSelection(PacketUpdate packet, boolean notify) {
PacketPayloadArrays payload = (PacketPayloadArrays) packet.payload; PacketPayloadArrays payload = (PacketPayloadArrays) packet.payload;
int position = payload.intPayload[0]; int position = payload.intPayload[0];
setTrigger(position, ActionManager.triggers.get(payload.stringPayload[0]), false); setTrigger(position, ActionManager.triggers.get(payload.stringPayload[0]), notify);
setAction(position, ActionManager.actions.get(payload.stringPayload[1]), false); setAction(position, ActionManager.actions.get(payload.stringPayload[1]), notify);
int itemID = payload.intPayload[1]; int itemID = payload.intPayload[1];
if (itemID <= 0) { if (itemID <= 0) {
setTriggerParameter(position, null, false); setTriggerParameter(position, null, notify);
return; return;
} }
ITriggerParameter param = new TriggerParameter(); ITriggerParameter param = new TriggerParameter();
param.set(new ItemStack(itemID, payload.intPayload[2], payload.intPayload[3])); param.set(new ItemStack(itemID, payload.intPayload[2], payload.intPayload[3]));
setTriggerParameter(position, param, false); setTriggerParameter(position, param, notify);
} }
private PacketPayload getSelectionPayload(int position){ private PacketPayload getSelectionPayload(int position) {
PacketPayloadArrays payload = new PacketPayloadArrays(4, 0, 2); PacketPayloadArrays payload = new PacketPayloadArrays(4, 0, 2);
payload.intPayload[0] = position; payload.intPayload[0] = position;
if (pipe.gate.actions[position] != null) { if (pipe.gate.triggers[position] != null) {
payload.stringPayload[0] = pipe.gate.actions[position].getUniqueTag(); payload.stringPayload[0] = pipe.gate.triggers[position].getUniqueTag();
} else { } else {
payload.stringPayload[0] = ""; payload.stringPayload[0] = "";
} }
@ -270,7 +268,7 @@ public class ContainerGateInterface extends BuildCraftContainer {
int length = _potentialActions.size(); int length = _potentialActions.size();
PacketPayloadArrays payload = new PacketPayloadArrays(1, 0, length); PacketPayloadArrays payload = new PacketPayloadArrays(1, 0, length);
payload.intPayload[1] = length; payload.intPayload[0] = length;
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
payload.stringPayload[i] = _potentialActions.get(i).getUniqueTag(); payload.stringPayload[i] = _potentialActions.get(i).getUniqueTag();
} }
@ -358,7 +356,7 @@ public class ContainerGateInterface extends BuildCraftContainer {
} }
public boolean isNearbyTriggerActive(ITrigger trigger, ITriggerParameter parameter) { public boolean isNearbyTriggerActive(ITrigger trigger, ITriggerParameter parameter) {
return pipe.gate != null && pipe.gate.isNearbyTriggerActive(trigger, parameter); return pipe.gate.isNearbyTriggerActive(trigger, parameter);
} }
public void setTrigger(int position, ITrigger trigger, boolean notify) { public void setTrigger(int position, ITrigger trigger, boolean notify) {
@ -379,15 +377,15 @@ public class ContainerGateInterface extends BuildCraftContainer {
* ACTIONS * * ACTIONS *
*/ */
public boolean hasActions() { public boolean hasActions() {
return _potentialActions.size() > 0; return !_potentialActions.isEmpty();
} }
public IAction getFirstAction() { public IAction getFirstAction() {
return _potentialActions.size() > 0 ? _potentialActions.getFirst() : null; return _potentialActions.peekFirst();
} }
public IAction getLastAction() { public IAction getLastAction() {
return _potentialActions.size() > 0 ? _potentialActions.getLast() : null; return _potentialActions.peekLast();
} }
public Iterator<IAction> getActionIterator(boolean descending) { public Iterator<IAction> getActionIterator(boolean descending) {

View file

@ -155,7 +155,7 @@ public class PacketHandlerTransport implements IPacketHandler {
if (!(container instanceof ContainerGateInterface)) if (!(container instanceof ContainerGateInterface))
return; return;
((ContainerGateInterface) container).setSelection(packet); ((ContainerGateInterface) container).setSelection(packet, false);
} }
private void onPipeContentNBT(EntityPlayer player, PacketPipeTransportNBT packet) { private void onPipeContentNBT(EntityPlayer player, PacketPipeTransportNBT packet) {
@ -258,7 +258,7 @@ public class PacketHandlerTransport implements IPacketHandler {
if (!(playerEntity.openContainer instanceof ContainerGateInterface)) if (!(playerEntity.openContainer instanceof ContainerGateInterface))
return; return;
((ContainerGateInterface) playerEntity.openContainer).setSelection(packet); ((ContainerGateInterface) playerEntity.openContainer).setSelection(packet, true);
} }
/** /**