/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) { if (playerIn.isRiding() && playerIn.ridingEntity instanceof EntityPig) { EntityPig entitypig = (EntityPig)playerIn.ridingEntity; if (entitypig.getAIControlledByPlayer().isControlledByPlayer() && itemStackIn.getMaxDamage() - itemStackIn.getMetadata() >= 7) { entitypig.getAIControlledByPlayer().boostSpeed(); itemStackIn.damageItem(7, playerIn); if (itemStackIn.stackSize == 0) { ItemStack itemstack = new ItemStack(Items.fishing_rod); itemstack.setTagCompound(itemStackIn.getTagCompound()); return itemstack; } } } playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]); return itemStackIn; }
private EntitySkeleton createSkeleton(DifficultyInstance p_188514_1_, EntityHorse p_188514_2_) { EntitySkeleton entityskeleton = new EntitySkeleton(p_188514_2_.worldObj); entityskeleton.onInitialSpawn(p_188514_1_, (IEntityLivingData)null); entityskeleton.setPosition(p_188514_2_.posX, p_188514_2_.posY, p_188514_2_.posZ); entityskeleton.hurtResistantTime = 60; entityskeleton.enablePersistence(); if (entityskeleton.getItemStackFromSlot(EntityEquipmentSlot.HEAD) == null) { entityskeleton.setItemStackToSlot(EntityEquipmentSlot.HEAD, new ItemStack(Items.IRON_HELMET)); } EnchantmentHelper.addRandomEnchantment(entityskeleton.getRNG(), entityskeleton.getHeldItemMainhand(), (int)(5.0F + p_188514_1_.getClampedAdditionalDifficulty() * (float)entityskeleton.getRNG().nextInt(18)), false); EnchantmentHelper.addRandomEnchantment(entityskeleton.getRNG(), entityskeleton.getItemStackFromSlot(EntityEquipmentSlot.HEAD), (int)(5.0F + p_188514_1_.getClampedAdditionalDifficulty() * (float)entityskeleton.getRNG().nextInt(18)), false); entityskeleton.worldObj.spawnEntityInWorld(entityskeleton); return entityskeleton; }
public EntityPig(World worldIn) { super(worldIn); this.setSize(0.9F, 0.9F); ((PathNavigateGround)this.getNavigator()).setAvoidsWater(true); this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(1, new EntityAIPanic(this, 1.25D)); this.tasks.addTask(2, this.aiControlledByPlayer = new EntityAIControlledByPlayer(this, 0.3F)); this.tasks.addTask(3, new EntityAIMate(this, 1.0D)); this.tasks.addTask(4, new EntityAITempt(this, 1.2D, Items.carrot_on_a_stick, false)); this.tasks.addTask(4, new EntityAITempt(this, 1.2D, Items.carrot, false)); this.tasks.addTask(5, new EntityAIFollowParent(this, 1.1D)); this.tasks.addTask(6, new EntityAIWander(this, 1.0D)); this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); this.tasks.addTask(8, new EntityAILookIdle(this)); }
private static void setupMaterials() { // regular materials advancedWood = EnumHelper.addToolMaterial("advancedWood", 1, 236, 8.0F, 1.75F, 8); (advancedStone = EnumHelper.addToolMaterial("advancedStone", 2, 524, 12.0F, 3.0F, 3)).setRepairItem(new ItemStack(ACBlocks.advancedStone)); (advancedIron = EnumHelper.addToolMaterial("advancedIron", 3, 2250, 18.0F, 10.0F, 7)).setRepairItem(new ItemStack(Blocks.IRON_BLOCK)); (advancedGold = EnumHelper.addToolMaterial("advancedGold", 2, 1561, 8.0F, 6.0F, 15)).setRepairItem(new ItemStack(Blocks.GOLD_BLOCK)); (advancedEmerald = EnumHelper.addToolMaterial("advancedEmerald", 4, 3122, 12.0F, ACConfig.emeraldSwordDamage - 4, 22)).setRepairItem(new ItemStack(Blocks.EMERALD_BLOCK)); (advancedDiamond = EnumHelper.addToolMaterial("advancedDiamond", 4, 8192, 24.0F, 20.0F, 5)).setRepairItem(new ItemStack(Blocks.DIAMOND_BLOCK)); (netherStar = EnumHelper.addToolMaterial("netherStar", 4, 9366, 20.0F, 26.0F, 1)).setRepairItem(new ItemStack(Items.NETHER_STAR)); (advancedNetherStar = EnumHelper.addToolMaterial("advancedNetherStar", 5, 16384, 30.0F, 56.0F, 0)).setRepairItem(new ItemStack(ACBlocks.netherStarBlock)); creative = EnumHelper.addToolMaterial("creative_", 1000, 1, 0, 0, 0); // thaumic materials // advancedThaumium = EnumHelper.addToolMaterial("advancedThaumium", 3, 2250, 18.0F, 11.0F, 12); // advancedElemental = EnumHelper.addToolMaterial("advancedElemental", 4, 6144, 24.0F, 22.0F, 8); // advancedVoid = EnumHelper.addToolMaterial("advancedVoid", 4, 524, 18.0F, 24.0F, 12); // advancedCrimson = EnumHelper.addToolMaterial("advancedCrimson", 4, 668, 20.0F, 30.0F, 12); // advancedPrimal = EnumHelper.addToolMaterial("advancedPrimal", 5, 937, 22.0F, 36.0F, 12); // if(ASModIntegration.thaumcraftExists) { // advancedThaumium.setRepairItem(new ItemStack(BlocksTC.metal, 1, 0)); // advancedVoid.setRepairItem(new ItemStack(BlocksTC.metal, 1, 1)); // } }
private EntitySkeleton createSkeleton(DifficultyInstance p_188514_1_, AbstractHorse p_188514_2_) { EntitySkeleton entityskeleton = new EntitySkeleton(p_188514_2_.world); entityskeleton.onInitialSpawn(p_188514_1_, (IEntityLivingData)null); entityskeleton.setPosition(p_188514_2_.posX, p_188514_2_.posY, p_188514_2_.posZ); entityskeleton.hurtResistantTime = 60; entityskeleton.enablePersistence(); if (entityskeleton.getItemStackFromSlot(EntityEquipmentSlot.HEAD).func_190926_b()) { entityskeleton.setItemStackToSlot(EntityEquipmentSlot.HEAD, new ItemStack(Items.IRON_HELMET)); } entityskeleton.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, EnchantmentHelper.addRandomEnchantment(entityskeleton.getRNG(), entityskeleton.getHeldItemMainhand(), (int)(5.0F + p_188514_1_.getClampedAdditionalDifficulty() * (float)entityskeleton.getRNG().nextInt(18)), false)); entityskeleton.setItemStackToSlot(EntityEquipmentSlot.HEAD, EnchantmentHelper.addRandomEnchantment(entityskeleton.getRNG(), entityskeleton.getItemStackFromSlot(EntityEquipmentSlot.HEAD), (int)(5.0F + p_188514_1_.getClampedAdditionalDifficulty() * (float)entityskeleton.getRNG().nextInt(18)), false)); entityskeleton.world.spawnEntityInWorld(entityskeleton); return entityskeleton; }
/** * Called when this entity is broken. Entity parameter may be null. */ public void onBroken(Entity brokenEntity) { if (this.worldObj.getGameRules().getBoolean("doEntityDrops")) { if (brokenEntity instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer)brokenEntity; if (entityplayer.capabilities.isCreativeMode) { return; } } this.entityDropItem(new ItemStack(Items.painting), 0.0F); } }
private static void tweakRecipes() { if (EtFuturum.enableDoors) { Items.wooden_door.setMaxStackSize(64); Items.iron_door.setMaxStackSize(64); removeFirstRecipeFor(Items.wooden_door); removeFirstRecipeFor(Items.iron_door); } if (EtFuturum.enableFences) { removeFirstRecipeFor(Blocks.fence); removeFirstRecipeFor(Blocks.fence_gate); Blocks.fence.setCreativeTab(null); Blocks.fence_gate.setCreativeTab(null); } if (EtFuturum.enableBurnableBlocks) { Blocks.fire.setFireInfo(Blocks.fence_gate, 5, 20); Blocks.fire.setFireInfo(Blocks.fence, 5, 20); Blocks.fire.setFireInfo(Blocks.deadbush, 60, 100); } }
@Override public void handleGUIButtonPress(int guiID, EntityPlayer player) { if (guiID == 1) { if (filterMode.ordinal() >= EnumFilterMode.values().length - 1) { filterMode = EnumFilterMode.ITEM; } else { filterMode = EnumFilterMode.values()[filterMode.ordinal() + 1]; } //when an SideOnly exception is thrown this method automatically will set the filter mode to Item. filterHandler.doesItemMatchFilter(new ItemStack(Items.STICK)); } else if (guiID == 2) { creativeTabID++; if (creativeTabID == 5 || creativeTabID == 11) creativeTabID++; if (creativeTabID >= CreativeTabs.CREATIVE_TAB_ARRAY.length) { creativeTabID = 0; } } else if (guiID == 0) { redstoneMode++; if (redstoneMode > 2) redstoneMode = 0; } }
@Override public void addRecipes() { if (this.Enabled) { // One Firework Rocket Launcher (empty) GameRegistry.addRecipe(new ItemStack(this, 1 , this.getMaxDamage()), "x ", "yx ", "zyx", 'x', Blocks.planks, 'y', Items.iron_ingot, 'z', Items.flint_and_steel ); } else if (Main.noCreative) { this.setCreativeTab(null); } // Not enabled and not allowed to be in the creative menu // Fill the RPG with 1 rocket GameRegistry.addRecipe(new ItemStack(this), " ab", "zya", " x ", 'x', new ItemStack(this, 1 , this.getMaxDamage()), 'y', Blocks.tnt, 'z', Blocks.planks, 'a', Items.paper, 'b', Items.string ); }
/** * Turn one item from the furnace source stack into the appropriate smelted item in the furnace result stack */ public void smeltItem() { if (this.canSmelt()) { ItemStack itemstack = (ItemStack)this.furnaceItemStacks.get(0); ItemStack itemstack1 = FurnaceRecipes.instance().getSmeltingResult(itemstack); ItemStack itemstack2 = (ItemStack)this.furnaceItemStacks.get(2); if (itemstack2.func_190926_b()) { this.furnaceItemStacks.set(2, itemstack1.copy()); } else if (itemstack2.getItem() == itemstack1.getItem()) { itemstack2.func_190917_f(1); } if (itemstack.getItem() == Item.getItemFromBlock(Blocks.SPONGE) && itemstack.getMetadata() == 1 && !((ItemStack)this.furnaceItemStacks.get(1)).func_190926_b() && ((ItemStack)this.furnaceItemStacks.get(1)).getItem() == Items.BUCKET) { this.furnaceItemStacks.set(1, new ItemStack(Items.WATER_BUCKET)); } itemstack.func_190918_g(1); } }
/** * Gives armor or weapon for entity based on given DifficultyInstance */ protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty) { super.setEquipmentBasedOnDifficulty(difficulty); if (this.rand.nextFloat() < (this.world.getDifficulty() == EnumDifficulty.HARD ? 0.05F : 0.01F)) { int i = this.rand.nextInt(3); if (i == 0) { this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.IRON_SWORD)); } else { this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.IRON_SHOVEL)); } } }
/** * Drop 0-2 items of this living's type */ protected void dropFewItems(boolean p_70628_1_, int p_70628_2_) { int i = this.rand.nextInt(3) + 1 + this.rand.nextInt(1 + p_70628_2_); for (int j = 0; j < i; ++j) { if (this.isBurning()) { this.dropItem(Items.cooked_porkchop, 1); } else { this.dropItem(Items.porkchop, 1); } } if (this.getSaddled()) { this.dropItem(Items.saddle, 1); } }
@Override public void addRecipes() // Enabled defines whether or not the item can be crafted. Reloading existing weapons is always permitted. { if (this.Enabled) { // One quiverbow with 256 damage value (empty) GameRegistry.addRecipe(new ItemStack(this, 1 , this.getMaxDamage()), "zxy", "xzy", "zxy", 'x', Items.stick, 'y', Items.string, 'z', Items.leather ); } else if (Main.noCreative) { this.setCreativeTab(null); } // Not enabled and not allowed to be in the creative menu // Ammo ItemStack bundle = Helper.getAmmoStack(ArrowBundle.class, 0); Helper.makeAmmoRecipe(bundle, 1, 8, this.getMaxDamage(), this); Helper.makeAmmoRecipe(bundle, 2, 16, this.getMaxDamage(), this); Helper.makeAmmoRecipe(bundle, 3, 24, this.getMaxDamage(), this); Helper.makeAmmoRecipe(bundle, 4, 32, this.getMaxDamage(), this); Helper.makeAmmoRecipe(bundle, 5, 40, this.getMaxDamage(), this); Helper.makeAmmoRecipe(bundle, 6, 48, this.getMaxDamage(), this); Helper.makeAmmoRecipe(bundle, 7, 56, this.getMaxDamage(), this); Helper.makeAmmoRecipe(bundle, 8, 64, this.getMaxDamage(), this); }
@Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { GlStateManager.color(1, 1, 1, 1); GlStateManager.disableLighting(); RenderHelper.disableStandardItemLighting(); RenderHelper.enableGUIStandardItemLighting(); GlStateManager.enableAlpha(); Minecraft.getMinecraft().getTextureManager().bindTexture(GUIDEBOOK_GUI_TEXTURE); int i = (width - 256) / 2; int j = (height - 192) / 2; this.drawTexturedModalRect(i, j, 0, 0, 256, 192); this.itemRender.renderItemIntoGUI(new ItemStack(Items.WRITABLE_BOOK), (width / 2) - 100, (height / 2) - 85); //String text = "test tset"; //this.fontRendererObj.drawString(text, (width / 2) - ((text.length() * 5) / 2), (height / 2) - 30, TextFormatting.GRAY.getColorIndex()); }
/** * Drop 0-2 items of this living's type */ protected void dropFewItems(boolean p_70628_1_, int p_70628_2_) { EntityItem entityitem = this.dropItem(Items.nether_star, 1); if (entityitem != null) { entityitem.setNoDespawn(); } if (!this.worldObj.isRemote) { for (EntityPlayer entityplayer : this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, this.getEntityBoundingBox().expand(50.0D, 100.0D, 50.0D))) { entityplayer.triggerAchievement(AchievementList.killWither); } } }
/** * Called when the mob's health reaches 0. */ public void onDeath(DamageSource cause) { super.onDeath(cause); if (this.world.getGameRules().getBoolean("doMobLoot")) { if (cause.getEntity() instanceof EntitySkeleton) { int i = Item.getIdFromItem(Items.RECORD_13); int j = Item.getIdFromItem(Items.RECORD_WAIT); int k = i + this.rand.nextInt(j - i + 1); this.dropItem(Item.getItemById(k), 1); } else if (cause.getEntity() instanceof EntityCreeper && cause.getEntity() != this && ((EntityCreeper)cause.getEntity()).getPowered() && ((EntityCreeper)cause.getEntity()).isAIEnabled()) { ((EntityCreeper)cause.getEntity()).incrementDroppedSkulls(); this.entityDropItem(new ItemStack(Items.SKULL, 1, 4), 0.0F); } } }
/** * Called when item is crafted/smelted. Used only by maps so far. */ public void onCreated(ItemStack stack, World worldIn, EntityPlayer playerIn) { if (stack.hasTagCompound() && stack.getTagCompound().getBoolean("map_is_scaling")) { MapData mapdata = Items.filled_map.getMapData(stack, worldIn); stack.setItemDamage(worldIn.getUniqueDataId("map")); MapData mapdata1 = new MapData("map_" + stack.getMetadata()); mapdata1.scale = (byte)(mapdata.scale + 1); if (mapdata1.scale > 4) { mapdata1.scale = 4; } mapdata1.calculateMapCenter((double)mapdata.xCenter, (double)mapdata.zCenter, mapdata1.scale); mapdata1.dimension = mapdata.dimension; mapdata1.markDirty(); worldIn.setItemData("map_" + stack.getMetadata(), mapdata1); } }
public static int getLightLevel(ItemStack p_getLightLevel_0_) { if (p_getLightLevel_0_ == null) { return 0; } else { Item item = p_getLightLevel_0_.getItem(); if (item instanceof ItemBlock) { ItemBlock itemblock = (ItemBlock)item; Block block = itemblock.getBlock(); if (block != null) { return block.getLightValue(block.getDefaultState()); } } return item == Items.LAVA_BUCKET ? Blocks.LAVA.getLightValue(Blocks.LAVA.getDefaultState()) : (item != Items.BLAZE_ROD && item != Items.BLAZE_POWDER ? (item == Items.GLOWSTONE_DUST ? 8 : (item == Items.PRISMARINE_CRYSTALS ? 8 : (item == Items.MAGMA_CREAM ? 8 : (item == Items.NETHER_STAR ? Blocks.BEACON.getLightValue(Blocks.BEACON.getDefaultState()) / 2 : 0)))) : 10); } }
public static void tweakVanilla() { ((ItemFood) Items.BEEF).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 20, 0), 20); ((ItemFood) Items.PORKCHOP).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 25, 0), 25); ((ItemFood) Items.FISH).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 30, 1), 60); // Both fish types here ((ItemFood) Items.MUTTON).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 20, 0), 25); ((ItemFood) Items.RABBIT).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 25, 0), 30); if(BBConfig.makeStuffStackable) { // Let's face it, the vanilla stack sizes for these suck. Items.MINECART.setMaxStackSize(16); // Strangely enough the oak one doesn't change name. Items.OAK_DOOR.setMaxStackSize(16); Items.SPRUCE_DOOR.setMaxStackSize(16); Items.BIRCH_DOOR.setMaxStackSize(16); Items.ACACIA_DOOR.setMaxStackSize(16); Items.DARK_OAK_DOOR.setMaxStackSize(16); Items.IRON_DOOR.setMaxStackSize(16); } if(BBConfig.moduleFurnaces) Items.FURNACE_MINECART.setUnlocalizedName(ModMain.MODID + ".kilnCart"); }
public ItemStack getPotion() { ItemStack itemstack = (ItemStack)this.getDataManager().get(ITEM); if (itemstack.getItem() != Items.SPLASH_POTION && itemstack.getItem() != Items.LINGERING_POTION) { if (this.world != null) { LOGGER.error("ThrownPotion entity {} has no item?!", new Object[] {Integer.valueOf(this.getEntityId())}); } return new ItemStack(Items.SPLASH_POTION); } else { return itemstack; } }
@Override public void addRecipes() { GameRegistry.addRecipe(new ItemStack(this, 1, this.getMaxDamage()), "x x", "x x", "xgx", 'x', Blocks.glass_pane, 'g', new ItemStack(Items.dye, 1, 4) ); }
@Override public void registerRecipes() { RezolveMod.addRecipe( new ItemStack(this.itemBlock), "oNo", "cRc", "oDo", 'o', Blocks.OBSIDIAN, 'N', Items.NETHER_STAR, 'c', RezolveMod.ETHERNET_CABLE_BLOCK, 'R', RezolveMod.REMOTE_SHELL_BLOCK, 'D', Items.IRON_DOOR ); }
protected void initEntityAI() { this.tasks.addTask(1, new EntityAISwimming(this)); this.tasks.addTask(1, new EntityRabbit.AIPanic(this, 2.2D)); this.tasks.addTask(2, new EntityAIMate(this, 0.8D)); this.tasks.addTask(3, new EntityAITempt(this, 1.0D, Items.CARROT, false)); this.tasks.addTask(3, new EntityAITempt(this, 1.0D, Items.GOLDEN_CARROT, false)); this.tasks.addTask(3, new EntityAITempt(this, 1.0D, Item.getItemFromBlock(Blocks.YELLOW_FLOWER), false)); this.tasks.addTask(4, new EntityRabbit.AIAvoidEntity(this, EntityPlayer.class, 8.0F, 2.2D, 2.2D)); this.tasks.addTask(4, new EntityRabbit.AIAvoidEntity(this, EntityWolf.class, 10.0F, 2.2D, 2.2D)); this.tasks.addTask(4, new EntityRabbit.AIAvoidEntity(this, EntityMob.class, 4.0F, 2.2D, 2.2D)); this.tasks.addTask(5, new EntityRabbit.AIRaidFarm(this)); this.tasks.addTask(6, new EntityAIWander(this, 0.6D)); this.tasks.addTask(11, new EntityAIWatchClosest(this, EntityPlayer.class, 10.0F)); }
protected void dropApple(World worldIn, BlockPos pos, IBlockState state, int chance) { if (state.getValue(VARIANT) == BlockPlanks.EnumType.OAK && worldIn.rand.nextInt(chance) == 0) { spawnAsEntity(worldIn, pos, new ItemStack(Items.APPLE)); } }
public boolean processInteract(EntityPlayer player, EnumHand hand, @Nullable ItemStack stack) { if (stack != null && stack.getItem() == Items.SPAWN_EGG) { if (!this.worldObj.isRemote) { Class <? extends Entity > oclass = EntityList.NAME_TO_CLASS.get(ItemMonsterPlacer.getEntityIdFromItem(stack)); if (oclass != null && this.getClass() == oclass) { EntityAgeable entityageable = this.createChild(this); if (entityageable != null) { entityageable.setGrowingAge(-24000); entityageable.setLocationAndAngles(this.posX, this.posY, this.posZ, 0.0F, 0.0F); this.worldObj.spawnEntityInWorld(entityageable); if (stack.hasDisplayName()) { entityageable.setCustomNameTag(stack.getDisplayName()); } if (!player.capabilities.isCreativeMode) { --stack.stackSize; } } } } return true; } else { return false; } }
@Override public NonNullList<ItemStack> craftRecipe(ItemStackHandler inputStacks) { ItemStack[] recipeIngredients = getRecipeIngredients(inputStacks); ItemStack enchantedTool = recipeIngredients[0]; ItemStack enchantedBook = recipeIngredients[1]; Map<Enchantment, Integer> bookMap = EnchantmentHelper.getEnchantments(enchantedBook); bookMap.forEach((enchant, lvl) -> enchantedTool.addEnchantment(enchant, lvl)); enchantedBook.shrink(1); return NonNullList.from(ItemStack.EMPTY, new ItemStack(Items.BOOK)); }
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack) { if (te instanceof IWorldNameable && ((IWorldNameable)te).hasCustomName()) { player.addStat(StatList.getBlockStats(this)); player.addExhaustion(0.005F); if (worldIn.isRemote) { return; } int i = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack); Item item = this.getItemDropped(state, worldIn.rand, i); if (item == Items.field_190931_a) { return; } ItemStack itemstack = new ItemStack(item, this.quantityDropped(worldIn.rand)); itemstack.setStackDisplayName(((IWorldNameable)te).getName()); spawnAsEntity(worldIn, pos, itemstack); } else { super.harvestBlock(worldIn, player, pos, state, (TileEntity)null, stack); } }
/** * Used to check if a recipe matches current crafting inventory */ public boolean matches(InventoryCrafting inv, World worldIn) { int i = 0; ItemStack itemstack = null; for (int j = 0; j < inv.getSizeInventory(); ++j) { ItemStack itemstack1 = inv.getStackInSlot(j); if (itemstack1 != null) { if (itemstack1.getItem() == Items.FILLED_MAP) { if (itemstack != null) { return false; } itemstack = itemstack1; } else { if (itemstack1.getItem() != Items.MAP) { return false; } ++i; } } } return itemstack != null && i > 0; }
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random) { Enchantment enchantment = Enchantment.enchantmentsBookList[random.nextInt(Enchantment.enchantmentsBookList.length)]; int i = MathHelper.getRandomIntegerInRange(random, enchantment.getMinLevel(), enchantment.getMaxLevel()); ItemStack itemstack = Items.enchanted_book.getEnchantedItemStack(new EnchantmentData(enchantment, i)); int j = 2 + random.nextInt(5 + i * 10) + 3 * i; if (j > 64) { j = 64; } recipeList.add(new MerchantRecipe(new ItemStack(Items.book), new ItemStack(Items.emerald, j), itemstack)); }
@Override public void addRecipes() { if (this.Enabled) { // One empty double crossbow (upgraded from regular crossbow) GameRegistry.addShapelessRecipe(new ItemStack(this, 1 , this.getMaxDamage()), Blocks.sticky_piston, Items.repeater, Helper.getWeaponStackByClass(Crossbow_Compact.class, true) ); } else if (Main.noCreative) { this.setCreativeTab(null); } // Not enabled and not allowed to be in the creative menu GameRegistry.addShapelessRecipe(new ItemStack(this), // Fill the empty crossbow with two arrows Items.arrow, Items.arrow, new ItemStack(this, 1 , this.getMaxDamage()) ); GameRegistry.addShapelessRecipe(new ItemStack(this, 1, 1), // Fill the empty crossbow with one arrow Items.arrow, new ItemStack(this, 1 , this.getMaxDamage()) ); GameRegistry.addShapelessRecipe(new ItemStack(this), // Fill the half empty crossbow with one arrow Items.arrow, new ItemStack(this, 1 , 1) ); }
/** * Called when the mob's health reaches 0. */ public void onDeath(DamageSource cause) { super.onDeath(cause); this.setSize(0.2F, 0.2F); this.setPosition(this.posX, this.posY, this.posZ); this.motionY = 0.10000000149011612D; if ("Notch".equals(this.getName())) { this.dropItem(new ItemStack(Items.APPLE, 1), true, false); } if (!this.world.getGameRules().getBoolean("keepInventory") && !this.isSpectator()) { this.func_190776_cN(); this.inventory.dropAllItems(); } if (cause != null) { this.motionX = (double)(-MathHelper.cos((this.attackedAtYaw + this.rotationYaw) * 0.017453292F) * 0.1F); this.motionZ = (double)(-MathHelper.sin((this.attackedAtYaw + this.rotationYaw) * 0.017453292F) * 0.1F); } else { this.motionX = 0.0D; this.motionZ = 0.0D; } this.addStat(StatList.DEATHS); this.takeStat(StatList.TIME_SINCE_DEATH); this.extinguish(); this.setFlag(0, false); }
@Test public void test_item() { Map<String, ItemFilter> map = gson.fromJson("{\"filter\":\"minecraft:apple\"}", new TypeToken<Map<String, ItemFilter>>() {}.getType()); ItemFilter filter = map.get("filter"); assertTrue(filter.accepts(new ItemStack(Items.APPLE))); assertFalse(filter.accepts(new ItemStack(Items.GOLD_INGOT))); }
@Override protected void loadUsageRecipeHandler(ItemStack ingredient) { if (ingredient.getItem() == Items.gold_nugget) { NeiLotrUtil.itemStackIteration((count,itemStack) -> { handleRecipe(itemStack, true); }); } else { handleRecipe(ingredient, true); } }
/** * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig. */ public boolean interact(EntityPlayer player) { ItemStack itemstack = player.inventory.getCurrentItem(); if (itemstack != null && itemstack.getItem() == Items.shears && !this.getSheared() && !this.isChild()) { if (!this.worldObj.isRemote) { this.setSheared(true); int i = 1 + this.rand.nextInt(3); for (int j = 0; j < i; ++j) { EntityItem entityitem = this.entityDropItem(new ItemStack(Item.getItemFromBlock(Blocks.wool), 1, this.getFleeceColor().getMetadata()), 1.0F); entityitem.motionY += (double)(this.rand.nextFloat() * 0.05F); entityitem.motionX += (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F); entityitem.motionZ += (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F); } } itemstack.damageItem(1, player); this.playSound("mob.sheep.shear", 1.0F, 1.0F); } return super.interact(player); }
@SubscribeEvent public void onLocalPlayerUpdate(LocalPlayerUpdateEvent event) { if (MC.player != null) { int health = (int)(MC.player.getHealth() + MC.player.getAbsorptionAmount()); if (health <= threshold.get() || (noTotem.getAsBoolean() && !((MC.player.getHeldItemOffhand().getItem() == Items.TOTEM_OF_UNDYING) || MC.player.getHeldItemMainhand().getItem() == Items.TOTEM_OF_UNDYING))) { AutoReconnectMod.hasAutoLogged = true; getNetworkManager().closeChannel(new TextComponentString("Health too low (" + health + ")")); disable(); } } }
/** * Called when the mob's health reaches 0. */ public void onDeath(DamageSource cause) { super.onDeath(cause); this.setSize(0.2F, 0.2F); this.setPosition(this.posX, this.posY, this.posZ); this.motionY = 0.10000000149011612D; if (this.getName().equals("Notch")) { this.dropItem(new ItemStack(Items.apple, 1), true, false); } if (!this.worldObj.getGameRules().getBoolean("keepInventory")) { this.inventory.dropAllItems(); } if (cause != null) { this.motionX = (double)(-MathHelper.cos((this.attackedAtYaw + this.rotationYaw) * (float)Math.PI / 180.0F) * 0.1F); this.motionZ = (double)(-MathHelper.sin((this.attackedAtYaw + this.rotationYaw) * (float)Math.PI / 180.0F) * 0.1F); } else { this.motionX = this.motionZ = 0.0D; } this.triggerAchievement(StatList.deathsStat); this.func_175145_a(StatList.timeSinceDeathStat); }
private CentrifugeRecipes() { this.addRecipe(new ItemStack[] { new ItemStack(TechnicalItem.BauxiteDust, 20), null, null }, new ItemStack[] { new ItemStack(TechnicalItem.GibbsiteDust, 5), new ItemStack(TechnicalItem.BoehmiteDust, 5), new ItemStack(TechnicalItem.DiasporeDust, 5), new ItemStack(TechnicalItem.GoethiteDust, 2), new ItemStack(TechnicalItem.HematiteDust2, 2), new ItemStack(TechnicalItem.AnataseDust, 1) }, Tier.medium); this.addRecipe(new ItemStack[] { new ItemStack(TechnicalItem.ColtanDust, 2), null, null}, new ItemStack[] { new ItemStack(TechnicalItem.ColumbiteDust, 1), new ItemStack(TechnicalItem.TantaliteDust, 1) }, Tier.advanced); this.addRecipe(new ItemStack[] { new ItemStack(TechnicalBlock.DirtGold, 14), new ItemStack(Items.water_bucket, 1), null }, new ItemStack[] { new ItemStack(Blocks.dirt, 14), new ItemStack(Items.gold_nugget, 1), new ItemStack(Items.bucket, 1) }, Tier.normal); this.addRecipe(new ItemStack[] { new ItemStack(Blocks.dirt, 14), new ItemStack(Items.water_bucket, 1), null }, new ItemStack[] { new ItemStack(Blocks.dirt, 14), new ItemStack(Items.bucket, 1) }, Tier.normal); }
public void openBook(ItemStack stack, EnumHand hand) { Item item = stack.getItem(); if (item == Items.WRITABLE_BOOK) { this.mc.displayGuiScreen(new GuiScreenBook(this, stack, true)); } }
public static int getPotionSlot(boolean hotbarOnly) { try { int potSlot = (hotbarOnly ? player_itemSlotHotbar(Items.field_151068_bn) : player_itemSlot(Items.field_151068_bn)); if (potSlot == -1) return -1; ItemStack potStack = Wrapper.player_inventoryItems()[potSlot]; if (potStack == null) return -1; if (isHealthPot(potStack)) return potSlot; return -1; } catch (Exception e) { return -1; } }
protected static void scaleMap(ItemStack p_185063_0_, World p_185063_1_, int p_185063_2_) { MapData mapdata = Items.FILLED_MAP.getMapData(p_185063_0_, p_185063_1_); p_185063_0_.setItemDamage(p_185063_1_.getUniqueDataId("map")); MapData mapdata1 = new MapData("map_" + p_185063_0_.getMetadata()); mapdata1.scale = (byte)MathHelper.clamp_int(mapdata.scale + p_185063_2_, 0, 4); mapdata1.trackingPosition = mapdata.trackingPosition; mapdata1.calculateMapCenter((double)mapdata.xCenter, (double)mapdata.zCenter, mapdata1.scale); mapdata1.dimension = mapdata.dimension; mapdata1.markDirty(); p_185063_1_.setItemData("map_" + p_185063_0_.getMetadata(), mapdata1); }