Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.16.5] Will we see a return of the programmatic Dimension in 1.16+?


Recommended Posts

Hey all.
 

Title + Is there any possible way I can update my mod (code below) to 1.16? Can datapacks do this? Am I going about it wrong in 1.16?

 

Here is a brief sample of my problem:


I am updating an incomplete 1.12.2 mod I have to the latest version of forge.

In my mod, the dimension chunks are supposed to be semi-clones of the overworld (with tweaked settings). In 1.12.2, I could do this:
 

public class TUDChunkGenerator implements IChunkGenerator
{	
	protected final World overWorldObj;
	protected IChunkGenerator overworldChunkGenerator;
	
	protected final World worldObj;
	
	public TUDChunkGenerator(World overWorldObj, World worldObj)
	{
		this.overWorldObj = overWorldObj; //Should always be dimension 0, overworld.
		this.overworldChunkGenerator = overWorldObj.getWorldType().getChunkGenerator(worldObj, overWorldObj.getWorldInfo().getGeneratorOptions());
		
		this.worldObj = worldObj;
	}
	
	@Override
	public Chunk generateChunk(int x, int z)
	{
		return overworldChunkGenerator.generateChunk(x, z);
	}
	
	@Override
	public void populate(int x, int z)
	{
		overworldChunkGenerator.populate(x, z);
	}
	
	@Override
	public boolean generateStructures(Chunk chunkIn, int x, int z)
	{
		return overworldChunkGenerator.generateStructures(chunkIn, x, z);
	}
	
	...
}


While this worked wonderfully in the old times, the abandonment of the old school dimension support seems to have rendered my mod quite hard to do nowadays, if not impossible.

For starters, IChunkGenerator is gone.

import net.minecraft.world.gen.IChunkGenerator;

Now, I did notice that there is a net.minecraft.world.gen.ChunkGenerator, however it is almost entirely obfuscated. I see some related methods so there is some hope but it seems wrong to use, maybe impossible to use.

 

Is there anyway I can determine dimension in 1.16? See note 2 for possible answer.

Attached, I have included the critical .java files for my mod. They were previously made in the last recommended 1.12.2 build for forge. I put them here so you can review them in any chance anyone can help me. I am pretty concerned that none of this code will end up being effectively ported/replaced/updated to achieve the same goal.

Is there anyway I can use datapack dimensions to clone the overworld?
 

 

 

 

 


ACTIVE DEVELOPMENT NOTES
1: WorldProvider is gone. Maybe the replacement is net.minecraft.world.Dimension? However, that is marked final. Maybe the datapacks can replace this portion?


2: net.minecraft.block.AbstractFirBlock contains this:

   private static boolean canLightPortal(World world) {
      return world.getDimensionKey() == World.OVERWORLD || world.getDimensionKey() == World.THE_NETHER;
   }

    As long as the way MC creates those keys works, this should be a replacement for dimensionId comparisons

public static final RegistryKey<World> OVERWORLD = RegistryKey.getOrCreateKey(Registry.WORLD_KEY, new ResourceLocation("overworld"));
//old: 
activeWorld.provider.getDimension() == Config.theUpsideDownDimensionID

//new?:
activeWorld.getDimensionKey() == TUDDimension.TUDDimensionKey)


