예제 #1
0
 @Override
 public boolean onBlockActivated(
     World world, int x, int y, int z, EntityPlayer player, int i, float f, float f1, float f2) {
   TileEntityBFurnace tile = (TileEntityBFurnace) world.getBlockTileEntity(x, y, z);
   if (tile == null || tile.getBlockMetadata() == 0) return false;
   if ((tile.getBlockMetadata() == 1 || tile.getBlockMetadata() == 2) && tile.direction != i)
     return false;
   return tile.interact(player);
 }
예제 #2
0
 @Override
 public void onBlockPlacedBy(
     World world, int x, int y, int z, EntityLivingBase entity, ItemStack item) {
   int dir = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
   TileEntityBFurnace tile = (TileEntityBFurnace) world.getBlockTileEntity(x, y, z);
   tile.direction = getFacingOnMeta(dir);
   if (item.hasDisplayName()) {
     tile.setCustomName(item.getDisplayName());
   }
 }
예제 #3
0
  @Override
  public int getLightValue(IBlockAccess world, int x, int y, int z) {
    boolean power = false;
    TileEntityBFurnace bfurn = getFurnaceInstance(world, x, y, z);
    if (bfurn == null) return 0;

    power = bfurn.isBurning();
    if (power) {
      return 15;
    }
    return super.getLightValue(world, x, y, z);
  }
예제 #4
0
 public int getBlockTextureInt(IBlockAccess world, int x, int y, int z, int side) {
   TileEntityBFurnace tile = (TileEntityBFurnace) world.getBlockTileEntity(x, y, z);
   if (tile != null) {
     byte facing = tile.direction;
     int meta = tile.getBlockMetadata();
     if (meta == 2) // output
     {
       if (side == 0) return 0;
     }
     if (meta == 1 || meta == 2) // Input/fuel
     {
       if (side != facing) return 0;
       else return 2;
     }
   }
   if (side == 0 || side == 1) return 1;
   return 0;
 }
예제 #5
0
  /** Called whenever the block is removed. */
  @Override
  public void breakBlock(World world, int x, int y, int z, int i1, int i2) {
    TileEntityBFurnace tile = (TileEntityBFurnace) world.getBlockTileEntity(x, y, z);

    if (tile != null) {
      for (int var6 = 0; var6 < tile.getSizeInventory(); ++var6) {
        ItemStack var7 = tile.getStackInSlot(var6);

        if (var7 != null) {
          float var8 = this.rand.nextFloat() * 0.8F + 0.1F;
          float var9 = this.rand.nextFloat() * 0.8F + 0.1F;
          float var10 = this.rand.nextFloat() * 0.8F + 0.1F;

          while (var7.stackSize > 0) {
            int var11 = this.rand.nextInt(21) + 10;

            if (var11 > var7.stackSize) {
              var11 = var7.stackSize;
            }

            var7.stackSize -= var11;
            EntityItem var12 =
                new EntityItem(
                    world,
                    (double) ((float) x + var8),
                    (double) ((float) y + var9),
                    (double) ((float) z + var10),
                    new ItemStack(var7.itemID, var11, var7.getItemDamage()));

            if (var7.hasTagCompound()) {
              var12.getEntityItem().setTagCompound((NBTTagCompound) var7.getTagCompound().copy());
            }

            float var13 = 0.05F;
            var12.motionX = (double) ((float) this.rand.nextGaussian() * var13);
            var12.motionY = (double) ((float) this.rand.nextGaussian() * var13 + 0.2F);
            var12.motionZ = (double) ((float) this.rand.nextGaussian() * var13);
            world.spawnEntityInWorld(var12);
          }
        }
      }
    }
    super.breakBlock(world, x, y, z, i1, i2);
  }