Пример #1
0
  @Override
  public boolean placeBlockAt(
      ItemStack stack,
      EntityPlayer player,
      World world,
      int x,
      int y,
      int z,
      int side,
      float hitX,
      float hitY,
      float hitZ,
      int metadata) {
    boolean place =
        super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata);

    if (place) {
      TileEntityEnergyCube tileEntity = (TileEntityEnergyCube) world.getBlockTileEntity(x, y, z);
      tileEntity.tier = ((IEnergyCube) stack.getItem()).getEnergyCubeTier(stack);
      tileEntity.electricityStored = getEnergy(stack);

      ((ISustainedInventory) tileEntity).setInventory(getInventory(stack));

      if (!world.isRemote) {
        PacketHandler.sendPacket(
            Transmission.ALL_CLIENTS,
            new PacketTileEntity()
                .setParams(Object3D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList())));
      }
    }

    return place;
  }
Пример #2
0
  @Override
  public void onContainerClosed(EntityPlayer entityplayer) {
    super.onContainerClosed(entityplayer);

    tileEntity.playersUsing.remove(entityplayer);
    tileEntity.closeChest();
  }
Пример #3
0
  public ContainerEnergyCube(InventoryPlayer inventory, TileEntityEnergyCube unit) {
    tileEntity = unit;
    addSlotToContainer(new SlotCharge(unit, 0, 8, 8));
    addSlotToContainer(new SlotDischarge(unit, 1, 8, 40));

    int slotX;

    for (slotX = 0; slotX < 3; ++slotX) {
      for (int slotY = 0; slotY < 9; ++slotY) {
        addSlotToContainer(
            new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18));
      }
    }

    for (slotX = 0; slotX < 9; ++slotX) {
      addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142));
    }

    tileEntity.playersUsing.add(inventory.player);
    tileEntity.openChest();
  }
Пример #4
0
 @Override
 public boolean canInteractWith(EntityPlayer entityplayer) {
   return tileEntity.isUseableByPlayer(entityplayer);
 }