Search in sources :

Example 6 with ItemStack

use of net.minecraft.item.ItemStack in project BetterStorage by copygirl.

the class Recipes method addCardboardRecipes.

private static void addCardboardRecipes() {
    // Cardboard sheet recipe
    if (BetterStorageItems.cardboardSheet != null) {
        GameRegistry.addShapelessRecipe(new ItemStack(BetterStorageItems.cardboardSheet, 4), Items.paper, Items.paper, Items.paper, Items.paper, Items.paper, Items.paper, Items.paper, Items.paper, Items.slime_ball);
    }
    // Cardboard helmet recipe
    if (BetterStorageItems.cardboardHelmet != null)
        GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BetterStorageItems.cardboardHelmet), "ooo", "o o", 'o', "sheetCardboard"));
    // Cardboard chestplate recipe
    if (BetterStorageItems.cardboardChestplate != null)
        GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BetterStorageItems.cardboardChestplate), "o o", "ooo", "ooo", 'o', "sheetCardboard"));
    // Cardboard leggings recipe
    if (BetterStorageItems.cardboardLeggings != null)
        GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BetterStorageItems.cardboardLeggings), "ooo", "o o", "o o", 'o', "sheetCardboard"));
    // Cardboard boots recipe
    if (BetterStorageItems.cardboardBoots != null)
        GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BetterStorageItems.cardboardBoots), "o o", "o o", 'o', "sheetCardboard"));
    // Cardboard sword recipe
    if (BetterStorageItems.cardboardSword != null)
        GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BetterStorageItems.cardboardSword), "o", "o", "/", 'o', "sheetCardboard", '/', Items.stick));
    // Cardboard pickaxe recipe
    if (BetterStorageItems.cardboardPickaxe != null)
        GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BetterStorageItems.cardboardPickaxe), "ooo", " / ", " / ", 'o', "sheetCardboard", '/', Items.stick));
    // Cardboard shovel recipe
    if (BetterStorageItems.cardboardShovel != null)
        GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BetterStorageItems.cardboardShovel), "o", "/", "/", 'o', "sheetCardboard", '/', Items.stick));
    // Cardboard axe recipe
    if (BetterStorageItems.cardboardAxe != null) {
        GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BetterStorageItems.cardboardAxe), "oo", "o/", " /", 'o', "sheetCardboard", '/', Items.stick));
        GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BetterStorageItems.cardboardAxe), "oo", "/o", "/ ", 'o', "sheetCardboard", '/', Items.stick));
    }
    // Cardboard hoe recipe
    if (BetterStorageItems.cardboardHoe != null) {
        GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BetterStorageItems.cardboardHoe), "oo", " /", " /", 'o', "sheetCardboard", '/', Items.stick));
        GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BetterStorageItems.cardboardHoe), "oo", "/ ", "/ ", 'o', "sheetCardboard", '/', Items.stick));
    }
    if (BetterStorageItems.anyCardboardItemsEnabled) {
        // Crafting Station: Add cardboard enchantment recipe
        BetterStorageCrafting.addStationRecipe(new CardboardEnchantmentRecipe());
        // Crafting Station: Add cardboard repair recipe
        if (BetterStorageItems.cardboardSheet != null)
            BetterStorageCrafting.addStationRecipe(new CardboardRepairRecipe());
    }
}
Also used : CardboardRepairRecipe(net.mcft.copy.betterstorage.item.cardboard.CardboardRepairRecipe) CardboardEnchantmentRecipe(net.mcft.copy.betterstorage.item.cardboard.CardboardEnchantmentRecipe) ShapedOreRecipe(net.minecraftforge.oredict.ShapedOreRecipe) ItemStack(net.minecraft.item.ItemStack)

Example 7 with ItemStack

use of net.minecraft.item.ItemStack in project BetterStorage by copygirl.

the class ItemBackpack method damageArmor.

@Override
public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) {
    if (!takesDamage(stack, source))
        return;
    stack.damageItem(damage, entity);
    if (stack.stackSize > 0)
        return;
    PropertiesBackpack backpackData = ItemBackpack.getBackpackData(entity);
    if (backpackData.contents != null)
        for (ItemStack s : backpackData.contents) WorldUtils.dropStackFromEntity(entity, s, 2.0F);
    entity.renderBrokenItemStack(stack);
}
Also used : PropertiesBackpack(net.mcft.copy.betterstorage.misc.PropertiesBackpack) ItemStack(net.minecraft.item.ItemStack)

Example 8 with ItemStack

use of net.minecraft.item.ItemStack in project BetterStorage by copygirl.

the class ItemBackpack method onPlaceBackpack.

/** Places an equipped backpack when the player right clicks
	 *  on the ground while sneaking and holding nothing. */
public static boolean onPlaceBackpack(EntityPlayer player, int x, int y, int z, int side) {
    if (player.getCurrentEquippedItem() != null || !player.isSneaking())
        return false;
    ItemStack backpack = ItemBackpack.getBackpack(player);
    if (backpack == null)
        return false;
    boolean success = false;
    if (!ItemBackpack.isBackpackOpen(player)) {
        // Try to place the backpack as if it was being held and used by the player.
        success = backpack.getItem().onItemUse(backpack, player, player.worldObj, x, y, z, side, 0, 0, 0);
        if (backpack.stackSize <= 0) {
            ItemBackpack.setBackpack(player, null, null);
            backpack = null;
        }
    }
    // Make sure the client has the same information as the server. It does not sync when backpackChestplate is disabled because there are no changes to the slot in that case.
    if (!player.worldObj.isRemote && success && player instanceof EntityPlayerMP && BetterStorage.globalConfig.getBoolean(GlobalConfig.backpackChestplate)) {
        ((EntityPlayerMP) player).playerNetServerHandler.sendPacket(new S2FPacketSetSlot(0, 6, backpack));
    }
    if (success)
        player.swingItem();
    return success;
}
Also used : S2FPacketSetSlot(net.minecraft.network.play.server.S2FPacketSetSlot) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack)

Example 9 with ItemStack

use of net.minecraft.item.ItemStack in project BetterStorage by copygirl.

the class ItemBucketSlime method onEaten.

@Override
public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) {
    Handler handler = getHandler(stack);
    if (handler != null) {
        player.getFoodStats().addStats(handler.foodAmount(), handler.saturationAmount());
        NBTTagList effectList = (NBTTagList) StackUtils.getTag(stack, "Effects");
        if (effectList != null) {
            for (int i = 0; i < effectList.tagCount(); i++) {
                PotionEffect effect = PotionEffect.readCustomPotionEffectFromNBT(effectList.getCompoundTagAt(i));
                int duration = (int) (effect.getDuration() * handler.durationMultiplier());
                effect = new PotionEffect(effect.getPotionID(), duration, effect.getAmplifier());
                player.addPotionEffect(effect);
            }
        }
        handler.onEaten(player, false);
    }
    return new ItemStack(Items.bucket);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) PotionEffect(net.minecraft.potion.PotionEffect) ItemStack(net.minecraft.item.ItemStack)

Example 10 with ItemStack

use of net.minecraft.item.ItemStack in project BetterStorage by copygirl.

the class ItemBucketSlime method onItemUse.

@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
    // instead of placing it in the world.
    if (player.isSneaking())
        return false;
    if (world.isRemote)
        return true;
    x += Facing.offsetsXForSide[side];
    y += Facing.offsetsYForSide[side];
    z += Facing.offsetsZForSide[side];
    String id = getSlimeId(stack);
    String name = StackUtils.get(stack, (String) null, "Slime", "name");
    Entity entity = EntityList.createEntityByName(id, world);
    Handler handler = getHandler(id);
    if ((entity != null) && (handler != null) && (entity instanceof EntityLiving)) {
        EntityLiving slime = (EntityLiving) entity;
        float rotation = MathHelper.wrapAngleTo180_float(world.rand.nextFloat() * 360.0F);
        slime.setLocationAndAngles(x + 0.5, y, z + 0.5, rotation, 0.0F);
        slime.rotationYawHead = slime.renderYawOffset = rotation;
        if (name != null)
            slime.setCustomNameTag(name);
        handler.setSize(slime, 1);
        NBTTagList effectList = (NBTTagList) StackUtils.getTag(stack, "Effects");
        if (effectList != null)
            for (int i = 0; i < effectList.tagCount(); i++) slime.addPotionEffect(PotionEffect.readCustomPotionEffectFromNBT(effectList.getCompoundTagAt(i)));
        world.spawnEntityInWorld(slime);
        slime.playSound("mob.slime.big", 1.2F, 0.6F);
        player.setCurrentItemOrArmor(EquipmentSlot.HELD, new ItemStack(Items.bucket));
    }
    return true;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) Entity(net.minecraft.entity.Entity) EntityLiving(net.minecraft.entity.EntityLiving) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemStack (net.minecraft.item.ItemStack)2512 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)250 ArrayList (java.util.ArrayList)244 EntityItem (net.minecraft.entity.item.EntityItem)170 Slot (net.minecraft.inventory.Slot)164 TileEntity (net.minecraft.tileentity.TileEntity)155 EntityPlayer (net.minecraft.entity.player.EntityPlayer)153 Block (net.minecraft.block.Block)148 Item (net.minecraft.item.Item)118 BlockPos (net.minecraft.util.math.BlockPos)83 NBTTagList (net.minecraft.nbt.NBTTagList)74 IInventory (net.minecraft.inventory.IInventory)73 IBlockState (net.minecraft.block.state.IBlockState)70 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)67 FluidStack (net.minecraftforge.fluids.FluidStack)63 ShapedOreRecipe (net.minecraftforge.oredict.ShapedOreRecipe)63 World (net.minecraft.world.World)56 List (java.util.List)55 ResourceLocation (net.minecraft.util.ResourceLocation)50 Entity (net.minecraft.entity.Entity)47