Jump to content

Recommended Posts

Posted

I recently tried to update Doomlike Dungeons to 1.10.2; the update to 1.10 was so easy, it literally required no code changes to make it work.  Unfortunately this doesn't seem to be the case with 1.10.2.  The code produces no errors, but my IWorldGenerator class (GenerationHandler) never seems to be triggered or to trigger world-gen.  Everything works correctly when I spawn a dungeon in with a cheat code, they never appear with natural world-gen -- the game runs normally but no dungeons ever generation (without cheats).

 

I'm not sure if something has to be registered differently, or if there is some extra-registration, or what -- or if this is simply a bug in the new Forge version.  I've tried moving the registration of the IWorldGenerator out the constructor, but this made no difference.

 

From DoomlikeDungoens.java:

    
    @EventHandler 
    public void init(FMLInitializationEvent event) {
    	if(ConfigHandler.naturalSpawn) dungeonPlacer = new GenerationHandler();
    }

 

 

My IWorldGenerator:

 

package jaredbgreat.dldungeons;


/* 
* This mod is the creation and copyright (c) 2015 
* of Jared Blackburn (JaredBGreat).
* 
* It is licensed under the creative commons 4.0 attribution license: * 
* https://creativecommons.org/licenses/by/4.0/legalcode
*/	


import static jaredbgreat.dldungeons.builder.Builder.placeDungeon;

import java.util.HashSet;
import java.util.Random;

import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkGenerator;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.BiomeDictionary.Type;
import net.minecraftforge.fml.common.IWorldGenerator;
import net.minecraftforge.fml.common.registry.GameRegistry;

