Exemplo n.º 1
0
 public int getItemBurnTime(ItemStack itemstack) {
   if (itemstack == null) {
     return 0;
   } else {
     Item item = itemstack.getItem();
     if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air) {
       Block block = Block.getBlockFromItem(item);
       if (block == Blocks.wooden_slab) {
         return 8000 / NuclearCraft.crusherCrushEfficiency;
       }
       if (block.getMaterial() == Material.wood) {
         return 16000 / NuclearCraft.crusherCrushEfficiency;
       }
       if (block == Blocks.coal_block) {
         return 960000 / NuclearCraft.crusherCrushEfficiency;
       }
     }
     if (item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("WOOD"))
       return 8000 / NuclearCraft.crusherCrushEfficiency;
     if (item instanceof ItemSword && ((ItemSword) item).getToolMaterialName().equals("WOOD"))
       return 8000 / NuclearCraft.crusherCrushEfficiency;
     if (item instanceof ItemHoe && ((ItemHoe) item).getToolMaterialName().equals("WOOD"))
       return 8000 / NuclearCraft.crusherCrushEfficiency;
     if (item == Items.stick) return 4000 / NuclearCraft.crusherCrushEfficiency;
     if (item == Items.coal) return 96000 / NuclearCraft.crusherCrushEfficiency;
     if (item == Items.lava_bucket) return 1200000 / NuclearCraft.crusherCrushEfficiency;
     if (item == Item.getItemFromBlock(Blocks.sapling))
       return 4000 / NuclearCraft.crusherCrushEfficiency;
     if (item == Items.blaze_rod) return 144000 / NuclearCraft.crusherCrushEfficiency;
     return (GameRegistry.getFuelValue(itemstack) * 48) / NuclearCraft.crusherCrushEfficiency;
   }
 }
 private void drawTally(int j, int k) {
   ItemHashMap<Integer> map = array.tally();
   int i = 0;
   int n = 8;
   for (ItemStack is : map.keySet()) {
     int dx = j + 10 + (i / n) * 50;
     int dy = k + 30 + (i % n) * 22;
     ItemStack is2 = is.copy();
     if (ChromaBlocks.CHROMA.match(is)) {
       is2 = ChromaItems.BUCKET.getStackOfMetadata(0);
     } else if (ChromaBlocks.RUNE.match(is)) {
       is2 = ChromaBlocks.RUNE.getStackOfMetadata(getElementByTick());
     } else if (page == ChromaResearch.PORTALSTRUCT
         && Block.getBlockFromItem(is.getItem()) == Blocks.bedrock) {
       is2 = ChromaItems.ENDERCRYSTAL.getStackOfMetadata(1);
     } else if (page == ChromaResearch.TREE
         && Block.getBlockFromItem(is.getItem()) == ChromaBlocks.PYLON.getBlockInstance()) {
       is2 = ChromaTiles.POWERTREE.getCraftedProduct();
     } else if (page == ChromaResearch.CLOAKTOWER
         && Block.getBlockFromItem(is.getItem())
             == ChromaBlocks.TILEMODELLED2.getBlockInstance()) {
       is2 = ChromaTiles.CLOAKING.getCraftedProduct();
     }
     api.drawItemStackWithTooltip(itemRender, fontRendererObj, is2, dx, dy);
     fontRendererObj.drawString(String.valueOf(map.get(is)), dx + 20, dy + 5, 0xffffff);
     i++;
   }
 }
  @Override
  public int getItemBurnTime(ItemStack p_145952_0_) {
    if (p_145952_0_ == null) {
      return 0;
    } else {
      Item item = p_145952_0_.getItem();

      if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air) {
        Block block = Block.getBlockFromItem(item);

        if (block == Blocks.wooden_slab) {
          return 100;
        }

        if (block.getMaterial() == Material.wood) {
          return 200;
        }

        if (block == Blocks.coal_block) {
          return 8000;
        }
      }
      if (item == Items.stick) return 75;
      if (item == Items.coal) return 800;
      if (item == Item.getItemFromBlock(Blocks.sapling)) return 100;
      if (item == Item.getItemFromBlock(ZombieModpackWorld.zombieFlesh)) {
        return 700;
      }
      return 0;
    }
  }
  private List<IBlockState> oresToBlocks(List<ItemStack> list) {
    List<IBlockState> blocks = Lists.newArrayList();
    for (ItemStack stack : list)
      if (Block.getBlockFromItem(stack.getItem()) != null
          && Block.getBlockFromItem(stack.getItem()) != Blocks.AIR)
        blocks.add(Block.getBlockFromItem(stack.getItem()).getStateFromMeta(stack.getItemDamage()));

    return blocks;
  }
 public Block getBlockVariant(int meta) {
   if (slabType == ReinforcedSlabType.OTHER) {
     return Block.getBlockFromItem(
         new ItemStack(mod_SecurityCraft.reinforcedStoneSlabs, 1, meta).getItem());
   } else {
     return Block.getBlockFromItem(
         new ItemStack(mod_SecurityCraft.reinforcedWoodSlabs, 1, meta).getItem());
   }
 }
