コード例 #1
0
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int side,
      float hitX,
      float hitY,
      float hitZ) {

    if (player.isSneaking()) {
      if (!world.isRemote) {
        IInventoryProvider te =
            TileEntityUtils.getTileEntity(IInventoryProvider.class, world, x, y, z);
        MalisisInventory.open((EntityPlayerMP) player, te);
      }
    } else {
      TEKnifeSwitch te = TileEntityUtils.getTileEntity(TEKnifeSwitch.class, world, x, y, z);
      if (te == null) return true;

      if (te.isMoving()) return true;

      te.pushMe();
      if (te.getState() == TEGenericControl.State.TURNINGON)
        world.playSoundEffect(
            (double) x + 0.5D, (double) y + 0.5D, (double) z + 0.5D, "random.click", 0.3F, 0.6F);
      else
        world.playSoundEffect(
            (double) x + 0.5D, (double) y + 0.5D, (double) z + 0.5D, "random.click", 0.3F, 0.5F);
    }
    return true;
  }
コード例 #2
0
  @Override
  public void onBlockPlacedBy(
      World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {

    ForgeDirection dir = Utilities.metaToDir(world.getBlockMetadata(x, y, z));
    TEKnifeSwitch te = TileEntityUtils.getTileEntity(TEKnifeSwitch.class, world, x, y, z);
    if (te != null) te.setDirection(dir);
    else System.out.println("TE is NULL! :(");
  }
コード例 #3
0
  @Override
  public AxisAlignedBB[] getBoundingBox(
      IBlockAccess world, int x, int y, int z, BoundingBoxType type) {
    RustyHatchTileEntity te =
        TileEntityUtils.getTileEntity(RustyHatchTileEntity.class, world, x, y, z);
    if (te == null || te.isMoving() || te.getMovement() == null || te.getMultiBlock() == null)
      return AABBUtils.identities();

    AxisAlignedBB aabb = te.getMovement().getBoundingBox(te, te.isTopBlock(x, y, z), type);
    if (aabb != null) aabb.offset(-x, -y, -z);
    return new AxisAlignedBB[] {aabb};
  }
コード例 #4
0
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int side,
      float hitX,
      float hitY,
      float hitZ) {
    if (world.isRemote) return true;

    RustyHatchTileEntity te =
        TileEntityUtils.getTileEntity(RustyHatchTileEntity.class, world, x, y, z);
    if (te == null) return true;

    te.openOrCloseDoor();
    return true;
  }