Jump to content

[1.10.2] Problems picking up carrots


Dustpuppy

Recommended Posts

Hi,

it sounds silly, if i say that i have problems picking up carrots, but it's real.

I have a farming station. Works like i want, but not with carrots.

Problem is only at pickup of items.

It destroys the block if the crop is in the age to get harvested. Then it picks up all items inside a given box. It works for wheat + seeds, for potatoes, for my custom wheat.

If i plant carrots, it will pick them up and place into the seed slot, but in no other slot. All other crops will work right. First i was thinking, it's because carrots have no extra seeds, like wheat, but potatoes are working too and they also have no extra seed.

 

This is the part of the code, where i pickup the items.

Spoiler

	public void handlePickup() {
		BlockPos centerOfField = getCenterOfField();

		double posX = centerOfField.getX();
		double posY = centerOfField.getY();
		double posZ = centerOfField.getZ();
		if (!worldObj.isRemote) {
			for (Object obj : worldObj.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(posX - 3, posY - 3, posZ - 3, posX + 3, posY + 3, posZ + 3))) {
				if (obj instanceof EntityItem) 
				{
					EntityItem item = (EntityItem) obj;
					ItemStack pickupItemStack = item.getEntityItem();
					Item pickupItem = pickupItemStack.getItem();

					// go over all output slots
					for (int i = seedSlot; i < slotSize; i++) 
					{
						ItemStack stackSlot = getStackInSlot(i);
						if (stackSlot == null) 
						{
							if (i == seedSlot && (pickupItem == Items.WHEAT_SEEDS	|| pickupItem == Items.CARROT || pickupItem == Items.POTATO || pickupItem == thewizardmod.plants.StartupCommon.wheatSeeds)) 
							{
								setInventorySlotContents(i, pickupItemStack);
								item.setDead();
								break;
							}
							if (i > seedSlot) {
								setInventorySlotContents(i, pickupItemStack);
								item.setDead();
								break;
							}
						} 
						else 
						{
							Item slotItem = stackSlot.getItem();
							if (pickupItem == slotItem) 
							{
								if (stackSlot.stackSize < getInventoryStackLimit()) 
								{
									stackSlot.stackSize += pickupItemStack.stackSize;
									setInventorySlotContents(i, stackSlot);
									item.setDead();
									break;
								}
							}
						}
					}
				}
			}
		}
	}

 

 

Link to comment
Share on other sites

Wait!

The problem is bigger, then expected. It happens with every crop.

If the machine plants carrots, it will pick them up only until the seed slot is full.

If it plants potatoes,  just fills up the seed slot.

Same for wheat and custom wheat.

If i throw what ever on the field, it will be picked up.

 

Edited by Dustpuppy
Link to comment
Share on other sites

I'm getting mad. Changed the position of some variables. Now it's working, but not for potatos.

Spoiler

	public void handlePickup() {
		BlockPos centerOfField = getCenterOfField();

		double posX = centerOfField.getX();
		double posY = centerOfField.getY();
		double posZ = centerOfField.getZ();
		if (!worldObj.isRemote) {
			for (Object obj : worldObj.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(posX - 3, posY - 3, posZ - 3, posX + 3, posY + 3, posZ + 3))) {
				if (obj instanceof EntityItem) 
				{

					// go over all output slots
					for (int i = seedSlot; i < slotSize; i++) 
					{
						EntityItem item = (EntityItem) obj;
						ItemStack pickupItemStack = item.getEntityItem();
						Item pickupItem = pickupItemStack.getItem();
						ItemStack stackSlot = getStackInSlot(i);
						if (stackSlot == null) 
						{
							if (i == seedSlot && (pickupItem == Items.WHEAT_SEEDS	|| pickupItem == Items.CARROT || pickupItem == Items.POTATO || pickupItem == thewizardmod.plants.StartupCommon.wheatSeeds)) 
							{
								setInventorySlotContents(i, pickupItemStack);
								item.setDead();
								break;
							}
							if (i > seedSlot) {
								setInventorySlotContents(i, pickupItemStack);
								item.setDead();
								break;
							}
						} 
						else 
						{
							Item slotItem = stackSlot.getItem();
							if (pickupItem == slotItem) 
							{
								if (stackSlot.stackSize < getInventoryStackLimit()) 
								{
									stackSlot.stackSize += pickupItemStack.stackSize;
									setInventorySlotContents(i, stackSlot);
									item.setDead();
									break;
								}
							}
						}
					}
				}
			}
		}
	}

 

 

Link to comment
Share on other sites

You do know about getEntitiesWithinAABB(EntityItem.class, AABB) don't you?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Your post made no sense. None.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