3: "World" seems to have been replaced by ServerWorld; at least the ChunkGeneration section.

	//OLD:
	public TUDChunkGenerator(World overWorldObj, World worldObj)
	{
		this.overworldChunkGenerator = overWorldObj.getWorldType().getChunkGenerator(worldObj, overWorldObj.getWorldInfo().getGeneratorOptions());
		
	//New?: /////UNTESTED//////, simple guess based of vanilla implementation
	public TUDChunkGenerator(ServerWorld overWorldObj, ServerWorld worldObj)
	{
		this.overworldChunkGenerator = overWorldObj.getChunkProvider().getChunkGenerator();
	}


4: ChunkGenerator::func_235957_b_() == ChunkGenerator::getDimensionStructureSettings()


5: Huh! No errors anymore. I can't even remotely test this yet, but I THINK this function relay could do exactly what the old one did. Assuming I can find a way to register/use this ChunkGenerator, I will report back.

package io.github.ragnarven.tud.dimension;

import com.mojang.serialization.Codec;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunk;
import net.minecraft.world.gen.*;
import net.minecraft.world.gen.feature.structure.StructureManager;
import net.minecraft.world.server.ServerWorld;

/**
 * Created by Andrew on 3/17/2020 at 8:50 PM.
 */
public class TUDChunkGenerator extends ChunkGenerator
{
	protected final World overWorldObj;
	protected ChunkGenerator overworldChunkGenerator;
	
	protected final World worldObj;
	
	//protected List<Biome.SpawnListEntry> mobs = Lists.newArrayList(/*new Biome.SpawnListEntry(EntityZombie.class, 100, 2, 2)*/);
	
	public TUDChunkGenerator(ServerWorld overWorldObj, ServerWorld worldObj)
	{
		super(overWorldObj.getChunkProvider().getChunkGenerator().getBiomeProvider(), overWorldObj.getChunkProvider().getChunkGenerator().func_235957_b_());
		this.overWorldObj = overWorldObj; //Should always be dimension 0, overworld.
		this.overworldChunkGenerator = overWorldObj.getChunkProvider().getChunkGenerator();
		
		this.worldObj = worldObj;
	}
	
	@Override
	protected Codec<? extends ChunkGenerator> func_230347_a_()
	{
		//I think thats has something to do with the registry stuff, I don't know enough to fill this in yet.
		//func_230347_a_ is also PROTECTED in ChunkGenerator. I am nearly certain I need to make some kind of registry key or codec for this.
		
		//net.minecraft.world.gen.FlatChunkGenerator
		//public static final Codec<FlatChunkGenerator> field_236069_d_ = FlatGenerationSettings.field_236932_a_.fieldOf("settings").xmap(FlatChunkGenerator::new, FlatChunkGenerator::func_236073_g_).codec();
		return null;
	}
	
	@Override
	public ChunkGenerator func_230349_a_(long p_230349_1_)
	{
		return this;
	}
	
	@Override
	public void generateSurface(WorldGenRegion worldGenRegion, IChunk chunk)
	{
		overworldChunkGenerator.generateSurface(worldGenRegion, chunk);
	}
	
	@Override
	public void func_230352_b_(IWorld world, StructureManager structureManager, IChunk chunk)
	{
		overworldChunkGenerator.func_230352_b_(world, structureManager, chunk);
	}
	
	@Override
	public int getHeight(int x, int z, Heightmap.Type heightmapType)
	{
		return overworldChunkGenerator.getHeight(x, z, heightmapType);
	}
	
	@Override
	public IBlockReader func_230348_a_(int p_230348_1_, int p_230348_2_)
	{
		return overworldChunkGenerator.func_230348_a_(p_230348_1_, p_230348_2_);
	}
}


6. Okay so now with the ChunkGenerator not erroring, I have to figure out how to replace my old WorldProvider (TUDDimensionUpsideDown.java below). This is going to brutal because WorldProvider is gone and I have no clue where it went. Dimension (as mentioned in note 1) is final. This may be the stopping point, short of some hacky fixes and I am pretty opposed to that. If you are reading this and can guide me, please help lol.

My initial thought is maybe somehow I can link my class to the datapack. Maybe I can register my ChunkGenerator as a GeneratorType as referenced by the [dimension_name].jsons?

//EXAMPLE: (currently does NOT replicate the overworld perfectly. Can't find vanilla datapacks)
{
	"type": "theupsidedown:theupsidedown",
	"generator": {
		"type": "minecraft:noise", //This line maybe? Certainly WILL require registry, maybe use of that codec function I cant figure out.
		"seed": 0,
		"settings": "minecraft:overworld",
		"biome_source": {
			"type": "minecraft:vanilla_layered",
			"seed": 0
		}
	}
}


7. Unfortunately, this appears to be the end of the line. There is no way to make a dimension without the json, data driven ones, which means I cannot register my custom ChunkGenerator at this time. Please see my feature request if you need such a feature too.





 

TUDAtmosphereHandler.java TUDChunkGenerator.java TUDDimensionUpsideDown.java

Edited by SubliminallySublime
Added to note 7. End of updates.
Link to post
Share on other sites
32 minutes ago, SubliminallySublime said:

If you know why my feature request was removed please let me know what I did wrong. 

It was removed, because you shouldn't be posting whats essentially the same topic twice.

Link to post
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.

Guest
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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.