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

package com.Floey.Core;

 

import net.minecraft.world.World;

import net.minecraft.world.gen.feature.WorldGenerator;

 

import java.util.Random;

 

public class IWorldGen extends WorldGenerator

{

 

    @Override

    public boolean generate(World p_76484_1_, Random p_76484_2_, int p_76484_3_, int p_76484_4_, int p_76484_5_) {

        for (int l = 0; l < 10; ++l)

        {

            int i1 = p_76484_3_ + p_76484_2_.nextInt[nobbc](8)[/nobbc] - p_76484_2_.nextInt[nobbc](8)[/nobbc];

            int j1 = p_76484_4_ + p_76484_2_.nextInt(4) - p_76484_2_.nextInt(4);

            int k1 = p_76484_5_ + p_76484_2_.nextInt[nobbc](8)[/nobbc] - p_76484_2_.nextInt[nobbc](8)[/nobbc];

 

            if (p_76484_1_.isAirBlock(i1, j1, k1))

            {

                int l1 = 1 + p_76484_2_.nextInt(p_76484_2_.nextInt(1) + 1);

 

                for (int i2 = 0; i2 < l1; ++i2)

                {

                    if (Registry.blockSharpStone.canBlockStay(p_76484_1_, i1, j1 + i2, k1))

                    {

                        p_76484_1_.setBlock(i1, j1 + i2, k1, Registry.blockSharpStone, 0, 2);

                    }

                }

            }

        }

 

        return true;

    }

}

 

  • Author

Thanks

 

I would like my block in the world Spawns but I have no idea how to do it xD

name your variables from p_76484_2 to something more understandable.

alt-shift-r does wonders.

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.

  • Author

package com.Floey.Core;

import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenerator;

import java.util.Random;

public class IWorldGen extends WorldGenerator
{