Exemplo n.º 6
0
 @Override
 public String getUnlocalizedName(ItemStack stack) {
   String name =
       "tile."
           + ((IDivineMetaBlock) Block.getBlockFromItem(stack.getItem()))
               .getNames()[stack.getItemDamage()]
           + ((IDivineMetaBlock) Block.getBlockFromItem(stack.getItem())).getSuffix();
   return name;
 }
Exemplo n.º 7
0
  public static FluidStack fromItemStack(ItemStack itemStack) {
    if (itemStack == null
        || itemStack.getItem() == null
        || Block.getBlockFromItem(itemStack.getItem()) == null) return null;

    Block block = Block.getBlockFromItem(itemStack.getItem());
    Fluid fluid = getFluidTypeOfBlock(block);

    return fluid != null ? new FluidStack(fluid, FluidContainerRegistry.BUCKET_VOLUME) : null;
  }
  @Override
  public void invalidate() {
    super.invalidate();

    if (formed && !worldObj.isRemote) {
      //			int f = facing;
      TileEntity master = master();
      if (master == null) master = this;

      int startX = master.xCoord;
      int startY = master.yCoord;
      int startZ = master.zCoord;

      for (int yy = -1; yy <= 1; yy++)
        for (int zz = -1; zz <= 1; zz++)
          for (int xx = -1; xx <= 1; xx++) {
            ItemStack s = null;
            int prevPos = 0;
            TileEntity te = worldObj.getTileEntity(startX + xx, startY + yy, startZ + zz);
            if (te instanceof TileEntityBottlingMachine) {
              s = ((TileEntityBottlingMachine) te).getOriginalBlock();
              prevPos = ((TileEntityBottlingMachine) te).pos;
              ((TileEntityBottlingMachine) te).formed = false;
            }
            if (startX + xx == xCoord && startY + yy == yCoord && startZ + zz == zCoord)
              s = this.getOriginalBlock();
            if (s != null && Block.getBlockFromItem(s.getItem()) != null) {
              if (startX + xx == xCoord && startY + yy == yCoord && startZ + zz == zCoord)
                worldObj.spawnEntityInWorld(
                    new EntityItem(worldObj, xCoord + .5, yCoord + .5, zCoord + .5, s));
              else {
                if (Block.getBlockFromItem(s.getItem()) == IEContent.blockMetalMultiblocks)
                  worldObj.setBlockToAir(startX + xx, startY + yy, startZ + zz);
                worldObj.setBlock(
                    startX + xx,
                    startY + yy,
                    startZ + zz,
                    Block.getBlockFromItem(s.getItem()),
                    s.getItemDamage(),
                    0x3);
              }
              TileEntity tile = worldObj.getTileEntity(startX + xx, startY + yy, startZ + zz);
              if (tile instanceof TileEntityConveyorBelt) {
                int l = prevPos % 6 / 3;
                int w = prevPos % 3;
                int fExpected =
                    l == 1
                        ? (w == 0 ? ForgeDirection.OPPOSITES[facing] : facing)
                        : w < 2 ? ForgeDirection.ROTATION_MATRIX[mirrored ? 0 : 1][facing] : facing;
                ((TileEntityConveyorBelt) tile).facing = fExpected;
              }
            }
          }
    }
  }
