Posted March 25, 201312 yr I have been working on adding compost to my mod I created the item for it and the recipes. My plan is for compost to be similar to bone meal but different. Rather than fully growing the wheat it will make the wheat have a better harvest. In order to accomplish this I created a new crop file that is a copy of the BlockCrops with a few minor changes. My issue is I don't know how to detect when a player right clicks the wheat with compost in their hand and then replace it with my version of the wheat. I figured I would use an event but I'm not sure which one or how the code would work. TIA. Here is my custom crops code and my compost item code. CropCompostedWheat.java package richard.RecipeExpansionPack; //Removed the imports to make it easier for you guys to read public class CropCompostedWheat extends BlockCrops { @SideOnly(Side.CLIENT) private Icon[] field_94363_a; protected CropCompostedWheat(int par1) { super(par1); this.setTickRandomly(true); float f = 0.5F; this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f); this.setCreativeTab((CreativeTabs)null); this.setHardness(0.0F); this.setStepSound(soundGrassFootstep); this.disableStats(); } /** * Gets the growth rate for the crop. Setup to encourage rows by halving growth rate if there is diagonals, crops on * different sides that aren't opposing, and by adding growth for every crop next to this one (and for crop below * this one). Args: x, y, z */ @SideOnly(Side.CLIENT) /** * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata */ public Icon getBlockTextureFromSideAndMetadata(int par1, int par2) { if (par2 < 0 || par2 > 7) { par2 = 7; } return this.field_94363_a[par2]; } /** * Returns the ID of the items to drop on destruction. */ @Override public int quantityDropped(Random par1Random) { return 3; } @SideOnly(Side.CLIENT) @Override public void func_94332_a(IconRegister par1IconRegister) { this.field_94363_a = new Icon[8]; for (int i = 0; i < this.field_94363_a.length; ++i) { this.field_94363_a[i] = par1IconRegister.func_94245_a("RecipeExpansionPack:cropsc_" + i); } } } ItemCompostComplete.java package richard.RecipeExpansionPack; //Again Removed Imports public class ItemCompostComplete extends Item { public ItemCompostComplete(int par1) { super(par1); } public void func_94581_a(IconRegister iconRegister) { iconIndex = iconRegister.func_94245_a("RecipeExpansionPack:woodbucket-c"); } } RecipeExpansionPack.java package richard.RecipeExpansionPack; //Removed Imports @Mod(modid="REP", name="RecipeExpansionPack", version="1.0.0") @NetworkMod(clientSideRequired=true, serverSideRequired=false) public class RecipeExpansionPack { // The instance of your mod that Forge uses. @Instance("RecipeExpansionPack") public static RecipeExpansionPack instance; //New Items public static Item bucketWoodEmpty = (new ItemWoodBucket(5000, 0)).setUnlocalizedName("woodbucket").setMaxStackSize(16); public static Item bucketWoodWater = (new ItemWoodBucket(5001, Block.waterMoving.blockID)).setUnlocalizedName("woodbucketWater").setContainerItem(bucketWoodEmpty); public static Item bucketWoodMilk = (new ItemWoodBucketMilk(5002)).setUnlocalizedName("woodbucketmilk").setContainerItem(bucketWoodEmpty); public static Item bucketCompostOne = new ItemCompostOne(5003).setUnlocalizedName("wcompostone"); public static Item bucketCompostTwo = new ItemCompostTwo(5004).setUnlocalizedName("wcomposttwo"); public static Item bucketCompostThree = new ItemCompostThree(5005).setUnlocalizedName("wcompostthree"); public static Item bucketCompostComplete = new ItemCompostComplete(5006).setUnlocalizedName("wcompostcomplete"); //New Blocks public static final Block CompostedWheatCrop = new CropCompostedWheat(503); // Says where the client and server 'proxy' code is loaded. @SidedProxy(clientSide="richard.RecipeExpansionPack.client.ClientProxy", serverSide="richard.RecipeExpansionPack.CommonProxy") public static CommonProxy proxy; @PreInit public void preInit(FMLPreInitializationEvent event) { // Stub Method } @Init public void load(FMLInitializationEvent event) { proxy.registerRenderers(); //Register new events MinecraftForge.EVENT_BUS.register(new ModEvents()); //Register New Blocks & Set names of Items GameRegistry.registerBlock(CompostedWheatCrop, "CompostedWheatCrop"); LanguageRegistry.addName(bucketWoodEmpty, "Wooden Bucket"); LanguageRegistry.addName(bucketWoodWater, "Water Bucket"); LanguageRegistry.addName(bucketWoodMilk, "Milk Bucket"); LanguageRegistry.addName(bucketCompostOne, "Compost - 1/4"); LanguageRegistry.addName(bucketCompostTwo, "Compost - 2/4"); LanguageRegistry.addName(bucketCompostThree, "Compost - 3/4"); LanguageRegistry.addName(bucketCompostComplete, "Compost"); //Recipe for Compost - 1 GameRegistry.addShapelessRecipe(new ItemStack(bucketCompostOne), new ItemStack(Item.seeds), new ItemStack(bucketWoodEmpty)); GameRegistry.addShapelessRecipe(new ItemStack(bucketCompostOne), new ItemStack(Block.sapling), new ItemStack(bucketWoodEmpty)); //Recipe for Compost - 2 GameRegistry.addShapelessRecipe(new ItemStack(bucketCompostTwo), new ItemStack(Item.seeds), new ItemStack(bucketCompostOne)); GameRegistry.addShapelessRecipe(new ItemStack(bucketCompostTwo), new ItemStack(Block.sapling), new ItemStack(bucketCompostOne)); //Recipe for Compost - 3 GameRegistry.addShapelessRecipe(new ItemStack(bucketCompostThree), new ItemStack(Item.seeds), new ItemStack(bucketCompostTwo)); GameRegistry.addShapelessRecipe(new ItemStack(bucketCompostThree), new ItemStack(Block.sapling), new ItemStack(bucketCompostTwo)); //Recipe for Compost - final GameRegistry.addShapelessRecipe(new ItemStack(bucketCompostComplete), new ItemStack(Item.seeds), new ItemStack(bucketCompostThree)); GameRegistry.addShapelessRecipe(new ItemStack(bucketCompostComplete), new ItemStack(Block.sapling), new ItemStack(bucketCompostThree)); } @PostInit public void postInit(FMLPostInitializationEvent event) { // Stub Method } } Creator of the Recipe Expansion Pack mod. http://www.minecraftforum.net/topic/1983421-172-forge-recipe-expansion-pack-version-012/ Updated to 1.7.2!
March 25, 201312 yr Have you looked at how bonemeal works? I guess the onItemUse could be the one you are looking for? If you guys dont get it.. then well ya.. try harder...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.