private void setWorld(World worldObj) { if (worldObj != null && this.worldObj == null) { this.worldObj = worldObj; transport.setWorld(worldObj); logic.setWorld(worldObj); } }
public void writeToNBT(NBTTagCompound nbttagcompound) { transport.writeToNBT(nbttagcompound); logic.writeToNBT(nbttagcompound); // Save pulser if any if (gate != null) { NBTTagCompound nbttagcompoundC = new NBTTagCompound(); gate.writeToNBT(nbttagcompoundC); nbttagcompound.setTag("Gate", nbttagcompoundC); // Wire states are stored for pipes with gates only for (int i = 0; i < 4; ++i) nbttagcompound.setBoolean("wireState[" + i + "]", broadcastSignal[i]); nbttagcompound.setBoolean("redstoneState", broadcastRedstone); } for (int i = 0; i < 4; ++i) nbttagcompound.setBoolean("wireSet[" + i + "]", wireSet[i]); for (int i = 0; i < 8; ++i) { nbttagcompound.setInteger( "action[" + i + "]", activatedActions[i] != null ? activatedActions[i].getId() : 0); nbttagcompound.setInteger( "trigger[" + i + "]", activatedTriggers[i] != null ? activatedTriggers[i].getId() : 0); } for (int i = 0; i < 8; ++i) if (triggerParameters[i] != null) { NBTTagCompound cpt = new NBTTagCompound(); triggerParameters[i].writeToNBT(cpt); nbttagcompound.setTag("triggerParameters[" + i + "]", cpt); } }
public void initialize() { if (!initialized) { transport.initialize(); logic.initialize(); initialized = true; updateSignalState(); } }
private void setPosition(int xCoord, int yCoord, int zCoord) { this.xCoord = xCoord; this.yCoord = yCoord; this.zCoord = zCoord; transport.setPosition(xCoord, yCoord, zCoord); logic.setPosition(xCoord, yCoord, zCoord); }
public void setTile(TileEntity tile) { this.container = (TileGenericPipe) tile; transport.setTile((TileGenericPipe) tile); logic.setTile((TileGenericPipe) tile); setPosition(tile.xCoord, tile.yCoord, tile.zCoord); setWorld(tile.worldObj); }
public void readFromNBT(NBTTagCompound nbttagcompound) { transport.readFromNBT(nbttagcompound); logic.readFromNBT(nbttagcompound); // Load pulser if any if (nbttagcompound.hasKey("Gate")) { NBTTagCompound nbttagcompoundP = nbttagcompound.getCompoundTag("Gate"); gate = new GateVanilla(this); gate.readFromNBT(nbttagcompoundP); } else if (nbttagcompound.hasKey("gateKind")) { // Legacy implementation Gate.GateKind kind = Gate.GateKind.values()[nbttagcompound.getInteger("gateKind")]; if (kind != Gate.GateKind.None) { gate = new GateVanilla(this); gate.kind = kind; } } // Wire states are restored for pipes with gates if (gate != null) { for (int i = 0; i < 4; ++i) broadcastSignal[i] = nbttagcompound.getBoolean("wireState[" + i + "]"); broadcastRedstone = nbttagcompound.getBoolean("redstoneState"); } for (int i = 0; i < 4; ++i) wireSet[i] = nbttagcompound.getBoolean("wireSet[" + i + "]"); for (int i = 0; i < 8; ++i) { activatedActions[i] = ActionManager.actions[nbttagcompound.getInteger("action[" + i + "]")]; activatedTriggers[i] = ActionManager.triggers[nbttagcompound.getInteger("trigger[" + i + "]")]; } // Force any triggers to be resolved fixTriggers(); for (int i = 0; i < 8; ++i) if (nbttagcompound.hasKey("triggerParameters[" + i + "]")) { triggerParameters[i] = new TriggerParameter(); triggerParameters[i].readFromNBT( nbttagcompound.getCompoundTag("triggerParameters[" + i + "]")); } }
public void updateEntity() { transport.updateEntity(); logic.updateEntity(); if (internalUpdateScheduled) { internalUpdate(); internalUpdateScheduled = false; } // Do not try to update gates client side. if (worldObj.isRemote) return; if (actionTracker.markTimeIfDelay(worldObj, 10)) { resolveActions(); } // Update the gate if we have any if (gate != null) { gate.update(); } }
@Override public boolean doDrop() { return logic.doDrop(); }
public boolean outputOpen(ForgeDirection to) { return transport.outputOpen(to) && logic.outputOpen(to); }
public boolean inputOpen(ForgeDirection from) { return transport.inputOpen(from) && logic.inputOpen(from); }
public boolean canPipeConnect(TileEntity tile, ForgeDirection side) { return logic.canPipeConnect(tile, side) && transport.canPipeConnect(tile, side); }
public void onNeighborBlockChange(int blockId) { logic.onNeighborBlockChange(blockId); transport.onNeighborBlockChange(blockId); updateSignalState(); }
public void onBlockPlaced() { logic.onBlockPlaced(); transport.onBlockPlaced(); }
public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer) { return logic.blockActivated(entityplayer); }