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 am a tutorial-reading, source-code-speculating newb, so pardon my ignorance.

 

When I try to make a block plant something, the plant appears, but as soon as I interact with it (right-click, left-click, etc.), it disappears.  I hope that this is a problem that you veterans are familiar with, because I have no real idea what's going on.

 

I want to make a version of a dropper that plants on tilled soil.  To do this, I made a block, extended the dropper class, and overwrote the dispense method. 

 

In the method, I call the onItemUse method of the seeds, and according to a println, the 'player', ' x' ,'y' ,'z' , and 'direction' of the onItemUse call are the same as when I do it myself (manually planting still works).

 

here is what I added to the dispense method.

                	//first, we parasitically use the first player in the world list.
                	//(change this later)
                	World world=Minecraft.getMinecraft().theWorld;
                	int tarx=x + Facing.offsetsXForSide[i1],
                		tary=y + Facing.offsetsYForSide[i1],
                		tarz=z + Facing.offsetsZForSide[i1];
                	float	f1=1, f2=1, f3=1;
                	boolean used = false;
                    if (world.playerEntities.size()>0)
                    {
                    	EntityPlayer oddballPlayer = (EntityPlayer) world.playerEntities.get(0);
                		used = itemstack.getItem().onItemUse(itemstack, oddballPlayer, world, tarx, tary, tarz, 1, f1, f2, f3);
                    	if (used){
                			System.out.println("I PLANTED!");
                		}else{
                			System.out.println("I tried...");
                		}
                	}

                    if (used){
                    	itemstack1 = itemstack.copy();

                    	if (--itemstack1.stackSize == 0)
                    	{
                    		itemstack1 = null;
                    	}	
                    }else{
                    	itemstack1 = getBehaviorForItemStack(itemstack).dispense(blocksourceimpl, itemstack);
                    }

 

the full class is here:

http://pastebin.com/2cQKdpGE

//first, we parasitically use the first player in the world list.
                	//(change this later)
                	World world=Minecraft.getMinecraft().theWorld;

You need to change that now. It is client-side only, while placing blocks is server side.

  • Author
You need to change that now.

 

Thanks GoToLink!

 

I wondered if this was some client/server thing, but as I said, I'm new, and I really don't know how the client/server thing works.  If you have any advice on learning the client/server thing, I'll eat it up, but if not, I'm sure I can figure it out somewhere else.

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.