Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.chef.mod.crops;
- import net.minecraft.block.Block;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.init.Blocks;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemFood;
- import net.minecraft.item.ItemReed;
- import net.minecraft.item.ItemStack;
- import net.minecraft.world.World;
- public class ItemCorn extends ItemFood {
- private Block field_150935_a;
- private static final String __OBFID = "CL_00001773";
- public ItemCorn(Block cropCornPlant, int i, float float1)
- {
- super(i, float1, false);
- this.field_150935_a = cropCornPlant;
- }
- /**
- * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
- * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
- */
- public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int i, float hitX, float hitY, float hitZ) {
- Block block = world.getBlock(x, y, z);
- if (block == Blocks.snow_layer && (world.getBlockMetadata(x, y, z) & 7) < 1)
- {
- i = 1;
- }
- else if (block != Blocks.vine && block != Blocks.tallgrass && block != Blocks.deadbush)
- {
- if (i == 0)
- {
- --y;
- }
- if (i == 1)
- {
- ++y;
- }
- if (i == 2)
- {
- --z;
- }
- if (i == 3)
- {
- ++z;
- }
- if (i == 4)
- {
- --x;
- }
- if (i == 5)
- {
- ++x;
- }
- }
- if (!entityplayer.canPlayerEdit(x, y, z, i, itemstack))
- {
- return false;
- }
- else if (itemstack.stackSize == 0)
- {
- return false;
- }
- else
- {
- if (world.canPlaceEntityOnSide(this.field_150935_a, x, y, z, false, i, (Entity)null, itemstack))
- {
- int i1 = this.field_150935_a.onBlockPlaced(world, x, y, z, i, hitX, hitY, hitZ, 0);
- if (world.setBlock(x, y, z, this.field_150935_a, i1, 3))
- {
- if (world.getBlock(x, y, z) == this.field_150935_a)
- {
- this.field_150935_a.onBlockPlacedBy(world, x, y, z, entityplayer, itemstack);
- this.field_150935_a.onPostBlockPlaced(world, x, y, z, i1);
- }
- world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), this.field_150935_a.stepSound.func_150496_b(), (this.field_150935_a.stepSound.getVolume() + 1.0F) / 2.0F, this.field_150935_a.stepSound.getPitch() * 0.8F);
- --itemstack.stackSize;
- }
- }
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment