Ejemplo n.º 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);
    }
  }
Ejemplo n.º 2
0
  @Override
  public ArrayList getNetworkedData(ArrayList data) {
    data.add(facing);
    data.add(redstone);

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

    return data;
  }
Ejemplo n.º 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);
    }
  }
Ejemplo n.º 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);
    }
  }
Ejemplo n.º 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;
  }