Jump to content

[1.7.10][SOLVED] Need help with a 1 layer flat chunk generator


Recommended Posts

Posted

Hey there, I'm working on a custom dimension but for my dimension i need a chunk provider that makes it so it only generates a custom block 1 layer above the void. Although I've tried reading into guides/tutrials about world generation i could not put my head around it. Would someone be able to help me out as I find the world generating code quite confusing?

Posted

In your dimension's

IChunkProvider

in

provideChunk

method, create new

Chunk

with

Block[]

in arguments. Pas it as

Block[]

blocks

where

Block[] blocks = new Block[655536]

. Before creating new

Chunk

, fill

blocks

with blocks you need, where you need, using this to set block:

blocks[blockXPos <<11 | blockZPos << 7 | blockYPos] = blockYouWantThere

.

Posted

I assume you meant something like this?

 

public Chunk provideChunk(int par1, int par2)
{
	Block[] blocks = new Block[655536];
	Chunk chunk = new Chunk(world, blocks, par2, par2);
	for(int x = 0; x < 16; x++)
	{
		for(int z = 0; z < 16; z++)
		{
			blocks[0] = BlockHandler.MossDirt;
		}
	}
	return chunk;
}

Posted
  On 10/27/2015 at 5:27 PM, nexusrightsi said:

I assume you meant something like this?

 

public Chunk provideChunk(int par1, int par2)
{
	Block[] blocks = new Block[655536];
	Chunk chunk = new Chunk(world, blocks, par2, par2);
	for(int x = 0; x < 16; x++)
	{
		for(int z = 0; z < 16; z++)
		{
			blocks[0] = BlockHandler.MossDirt;
		}
	}
	return chunk;
}

Nearly. Apply changes to

blocks

before

Chunk chunk = new Chunk

. Also, below i told you how to convert x, y and inside chunk to position in

blocks

(

x<<11 | z<< 7 | y

).

Posted

I honestly don't get it. the "below i told you how to convert x, y and inside chunk to position in blocks (x<<11 | z<< 7 | y)" confuses me of what to do. could you perhaps give me some pseudo-code example?

Posted
  On 10/27/2015 at 7:25 PM, nexusrightsi said:

I honestly don't get it. the "below i told you how to convert x, y and inside chunk to position in blocks (x<<11 | z<< 7 | y)" confuses me of what to do. could you perhaps give me some pseudo-code example?

Ok, let's say that i want to set some blocks blocks at (x, y, z) to diamond blocks.

In here, i'm putting diamond blocks at (0, 0, 0), (12, 128, 16) and (7, 245, 11):

blocks[0<<11 | 0<< 7 | 0] = Blocks.diamondBlock;
blocks[12<<11 | 16<< 7 | 128] = Blocks.diamondBlock;
blocks[7<<11 | 11<< 7 | 245] = Blocks.diamondBlock;

Posted

You don't want 655536, but 16*16*128=65536, see the extra 5?

 

Also, he told you to populate the

blocks

array before making a new chunk, else you would create an empty Chunk and than populate an array which will never be used again in that method.

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/

Posted

right got that, while i was at it i tried testing out to see if i was able to enter the dimension. Although the teleporter tp'd me back onto the exact same spot i already was in the overworld...

if(!world.isRemote)
	{

		FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().transferPlayerToDimension( (EntityPlayerMP) player,
				0, new TeleportTo(MinecraftServer.getServer().worldServerForDimension(ARMain.dimensionId))); 
	}

was used to tp to my dimension. its called upon activating a block.

Posted
  On 10/27/2015 at 8:28 PM, elix said:

  Quote

You don't want 655536, but 16*16*128=65536, see the extra 5?

Yes, not 655536... But neither 16*16*128 (=32768) xD...

You want 16*16*256=65536...

 

I figured xD ah well thanks anyways for the help, i just assume that I switch out the coords with the ints of my for loops so it runs through the entire chunk.

Posted
  On 10/27/2015 at 8:30 PM, nexusrightsi said:

  Quote

  Quote

