Jump to content

Would that work ?


FloeyGh

Recommended Posts

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;

    }

}

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

You still have those

i1

,

j1

and

k1

variables.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

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

Link to comment
Share on other sites

 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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

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.

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



×
×
  • Create New...

Important Information

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