Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.theishiopian.foragecraft.blocks;
- import java.util.List;
- import java.util.Random;
- import net.minecraft.block.BlockCrops;
- import net.minecraft.block.SoundType;
- import net.minecraft.block.state.IBlockState;
- import net.minecraft.client.renderer.block.model.ModelResourceLocation;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.math.BlockPos;
- import net.minecraft.world.IBlockAccess;
- import net.minecraftforge.client.model.ModelLoader;
- import net.minecraftforge.fml.relauncher.Side;
- import net.minecraftforge.fml.relauncher.SideOnly;
- public class ModCropsBasic extends BlockCrops
- {
- private final Item crop;
- private final Item seed;
- // creates a basic, vanilla style crop block, similar to wheat or potatoes.
- // Currently used for leeks
- public ModCropsBasic(Item seed, Item crop, String name)
- {
- this.setDefaultState(this.blockState.getBaseState().withProperty(this.getAgeProperty(), Integer.valueOf(0)));
- this.setTickRandomly(true);
- this.setCreativeTab((CreativeTabs) null); //sure, why not?
- this.setHardness(0.0F);
- this.setSoundType(SoundType.PLANT);
- this.disableStats();//???
- this.crop = crop;
- this.seed = seed;
- this.setUnlocalizedName(name).setRegistryName(name);//don't forget to register ;)
- }
- @Override
- public int getMaxAge()
- {
- return 7;
- }
- @Override
- public Item getSeed()
- {
- return this.seed;
- }
- @Override
- public Item getCrop()
- {
- return this.crop;
- }
- @SideOnly(Side.CLIENT)
- public void initModel()
- {
- ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), 0,
- new ModelResourceLocation(getRegistryName(), "inventory"));
- }
- @Override
- public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
- {
- List<ItemStack> dropList = new java.util.ArrayList<ItemStack>();
- if(this.getAge(state)<7)dropList.add(new ItemStack(this.seed));
- else
- {
- Random rand = new Random();
- dropList.add(new ItemStack(this.crop, rand.nextInt(2)+1));
- dropList.add(new ItemStack(this.seed, rand.nextInt(1)+1));
- }
- return dropList;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement