Пример #1
0
  @Override
  public void update() {

    if (tick == 0) {
      logic.world = world;
      logic.x = x;
      logic.y = y;
      logic.z = z;
    }
    logic.update();
    super.update();
    if (tick == 3) updateConnections();
  }
Пример #2
0
  @Override
  public void save(NBTTagCompound tag) {

    super.save(tag);
    for (int i = 0; i < 6; i++) {
      tag.setBoolean("connections" + i, connections[i]);
    }
    tag.setByte("tubeColor", (byte) color.ordinal());

    NBTTagCompound logicTag = new NBTTagCompound();
    logic.writeToNBT(logicTag);
    tag.setTag("logic", logicTag);
  }
Пример #3
0
  @Override
  public void load(NBTTagCompound tag) {

    super.load(tag);
    int connectionCount = 0;
    for (int i = 0; i < 6; i++) {
      connections[i] = tag.getBoolean("connections" + i);
      if (connections[i]) connectionCount++;
    }
    isCrossOver = connectionCount != 2;
    color = TubeColor.values()[tag.getByte("tubeColor")];

    NBTTagCompound logicTag = tag.getCompoundTag("logic");
    logic.readFromNBT(logicTag);
  }
Пример #4
0
  /**
   * Event called when the part is activated (right clicked)
   *
   * @param player Player that right clicked the part
   * @param item Item that was used to click it
   * @return Whether or not an action occurred
   */
  @Override
  public boolean onActivated(EntityPlayer player, ItemStack item) {

    if (world == null) return false;

    if (!world.isRemote) {

      if (item != null && item.getItem() == Items.dye) {

        if (item.getItemDamage() < 16) {
          color = TubeColor.values()[item.getItemDamage()];
          updateConnections();
          notifyUpdate();
          return true;
        }
      } else if (item != null) {
        logic.injectStack(item, ForgeDirection.DOWN, TubeColor.NONE, false);
      }
    }
    return false;
  }
Пример #5
0
  /**
   * This render method gets called every tick. You should use this if you're doing animations
   *
   * @param loc Distance from the player's position
   * @param pass Render pass (0 or 1)
   * @param frame Partial tick for smoother animations
   */
  @Override
  public void renderDynamic(Vector3 loc, int pass, float frame) {

    logic.renderDynamic(loc, frame);
  }