Minecraft – Generating all blocks of one type as another type

minecraft-java-edition

Is there a mod or other method by which I could have a world in which wherever one type of block would normally be generated another type would be instead? Specifically, I was thinking it would be interesting and difficult to attempt playing in a world where all generated wood would be generated as obsidian instead and vice versa.

Is there any existing way to do this? If not, can anyone guess how difficult such a mod would be to create? I've never done any modding of Minecraft before, but I have plenty of programming experience, and if it wouldn't be too time consuming of a project I would attempt it.

Best Answer

I know this is an older question but if you have not found a solution to this or a mod implementing this functionality already I am just making a quick glance over the Minecraft source generated by the latest Minecraft Coder Pack (9.03 for Minecraft 1.7.2) and in the BlockSapling class (net.minecraft.block.BlockSapling) I found a list of imports for the tree types that can be grown from saplings

import net.minecraft.world.gen.feature.WorldGenBigTree;
import net.minecraft.world.gen.feature.WorldGenCanopyTree;
import net.minecraft.world.gen.feature.WorldGenForest;
import net.minecraft.world.gen.feature.WorldGenMegaJungle;
import net.minecraft.world.gen.feature.WorldGenMegaPineTree;
import net.minecraft.world.gen.feature.WorldGenSavannaTree;
import net.minecraft.world.gen.feature.WorldGenTaiga2;
import net.minecraft.world.gen.feature.WorldGenTrees;
import net.minecraft.world.gen.feature.WorldGenerator;

In the tree generating classes there are generate methods

public boolean generate(World, Random, int, int, int)

Since these are the main tree generating classes for world generation you could find where they create the logs (Blocks.log and Blocks.log2) and change the generated type.

Keep in mind you will need to change the block leaves look for when they do their random tick (that is if you still want leaves). From what I can see you would change line 134 (as generated by this version of MCP) in net.minecraft.block.BlockLeaves

if (var15 != Blocks.log && var15 != Blocks.log2)

to

if (var15 != Blocks.obsidian)

As for obsidian to logs, you would need to do the following:

In BlockLiquid.java (net.minecraft.block.BlockLiquid) on line 526 (as generated by this version of MCP) you will find

p_149805_1_.setBlock(p_149805_2_, p_149805_3_, p_149805_4_, Blocks.obsidian);

which when deobfuscated would be

par1World.setBlock(xCoord, yCoord, zCoord, Blocks.obsidian);

you would change the Blocks.obsidian to Blocks.log and possibly set a randomized metadata value.

If you also wanted the obsidian in the end to be generated as logs you would edit net.minecraft.world.gen.feature.WorldGenSpikes, on line 55 (also as generated by the current MCP) you would do the same as above.

Now as I have seen in one of the comments, there is the problem of wood being burned by lava before the player can get to it. The solution to this is also the reason it was never a problem. The only time obsidian is created naturally is in The End (the obsidian pillars) and whenever water flows over lava. Since there would not naturally be any air around the obsidian (either being stone, gravel, ores, water, or lava) fire can not be started and cannot destroy the logs.

Edit: If you wanted to change the behavior and block type used by nether portals that might be a bit more complicated, and changing this would cause the possibility of burning portals, since they can be generated near fire or lava in either world.