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

  I have been looking around for how to get a mob (right now just a block for testing) to till and plant wheat.  Will have harvest and put in an inventory later.  Just working on the start for now.

 

  Well, I have the code done so it will check the nearby blocks out to 4 in each direction to see if it is dirt or grass.  I can't find how to till the ground, would it just be destroy the block and replace with a farmland?  Sadly, I haven't found the functions for doing that either.  I just don't know where to look for the functions, have looked in the JavaDocs but I don't see the logic in many of the groupings yet.

 

  A snippet would be great or just a function name that I can look up, anything for this poor old guy.  Thanks.

 

Marstone

if you can get the blocks x y amd z you can use worldObj.setblock(x,y.z.Id);

and then maybe set the block above to what ever in code a seed does.

@Chibill is right, but I found a more appropriate method. If you look inside the ItemHoe class, you'll find a method to use a hoe on a block. The code looks as follows:

 

            UseHoeEvent event = new UseHoeEvent(par2EntityPlayer, par1ItemStack, par3World, par4, par5, par6); // Create a new event on creating farmland
            if (MinecraftForge.EVENT_BUS.post(event)) // Push the event into the bus, returns false when cancelled
            {
                return false;
            }

            if (event.getResult() == Result.ALLOW) // Event returns true when dirt can be changed to farmland
            {
                par1ItemStack.damageItem(1, par2EntityPlayer); // Do your stuff here
                return true;
            }

 

You'll find this in the onItemUse() method :)

 

I don't know if you can use this for a "non existing" hoe stack (new ItemStack(Item.stoneHoe)), but it's worth a try.

  • Author

okay, yeah the x,y,z is known from the search of blocks that can be tilled.  Will give setblock a try.  Thanks for the idea, I am still way to new to this and finding things in JD doesn't come natural to my brain (yet).

 

as for the hoe event, maybe (I even looked at the hoe for how it worked and missed it).  Since it is a block or later a mob I wouldn't have a EntityPlayer to pass to the function.

 

  • Author

okay, got that working, using the world placeblock method right now.  Can anyone tell me what the actual block name of the farmland is?  It is item id 60 but would like to program it correctly using "Block.?farmLand?.blockID"  instead of hardcoding the 60 in.

 

When I change my villager from a block to an actual mob, I will try sending the hoe event to see if it will add the animation of the surface breaking like when a player hoes the ground.  Thanks guys, now on to working out more logic, then putting it under a mob.

  • Author

yea, found the name.  it is tilledfield.  Block.tilledField.blockID instead of 60.  Now on to collecting items dropped when breaking the crops.

 

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.