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 a plant that I want generated in the swamps, I did that part, but I only want it to spawn near or within 2 blocks of water. I have a different plant that is using this code

 

 

 

public void randomDisplayTick(World world, int i, int j, int k, Random random)
        {
        	int dist=2;
            boolean isblocknear=false;
            for (int x0 = -dist; x0 <= dist; ++x0)
            {
            	for (int y0 = -dist; y0 <= dist; ++y0)
            	{
            		for (int z0 = -dist; z0 <= dist; ++z0)
            		{
            			if(world.getBlockId(i + x0, j + y0, k + z0)==MTJT.lovePlant.blockID && (x0!=0 || y0!=0 || z0!=0))
            			{
            				isblocknear=true;
            				world.spawnParticle("heart", i+0.5, j+1.0, k+0.5, 0.0D, 0.08D, 0.0D);
            				break;
            			}
            		}
            		if(isblocknear)
                    break;
            		}
            		if(isblocknear)
                    break;
            	} 
        			
        	}

 

 

 

This code will allow the plant if generated near another plant of the same type to spawn particles. It works great, but when applying this code to my other plant, it crashes the game...of course I changed the random display tick to on block added, and the Block love plant to the block waterstill. But this code is not working for the purpose I need.....Any help is appreciated

well first of all the three breaks is unnecessary

 

label0:
for(...
for(....
for(....)
if(....)
break label0;

 

also post the crash report please[/code]

I think its my java of the variables.

  • Author

Well, I figured out it was crashing because of the else statement I had after this

 

if(world.getBlockId(i + x0, j + y0, k + z0)==MTJT.lovePlant.blockID && (x0!=0 || y0!=0 || z0!=0))
            			{
            				isblocknear=true;
            				world.spawnParticle("heart", i+0.5, j+1.0, k+0.5, 0.0D, 0.08D, 0.0D);
            				break;
            			}

 

saying basically if it is not water than dont generate. I had removed the crash reports after this had stopped crashing when I removed it. I also found a method in the block class that may be of use, canPlaceBlockAt, not sure how I would modify this code I have or use the method properly. I also removed the breaks and it still spawns everywhere but where I want it to...

You might want to look at the existing plant code.  IIRC there's already a "nearby water" detection loop for spawning reeds.

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.

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.