Exemplo n.º 9
0
  private boolean smeltBlock(Coord4D block) {
    ItemStack stack = block.getStack(worldObj);

    if (stack == null) {
      return false;
    }

    ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(block.getStack(worldObj));

    if (result != null) {
      if (!worldObj.isRemote) {
        Block b = block.getBlock(worldObj);
        int meta = block.getMetadata(worldObj);

        if (Block.getBlockFromItem(result.getItem()) != Blocks.air) {
          worldObj.setBlock(
              block.xCoord,
              block.yCoord,
              block.zCoord,
              Block.getBlockFromItem(result.getItem()),
              result.getItemDamage(),
              3);
        } else {
          worldObj.setBlockToAir(block.xCoord, block.yCoord, block.zCoord);

          EntityItem item =
              new EntityItem(
                  worldObj,
                  block.xCoord + 0.5,
                  block.yCoord + 0.5,
                  block.zCoord + 0.5,
                  result.copy());
          item.motionX = 0;
          item.motionY = 0;
          item.motionZ = 0;
          worldObj.spawnEntityInWorld(item);
        }

        worldObj.playAuxSFXAtEntity(
            null,
            2001,
            block.xCoord,
            block.yCoord,
            block.zCoord,
            Block.getIdFromBlock(b) + (meta << 12));
      }

      spawnParticlesAt(new Pos3D(block).translate(0.5, 0.5, 0.5));

      return true;
    }

    return false;
  }
Exemplo n.º 10
0
 public static String getFullName(ItemStack itemStack) {
   if (itemStack == null) return null;
   String name;
   if (Block.getBlockFromItem(itemStack.getItem()) == Blocks.air) {
     name = GameData.getItemRegistry().getNameForObject(itemStack.getItem());
   } else {
     name =
         GameData.getBlockRegistry().getNameForObject(Block.getBlockFromItem(itemStack.getItem()));
   }
   return name + ":" + itemStack.getItemDamage();
 }
Exemplo n.º 11
0
  public static boolean contains(ArrayList list, ItemStack stack) {
    if (stack == null || stack.getItem() == null) return false;

    Object object = stack.getItem();

    Material material = null;

    if (object instanceof ItemBlock) {
      object = Block.getBlockFromItem((Item) object);
      material = ((Block) object).getMaterial();
    }

    int[] ores = OreDictionary.getOreIDs(stack);

    for (int i = 0; i < list.size(); i++) {
      if (list.get(i) instanceof ItemStack
          && ItemStack.areItemStacksEqual(stack, (ItemStack) list.get(i))) return true;

      if (list.get(i) == object) return true;

      if (list.get(i) == material) return true;

      if (list.get(i) instanceof String)
        for (int j = 0; j < ores.length; j++) {
          if (OreDictionary.getOreName(ores[j]).contains((CharSequence) list.get(i))) return true;
        }
    }
    return false;
  }
