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

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