Esempio n. 1
0
 private void setWorld(World worldObj) {
   if (worldObj != null && this.worldObj == null) {
     this.worldObj = worldObj;
     transport.setWorld(worldObj);
     logic.setWorld(worldObj);
   }
 }
Esempio n. 2
0
  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);
      }
  }
Esempio n. 3
0
 public void initialize() {
   if (!initialized) {
     transport.initialize();
     logic.initialize();
     initialized = true;
     updateSignalState();
   }
 }
Esempio n. 4
0
  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);
  }
Esempio n. 5
0
  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);
  }
Esempio n. 6
0
  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 + "]"));
      }
  }
Esempio n. 7
0
  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();
    }
  }
Esempio n. 8
0
 @Override
 public boolean doDrop() {
   return logic.doDrop();
 }
Esempio n. 9
0
 public boolean outputOpen(ForgeDirection to) {
   return transport.outputOpen(to) && logic.outputOpen(to);
 }
Esempio n. 10
0
 public boolean inputOpen(ForgeDirection from) {
   return transport.inputOpen(from) && logic.inputOpen(from);
 }
Esempio n. 11
0
 public boolean canPipeConnect(TileEntity tile, ForgeDirection side) {
   return logic.canPipeConnect(tile, side) && transport.canPipeConnect(tile, side);
 }
Esempio n. 12
0
  public void onNeighborBlockChange(int blockId) {
    logic.onNeighborBlockChange(blockId);
    transport.onNeighborBlockChange(blockId);

    updateSignalState();
  }
Esempio n. 13
0
 public void onBlockPlaced() {
   logic.onBlockPlaced();
   transport.onBlockPlaced();
 }
Esempio n. 14
0
 public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer) {
   return logic.blockActivated(entityplayer);
 }