Exemplo n.º 12
0
  public void newDay(Collection<TownBuilding> buildings) {
    Set<GatheringLocation> previous = new HashSet(locations);
    locations = new HashSet();

    // Remove all previous locations
    for (GatheringLocation location : previous) {
      World world = DimensionManager.getWorld(location.dimension);
      if (world.getBlock(location.x, location.y, location.z) == location.block) {
        if (world.getBlockMetadata(location.x, location.y, location.z) == location.meta) {
          world.setBlockToAir(location.x, location.y, location.z);
        }
      }
    }

    // Create some new spawn spots based on where we have buildings
    for (TownBuilding building : buildings) {
      World world = DimensionManager.getWorld(building.dimension);
      int placed = 0;
      for (int i = 0; i < 64 && placed < 10; i++) {
        int x = building.xCoord + 32 - world.rand.nextInt(64);
        int y = building.yCoord + 4 - world.rand.nextInt(8);
        int z = building.zCoord + 32 - world.rand.nextInt(64);
        if (world.getBlock(x, y, z) == Blocks.grass
            && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z)) {
          ItemStack random = getRandomBlock();
          Block block = Block.getBlockFromItem(random.getItem());
          int meta = random.getItemDamage();
          if (world.setBlock(x, y + 1, z, block, meta, 2)) {
            locations.add(new GatheringLocation(block, meta, building.dimension, x, y + 1, z));
            placed++;
          }
        }
      }
    }
  }
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int side,
      float xOffset,
      float yOffset,
      float zOffset) {

    ItemStack ci = player.inventory.mainInventory[player.inventory.currentItem];
    if (ci != null && Block.getBlockFromItem(ci.getItem()).equals(this)) {
      for (int i = y + 1, e = world.getActualHeight(); i < e; ++i) {
        Block block = world.getBlock(x, i, z);
        if (block.isAir(world, x, i, z) || block.isReplaceable(world, x, i, z)) {
          if (!world.isRemote && world.setBlock(x, i, z, this, 0, 3)) {
            world.playAuxSFXAtEntity(null, 2001, x, i, z, Block.getIdFromBlock(this));
            if (!player.capabilities.isCreativeMode) {
              ci.stackSize--;
              if (ci.stackSize == 0) {
                player.inventory.mainInventory[player.inventory.currentItem] = null;
              }
            }
          }
          return true;
        } else if (!block.equals(this)) {
          return false;
        }
      }
    }
    return false;
  }
 @Override
 public boolean onBlockActivated(
     World world,
     int x,
     int y,
     int z,
     EntityPlayer player,
     int side,
     float hitX,
     float hitY,
     float hitZ) {
   if (player.getCurrentEquippedItem() != null) {
     if (player.getCurrentEquippedItem().getItem() instanceof ItemBlock) {
       if (world.getTileEntity(x, y, z) instanceof TileEntityDisguiseBlock) {
         TileEntityDisguiseBlock te = (TileEntityDisguiseBlock) world.getTileEntity(x, y, z);
         if (te != null) {
           if (!player.isSneaking()) {
             if (!((ItemBlock) player.getCurrentEquippedItem().getItem())
                 .field_150939_a.hasTileEntity(te.getMetadata())) {
               te.setBlock(
                   Block.getBlockFromItem(player.getCurrentEquippedItem().getItem()),
                   player.getCurrentEquippedItem().getItemDamage());
               return true;
             }
           }
         }
       }
     }
   }
   return false;
 }
Exemplo n.º 15
0
  @SubscribeEvent
  public void CraftingEvent(PlayerEvent.ItemCraftedEvent event) {
    if (event.crafting.getItem() == ModItems.nileEssence) {
      event.player.addStat(ModAchievements.NileStart, 1);
    }
    if (event.crafting.getItem() == ModItems.nileDust) {
      event.player.addStat(ModAchievements.NileStart, 1);
    }
    if (event.crafting.getItem() == ModItems.nileSword) {
      event.player.addStat(ModAchievements.buildNileSword, 1);
    }
    if (Block.getBlockFromItem(event.crafting.getItem()).equals(ModBlocks.nileWorktable)) {
      event.player.addStat(ModAchievements.buildNWorkBench, 1);
    }
    if (event.crafting.getItem() == ModItems.nileBone) {
      event.player.addStat(ModAchievements.buildBone, 1);
    }

    if (Constants.DEF_DARKLOAD == true) {
      if (event.crafting.getItem() == ModItems.darkEssence) {
        event.player.addStat(ModAchievements.DarkStart, 1);
      }
      if (event.crafting.getItem() == ModItems.darkDust) {
        event.player.addStat(ModAchievements.DarkStart, 1);
      }
      /*if(event.crafting.getItem() == ModItems.darkSword){
      	event.player.addStat(ModAchievements.buildNileSword, 1);
      }
      if(event.crafting.getItem() == ModItems.darkNileBone){
      	event.player.addStat(ModAchievements.buildBone, 1);
      }*/
    }
  }
 @Override
 public String getUnlocalizedName(ItemStack itemStack) {
   BlockDirtSlab slab = (BlockDirtSlab) Block.getBlockFromItem(itemStack.getItem());
   return super.getUnlocalizedName()
       + "."
       + (new StringBuilder()).append(slab.func_150002_b(itemStack.getItemDamage())).toString();
 }
Exemplo n.º 17
0
 @Override
 public IBlock asBlock() {
   ResourceLocation name =
       Block.REGISTRY.getNameForObject(Block.getBlockFromItem(stack.getItem()));
   if (Block.REGISTRY.containsKey(name)) {
     return new MCItemBlock(stack);
   } else {
     throw new ClassCastException("This item is not a block");
   }
 }