    @Override
    public boolean generate(World Chunk, Random Random, int BlockX, int BlockY, int BlockZ) {
        for (int l = 0; l < 10; ++l)
        {
            int i1 = BlockX + Random.nextInt( - Random.nextInt(;
            int j1 = BlockY + Random.nextInt(4) - Random.nextInt(4);
            int k1 = BlockZ + Random.nextInt( - Random.nextInt(;

            if (Chunk.isAirBlock(i1, j1, k1))
            {
                int l1 = 1 + Random.nextInt(Random.nextInt(1) + 1);

                for (int i2 = 0; i2 < l1; ++i2)
                {
                    if (Registry.blockSharpStone.canBlockStay(Chunk, i1, j1 + i2, k1))
                    {
                        Chunk.setBlock(i1, j1 + i2, k1, Registry.blockSharpStone, 0, 2);
                    }
                }
            }
        }

        return true;
    }
}

Better ?

What are i1, j1 and k1?

 

(Tip: you can disable smileys by clicking on "Attachments and other options" before posting.)

You should find a tutorial which explains things thoroughly, and make sure you actually read everything else, not just the code. You clearly didn't write that yourself, or else you would know what those variables are.

Giving the topic a nicer (more descriptive) name would be helpful as well.

just you wait! ;)

  • Author

package com.Floey.Core;

 

import net.minecraft.world.World;

import net.minecraft.world.gen.feature.WorldGenerator;

 

import java.util.Random;

 

public class IWorldGen extends WorldGenerator

{

 

    @Override

    public boolean generate(World world, Random Random, int BlockX, int BlockY, int BlockZ) {

        for (int l = 0; l < 10; ++l)

        {

            int x = BlockX + Random.nextInt(8) - Random.nextInt(8);

            int y = BlockY + Random.nextInt(4) - Random.nextInt(4);

            int z = BlockZ + Random.nextInt(8) - Random.nextInt(8);

 

            if (world.isAirBlock(x, y, z))

            {

                int l1 = 1 + Random.nextInt(Random.nextInt(1) + 1);

 

                for (int i2 = 0; i2 < l1; ++i2)

                {

                    if (Registry.blockSharpStone.canBlockStay(world, x, y + i2, z))

                    {

                        world.setBlock(x, y + i2, z, Registry.blockSharpStone, 0, 2);

                    }

                }

            }

        }

 

        return true;

    }

}

 

but now :D

 int l1 = 1 + Random.nextInt(Random.nextInt(1) + 1);

 

l1 (which is a bad variable name) will always be 1.  A random number from 0 (inclusive) to 1 (exclusive) will always be 0.  0 + 1 = 1, rand(1) again will always be 0.  0 + 1 = 1, l1 is 1.

 

And I don't know what the problem is.  You didn't say.  That said,

BlockX, BlockY, and BlockZ

are not block locations, they're chunk locations.  You need to multiply them by 16 before you do anything with them.

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.

Can't they just give me the right code? pls xD

 

Nope.

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.

Can't they just give me the right code? pls xD

 

That's not what modding is about.

 

We can guide you but you do all the stuff by yourself.

If my post helped you, please press that "Thank You"-button to show your appreciation.

 

Also if you don't know Java, I would suggest you read the official tutorials by Oracle to get an idea of how to do this. Thanks, and good modding!

 

Also if you haven't, set up a Git repo for your mod not only for convinience but also to make it easier to help you.

Modding requires basic programming knowledge. If you are not willing to spend some time learning at least the basics, you should not make a mod. Nobody will write your mod for you.

 

Well they could.  Bud you'd have to pay them.

I get paid about $25 an hour for my workjob, but freelance I'd charge $250/hr.

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.

  • Author

public class IWorldGen implements IWorldGenerator {

    @Override

    public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {

        int xMin = chunkX << 4;

        int zMin = chunkZ << 4;

 

        int startX = xMin + random.nextInt(16);

        int startZ = zMin + random.nextInt(16);

 

        int tries = random.nextInt(2);

 

        for (int i = 0; i < tries; i++) {

            int x = startX + random.nextInt(8) - random.nextInt(8);

            int z = startZ + random.nextInt(8) - random.nextInt(8);

            int y = world.getHeightValue(x, z);

 

            if ((world.isAirBlock(x, y, z) || (world.getBlock(x, y, z) == Blocks.snow)) && Registry.blockSharpStone.canBlockStay(world, x, y, z)) {

                if (random.nextInt(50) > 1)

                    continue;

 

                world.setBlock(x, y, z, Registry.blockSharpStone, 0, 0);

            }

        }

    }

}

 

For the code? 0.0

Your second set of randoms, inside the for-loop, can cause (almost certainly will cause) the "I am generating in this chunk" to decide "nope, I'm generating in the next chunk."  Drop the +random(16) from the definition of startX and startZ and instead put them in place of the rand(8 ) - rand(8 )

 

Secondly, your maximum number of tries shouldn't be random if you're just going to discard 98% of the valid positions (and a countless number of invalid ones).  To boot, you're trying "at most one time."

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.

  • Author

public class IWorldGen implements IWorldGenerator {

    @Override

    public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {

        int xMin = chunkX << 4;

        int zMin = chunkZ << 4;

 

        int startX = xMin- random.nextInt(8);

        int startZ = zMin - random.nextInt(8);

 

        int tries = random.nextInt(2);

 

        for (int i = 0; i < tries; i++) {

            int x = startX + random.nextInt(8) - random.nextInt(8);

            int z = startZ + random.nextInt(8) - random.nextInt(8);

            int y = world.getHeightValue(x, z);

 

            if ((world.isAirBlock(x, y, z) || (world.getBlock(x, y, z) == Blocks.snow)) && Registry.blockSharpStone.canBlockStay(world, x, y, z)) {

                if (random.nextInt(50) > 1)

                    continue;

 

                world.setBlock(x, y, z, Registry.blockSharpStone, 0, 0);

            }

        }

    }

}

 

is it ok ?

No

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.