Jump to content

Recommended Posts

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...

Posted

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)

Posted

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.

Posted

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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