예제 #1
0
  @Override
  public void writeToNBT(NBTTagCompound nbtTags) {
    super.writeToNBT(nbtTags);

    nbtTags.setInteger("facing", facing);
    nbtTags.setBoolean("redstone", redstone);

    for (ITileComponent component : components) {
      component.write(nbtTags);
    }
  }
예제 #2
0
  @Override
  public ArrayList getNetworkedData(ArrayList data) {
    data.add(facing);
    data.add(redstone);

    for (ITileComponent component : components) {
      component.write(data);
    }

    return data;
  }
예제 #3
0
  @Override
  public void readFromNBT(NBTTagCompound nbtTags) {
    super.readFromNBT(nbtTags);

    facing = nbtTags.getInteger("facing");
    redstone = nbtTags.getBoolean("redstone");

    for (ITileComponent component : components) {
      component.read(nbtTags);
    }
  }
예제 #4
0
  @Override
  public void handlePacketData(ByteBuf dataStream) {
    facing = dataStream.readInt();
    redstone = dataStream.readBoolean();

    if (clientFacing != facing) {
      MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
      worldObj.notifyBlocksOfNeighborChange(
          xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
      clientFacing = facing;
    }

    for (ITileComponent component : components) {
      component.read(dataStream);
    }
  }
예제 #5
0
  @Override
  public void updateEntity() {
    if (!worldObj.isRemote && general.destroyDisabledBlocks) {
      MachineType type = MachineType.get(getBlockType(), getBlockMetadata());

      if (type != null && !type.isEnabled()) {
        Mekanism.logger.info(
            "[Mekanism] Destroying machine of type '"
                + type.name
                + "' at coords "
                + Coord4D.get(this)
                + " as according to config.");
        worldObj.setBlockToAir(xCoord, yCoord, zCoord);
        return;
      }
    }

    for (ITileComponent component : components) {
      component.tick();
    }

    onUpdate();

    if (!worldObj.isRemote) {
      openedThisTick.clear();

      if (doAutoSync && playersUsing.size() > 0) {
        for (EntityPlayer player : playersUsing) {
          Mekanism.packetHandler.sendTo(
              new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())),
              (EntityPlayerMP) player);
        }
      }
    }

    ticker++;
    redstoneLastTick = redstone;
  }