Jump to content

[1.7.10][SOLVED]Tree Generation In Custom Dimension


Recommended Posts

Posted

I have a tree generation issue with my mod. I can generate trees in my dimension but then it will also generate trees in the overworld. My goal is to have a custom tree that just generates in my dimension. Here is the code that causes this issue:

 

package com.mjj.colormod.handler;

import java.util.Random;

import com.mjj.colormod.dimension.WorldGenCrypticMinable;
import com.mjj.colormod.maps.CrypticWorldGenTrees;

import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenMinable;
import cpw.mods.fml.common.IWorldGenerator;

public class EventManager implements IWorldGenerator
{
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
{
	switch (world.provider.dimensionId)
	{
	case -1:
		generateNether(world, random, chunkX * 16, chunkZ * 16);
	case 0:
		generateSurface(world, random, chunkX * 16, chunkZ * 16);
	case 1:
		generateEnd(world, random, chunkX * 16, chunkZ * 16);
	case 3:
		generateCryptic(world, random, chunkX * 16, chunkZ * 16);
	}
}

private void generateEnd(World world, Random random, int x, int z)
{

}

private void generateCryptic(World world, Random random, int x, int z)
{
	for (int i = 0; i < 10; i++) 
	 {
	 //16x16 area up to y = 64
	 int randPosX = x + random.nextInt(16);
	 int randPosY = random.nextInt(64);
	 int randPosZ = z + random.nextInt(16);
	 // 10 blocks per vein
	 (new WorldGenCrypticMinable(BlockHandler.blueOre, 50)).generate(world, random, randPosX, randPosY, randPosZ);
	 }

	for(int t = 0; t < 20; t++){
		int chunkX = x + random.nextInt(16);
		int chunkY = random.nextInt(90);
		int chunkZ = z + random.nextInt(16);

		(new CrypticWorldGenTrees(false, 7, 0, 0, false)).generate(world, random, chunkX, chunkY, chunkZ);
	}
}

private void generateSurface(World world, Random random, int x, int z)
{
	this.addOreSpawn(BlockHandler.blueOre, world, random, x, z, 16, 16, 8, 6, 10, 65);
	this.addOreSpawn(BlockHandler.greenOre, world, random, x, z, 16, 16, 7, 5, 18, 45);
	this.addOreSpawn(BlockHandler.purpleOre, world, random, x, z, 16, 16, 6, 4, 2, 25);

	this.addOreSpawn(BlockHandler.redOre, world, random, x, z, 16, 16, 8, 6, 10, 65);
	this.addOreSpawn(BlockHandler.orangeOre, world, random, x, z, 16, 16, 7, 5, 18, 45);
	this.addOreSpawn(BlockHandler.yellowOre, world, random, x, z, 16, 16, 6, 4, 2, 25);
}

private void generateNether(World world, Random random, int x, int z)
{

}

/**
 * Adds an Ore Spawn to Minecraft. Simply register all Ores to spawn with this method in your Generation method in your IWorldGeneration extending Class
 * 
 * @param The Block to spawn
 * @param The World to spawn in
 * @param A Random object for retrieving random positions within the world to spawn the Block
 * @param An int for passing the X-Coordinate for the Generation method
 * @param An int for passing the Z-Coordinate for the Generation method
 * @param An int for setting the maximum X-Coordinate values for spawning on the X-Axis on a Per-Chunk basis
 * @param An int for setting the maximum Z-Coordinate values for spawning on the Z-Axis on a Per-Chunk basis
 * @param An int for setting the maximum size of a vein
 * @param An int for the Number of chances available for the Block to spawn per-chunk
 * @param An int for the minimum Y-Coordinate height at which this block may spawn
 * @param An int for the maximum Y-Coordinate height at which this block may spawn
 **/
public void addOreSpawn(Block block, World world, Random random, int blockXPos, int blockZPos, int maxX, int maxZ, int maxVeinSize, int chancesToSpawn, int minY, int maxY)
{
	assert maxY > minY : "The maximum Y must be greater than the Minimum Y";
	assert maxX > 0 && maxX <= 16 : "addOreSpawn: The Maximum X must be greater than 0 and less than 16";
	assert minY > 0 : "addOreSpawn: The Minimum Y must be greater than 0";
	assert maxY < 256 && maxY > 0 : "addOreSpawn: The Maximum Y must be less than 256 but greater than 0";
	assert maxZ > 0 && maxZ <= 16 : "addOreSpawn: The Maximum Z must be greater than 0 and less than 16";

	int diffBtwnMinMaxY = maxY - minY;
	for (int x = 0; x < chancesToSpawn; x++)
	{
		int posX = blockXPos + random.nextInt(maxX);
		int posY = minY + random.nextInt(diffBtwnMinMaxY);
		int posZ = blockZPos + random.nextInt(maxZ);
		(new WorldGenMinable(block, maxVeinSize)).generate(world, random, posX, posY, posZ);
	}
}
}

 

If I comment out:

for(int t = 0; t < 20; t++){
		int chunkX = x + random.nextInt(16);
		int chunkY = random.nextInt(90);
		int chunkZ = z + random.nextInt(16);

		(new CrypticWorldGenTrees(false, 7, 0, 0, false)).generate(world, random, chunkX, chunkY, chunkZ);
	}

 

that ^^^ it will remove both trees from the overworld and the custom dimension. I don't understand why though considering the the for loop is in the generateCryptic method not the generateSurface method. Any help would be much appriciated.

 

Thanks

~vandy22

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 can't figure out if you're looking for help trying to steal someone elses work, or cheat at the game....
    • Title: Why Is It So Hard to Rename and Restructure Mods Like Xray or AntiXray? 🤔 Post text: Hey everyone! I’ve been digging into Minecraft modding for a while and have one big question that I can’t figure out on my own. Maybe someone with more experience could help or give me some advice. Here’s the issue: When I take a “normal” Minecraft mod — for example, one that just adds some blocks or new items — I can easily change its structure, package names, or even rebrand it entirely. It’s straightforward. But as soon as I try this with cheat-type mods like XrayMod or AntiXray, everything falls apart. Even if I just rename the classes, refactor the packages, or hide its identity somehow, the mod either breaks or stops working properly. XrayMod in particular is proving to be a nightmare to modify without losing its core function. So my question is — why is this so much harder with cheat mods like Xray? Is there something fundamentally different about how they’re coded, loaded, or protected that prevents simple renaming or restructuring? And if so, how can I actually learn to understand someone else’s cheat mod enough to safely refactor it without breaking the core features? I’ve already been spending over two months trying to figure this out and haven’t gotten anywhere. It feels like there must be some trick or knowledge I’m missing. Would really appreciate any thoughts, tips, or references — maybe there are guides or techniques for understanding cheat-mod internals? Or if you’ve successfully “disguised” a cheat mod like Xray before, I’d love to hear how you did it. Thanks in advance for any help or discussion. ✌️
    • just started making cinamatic contect check it out on my channel or check out my facebook page    Humbug City Minecraft Youtube https://www.youtube.com/watch?v=v2N6OveKwno https://www.facebook.com/profile.php?id=61575866982337  
    • Where did you get the schematic? Source/Link? And do use an own modpack or a pre-configured from curseforge? If yes, which one On a later time, I can make some tests on my own - but I need the schematic and the modpack name
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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