Exemplo n.º 18
0
 @Override
 public int getExpDrop(IBlockAccess world, int meta, int fortune) {
   if (name.equals("oreCoal")) return Blocks.coal_ore.getExpDrop(world, meta, fortune);
   else if (name.equals("oreIron")) return Blocks.iron_ore.getExpDrop(world, meta, fortune);
   else if (name.equals("oreLapis")) return Blocks.lapis_ore.getExpDrop(world, meta, fortune);
   else if (name.equals("oreGold")) return Blocks.gold_ore.getExpDrop(world, meta, fortune);
   else if (name.equals("oreDiamond")) return Blocks.diamond_ore.getExpDrop(world, meta, fortune);
   else if (name.equals("oreRedstone"))
     return Blocks.redstone_ore.getExpDrop(world, meta, fortune);
   else if (name.equals("oreEmerald")) return Blocks.emerald_ore.getExpDrop(world, meta, fortune);
   else if (name.equals("oreSulfur"))
     return ArtificeBlocks.blockSulfur.getExpDrop(world, meta, fortune);
   else if (name.equals("oreEnder"))
     return ArtificeBlocks.blockEnderOre.getExpDrop(world, meta, fortune);
   else if (Block.getBlockFromItem(ItemHelper.getOre(name).getItem()) != this)
     return Block.getBlockFromItem(ItemHelper.getOre(name).getItem())
         .getExpDrop(world, meta, fortune);
   else return 0;
 }
Exemplo n.º 19
0
  @Override
  public boolean onBlockActivated(
      World par1World,
      int par2,
      int par3,
      int par4,
      EntityPlayer par5EntityPlayer,
      int par6,
      float par7,
      float par8,
      float par9) {
    ItemStack itemstack = par5EntityPlayer.inventory.getCurrentItem();
    int l = 0;
    l = this.thisChainLength(par1World, par2, par3, par4);

    if (itemstack == null) {
      if (l < 0) {
        return false;
      } else if (l < 65) {
        par5EntityPlayer.inventory.addItemStackToInventory(
            new ItemStack(DCsIronChain.ironChain, l));
        par5EntityPlayer.inventory.addItemStackToInventory(
            new ItemStack(DCsIronChain.anchorBolt, 1));
        if (l > 0) {
          par1World.playSoundAtEntity(par5EntityPlayer, "dcironchain:chain", 1.0F, 0.7F);
        } else {
          par1World.playSoundAtEntity(par5EntityPlayer, "random.pop", 0.4F, 1.9F);
        }

        for (int i = 0; i < (l + 1); i++) {
          par1World.setBlockToAir(par2, (par3 - l + i), par4);
        }
      }
      return false;
    } else if (this.canPlace(itemstack)) {
      Block placeID = Block.getBlockFromItem(itemstack.getItem());
      if (placeID == null) return false;
      int placeMeta = itemstack.getItemDamage();

      if ((l < 65) && par1World.isAirBlock(par2, (par3 - l - 1), par4)) {
        par1World.setBlock(par2, (par3 - l - 1), par4, placeID, placeMeta, 3);
        par1World.playSoundAtEntity(par5EntityPlayer, "dcironchain:chain", 1.0F, 0.7F);
        if (!par5EntityPlayer.capabilities.isCreativeMode && --itemstack.stackSize <= 0) {
          par5EntityPlayer.inventory.setInventorySlotContents(
              par5EntityPlayer.inventory.currentItem, (ItemStack) null);
        }
        return true;
      } else {
        return false;
      }

    } else {
      return false;
    }
  }
