Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Well, as some of you may know already, I made a tool that when right clicked on crops it will drop the items from that crop and also some extra.

 

Problem now is that when using combined with Pam's Harvescraft and the function that mod has for right click to harvest crops (My mod does it also, but I disabled my right click on this tests) so, problem is, that the effect of my tool gets "nulled" The code gets called but nothing spawns in the world.

 

	public void spawnDrops(List<ItemStack> doDrops, World world, BlockPos pos, ItemStack stack, EntityPlayer player){

	world.playSound(player, pos, SoundEvents.BLOCK_CLOTH_FALL, SoundCategory.BLOCKS, 1.0F, 1.0F);

	System.out.println(doDrops);

	if(!world.isRemote){

		System.out.println("REMOTE");

	for(ItemStack drop : doDrops){

		EntityItem itemDrop = new EntityItem(world, pos.getX()+.5, pos.getY()+.5, pos.getZ()+.5, drop);
	   	world.spawnEntityInWorld(itemDrop);
	   	
	   	System.out.println("DROP");
	   	   	
	   	dropExtra = this.returnToolChances(stack.getItem());
	   	
	   	if(dropExtra==0){
	   	
	   	EntityItem itemDropExtra = new EntityItem(world, pos.getX()+.5, pos.getY()+.5, pos.getZ()+.5, drop.copy());
	   	world.spawnEntityInWorld(itemDropExtra);
	   	
	   	System.out.println("EXTRA");
	   	
	   	}

	}

	stack.damageItem(1, player);

	}
}

 

System.out.println(doDrops); prints in the console, however System.out.println("REMOTE"); never prints. But as soon as I disable the Right click functionality on Pams my code works ok again.

 

Anyone has any clue what could be going on here? I have some guesses, but not sure...

  • Author

Where are you calling spawnDrops? Why are you spawning drops manually? You should be using HarvestDropsEvent and add to the list of drops there.

I don't think I have access to the HarvestDropsEvent maybe I'm wrong, really not sure. All this happens when the player right clicks on a crop and the crop is ready to harvest.

 

I'm still polishing the code and making it better, so I really don't have to check for the type of crop and it's max age, but instead use the isMaxAge present on BlockCrops (On the future for sure I will ask help about how to make it work with crops from other mods, for example Pams)

 

So, the code can be found here http://pastebin.com/j7hHsQNd (Please don't laugh too hard :P I learn something new every day)

  • Author

Sorry I forgot to add, even when the sound that is present there plays, the item never takes damage, so, I don't know why, but somehow that code is stopped somewhere before it completes running.

 

My guess was that Pams is returning "EnumActionResult.SUCCESS;" at some point and my code stop executing? But I don't know if that even possible.

  • Author

There is no way your code is simply stopped in the middle of a method. Please use a debugger and find out where exactly the execution goes in your method.

Thanks, never did that, so not sure what you talking about, but gonna investigate. Hopefully that works outside Eclipse as I have to do that test with Pams Harvestcraft installed.

 

From more testings, clearly something on Pams Harvestcraft is making my part of the code that is on "if(!world.isRemote)" to not execute. Here are the console Logs from Eclipse, and from MultiMC both, with Pams Right Click enabled and disabled.

 

3Tu5iwy.png

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.