/**
* The class responcible for determine where dungeons generate.  More 
* specifically, it will determine if a chunk being generated should be 
* the technical (not geometric) center of a dungeon.
* 
* @author Jared Blackburn
*
*/
public class GenerationHandler implements IWorldGenerator {

private static int frequency;
private static int factor = 6;
private static int minXZ;
private static Random mrand;
private static HashSet<Integer> dimensions;

public GenerationHandler() {
	GameRegistry.registerWorldGenerator(this, 100);
}


/**
 * Called when a new chunk generates to determine if a dungeon should be 
 * built centered on that chunk.
 * 
 * First it will make sure dungeons are aloud, including all config setting 
 * and world setting as well as the dimension and biome of the chunk.
 * 
 * If dungeons are allowed here then it will check if the chunk is the one 
 * in its area to have a dungeon.  To do this the map is logically divided 
 * into square areas the size of which depend on the frequency scale.  One 
 * chunk in each area is the technical center around with a dungeon will 
 * generate.  The chunk coordinates are divided by the area's width using 
 * integer division to round so that all chunks in the same area are given
 * the same two numbers.  These numbers are then used to create a random 
 * seeds from which coordinates from 0 to the area width are generated. If
 * the coords match the remainder of chunk coordinate divided by the width
 * of the area this chunk will have a dungeon; since all chunks in the area
 * will use the same random seed and thus have the same number one and only
 * one of them will have a dungeon (assuming dungeons are allowed in the 
 * worlds and in that chunk).
 * 
 * This allows dungeons to be placed randomly while ensuring a more consistent
 * distribution than simply giving each a random probability to have one.
 */
@Override
public void generate(Random random, int chunkX, int chunkZ, World world,
		IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
	// Prevent bad spawns
	if(world.isRemote) return;
	if((ConfigHandler.obeyRule && !world.getWorldInfo().isMapFeaturesEnabled())
			|| !ConfigHandler.naturalSpawn) return; 
	boolean blockedBiome = false;
	Type[] types = BiomeDictionary.getTypesForBiome((world.getBiomeGenForCoords(new BlockPos(chunkX * 16, 63, chunkZ * 16))));
	for(Type type : types) {			
		blockedBiome = ConfigHandler.biomeExclusions.contains(type) || blockedBiome;
	}
	if(blockedBiome) return;
	if((dimensions.contains(Integer.valueOf(world.provider.getDimension())) != ConfigHandler.positiveDims)) return;
	if((Math.abs(chunkX - (world.getSpawnPoint().getX() / 16)) < minXZ) 
			|| (Math.abs(chunkZ - (world.getSpawnPoint().getZ() / 16)) < minXZ)) return;

	mrand = new Random(world.getSeed() + world.provider.getDimension()
			+ (2027 * (long)(chunkX / factor)) 
			+ (1987 * (long)(chunkZ / factor)));
	int xrand = mrand.nextInt();
	int zrand = mrand.nextInt();
	int xuse = ((chunkX + xrand) % factor);
	int zuse = ((chunkZ + zrand) % factor);

	if((xuse == 0) && (zuse == 0)) {
		try {
			placeDungeon(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider);
		} catch (Throwable e) {
			System.err.println("[DLDUNGEONS] Danger!  Failed to finalize a dungeon after building!");
			e.printStackTrace();
		}
	}
}	


/**
 * Sets the frequency scale and converts into the 
 * width (and height) of the areas for which dungeons
 * are generated.
 * 
 * @param freqScale
 */
public static void setFrequency(int freqScale) {
	if((freqScale % 2) == 0) factor = 2;
	else factor = 3;
	System.out.println("freqScale = " + freqScale);
	factor = (1 << (freqScale / 2)) * factor;
	System.out.println("factor = " + factor);
}


/**
 * Sets the minimum number of chunks from spawn a dungeon center must be.
 * 
 * @param value
 */
public static void setMinXZ(int value) {
	minXZ = value;		
}


/**
 * Sets list of dimension id's to check for dungeons being allowed.
 * 
 * @param value
 */
public static void setDimensions(int[] value) {
	dimensions = new HashSet<Integer>();
	for(int i = 0; i < value.length; i++) {
		dimensions.add(Integer.valueOf(value[i]));
	}
}


/**
 * Add a dimension id to the list of dimension to consider when 
 * check if a dungeon is allowed.  (What this means can vary.)
 * 
 * @param value
 */
public static void addDimension(int value) {
	dimensions.add(Integer.valueOf(value));
}


/**
 * Remove a dimension id from the list of those to consider when potentially 
 * placing a dungeons.  (What this means can vary.)
 * 
 * @param value
 */
public static void subDimension(int value) {
	dimensions.remove(Integer.valueOf(value));
}
}

 

 

Does anyone know what's happened to break this? -- or is this actually Forge bug?

Developer of Doomlike Dungeons.

Posted

It's in the constrictor for his generator

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

So, does anyone know what's going on -- or should this be reported as a bug?  Its the same code that worked for 1.10, and 1.9.4.  I have tried moving the registration out of the constructor to the code block that creates it (since something don't like be registered on creation), but that made no difference.

 

At this point, I'm thinking this actually is a Forge bug rather than an error of mine.

Developer of Doomlike Dungeons.

Posted

Try setting a breakpoint in

GenerationHandler#generate

, running Minecraft in debug mode and generating new chunks; is the breakpoint hit?

 

Also set a breakpoint in

GameRegistry.generateWorld

and see if the

GenerationHandler

instance is in

worldGenerators

,

worldGeneratorIndex

and

sortedGeneratorList

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Well, I used the simple profiler I built in (since F3 info isn't that good for infrequence, time consuming events).

 

It seems that GenerationHandler is working fine, but there was something wrong with the config.  I don't understand it, but it wasn't reading the config, but after I simply deleted it and let a new one be generated everything worked -- no change in the config reading code.  It wasn't generating dungeons because it was too close to spawn and hadn't read in the config changes I'd made to let them appear at a distance of 0.  Text editors read it fine, and Minecraft reads the new one fine.  So now it works, I just don't know what the problem was.

Developer of Doomlike Dungeons.

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

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

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