Question Clientbound Packet for Biomes

Mondbrille

New member
Hi everyone,

I'm collecting data of the current weather, temperature, sunrise, sunset and so on via OpenWeatherMap API.

My goal is to let it snow if it's <= 0°C and only rain if it's > 0°C.

To achieve this my idea is to set the biome permanently to smoething snowy, like SNOWY_PLAINS and if it's > 0°C I just cancel the BlockFormEvent (only if snow is due to form of course). So snow layers won't be able to form if > 0°C, but the player still sees snow instead of rain.

Is it possible to just replace the biome in the clientbound packets to e.g. PLAINS, if it's > 0°C and if so, how is this done?
 
Last edited:

Mondbrille

New member
I did some research and reverse engineering the couple last days. My results so far:

The packet is ClientboundLevelChunkWithLightPacket.

I created two own classes, CustomLevelChunk and CustomLevelChunkSection, which replace the original ones in the packet.

When the packet is about to send, my plugin cancels the original packet, creates a new ClientboundLevelChunkWithLightPacket with my custom objects and sends it to the client.

The biomes are stored in LevelChunkSection#biomes which type is PalettedContainer<Holder<Biome>>.

This works so far, but is there a better way than iterating through every block like i do in CustomLevelChunk#changeBiome(Biome) to change the biome for the whole chunk? Is it maybe possible to directly create a PalettedContainer completely filled with a biome in the constructor of CustomLevelChunkSection? And if so, how is this done? I have no idea how to use PalettedContainer 🤔
 

Attachments

  • CustomLevelChunk.java.txt
    2.1 KB · Views: 4
  • CustomLevelChunkSection.java.txt
    755 bytes · Views: 3
Last edited: