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

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