/** * Checks if an ItemStack contains an ore item. This is done by checking the item extends * BlockOre, or if the ore dictionary for entries that start with 'ore'. It will also check * the display name of the stack to see if it has the word Ore in it. * * @param stack The ItemStack to check. * @param checkName Whether or not the name of the ItemStack should be checked. * @return Whether or not the ItemStack is an ore. */ public static boolean isOre (@Nonnull ItemStack stack, boolean checkName) { if (Block.getBlockFromItem(stack.getItem()) instanceof BlockOre) { return true; } for (final int oreID : OreDictionary.getOreIDs(stack)) { if (OreDictionary.getOreName(oreID).startsWith("ore")) { return true; } } if (checkName && stack.getItem().getItemStackDisplayName(stack).matches(".*(^|\\s)([oO]re)($|\\s).")) { return true; } return false; }
@Override public boolean onItemUse(ItemStack stack,EntityPlayer player, World world, int x, int y,int z, int par7, float par8, float par9, float par10) { if(RpgInventoryMod.playerClass.contains(RpgBaseAddon.CLASSALCHEMIST)){ Block b = world.getBlock(x, y, z); if(b instanceof BlockOre){ if(b.equals(Blocks.gold_ore)) return true; world.setBlockToAir(x, y, z); if(b.equals(Blocks.lapis_ore)) world.setBlock(x, y, z, Blocks.lapis_block); else world.setBlock(x, y, z, Blocks.gold_ore); world.markBlockForUpdate(x, y, z); stack.damageItem(5, player); } } return true; }
private boolean shouldMineBlock(Block block, int x, int y, int z) { if (block instanceof BlockOre || block instanceof BlockRedstoneOre) { InventoryBasic minerInventory = this.miner.inventory; if (InventoryUtils.hasRoomInInventory(minerInventory)) { return true; } else { World world = this.miner.worldObj; ArrayList<ItemStack> items = block.getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 0); for (ItemStack item : items) { if (InventoryUtils.canFitItem(item, minerInventory)) { return true; } } } } return false; }
@Override public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int p_77663_4_, boolean inHand) { super.onUpdate(stack,worldIn,entityIn,p_77663_4_,inHand); if (inHand && worldIn.getTotalWorldTime() % 10 == 0 && !worldIn.isRemote) { boolean found = false; int x = (int) entityIn.posX; int y = (int) entityIn.posY; int z = (int) entityIn.posZ; for (int i=x-10;i<x+10;i++) { for (int j=z-10;j<z+10;j++) { for (int k=y-5;k<y+5;k++) { Block b = worldIn.getBlock(i, k, j); if ((b instanceof BlockOre || b instanceof DerpyOres || b.getUnlocalizedName().contains("ore"))&&b != GameRegistry.findBlock("minecraft", "coal_ore")) { found = true; } } } } NBTTagCompound tag = stack.getTagCompound(); if (tag == null) tag = new NBTTagCompound(); tag.setBoolean("active", found); stack.setTagCompound(tag); } }
private void seedMap() { // Iterate through the blockmap looking for known pattern types. // Though they probably should all be registered with Forge // dictionary it's not a requirement. final Iterator<Block> itr = Block.REGISTRY.iterator(); while (itr.hasNext()) { final Block block = itr.next(); final String blockName = MCHelper.nameOf(block); if (block instanceof BlockCrops) { final BlockCrops crop = (BlockCrops) block; if (crop.getMaxAge() == 3) { this.registerBlocks("#beets", blockName); } else if (blockName.equals("minecraft:wheat")) { this.registerBlocks("#wheat", blockName); } else if (crop.getMaxAge() == 7) { this.registerBlocks("#crop", blockName); } } else if (block instanceof BlockSapling) { this.registerBlocks("#sapling", blockName); } else if (block instanceof BlockReed) { this.registerBlocks("#reed", blockName); } else if (block instanceof BlockFence) { this.registerBlocks("#fence", blockName); } else if (block instanceof BlockFlower || block instanceof BlockMushroom) { this.registerBlocks("NOT_EMITTER", blockName); } else if (block instanceof BlockLog || block instanceof BlockPlanks) { this.registerBlocks("wood", blockName); } else if (block instanceof BlockDoor) { this.registerBlocks("bluntwood", blockName); } else if (block instanceof BlockLeaves) { this.registerBlocks("leaves", blockName); } else if (block instanceof BlockOre) { this.registerBlocks("ore", blockName); } else if (block instanceof BlockIce) { this.registerBlocks("ice", blockName); } } }
public static void registerForgeOres(){ for (String s : OreDictionary.getOreNames()) { if (s.contains("ore")){ OreDictionary.getOres(s).stream().filter(ore -> ore.getItem() instanceof ItemBlock).forEach(ore -> { Block block = ((ItemBlock) ore.getItem()).getBlock(); if (!(block instanceof BlockOre)) { OreUtil.addOre((BlockType) block); } }); } } }
/** * Checks if an ItemStack contains an ore item. This is done by checking the item extends * BlockOre, or if the ore dictionary for entries that start with 'ore'. It will also check * the display name of the stack to see if it has the word Ore in it. * * @param stack The ItemStack to check. * @param checkName Whether or not the name of the ItemStack should be checked. * @return Whether or not the ItemStack is an ore. */ public static boolean isOre (ItemStack stack, boolean checkName) { if (stack == null || stack.getItem() == null) return false; if (Block.getBlockFromItem(stack.getItem()) instanceof BlockOre) return true; for (final int oreID : OreDictionary.getOreIDs(stack)) if (OreDictionary.getOreName(oreID).startsWith("ore")) return true; if (checkName && stack.getItem().getItemStackDisplayName(stack).matches(".*(^|\\s)([oO]re)($|\\s).")) return true; return false; }
public void removeNearBlock(World world, BlockPos pos) { if(world.getBlockState(pos).getBlock() instanceof BlockOre) { world.setBlockToAir(pos); } }
protected boolean caveableBlock(IBlockState blockstate, IBlockState aboveblockstate) { if (aboveblockstate.getBlock().getMaterial() == Material.water) return false; return blockstate.getBlock() instanceof BlockRock || blockstate.getBlock() instanceof BlockOre || blockstate.getBlock() instanceof BlockSubSoil || blockstate.getBlock() instanceof BlockTopSoil; }
private void generatePillarSupports(World world, Chunk c, int x, int z) { if (FysiksFun.settings.worldSupportBlockID <= 0) { // System.out.println("warning... worldSupportBlockID: "+FysiksFun.settings.worldSupportBlockID); return; } for (int tries = 0; tries < 4; tries++) { int maxY = 10 + FysiksFun.rand.nextInt(92); int dx = FysiksFun.rand.nextInt(16); int dz = (FysiksFun.rand.nextInt(16) + Counters.tick) % 16; int y; for (y = 20; y < maxY; y++) { int id = c.getBlockID(dx, y, dz); if (id == 0) break; if (id == Block.dirt.blockID || id == Block.stone.blockID || id == Block.grass.blockID || id == Block.bedrock.blockID) continue; if (Block.blocksList[id] == null) { FysiksFun.logger.log(Level.SEVERE, "Bad block id=" + id + " found @" + Util.xyzString(x + dx, y, z + dz) + " while generating world supports"); break; } if (Block.blocksList[id] instanceof BlockOre) continue; break; } if (y == 20) continue; // This is a flatworld, don't do any pillars y = y - FysiksFun.rand.nextInt(6) - 2; if (y <= 8) continue; for (int tmp = -FysiksFun.rand.nextInt(8); tmp <= 0; tmp++) world.setBlock(x + dx, y + tmp, z + dz, FysiksFun.settings.worldSupportBlockID); // c.setBlockIDWithMetadata(dx, tmp, dz, Block.bedrock.blockID, 0); // System.out.println("Bedrock support @" + Util.xyzString(x + dx, // y, z + dz)); } }
private void breaking(ItemStack stack, BlockPos pos, EntityPlayerMP playermp) { World world = playermp.worldObj; IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); if (!world.isRemote) { if (!world.isAirBlock(pos)) { block.onBlockHarvested(world, pos, state, playermp); if (block.removedByPlayer(world, pos, playermp, true)) { block.onBlockDestroyedByPlayer(world, pos, state); if (!playermp.capabilities.isCreativeMode) { block.harvestBlock(world, playermp, pos, state, world.getTileEntity(pos)); block.dropXpOnBlockBreak(world, pos, block.getExpDrop(world, pos, 0)); stack.damageItem(1, playermp); } } playermp.playerNetServerHandler.sendPacket(new S23PacketBlockChange(world, pos)); } } if (block instanceof BlockRedstoneOre || block instanceof BlockOre || blocks.contains(block)) { if (playermp.worldObj.getBlockState(pos.up()).getBlock() instanceof BlockRedstoneOre || playermp.worldObj.getBlockState(pos.up()).getBlock() instanceof BlockOre || blocks.contains(playermp.worldObj.getBlockState(pos.up()).getBlock())) { this.breaking(stack, pos.up(), playermp); } if (playermp.worldObj.getBlockState(pos.down()).getBlock() instanceof BlockRedstoneOre || playermp.worldObj.getBlockState(pos.down()).getBlock() instanceof BlockOre || blocks.contains(playermp.worldObj.getBlockState(pos.down()).getBlock())) { this.breaking(stack, pos.down(), playermp); } if (playermp.worldObj.getBlockState(pos.north()).getBlock() instanceof BlockRedstoneOre || playermp.worldObj.getBlockState(pos.north()).getBlock() instanceof BlockOre || blocks.contains(playermp.worldObj.getBlockState(pos.north()).getBlock())) { this.breaking(stack, pos.north(), playermp); } if (playermp.worldObj.getBlockState(pos.south()).getBlock() instanceof BlockRedstoneOre || playermp.worldObj.getBlockState(pos.south()).getBlock() instanceof BlockOre || blocks.contains(playermp.worldObj.getBlockState(pos.south()).getBlock())) { this.breaking(stack, pos.south(), playermp); } if (playermp.worldObj.getBlockState(pos.west()).getBlock() instanceof BlockRedstoneOre || playermp.worldObj.getBlockState(pos.west()).getBlock() instanceof BlockOre || blocks.contains(playermp.worldObj.getBlockState(pos.west()).getBlock())) { this.breaking(stack, pos.west(), playermp); } if (playermp.worldObj.getBlockState(pos.east()).getBlock() instanceof BlockRedstoneOre || playermp.worldObj.getBlockState(pos.east()).getBlock() instanceof BlockOre || blocks.contains(playermp.worldObj.getBlockState(pos.east()).getBlock())) { this.breaking(stack, pos.east(), playermp); } } }
public static boolean isOre(BlockType blockState){ return blockState instanceof BlockOre | Ores.contains(blockState); }
@EventHandler public void preInit(FMLPreInitializationEvent event) { tabAtlantis = new CreativeTabs("tabAtlantis") {public Item getTabIconItem() {return AtlantisMod.pearl;}}; blockAtlantisPortal = (BlockPortal)(new BlockPortal()).setBlockName("blockAtlantisPortal").setBlockTextureName("portal"); blockDeepSand = (new BlockFalling()).setHardness(0.5F).setStepSound(Block.soundTypeSand).setBlockName("blockDeepSand").setCreativeTab(AtlantisMod.tabAtlantis).setBlockTextureName("atlantismod:deep_sand"); blockRottenPlanks = (new BlockRottenPlanks()).setHardness(1.5F).setStepSound(Block.soundTypeWood).setBlockName("rottenPlanks").setCreativeTab(AtlantisMod.tabAtlantis).setBlockTextureName("atlantismod:rotten_planks"); pearl = (new Item()).setUnlocalizedName("pearl").setCreativeTab(AtlantisMod.tabAtlantis).setTextureName("atlantismod:pearl"); atlantisWand = (ItemAtlantisWand)(new ItemAtlantisWand()).setUnlocalizedName("atlantisWand").setCreativeTab(AtlantisMod.tabAtlantis).setTextureName("atlantismod:portal_wand").setMaxStackSize(1); trident = (new ItemTrident(AtlantisMod.Trident)).setCreativeTab(AtlantisMod.tabAtlantis).setTextureName("atlantismod:trident").setUnlocalizedName("trident").setMaxStackSize(1); atlantisEye = (new ItemAtlantisEye(2,1.2F,false)).setAlwaysEdible().setUnlocalizedName("atlantisEye").setCreativeTab(AtlantisMod.tabAtlantis).setTextureName("atlantismod:atlantis_eye").setMaxStackSize(16); scepter = (new Item()).setUnlocalizedName("scepter").setCreativeTab(AtlantisMod.tabAtlantis).setTextureName("atlantismod:scepter").setMaxStackSize(1); necklace = (ItemNecklaceArmor)(new ItemNecklaceArmor(AtlantisMod.NecklaceArmor,0,1)).setUnlocalizedName("necklace").setMaxDamage(10000).setCreativeTab(AtlantisMod.tabAtlantis).setTextureName("atlantismod:necklace").setMaxStackSize(1); bubbleWand = (ItemBubbleWand)(new ItemBubbleWand()).setUnlocalizedName("bubbleWand").setCreativeTab(AtlantisMod.tabAtlantis).setTextureName("atlantismod:bubble_wand").setMaxStackSize(1); fishHead = (new Item()).setUnlocalizedName("fishHead").setCreativeTab(AtlantisMod.tabAtlantis).setTextureName("atlantismod:fish_head"); blockPearl = (new BlockCompressed(MapColor.snowColor)).setHardness(3.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setBlockName("blockPearl").setBlockTextureName("atlantismod:pearl_block").setCreativeTab(AtlantisMod.tabAtlantis); oreAtlanteum = (new BlockOre()).setHardness(3.0F).setResistance(5.0F).setBlockName("oreAtlanteum").setBlockTextureName("atlantismod:atlanteum_ore").setCreativeTab(AtlantisMod.tabAtlantis); blockAtlanteum = (new BlockCompressed(MapColor.cyanColor)).setHardness(3.0F).setResistance(10.0F).setStepSound(Block.soundTypeMetal).setBlockName("blockAtlanteum").setBlockTextureName("atlantismod:atlanteum_block").setCreativeTab(AtlantisMod.tabAtlantis); atlanteum = (new Item()).setUnlocalizedName("atlanteum").setCreativeTab(AtlantisMod.tabAtlantis).setTextureName("atlantismod:atlanteum"); nuggetAtlanteum = (new Item()).setUnlocalizedName("nuggetAtlanteum").setCreativeTab(AtlantisMod.tabAtlantis).setTextureName("atlantismod:atlanteum_nugget"); divingHelmet = (ItemDivingArmor)(new ItemDivingArmor(AtlantisMod.DivingSuit,0,0)).setCreativeTab(AtlantisMod.tabAtlantis).setMaxStackSize(1).setUnlocalizedName("divingHelmet").setTextureName("atlantismod:diving_helmet"); scubaSuit = (ItemDivingArmor)(new ItemDivingArmor(AtlantisMod.DivingSuit,0,1)).setCreativeTab(AtlantisMod.tabAtlantis).setMaxStackSize(1).setUnlocalizedName("scubaSuit").setTextureName("atlantismod:scuba_suit"); oxygenTank = (ItemDivingArmor)(new ItemDivingArmor(AtlantisMod.DivingSuit,0,2)).setMaxDamage(10000).setCreativeTab(AtlantisMod.tabAtlantis).setMaxStackSize(1).setUnlocalizedName("oxygenTank").setTextureName("atlantismod:oxygen_tank"); flippers = (ItemDivingArmor)(new ItemDivingArmor(AtlantisMod.DivingSuit,0,3)).setCreativeTab(AtlantisMod.tabAtlantis).setMaxStackSize(1).setUnlocalizedName("flippers").setTextureName("atlantismod:flippers"); blockSeaweed = (new BlockSeaweed()).setHardness(0.0F).setStepSound(Block.soundTypeGrass).setBlockName("blockSeaweed").setBlockTextureName("atlantismod:seaweed"); itemSeaweed = (new ItemSeaweed(AtlantisMod.blockSeaweed)).setUnlocalizedName("itemSeaweed").setCreativeTab(AtlantisMod.tabAtlantis).setTextureName("atlantismod:seaweed_item"); blockCoralOrange = (new BlockCoral(itemCoralOrange)).setHardness(0.0F).setStepSound(Block.soundTypeGrass).setBlockName("blockCoralOrange").setBlockTextureName("atlantismod:orange_coral"); blockCoralRed = (new BlockCoral(itemCoralRed)).setHardness(0.0F).setStepSound(Block.soundTypeGrass).setBlockName("blockCoralRed").setBlockTextureName("atlantismod:red_coral"); blockCoralPurple = (new BlockCoral(itemCoralPurple)).setHardness(0.0F).setStepSound(Block.soundTypeGrass).setBlockName("blockCoralPurple").setBlockTextureName("atlantismod:purple_coral"); blockCoralYellow = (new BlockCoral(itemCoralYellow)).setHardness(0.0F).setStepSound(Block.soundTypeGrass).setBlockName("blockCoralYellow").setBlockTextureName("atlantismod:yellow_coral"); itemCoralOrange = (new ItemSeaweed(AtlantisMod.blockCoralOrange)).setUnlocalizedName("itemCoralOrange").setCreativeTab(AtlantisMod.tabAtlantis).setTextureName("atlantismod:orange_coral_item"); itemCoralRed = (new ItemSeaweed(AtlantisMod.blockCoralRed)).setUnlocalizedName("itemCoralRed").setCreativeTab(AtlantisMod.tabAtlantis).setTextureName("atlantismod:red_coral_item"); itemCoralPurple = (new ItemSeaweed(AtlantisMod.blockCoralPurple)).setUnlocalizedName("itemCoralPurple").setCreativeTab(AtlantisMod.tabAtlantis).setTextureName("atlantismod:purple_coral_item"); itemCoralYellow = (new ItemSeaweed(AtlantisMod.blockCoralYellow)).setUnlocalizedName("itemCoralYellow").setCreativeTab(AtlantisMod.tabAtlantis).setTextureName("atlantismod:yellow_coral_item"); pebble = (new BlockPebble()).setHardness(2.0F).setResistance(5.0F).setStepSound(Block.soundTypeGravel).setBlockName("pebble").setCreativeTab(AtlantisMod.tabAtlantis).setBlockTextureName("atlantismod:pebble"); axePearl = (new ItemPearlAxe(AtlantisMod.PearlTool)).setUnlocalizedName("axePearl").setTextureName("atlantismod:pearl_axe").setCreativeTab(AtlantisMod.tabAtlantis); pickaxePearl = (new ItemPearlPickaxe(AtlantisMod.PearlTool)).setUnlocalizedName("pickaxePearl").setTextureName("atlantismod:pearl_pickaxe").setCreativeTab(AtlantisMod.tabAtlantis); hoePearl = (new ItemHoe(AtlantisMod.PearlTool)).setUnlocalizedName("hoePearl").setTextureName("atlantismod:pearl_hoe").setCreativeTab(AtlantisMod.tabAtlantis); shovelPearl = (new ItemSpade(AtlantisMod.PearlTool)).setUnlocalizedName("shovelPearl").setTextureName("atlantismod:pearl_shovel").setCreativeTab(AtlantisMod.tabAtlantis); swordPearl = (new ItemSword(AtlantisMod.PearlTool)).setUnlocalizedName("swordPearl").setTextureName("atlantismod:pearl_sword").setCreativeTab(AtlantisMod.tabAtlantis); axeAtlanteum = (new ItemAtlanteumAxe(AtlantisMod.AtlanteumTool)).setUnlocalizedName("axeAtlanteum").setTextureName("atlantismod:atlanteum_axe").setCreativeTab(AtlantisMod.tabAtlantis); pickaxeAtlanteum = (new ItemAtlanteumPickaxe(AtlantisMod.AtlanteumTool)).setUnlocalizedName("pickaxeAtlanteum").setTextureName("atlantismod:atlanteum_pickaxe").setCreativeTab(AtlantisMod.tabAtlantis); hoeAtlanteum = (new ItemHoe(AtlantisMod.AtlanteumTool)).setUnlocalizedName("hoeAtlanteum").setTextureName("atlantismod:atlanteum_hoe").setCreativeTab(AtlantisMod.tabAtlantis); shovelAtlanteum = (new ItemSpade(AtlantisMod.AtlanteumTool)).setUnlocalizedName("shovelAtlanteum").setTextureName("atlantismod:atlanteum_shovel").setCreativeTab(AtlantisMod.tabAtlantis); swordAtlanteum = (new ItemSword(AtlantisMod.AtlanteumTool)).setUnlocalizedName("swordAtlanteum").setTextureName("atlantismod:atlanteum_sword").setCreativeTab(AtlantisMod.tabAtlantis); helmetAtlanteum = (ItemAtlanteumArmor)(new ItemAtlanteumArmor(AtlantisMod.AtlanteumArmor,0,0)).setCreativeTab(AtlantisMod.tabAtlantis).setMaxStackSize(1).setUnlocalizedName("helmetAtlanteum").setTextureName("atlantismod:atlanteum_helmet"); chestAtlanteum = (ItemAtlanteumArmor)(new ItemAtlanteumArmor(AtlantisMod.AtlanteumArmor,0,1)).setCreativeTab(AtlantisMod.tabAtlantis).setMaxStackSize(1).setUnlocalizedName("chestAtlanteum").setTextureName("atlantismod:atlanteum_chestplate"); legsAtlanteum = (ItemAtlanteumArmor)(new ItemAtlanteumArmor(AtlantisMod.AtlanteumArmor,0,2)).setCreativeTab(AtlantisMod.tabAtlantis).setMaxStackSize(1).setUnlocalizedName("legsAtlanteum").setTextureName("atlantismod:atlanteum_leggings"); bootsAtlanteum = (ItemAtlanteumArmor)(new ItemAtlanteumArmor(AtlantisMod.AtlanteumArmor,0,3)).setCreativeTab(AtlantisMod.tabAtlantis).setMaxStackSize(1).setUnlocalizedName("bootsAtlanteum").setTextureName("atlantismod:atlanteum_boots"); atlantisOcean = (new BiomeGenAtlantisOcean(44)).setBiomeName("Atlantean Ocean").setHeight(new BiomeGenBase.Height(-1.9F, 0.1F)); coralReef = (new BiomeGenCoralReef(45)).setBiomeName("Coral Reef").setHeight(new BiomeGenBase.Height(-1.9F, 0.1F)); deepOcean = (new BiomeGenOcean(46)).setBiomeName("Deepest Ocean").setHeight(new BiomeGenBase.Height(-2.0F, 0.1F)); darkOcean = (new BiomeGenTheDeep(47)).setBiomeName("Dark Ocean").setHeight(new BiomeGenBase.Height(-1.9F, 0.1F)); biomes = new BiomeGenBase[]{AtlantisMod.atlantisOcean,AtlantisMod.coralReef,AtlantisMod.deepOcean}; blockRottenPlanks.setHarvestLevel("pickaxe", 2); blockDeepSand.setHarvestLevel("shovel", 1); blockPearl.setHarvestLevel("pickaxe", 2); oreAtlanteum.setHarvestLevel("pickaxe", 2); blockAtlanteum.setHarvestLevel("pickaxe", 2); this.doRegister(); }
private int getBlockColor(Block block) { if (block == null) return 0xff000000; if (block instanceof BlockOre) return 0xffff0000; return block.getMaterial().getMaterialMapColor().colorValue | 0xff000000; }