public static void applyBackers(List<MaterialDefinition> definitions) { for (MaterialDefinition definition : definitions) { ToolMaterial toolMaterial = definition.getToolMaterial(); ArmorMaterial armorMaterial = definition.getArmorMaterial(); RandoresItemData itemData = definition.getData(); RandoresItems.hoe.registerBacker(itemData, new ItemHoe(toolMaterial)); RandoresItems.sword.registerBacker(itemData, new ItemSword(toolMaterial)); RandoresItems.axe.registerBacker(itemData, new ConstructableAxe(toolMaterial, toolMaterial.getDamageVsEntity() + 5f, -3f)); RandoresItems.shovel.registerBacker(itemData, new ItemSpade(toolMaterial)); RandoresItems.pickaxe.registerBacker(itemData, new ConstructablePickaxe(toolMaterial)); RandoresItems.battleaxe.registerBacker(itemData, new ConstructableAxe(toolMaterial, toolMaterial.getDamageVsEntity() + 8f, -3.5f)); RandoresItems.helmet.registerBacker(itemData, armorMaterial); RandoresItems.chestplate.registerBacker(itemData, armorMaterial); RandoresItems.leggings.registerBacker(itemData, armorMaterial); RandoresItems.boots.registerBacker(itemData, armorMaterial); } }
public static void onPlayerInteract(PlayerInteractEvent event) { if (EtFuturum.enableGrassPath) if (event.entityPlayer != null) { World world = event.entityPlayer.worldObj; if (event.action == Action.RIGHT_CLICK_BLOCK) if (world.getBlock(event.x, event.y, event.z) == Blocks.grass) { ItemStack stack = event.entityPlayer.getCurrentEquippedItem(); if (stack != null && (stack.getItem() instanceof ItemSpade || isTinkersShovel(stack))) { world.setBlock(event.x, event.y, event.z, ModBlocks.grass_path); event.entityPlayer.swingItem(); stack.damageItem(1, event.entityPlayer); world.playSoundEffect(event.x + 0.5F, event.y + 0.5F, event.z + 0.5F, Block.soundTypeGravel.getStepResourcePath(), 1.0F, 0.8F); } } } }
/** * Finds or creates a shovel for an ore. */ public static void PopulateShovel(OreStuff stuff) { if (!stuff.HasShovel) { Item Shovel = Util.FindItemFromString(stuff.BaseName + "shovel"); if (Shovel != null) { stuff.HasShovel = true; } else { ItemSpade shovel; shovel = AutoItemAndBlock.CreateShovel(stuff.MetalMaterial, ModTabs.maintab, stuff.MetalMaterial.getHarvestLevel(), Reference.MODID + ":MissingShovelTexture", stuff.BaseName + "Shovel"); stuff.Shovel = shovel; } } }
@SubscribeEvent public void addVanillaTools(ValidatingToolsEvent event){ Iterator<Item> iterator = Item.itemRegistry.iterator(); while(iterator.hasNext()){ Item i = iterator.next(); if(i instanceof ItemSword){ event.addSword(i); } if(i instanceof ItemPickaxe){ event.addPickaxe(i); } if(i instanceof ItemSpade){ event.addShovel(i); } if(i instanceof ItemAxe){ event.addAxe(i); } if(i instanceof ItemHoe){ event.addHoe(i); } } }
/** * switches through input number to determine desired tool * * @param tool * @return */ public static Class getToolClassFromNode(Node tool) { if (tool != null) { if (tool.getNodeType() == Node.ELEMENT_NODE) { int toolIndex = 0; Element toolElement = (Element) tool; toolIndex = Integer.parseInt(toolElement.getTextContent()); switch (toolIndex) { case 0: return CuttingKnifeBase.class; case 1: return ItemAxe.class; case 2: return ItemPickaxe.class; case 3: return ItemSpade.class; } } } return CuttingKnifeBase.class; }
@Override protected boolean isItemValid(TileEntity tileEntity, ItemStack itemStack) { Class<?> cls = tileEntity.getClass(); if(cls != TEToolRack.class) return false; Item item = itemStack.getItem(); return item instanceof ItemTool || item instanceof ItemWeapon || item instanceof ItemHoe || item instanceof ItemProPick || item instanceof ItemBow || item instanceof ItemSword || item instanceof ItemAxe || item instanceof ItemSpade || item instanceof ItemShears || item instanceof ItemSpindle ; }
public static int getType(ItemStack itemStack) { Item item = itemStack.getItem(); if (item instanceof ItemPickaxe) { return TYPE_PICKAXE; } else if (item instanceof ItemAxe) { return TYPE_AXE; } else if (item instanceof ItemSpade) { return TYPE_SHOVEL; } else if (item instanceof ItemSword) { return TYPE_SWORD; } else if (item instanceof ItemHoe) { return TYPE_HOE; } else if (item instanceof ItemTool) { Set<String> toolClasses = ((ItemTool)item).getToolClasses(itemStack); if (toolClasses.contains("pickaxe")) return TYPE_PICKAXE; else if (toolClasses.contains("axe")) return TYPE_AXE; else if (toolClasses.contains("shovel")) return TYPE_SHOVEL; else if (toolClasses.contains("hoe")) return TYPE_HOE; else return -1; } else if (tinkersType(item)>=0) { //see if it's a tinkers type return tinkersType(item); } else { return -1; } }
private static String identityType(@Nonnull ItemStack stack) { Item item = stack.getItem(); if (item instanceof ItemArmor) { switch (((ItemArmor)item).armorType) { case HEAD: return "helmet"; case CHEST: return "chestplate"; case LEGS: return "leggings"; case FEET: return "boots"; default: break; } } else if (item instanceof ItemPickaxe) return "pickaxe"; else if (item instanceof ItemShears) return "shears"; else if (item instanceof ItemAxe) return "axe"; else if (item instanceof ItemSpade) return "shovel"; else if (item instanceof ItemBlock) return "block"; else if (item instanceof ItemBucket) return "bucket"; return "gizmo"; }
@SubscribeEvent public static void onRightClickBlock(PlayerInteractEvent.RightClickBlock event) { EntityPlayer player = event.getEntityPlayer(); World world = event.getWorld(); BlockPos pos = event.getPos(); EnumFacing face = event.getFace(); ItemStack stack = event.getItemStack(); Item item = stack.getItem(); if (item instanceof ItemSpade) { if (player.canPlayerEdit(pos.offset(face), face, stack)) { IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); if (face != EnumFacing.DOWN && world.isAirBlock(pos.up()) && block == GenesisBlocks.HUMUS) { world.playSound(player, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F); if (!world.isRemote) { IBlockState path = GenesisBlocks.HUMUS_PATH.getDefaultState(); world.setBlockState(pos, path, WorldFlags.UPDATE_BLOCK_AND_CLIENT_AND_RERENDER_ON_MAIN); stack.damageItem(1, player); } event.setCanceled(true); } } } }
/** * Creates a shovel from the specs provided. */ public static ItemSpade CreateShovel(ToolMaterial toolmaterial, CreativeTabs creative, int mininglevel, String Texture, String UnlocalizedName) { ItemSpade shovel; shovel = new AutoSpade(toolmaterial, creative, mininglevel, Texture, UnlocalizedName); return shovel; }
@Override protected void damageEntity(DamageSource src, float amount){ String type = String.valueOf(src == null ? null : src.getDamageType()); // null protection if(src instanceof EntityDamageSource && src.getEntity() instanceof EntityPlayer){ EntityPlayer player = (EntityPlayer)src.getEntity(); ItemStack item = player.getHeldItem(EnumHand.MAIN_HAND); if(item != null) { if (item.getItem() instanceof ItemSpade || item.getItem().getToolClasses(item).contains("shovel")) { this.kill(); } } } if(type.equals(DamageSource.outOfWorld.getDamageType())) { super.damageEntity(src,amount); // kill command and falling out of the world return; } if(type.equals(DamageSource.inWall.getDamageType())){ this.jumpOutOfWall(); } // damage handling if(LootableBodies.completelyInvulnerable) return; if(src instanceof EntityDamageSource ){ if(LootableBodies.hurtByAttacks) super.damageEntity(src,amount); return; } if(matchesAny(type, DamageSource.anvil, DamageSource.cactus, DamageSource.fall, DamageSource.fallingBlock, DamageSource.flyIntoWall, DamageSource.inFire, DamageSource.lava, DamageSource.magic, DamageSource.lightningBolt, DamageSource.onFire)){ if(LootableBodies.hurtByEnvironment)super.damageEntity(src,amount); return; } if(LootableBodies.hurtByMisc){ super.damageEntity(src,amount); return; } }
public ItemSpade setNameAndTab(String name, CreativeTabs tab, Item material) { this.setTextureName(ResourcePathHelper.getResourcesPath() + name); this.setUnlocalizedName(name); this.setCreativeTab(tab); this.material = material; return this; }
public ItemSpade setNameAndTab(String name, CreativeTabs tab) { this.setTextureName(ResourcePathHelper.getResourcesPath() + name); this.setUnlocalizedName(name); this.setCreativeTab(tab); return this; }
public static Item getColoredVersion(Item tool) { if (tool instanceof ItemPickaxe || tool instanceof ModPickaxe) { return ModItems.colored_pickaxe; } else if (tool instanceof ItemSpade || tool instanceof ModShovel) { return ModItems.colored_shovel; } else if (tool instanceof ItemAxe || tool instanceof ModAxe) { return ModItems.colored_axe; } else if (tool instanceof ItemHoe || tool instanceof ModHoe) { return ModItems.colored_hoe; } else if (tool instanceof Hammer) { return ModItems.colored_hammer; } else if (tool instanceof Trident) { Trident trident = (Trident) tool; switch (trident.HeadMaterial) { case EMERALD: return ModItems.diamond_colored_trident; case GOLD: return ModItems.gold_colored_trident; case IRON: return ModItems.iron_colored_trident; case STONE: return ModItems.stone_colored_trident; case WOOD: return ModItems.wood_colored_trident; default: return ModItems.colored_colored_trident; } } else if (tool instanceof ItemSword || tool instanceof ModSword) { return ModItems.colored_sword; } return null; }
public ToolShovel() { super(); this.vanillaEquivalent = new ItemSpade(ToolMaterial.EMERALD) { }; this.vanillaEquivalent.setUnlocalizedName("shovelDiamond") .setTextureName("diamond_shovel"); GameRegistry.registerItem(this.vanillaEquivalent, "dummy_shovel"); this.allowedEnchants.add(EnumEnchantmentType.digger); this.allowedEnchants.remove(EnumEnchantmentType.weapon); }
@Override public boolean canApply(ItemStack item) { if (item.getItem() instanceof ItemPickaxe || item.getItem() instanceof ItemSpade || item.getItem() instanceof ItemPrimalCrusher) return true; else return false; }
private static AdditionalCosts getAdditionalCosts (final Item output) { int index = 0; if (output instanceof ItemArmor) { index = ((ItemArmor) output).armorType; } else if (output instanceof ItemPickaxe) { index = 4; } else if (output instanceof ItemSword) { index = 5; } else if (output instanceof ItemAxe) { index = 6; } else if (output instanceof ItemSpade) { index = 7; } else if (output instanceof ItemHoe) { index = 8; } else if (output instanceof ItemBow) { index = 9; } else if (output instanceof ItemShears) { index = 10; } else if (output instanceof ItemFishingRod) { index = 11; } return AdditionalCosts.values()[index]; }
/** * Just a shortcut method to register items and keep code cleaner. */ public static void registerItems() { ToolMaterial bronzeMaterial = EnumHelper.addToolMaterial("bronze", 2, 350, 6.5F, 2.2F, 10); ToolMaterial steelMaterial = EnumHelper.addToolMaterial("steel", 3, 700, 7.0F, 2.7F, 12); //ingots ItemList.copper_ingot = new SimpleItem("copper_ingot"); ItemList.tin_ingot = new SimpleItem("tin_ingot"); ItemList.bronze_ingot = new SimpleItem("bronze_ingot"); ItemList.steel_ingot = new SimpleItem("steel_ingot"); //bronze tools ItemList.bronze_sword = (ItemSword) new ItemSword(bronzeMaterial).setUnlocalizedName("bronze_sword").setCreativeTab(FutureCraft.tabFutureCraft); GameRegistry.registerItem(ItemList.bronze_sword, "bronze_sword"); ItemList.bronze_shovel = (ItemSpade) new ItemSpade(bronzeMaterial).setUnlocalizedName("bronze_shovel").setCreativeTab(FutureCraft.tabFutureCraft); GameRegistry.registerItem(ItemList.bronze_shovel, "bronze_shovel"); ItemList.bronze_axe = (ItemAxe) new SimpleAxe(bronzeMaterial).setUnlocalizedName("bronze_axe").setCreativeTab(FutureCraft.tabFutureCraft); GameRegistry.registerItem(ItemList.bronze_axe, "bronze_axe"); ItemList.bronze_pickaxe = (ItemPickaxe) new SimplePickaxe(bronzeMaterial).setUnlocalizedName("bronze_pickaxe").setCreativeTab(FutureCraft.tabFutureCraft); GameRegistry.registerItem(ItemList.bronze_pickaxe, "bronze_pickaxe"); ItemList.bronze_hoe = (ItemHoe) new ItemHoe(bronzeMaterial).setUnlocalizedName("bronze_hoe").setCreativeTab(FutureCraft.tabFutureCraft); GameRegistry.registerItem(ItemList.bronze_hoe, "bronze_hoe"); //steel tools ItemList.steel_sword = (ItemSword) new ItemSword(steelMaterial).setUnlocalizedName("steel_sword").setCreativeTab(FutureCraft.tabFutureCraft); GameRegistry.registerItem(ItemList.steel_sword, "steel_sword"); ItemList.steel_shovel = (ItemSpade) new ItemSpade(steelMaterial).setUnlocalizedName("steel_shovel").setCreativeTab(FutureCraft.tabFutureCraft); GameRegistry.registerItem(ItemList.steel_shovel, "steel_shovel"); ItemList.steel_axe = (ItemAxe) new SimpleAxe(steelMaterial).setUnlocalizedName("steel_axe").setCreativeTab(FutureCraft.tabFutureCraft); GameRegistry.registerItem(ItemList.steel_axe, "steel_axe"); ItemList.steel_pickaxe = (ItemPickaxe) new SimplePickaxe(steelMaterial).setUnlocalizedName("steel_pickaxe").setCreativeTab(FutureCraft.tabFutureCraft); GameRegistry.registerItem(ItemList.steel_pickaxe, "steel_pickaxe"); ItemList.steel_hoe = (ItemHoe) new ItemHoe(steelMaterial).setUnlocalizedName("steel_hoe").setCreativeTab(FutureCraft.tabFutureCraft); GameRegistry.registerItem(ItemList.steel_hoe, "steel_hoe"); //space suit ItemList.space_suit_helmet = new ItemSpaceSuit(ArmorMaterial.IRON, 2, 0); GameRegistry.registerItem(ItemList.space_suit_helmet, "space_suit_helmet"); ItemList.space_suit_chestplate = new ItemSpaceSuit(ArmorMaterial.IRON, 2, 1); GameRegistry.registerItem(ItemList.space_suit_chestplate, "space_suit_chestplate"); ItemList.space_suit_leggings = new ItemSpaceSuit(ArmorMaterial.IRON, 2, 2); GameRegistry.registerItem(ItemList.space_suit_leggings, "space_suit_leggings"); ItemList.space_suit_boots = new ItemSpaceSuit(ArmorMaterial.IRON, 2, 3); GameRegistry.registerItem(ItemList.space_suit_boots, "space_suit_boots"); //misc ItemList.stone_channel = new SimpleItem("stone_channel"); ItemList.stone_cast = new SimpleItem("stone_cast"); ItemList.multimeter = new ItemMultimeter("multimeter"); ItemList.itemLaser = new ItemLaser("laser"); ItemList.creative_tab = new SimpleItem("creative_tab", false); }
@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(); }
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float f, float f1, float f2) { TileEntityRoad road = (TileEntityRoad)world.getBlockTileEntity(x, y, z); if(road == null) { return false; } int blockID = road.getSurface()[0]; ItemStack itemstack = player.getHeldItem(); if(itemstack != null) { if(!player.canPlayerEdit(x, y, z, i, itemstack)) { return false; } Block block = Block.blocksList[itemstack.itemID]; if(itemstack.getItem() instanceof ItemBlock && block != null) { if(!road.canBuild()) { return true; } if(upgradeRoad(world, x, y, z, 4, itemstack, block)) { if(!player.capabilities.isCreativeMode && !world.isRemote) { itemstack.stackSize --; if(itemstack.stackSize <= 0) { player.setCurrentItemOrArmor(0, null); } } return true; } } if(itemstack.getItem() instanceof ItemSpade) { if(this == BlockListMF.road) { if(!world.isRemote) { int m = world.getBlockMetadata(x, y, z); world.playAuxSFX(2001, x, y, z, blockID); world.setBlock(x, y, z, BlockListMF.Lowroad.blockID, m, 2); } return true; } } } return false; }
public void doConfig() { rightClickItem = getStackFromString(Config.rightClickItem); areaItem = getStackFromString(Config.areaItem); logger.info("Column item: " + areaItem.getUnlocalizedName()); nineItem = getStackFromString(Config.nineItem); hoeAreaItem = getStackFromString(Config.hoeAreaItem); swordAreaItem = getStackFromString(Config.swordAreaItem); //unbreakableItem = getStackFromString(Config.unbreakableItem); String[] seperatedItems = blacklist.split(","); blacklistedItems.clear(); for (int i = 0; i < seperatedItems.length; i++) { blacklistedItems.add(getStackFromString(seperatedItems[i]).getItem()); } ToolUpgradeRecipe.clear(); // place ToolUpgradeRecipe.addUpgradeRecipe(ItemTool.class, rightClickItem, ToolUpgrade.PLACE, XPAmount, allowPlace); // 3x1 ToolUpgradeRecipe.addUpgradeRecipe(ItemPickaxe.class, areaItem, ToolUpgrade.THREExONE, areaXPAmount, allow3x1Pick); ToolUpgradeRecipe.addUpgradeRecipe(ItemSpade.class, areaItem, ToolUpgrade.THREExONE, areaXPAmount, allow3x1Shovel); ToolUpgradeRecipe.addUpgradeRecipe(ItemAxe.class, areaItem, ToolUpgrade.THREExONE, areaXPAmount, allow3x1Axe); // 3x3 ToolUpgradeRecipe.addUpgradeRecipe(ItemPickaxe.class, nineItem, ToolUpgrade.THREExTHREE, nineXPAmount, allow3x3Pick); ToolUpgradeRecipe.addUpgradeRecipe(ItemSpade.class, nineItem, ToolUpgrade.THREExTHREE, nineXPAmount, allow3x3Shovel); //Hoe's in AoE for tall grass ToolUpgradeRecipe.addUpgradeRecipe(ItemHoe.class, hoeAreaItem, ToolUpgrade.HOExTHREE, hoeAreaXP, allow3x3Hoe); ToolUpgradeRecipe.addUpgradeRecipe(ItemSword.class, swordAreaItem, ToolUpgrade.SWORD_AOE, swordAreaXP, allowSwordAOE); //ToolUpgradeRecipe.addUpgradeRecipe(ItemTool.class, unbreakableItem, ToolUpgrade.UNBREAKABLE, unbreakableXP, allowUnbreakable); doBlacklist(Config.blacklistPlace,ToolUpgrade.PLACE); doBlacklist(Config.blacklist3x1,ToolUpgrade.THREExONE); doBlacklist(Config.blacklist3x3,ToolUpgrade.THREExTHREE); doBlacklist(Config.blacklistHoe,ToolUpgrade.HOExTHREE); doBlacklist(Config.blacklistSword,ToolUpgrade.SWORD_AOE); }
@SubscribeEvent(priority = EventPriority.HIGHEST) public void waterPadCreation(PlayerInteractEvent.RightClickBlock event) { // Fetch held item. final ItemStack stack = event.getItemStack(); // Check if holding shovel. if (!StackHelper.isValid(stack, ItemSpade.class)) { return; } // Fetch world information. final BlockPos pos = event.getPos(); final World world = event.getWorld(); final IBlockState state = world.getBlockState(pos); // Fetch the block at the location. final Block block = state.getBlock(); // Test that clicked block was farmland. if (block != Blocks.FARMLAND) { return; } // Deny the event. event.setUseBlock(Event.Result.DENY); event.setUseItem(Event.Result.DENY); event.setResult(Event.Result.DENY); // If we are on the client side we are done. if (event.getSide().isClient()) { return; } // Fetch the player. final EntityPlayer player = event.getEntityPlayer(); // Create the new block on the server side. world.setBlockState(pos, AgriBlocks.getInstance().WATER_PAD.getDefaultState(), 3); // Damage player's tool if not in creative. if (!player.capabilities.isCreativeMode) { stack.damageItem(1, player); } }
/** * Checks it the given ItemStack is an instance of ItemSpade * * @param itemstack * @return ItemSpade or not */ public static boolean isItemSpade(ItemStack itemstack) { return isItem(itemstack) && (itemstack.getItem() instanceof ItemSpade || isItemInfiShovel(itemstack)); }