You don't want 655536, but 16*16*128=65536, see the extra 5?

Yes, not 655536... But neither 16*16*128 (=32768) xD...

You want 16*16*256=65536...

 

I figured xD ah well thanks anyways for the help, i just assume that I switch out the coords with the ints of my for loops so it runs through the entire chunk.

Yup. But do you need to run through entire chunk? Or just through y=1? Don't do unnecessary operations. Null blocks in [] will be automatically read as air.

Posted
  On 10/27/2015 at 8:40 PM, elix said:

  Quote

  Quote

  Quote

You don't want 655536, but 16*16*128=65536, see the extra 5?

Yes, not 655536... But neither 16*16*128 (=32768) xD...

You want 16*16*256=65536...

 

I figured xD ah well thanks anyways for the help, i just assume that I switch out the coords with the ints of my for loops so it runs through the entire chunk.

Yup. But do you need to run through entire chunk? Or just through y=1? Don't do unnecessary operations. Null blocks in [] will be automatically read as air.

 

Oh no, not at all. I'm just running through the x and z's of the chunk because the y is always constant. also  while i was at it i tried testing out to see if i was able to enter the dimension. Although the teleporter tp'd me back onto the exact same spot i already was in the overworld...

if(!world.isRemote)
	{

		FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().transferPlayerToDimension( (EntityPlayerMP) player,
				0, new TeleportTo(MinecraftServer.getServer().worldServerForDimension(ARMain.dimensionId))); 
	}

was used to tp to my dimension. its called upon activating a block.

Posted

I seem to have a new problem now where it only places 1 block per chunk instead of running through my for loops for the entire x and z square coords. X6oUi3b.png

 

public Chunk provideChunk(int par1, int par2)
{
	Block[] blocks = new Block[65536];
	blocks[0] = BlockHandler.MossDirt;
	Chunk chunk = new Chunk(world, blocks, par1, par2);
	for(int x = 0; x < 15; x++)
	{
		for(int z = 0; z < 15; z++)
		{
			blocks[x<<11 | z<< 7 | 0] = BlockHandler.MossDirt;
		}
	}
	chunk.generateSkylightMap();

	return chunk;
}

Posted
  On 10/28/2015 at 9:20 AM, nexusrightsi said:

I seem to have a new problem now where it only places 1 block per chunk instead of running through my for loops for the entire x and z square coords. X6oUi3b.png

 

public Chunk provideChunk(int par1, int par2)
{
	Block[] blocks = new Block[65536];
	blocks[0] = BlockHandler.MossDirt;
	Chunk chunk = new Chunk(world, blocks, par1, par2);
	for(int x = 0; x < 15; x++)
	{
		for(int z = 0; z < 15; z++)
		{
			blocks[x<<11 | z<< 7 | 0] = BlockHandler.MossDirt;
		}
	}
	chunk.generateSkylightMap();

	return chunk;
}

Didn't i say that you run your loops before

Chunk chunk = new Chunk

? Or was it on another thread about dimensions? Anyway, you must run your loops before creating new chunk.

Posted
  On 10/28/2015 at 1:58 PM, nexusrightsi said:

Thank you, that fixed it ^_^also, nah you only told me to do the blocks array before the actual chunk creation. but thanks a lot!

Ok. If it is fixed, add [sOLVED] to the title after mc version. Like that, everybody knows that this problem is solved :) .

Posted
  On 10/28/2015 at 2:13 PM, elix said:

  Quote

Thank you, that fixed it ^_^also, nah you only told me to do the blocks array before the actual chunk creation. but thanks a lot!

Ok. If it is fixed, add [sOLVED] to the title after mc version. Like that, everybody knows that this problem is solved :) .