Exemplo n.º 20
0
  @Override
  public void loadUsageRecipes(ItemStack ingredient) {
    for (HeatRecipes recipe : RecipeManager.heat) {
      if ((recipe == null) || (ingredient.getItem() == null)) continue;

      if ((recipe.matches(ingredient))
          || (recipe.matches(Block.getBlockFromItem(ingredient.getItem())))) {
        arecipes.add(new CachedHeatRecipe(recipe));
      }
    }
  }
  @Override
  public void loadUsageRecipes(ItemStack ingredient) {
    if (Block.getBlockFromItem(ingredient.getItem()) instanceof BlockSpecialFlower) {
      ItemStack floatingFlower =
          new ItemStack(ModBlocks.floatingFlower, 1, OreDictionary.WILDCARD_VALUE);
      ItemStack result = new ItemStack(ModBlocks.floatingSpecialFlower);
      result.setTagCompound((NBTTagCompound) ingredient.getTagCompound().copy());

      arecipes.add(new CachedFloatingFlowerRecipe(floatingFlower, ingredient.copy(), result));
    }
  }
  @Override
  public void loadCraftingRecipes(ItemStack result) {
    if (Block.getBlockFromItem(result.getItem()) instanceof BlockFloatingSpecialFlower) {
      ItemStack floatingFlower =
          new ItemStack(ModBlocks.floatingFlower, 1, OreDictionary.WILDCARD_VALUE);
      ItemStack specialFlower = new ItemStack(ModBlocks.specialFlower);
      specialFlower.setTagCompound((NBTTagCompound) result.getTagCompound().copy());

      arecipes.add(new CachedFloatingFlowerRecipe(floatingFlower, specialFlower, result.copy()));
    }
  }
  @Override
  public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
    Item item = getItem(world, x, y, z);

    if (item == null) {
      return null;
    }

    Block block = item instanceof ItemBlock && !isFlowerPot() ? Block.getBlockFromItem(item) : this;
    return new ItemStack(item, 1, block.getDamageValue(world, x, y, z));
  }
 @Override
 public int getColorFromItemstack(ItemStack stack, int par2) {
   ItemStack contains;
   IBlockEverything block = (IBlockEverything) Block.getBlockFromItem(stack.getItem());
   if (stack.hasTagCompound()) {
     contains = block.getItemStackFromBlock(stack);
   } else {
     contains = null;
   }
   return EverythingColor.getAverageColor(contains);
 }
  @Override
  public void invalidate() {
    super.invalidate();
    if (formed && !worldObj.isRemote) {
      int startX = xCoord - offset[0];
      int startY = yCoord - offset[1];
      int startZ = zCoord - offset[2];
      if (!(offset[0] == 0 && offset[1] == 0 && offset[2] == 0)
          && !(worldObj.getTileEntity(startX, startY, startZ) instanceof TileEntitySheetmetalTank))
        return;

      for (int yy = 0; yy <= 4; yy++)
        for (int xx = -1; xx <= 1; xx++)
          for (int zz = -1; zz <= 1; zz++) {
            ItemStack s = null;
            TileEntity te = worldObj.getTileEntity(startX + xx, startY + yy, startZ + zz);
            if (te instanceof TileEntitySheetmetalTank) {
              s = ((TileEntitySheetmetalTank) te).getOriginalBlock();
              ((TileEntitySheetmetalTank) te).formed = false;
            }
            if (startX + xx == xCoord && startY + yy == yCoord && startZ + zz == zCoord)
              s = this.getOriginalBlock();
            if (s != null && Block.getBlockFromItem(s.getItem()) != null) {
              if (startX + xx == xCoord && startY + yy == yCoord && startZ + zz == zCoord)
                worldObj.spawnEntityInWorld(
                    new EntityItem(worldObj, xCoord + .5, yCoord + .5, zCoord + .5, s));
              else {
                if (Block.getBlockFromItem(s.getItem()) == IEContent.blockMetalMultiblocks)
                  worldObj.setBlockToAir(startX + xx, startY + yy, startZ + zz);
                worldObj.setBlock(
                    startX + xx,
                    startY + yy,
                    startZ + zz,
                    Block.getBlockFromItem(s.getItem()),
                    s.getItemDamage(),
                    0x3);
              }
            }
          }
    }
  }
Exemplo n.º 26
0
 private boolean shouldPlantSapling() {
   if (this.hasEnchantment(Enchantment.infinity)) return true;
   if (treeCopy.isDyeTree()) {
     return inv[0] != null
         && inv[0].stackSize > 0
         && Block.getBlockFromItem(inv[0].getItem()) == TreeGetter.getSaplingID();
   } else if (treeCopy.getTreeType() != null) {
     return inv[0] != null
         && inv[0].stackSize > 0
         && ReikaItemHelper.matchStacks(inv[0], treeCopy.getSapling());
   } else return false;
 }
