Advertisement
Guest User

Custom Pumpkin Seeds

a guest
Feb 13th, 2018
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.47 KB | None | 0 0
  1. package com.thatguy64.redstonestew;
  2.  
  3. import net.minecraft.block.Block;
  4. import net.minecraft.entity.player.EntityPlayer;
  5. import net.minecraft.init.Blocks;
  6. import net.minecraft.item.Item;
  7. import net.minecraft.item.ItemFood;
  8. import net.minecraft.item.ItemStack;
  9. import net.minecraft.world.IBlockAccess;
  10. import net.minecraft.world.World;
  11. import net.minecraftforge.common.EnumPlantType;
  12. import net.minecraftforge.common.IPlantable;
  13. import net.minecraftforge.common.util.ForgeDirection;
  14.  
  15. public class ItemSugarSeeds extends Item implements IPlantable
  16. {
  17.     private final Block theBlockPlant;
  18.     private final Block soilId;
  19.  
  20.     public ItemSugarSeeds(Block parBlockPlant, Block parSoilBlock)
  21.     {
  22.         theBlockPlant = parBlockPlant;
  23.         soilId = parSoilBlock;
  24.     }
  25.  
  26.     public boolean onItemUse(ItemStack parItemStack, EntityPlayer parPlayer,
  27.           World parWorld, int parX, int parY, int parZ, int par7, float par8,
  28.           float par9, float par10)
  29.     {
  30.      // not sure what this parameter does, copied it from potato
  31.         if (par7 != 1)
  32.         {
  33.             return false;
  34.         }
  35.         // check if player has capability to edit
  36.         else if (parPlayer.canPlayerEdit(parX, parY+1, parZ, par7, parItemStack))
  37.         {
  38.             // check that the soil block can sustain the plant
  39.             // and that block above is air so there is room for plant to grow
  40.             if (parWorld.getBlock(parX, parY, parZ).canSustainPlant(parWorld,
  41.                   parX, parY, parZ, ForgeDirection.UP, this) && parWorld
  42.                   .isAirBlock(parX, parY+1, parZ))
  43.             {
  44.              // place the plant block
  45.                 parWorld.setBlock(parX, parY+1, parZ, theBlockPlant);
  46.                 // decrement the stack of seed items
  47.                 --parItemStack.stackSize;
  48.                 return true;
  49.             }
  50.             else
  51.             {
  52.                 return false;
  53.             }
  54.         }
  55.         else
  56.         {
  57.             return false;
  58.         }
  59.     }
  60.  
  61.     @Override
  62.     public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z)
  63.     {
  64.         return EnumPlantType.Cave;
  65.     }
  66.  
  67.     @Override
  68.     public Block getPlant(IBlockAccess world, int x, int y, int z)
  69.     {
  70.         return theBlockPlant;
  71.     }
  72.  
  73.     @Override
  74.     public int getPlantMetadata(IBlockAccess world, int x, int y, int z)
  75.     {
  76.         return 0;
  77.     }
  78.  
  79.     public Block getSoilId()
  80.     {
  81.         return soilId;
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement