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());
}
}
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);
}
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;
}
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);
}
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;
}
Aggregations