Exemplo n.º 27
0
 @Override
 public ItemStack createStackedBlock(int p_149644_1_) {
   if (name.equals("oreCoal")) return new ItemStack(Blocks.coal_ore);
   else if (name.equals("oreIron")) return new ItemStack(Blocks.iron_ore);
   else if (name.equals("oreLapis")) return new ItemStack(Blocks.lapis_ore);
   else if (name.equals("oreGold")) return new ItemStack(Blocks.gold_ore);
   else if (name.equals("oreDiamond")) return new ItemStack(Blocks.diamond_ore);
   else if (name.equals("oreRedstone")) return new ItemStack(Blocks.redstone_ore);
   else if (name.equals("oreEmerald")) return new ItemStack(Blocks.emerald_ore);
   else if (name.equals("oreSulfur")) return new ItemStack(ArtificeBlocks.blockSulfur);
   else if (name.equals("oreEnder")) return new ItemStack(ArtificeBlocks.blockEnderOre);
   else return new ItemStack(Block.getBlockFromItem(ItemHelper.getOre(name).getItem()));
 }
  private double getMaxEnergyCapacity() {
    final Block blockID = Block.getBlockFromItem(this);
    final IBlockDefinition energyCell = Api.INSTANCE.definitions().blocks().energyCell();
    for (Block block : energyCell.maybeBlock().asSet()) {
      if (blockID == block) {
        return 200000;
      } else {
        return 8 * 200000;
      }
    }

    return 0;
  }
 @Override
 public void performEffect(IMasterRitualStone ritualStone) {
   String owner = ritualStone.getOwner();
   World world = ritualStone.getWorld();
   int x = ritualStone.getXCoord();
   int y = ritualStone.getYCoord();
   int z = ritualStone.getZCoord();
   TileEntity tile = world.getTileEntity(x, y + 1, z);
   IInventory tileEntity;
   if (tile instanceof IInventory) {
     tileEntity = (IInventory) tile;
   } else {
     return;
   }
   if (tileEntity.getSizeInventory() <= 0) {
     return;
   }
   int currentEssence = SoulNetworkHandler.getCurrentEssence(owner);
   if (currentEssence < this.getCostPerRefresh()) {
     EntityPlayer entityOwner = SpellHelper.getPlayerForUsername(owner);
     if (entityOwner == null) {
       return;
     }
     SoulNetworkHandler.causeNauseaToPlayer(owner);
   } else {
     for (int i = x - 2; i <= x + 2; i++) {
       for (int k = z - 2; k <= z + 2; k++) {
         for (int inv = 0; inv < tileEntity.getSizeInventory(); inv++) {
           if (world.getBlock(i, y, k).isReplaceable(world, i, y + 1, k)
               && tileEntity.getStackInSlot(inv) != null
               && tileEntity.getStackInSlot(inv).stackSize != 0) {
             if (tileEntity.getStackInSlot(inv).getItem() instanceof ItemBlock
                 && world.getBlock(i, y - 1, k) != null) {
               world.setBlock(
                   i,
                   y,
                   k,
                   Block.getBlockFromItem(tileEntity.getStackInSlot(inv).getItem()),
                   tileEntity.getStackInSlot(inv).getItemDamage(),
                   3);
               tileEntity.decrStackSize(inv, 1);
               tileEntity.markDirty();
               SoulNetworkHandler.syphonFromNetwork(owner, getCostPerRefresh());
             }
           }
         }
       }
     }
   }
 }
Exemplo n.º 30
0
  public static void register() {
    GameRegistry.registerBlock(blockExplosive, ItemBlockExplosive.class, "explosives");
    GameRegistry.registerBlock(blockMachine, ItemBlockMachine.class, "machine");
    GameRegistry.registerBlock(blockSulfurOre, "oreSulfur");

    /** Check for existence of radioactive Blocks. If it does not exist, then create it. */
    if (OreDictionary.getOres("blockRadioactive").size() > 0) {
      blockRadioactive =
          Block.getBlockFromItem(OreDictionary.getOres("blockRadioactive").get(0).getItem());
      DefenseTech.LOGGER.fine("Detected radioative block from another mod, utilizing it.");
    } else {
      blockRadioactive = Blocks.mycelium;
    }
  }