On 9/14/2017 at 0:27 PM, Dustpuppy said:

The problem is bigger, then expected. It happens with every crop.

How much time have you spent stepping through your code in the debugger? Invest an hour or two doing that and then come back with your observations (if you even have any remaining bugs).

Edited by jeffryfisher

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • look my mod-pack with 300+ plus mods is crashing and I'm not sure what mod is causing this it was working fine not that long ago... and if no one knows then my question would be is how do you read crash logs Crash Log https://pastebin.com/tak3uuEm 
    • I try to play with better combat, I install its dependency but it tells me that it needs version 1.0.2 and I already have it, what do I do? the dependency is player animator
    • I think my save file was potentially corrupted (based on what I have been reading online). The world has loaded and saved perfectly fine for weeks. Today I added about 6 new mods and updated 3 mod libraries, and then encountered the following error: "Errors in currently selected data packs prevented the world from loading. You can either try to load it with only the vanilla data pack ("safe mode"), or go back to the title screen and fix it manually." I have tried changing to a newer Forge version, reverting the updated mods back to original versions, removing the new mods, removing and readding all mods, removing my world file and loading the forge profile and adding it back, renaming the level.dat_old file as level.dat... Nothing has worked yet. Forge loads fine and I don't want to risk trying to reload the world in "safe mode" in case I end up losing mod-related content. Not sure how that works. I am having trouble reading the output log to determine what is causing the error. Any advice is better than none!! Thank you!     Info: Minecraft 1.20.1 Forge 47.1.3 Mod list (includes which mods are disabled, newly added before this error, and any changes I found after the error) : https://pastebin.com/nquXY1Hj Latest log: https://pastebin.com/U4fD0kAt
    • It all began with a chance encounter with a testimonial shared by Olivia, a fellow traveler on the winding road of cryptocurrency. Her words spoke of a miraculous recovery orchestrated by Wizard Web Recovery, a beacon of hope in the murky waters of online fraud. Intrigued by her story, I reached out to Wizard Web Recovery, hoping they could work their magic on my blocked crypto recovery. With bated breath, I shared my plight, providing evidence of my dilemma and praying for a solution. To my astonishment, a prompt response came, swift and reassuring. Wizard Web Recovery wasted no time in assessing my situation, guiding me through the process with patience and expertise. and then like a ray of sunshine breaking through the clouds, came the news I had longed for – a new private key had been generated, restoring my precious bitcoins. It was a moment of jubilation, a triumph over adversity that filled me with newfound hope. At that moment, I realized the true power of Wizard Web Recovery, not just as skilled technicians, but as guardians of trust in the digital realm. With their assistance, I reclaimed what was rightfully mine, turning despair into determination and paving the way for a brighter future. But their capabilities did not end there. Delving deeper into their expertise, I discovered that Wizard Web Recovery possessed a wealth of knowledge in reclaiming lost stolen cryptocurrency, and even exposing fraudulent investment schemes. So to all those who find themselves entangled in the web of online fraud, take heart. With the guidance of Wizard Web Recovery, there is a path to redemption.     Write Mail; ( Wizard webrecovery AT  vprogrammer. net ) 
    • It all began with a chance encounter with a testimonial shared by Olivia, a fellow traveler on the winding road of cryptocurrency. Her words spoke of a miraculous recovery orchestrated by Wizard Web Recovery, a beacon of hope in the murky waters of online fraud. Intrigued by her story, I reached out to Wizard Web Recovery, hoping they could work their magic on my blocked crypto recovery. With bated breath, I shared my plight, providing evidence of my dilemma and praying for a solution. To my astonishment, a prompt response came, swift and reassuring. Wizard Web Recovery wasted no time in assessing my situation, guiding me through the process with patience and expertise. and then like a ray of sunshine breaking through the clouds, came the news I had longed for – a new private key had been generated, restoring my precious bitcoins. It was a moment of jubilation, a triumph over adversity that filled me with newfound hope. At that moment, I realized the true power of Wizard Web Recovery, not just as skilled technicians, but as guardians of trust in the digital realm. With their assistance, I reclaimed what was rightfully mine, turning despair into determination and paving the way for a brighter future. But their capabilities did not end there. Delving deeper into their expertise, I discovered that Wizard Web Recovery possessed a wealth of knowledge in reclaiming lost stolen cryptocurrency, and even exposing fraudulent investment schemes. So to all those who find themselves entangled in the web of online fraud, take heart. With the guidance of Wizard Web Recovery, there is a path to redemption.    
  • Topics

×
×
  • Create New...

Important Information

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