Done and done ^_^

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I'm developing a Forge mod for Minecraft 1.16.5 to run on CatServer (version 1.16.5-1d8d6313, Forge 36.2.39). My mod needs to get the player's UUID from a ServerPlayerEntity object within a Forge ServerChatEvent handler. When I use serverPlayerEntity.getUUID(), my mod compiles fine, but I get a java.lang.NoSuchMethodError: net.minecraft.entity.player.ServerPlayerEntity.getUUID()Ljava/util/UUID; at runtime. I cannot use serverPlayerEntity.getUniqueID() as it causes a compile error (cannot find symbol). Is there a known issue with this on CatServer, or a recommended way for a Forge mod to reliably get a player's UUID from ServerPlayerEntity in this environment? My goal is to pass this UUID to the LuckPerms API (which is running as a Bukkit plugin and successfully connected via ServicesManager). erorr ChatMod: FMLServerStartedEvent received. Attempting to initialize LuckPerms connection... [22:45:20] [Server thread/INFO]: ⚙️ Початок ініціалізації LuckPerms API через Bukkit Services Manager... [22:45:20] [Server thread/INFO]: ✅ Bukkit ServicesManager успішно отримано. [22:45:20] [Server thread/INFO]: ✅ Реєстрацію сервісу LuckPerms знайдено. [22:45:20] [Server thread/INFO]: ✅ API LuckPerms успішно отримано від Bukkit plugin! [22:45:20] [Server thread/INFO]: Використовується реалізація: me.lucko.luckperms.common.api.LuckPermsApiProvider [22:45:20] [Server thread/INFO]: ✅ LuckPerms API схоже що успішно ініціалізовано через Bukkit Services Manager. [22:45:24] [User Authenticator #1/INFO]: UUID of player Hiklee is 92cd7721-2652-3867-896b-2ceba5b99306 [22:45:25] [Server thread/INFO]: Using new advancement loading for net.minecraft.advancements.PlayerAdvancements@24cb7a68 [22:45:26] [Server thread/INFO]: Hiklee[/127.0.0.1:41122] logged in with entity id 210 at (92.23203876864889, 95.6183020148442, 68.24087802017877) [22:45:28] [Async Chat Thread - #0/INFO]: ✅ Скасовано стандартне відправлення чату! [22:45:28] [Async Chat Thread - #0/ERROR]: Exception caught during firing event: net.minecraft.entity.player.ServerPlayerEntity.getUUID()Ljava/util/UUID; Index: 1 Listeners: 0: NORMAL 1: ASM: class com.example.chatmod.ChatEventHandler onPlayerChat(Lnet/minecraftforge/event/ServerChatEvent;)V java.lang.NoSuchMethodError: net.minecraft.entity.player.ServerPlayerEntity.getUUID()Ljava/util/UUID; at com.example.chatmod.ChatPacketHandler.getPlayerPrefix(ChatPacketHandler.java:46) at com.example.chatmod.ChatEventHandler.onPlayerChat(ChatEventHandler.java:32) at net.minecraftforge.eventbus.ASMEventHandler_1_ChatEventHandler_onPlayerChat_ServerChatEvent.invoke(.dynamic) at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) at net.minecraftforge.eventbus.EventBus.post(EventBus.java:303) at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283) at net.minecraftforge.common.ForgeHooks.onServerChatEvent(ForgeHooks.java:493) at net.minecraft.network.play.ServerPlayNetHandler.chat(ServerPlayNetHandler.java:1717) at net.minecraft.network.play.ServerPlayNetHandler.func_244548_c(ServerPlayNetHandler.java:1666) at net.minecraft.network.play.ServerPlayNetHandler.func_147354_a(ServerPlayNetHandler.java:1605) at net.minecraft.network.play.client.CChatMessagePacket.lambda$handle$0(CChatMessagePacket.java:34) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:750
    • Thank you so much for your help, I'll try it as soon as I can. I have a genuine question because I'm not familiar with the matter: Can a recipe error cause something as serious as the AMD error?
    • When i try to launch my modpack, the instance crashes and this is sent to the logs: Time: 2025-05-27 23:07:18 Description: Rendering overlay Below is the full log: https://mclo.gs/jP5G2EH
    • Make a test without delightful
  • Topics

×
×
  • Create New...

Important Information

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