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

so i made this new 'Ore' called Fertilized Dirt. It generates in the dirt on the surface of a world, but i want it to generate more near Villages.

Is there a way to detect nerby Village when generating the world?

 

BTW The block makes stone sound, even though i've set the material to GROUND, but i think it's problem with Forge, or has anything changed since 1.10?

 

Thanx for any response

setStepSound()

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.

If I did, I'd have said something, but I didn't, so 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.

  • Author

Ok, i made 4 variants - each with different metadata (0-3) and i want them to be randomly mixed in the veins.

 

package vms.archeology.worldgen;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.init.Biomes;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkGenerator;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import net.minecraft.world.gen.feature.WorldGenerator;
import net.minecraftforge.fml.common.IWorldGenerator;
import vms.archeology.blocks.FertilizedDirt;
import vms.archeology.init.ModBlocks;

public class DepositeGeneration implements IWorldGenerator{

private WorldGenerator villagers;

public DepositeGeneration() {
	fertilizedDirt = new WorldGenMinable(ModBlocks.fertilized_dirt.getDefaultState().withProperty(FertilizedDirt.DROP_ID, 0), 36, new DirtPredicate());
}

private void runGenerator(WorldGenerator generator, World world, Random rand, int chunk_X, int chunk_Z, int chancesToSpawn, int minHeight, int maxHeight) {
	if (minHeight < 0 || maxHeight > 256 || minHeight > maxHeight)
		throw new IllegalArgumentException("Illegal Height Arguments for WorldGenerator");

	int heightDiff = maxHeight - minHeight + 1;
	for (int i = 0; i < chancesToSpawn; i ++) {
		int x = chunk_X * 16 + rand.nextInt(16);
	        int y = minHeight + rand.nextInt(heightDiff);
	        int z = chunk_Z * 16 + rand.nextInt(16);
	        generator.generate(world, rand, new BlockPos(x, y, z));
	}
}

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
	switch(world.provider.getDimension()) {
	case 0:
		if(world.provider.getBiomeForCoords(new BlockPos(chunkX*16+random.nextInt(16),64,chunkZ*16+random.nextInt(16))) == Biomes.PLAINS){
			this.runGenerator(fertilizedDirt, world, random, chunkX, chunkZ, 50, 60, 90);
		}
	case 1:
		break;
	case -1:
		break;


	}
}

}

 

  • Author

how do i get from this if is village in the chunk, or where is the nearest village or something like that

  • Author

ok, i'm novice to programming in java, so can you please explain me how does this work?

 

i'm sorry, don't be mad at me please

  • Author

something like this?

 

if (MapGenVillage.Start.this.getBoundingBox().minX <= x && MapGenVillage.Start.this.getBoundingBox().maxX >= x)

  • Author

you mean IChunkProvider?

i tried this and i dont see any ChunkProviderOverworld passed into the generator

  • Author

THX

 

So if i understood correctly i can cast IchunkGenerator into ChunkProviderOverworld, but i can't figure out what next

  • Author

Ok, i have this:

if (chunkGenerator instanceof ChunkProviderOverworld) {
				ChunkProviderOverworld cpOverworld = (ChunkProviderOverworld) chunkProvider;
			}

 

if am i doing this right so far, how do i get the MapGenVillage out of it?

else tell me, what am i doing wrong

  • Author

I have this so far and i tried if it doesn't crash:

 

if (chunkGenerator instanceof ChunkProviderOverworld) {
			ChunkProviderOverworld cpOverworld = (ChunkProviderOverworld) chunkProvider;

			Field f;
			try {
				f = cpOverworld.getClass().getDeclaredField("villageGenerator");

				f.setAccessible(true);
				MapGenVillage genVillage = (MapGenVillage) f.get(cpOverworld);

				Utils.getLogger().info(genVillage.getStructureName());
			} catch (NoSuchFieldException e) {
				e.printStackTrace();
			} catch (SecurityException e) {
				e.printStackTrace();
			} catch (IllegalArgumentException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}

		}

 

But it crashes and i dont know why:

[19:14:52] [server thread/INFO]: Preparing start region for level 0
[19:14:53] [server thread/ERROR]: Encountered an unexpected exception
java.lang.ClassCastException: net.minecraft.world.gen.ChunkProviderServer cannot be cast to net.minecraft.world.gen.ChunkProviderOverworld
at vms.archeology.worldgen.DepositeGeneration.generate(DepositeGeneration.java:56) ~[DepositeGeneration.class:?]
at net.minecraftforge.fml.common.registry.GameRegistry.generateWorld(GameRegistry.java:122) ~[GameRegistry.class:?]
at net.minecraft.world.chunk.Chunk.populateChunk(Chunk.java:1070) ~[Chunk.class:?]
at net.minecraft.world.chunk.Chunk.populateChunk(Chunk.java:1052) ~[Chunk.class:?]
at net.minecraft.world.gen.ChunkProviderServer.provideChunk(ChunkProviderServer.java:164) ~[ChunkProviderServer.class:?]
at net.minecraft.server.MinecraftServer.initialWorldChunkLoad(MinecraftServer.java:340) ~[MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.loadAllWorlds(IntegratedServer.java:107) ~[integratedServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:124) ~[integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:507) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_111]

  • Author

I didn't notice that, sorry

 

BUT NOW IT WORKS!!

 

[19:31:42] [server thread/INFO] [archeology]: Village

 

I'll contiue and post something when i run into another dead end

  • Author

AWESOME

Everything seems to be working.

Tomorrow will be looking for the random metadata generation!

 

Thank you ;)

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.