Exemplo n.º 1
0
 private boolean hasItems(World par1World, int par2, int par3, int par4) {
   TileEntityLandmine te = (TileEntityLandmine) par1World.getBlockTileEntity(par2, par3, par4);
   if (te != null && te.getStackInSlot(0) != null
       || te.getStackInSlot(1) != null
       || te.getStackInSlot(2) != null) {
     return true;
   } else {
     return false;
   }
 }
Exemplo n.º 2
0
  @Override
  public IIcon getBlockTexture(
      IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) {
    TileEntityLandmine te =
        (TileEntityLandmine) par1IBlockAccess.getBlockTileEntity(par2, par3, par4);

    ItemStack camo = te.getStackInSlot(3);
    if (camo != null && camo.itemID < blocksList.length) {
      return Block.blocksList[camo.itemID].getIcon(par5, camo.getItemDamage());
    } else {
      return this.getIcon(par5, par1IBlockAccess.getBlockMetadata(par2, par3, par4));
    }
  }
Exemplo n.º 3
0
  @Override
  public int getLightValue(IBlockAccess world, int x, int y, int z) {
    if (world.getBlockId(x, y, z) == this.blockID
        && world.getBlockTileEntity(x, y, z) instanceof TileEntityLandmine) {
      TileEntityLandmine te = (TileEntityLandmine) world.getBlockTileEntity(x, y, z);

      if (te != null) {
        if (te.getStackInSlot(3) != null) {
          return lightValue[te.getStackInSlot(3).itemID];
        }
      }
    }
    return super.getLightValue(world, x, y, z);
  }
Exemplo n.º 4
0
 public void checkExplosion(World par1World, int par2, int par3, int par4, boolean skipCheck) {
   if (skipCheck || getMineState(par1World, par2, par3, par4) > 0) {
     if (hasItems(par1World, par2, par3, par4)) {
       TileEntityLandmine te = (TileEntityLandmine) par1World.getBlockTileEntity(par2, par3, par4);
       if (te.soundcountything <= 0) {
         par1World.playSoundEffect(
             (double) par2 + 0.5D,
             (double) par3 + 0.1D,
             (double) par4 + 0.5D,
             "random.click",
             0.3F,
             0.6F);
         te.setSoundPlayed();
       }
       new LandmineExplodeLogic(
               par1World, par2, par3, par4, getMineTriggerer(par1World, par2, par3, par4))
           .explode();
     }
   }
 }
Exemplo n.º 5
0
  @Override
  public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) {
    TileEntityLandmine tileentity =
        (TileEntityLandmine) par1World.getBlockTileEntity(par2, par3, par4);

    int metadata = par1World.getBlockMetadata(par2, par3, par4);

    if (tileentity != null
        && (!explodeOnBroken || !hasItems(par1World, par2, par3, par4))
        && par6 != 193
        && !tileentity.isExploding) {
      int id = this.blockID;
      if (id > 0) {
        ItemStack is = new ItemStack(id, 1, damageDropped(tileentity.triggerType));
        if (tileentity.isInvNameLocalized()) {
          is.setItemName(tileentity.getInvName());
        }
        dropBlockAsItem_do(
            par1World,
            par2,
            par3,
            par4,
            new ItemStack(id, 1, damageDropped(tileentity.triggerType)));
      }

      for (int j1 = 0; j1 < tileentity.getSizeInventory(); ++j1) {
        ItemStack itemstack = tileentity.getStackInSlot(j1);

        if (itemstack != null) {
          while (itemstack.stackSize > 0) {

            int ss = itemstack.stackSize;
            itemstack.stackSize -= ss;
            EntityItem entityitem =
                new EntityItem(
                    par1World,
                    (double) ((float) par2),
                    (double) ((float) par3),
                    (double) ((float) par4),
                    new ItemStack(itemstack.itemID, ss, itemstack.getItemDamage()));

            if (itemstack.hasTagCompound()) {
              entityitem
                  .getEntityItem()
                  .setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
            }

            float f3 = 0.05F;
            entityitem.motionX = (double) (f3);
            entityitem.motionY = (double) (f3 + 0.2F);
            entityitem.motionZ = (double) (f3);
            par1World.spawnEntityInWorld(entityitem);
          }
        }
      }

      par1World.func_96440_m(par2, par3, par4, par5);
    } else if (explodeOnBroken) {
      checkExplosion(par1World, par2, par3, par4, true);
    }

    super.breakBlock(par1World, par2, par3, par4, par5, par6);
  }