Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package mint.mintmats.items;
- import mint.mintmats.core.ClientProxy;
- import net.minecraft.block.Block;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.world.World;
- public class itemGrassSeedBag extends Item
- {
- public itemGrassSeedBag(int id)
- {
- super(id);
- this.setMaxStackSize(64);
- this.setCreativeTab(CreativeTabs.tabMaterials);
- }
- @Override
- public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float par8, float par9, float par10)
- {
- int detectedBlock = world.getBlockId(x, y, z);
- if(detectedBlock == Block.dirt.blockID)
- {
- boolean planted = false;
- for (int posX = x - 2; posX <= x + 2; posX++)
- {
- for (int posZ = z - 2; posZ <= z + 2; posZ++)
- {
- if (player.canPlayerEdit(posX, y, posZ, side, stack))
- {
- if (world.getBlockId(posX, y, posZ) == Block.dirt.blockID)
- {
- world.setBlockWithNotify(posX, y, posZ, Block.grass.blockID);
- planted = true;
- }
- }
- }
- }
- if (planted)
- {
- if (!player.capabilities.isCreativeMode){stack.stackSize--;}
- if (!world.isRemote)
- {
- for (int posX = x - 2; posX <= x + 2; posX++)
- {
- for (int posZ = z - 2; posZ <= z + 2; posZ++)
- {
- world.playAuxSFX(2001, posX, y, posZ, Block.leaves.blockID);
- }
- }
- return planted;
- }
- }
- }
- return false;
- }
- public String getTextureFile()
- {
- return ClientProxy.itemTex;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement