Jump to content

Recommended Posts

Posted

Hi.

 

Not too long ago I made a thread about my WorldGen system's odd behaviour.

I am not porting, but entirely rewriting my mod for 1.10.2. This is to ensure better code quality.

 

Anyways, I now need to remake the WorldGen system. I have a few problems and questions about this.

 

The main issues/questions I have are these:

 

  • My ores spawn very far away from the spawn. How are chunk coordinates chosen? Completely randomly, or based on player's position?
  • Can't keep up! Did the system time change... 

    is my system not efficient?

  • The main issue. To spawn my copper ore, I practically use iron's settings (count, vein size, min/max Y coords), but my ore is basically extremely common. It spawns in exponentially larger veins than iron does. Of course, I could just tune the settings down, but why does this happen, if I mostly use adapted vanilla code, and iron ore generation settings?

 

Now, explained what my issues are, here is the code.

 

[spoiler=ModWorldGen.java]

public class ModWorldGen {

private final static int NETHER = -1, OVERWORLD = 0, END = 1;

public static void register() {
	registerFeature(new FeatureOre(ModOres.Ore.COPPER, Blocks.STONE, 20, 8, 8, 0, 64), OVERWORLD);
	//registerFeature(new FeatureOre(ModOres.Ore.TIN, Blocks.STONE, 16, 6, 6, 0, 64), OVERWORLD);
}

private static void registerFeature(Feature feature, int... dimensions) {
	GameRegistry.registerWorldGenerator(new WorldGenFeature(feature, dimensions), 0);
}
}

 

 

 

[spoiler=WorldGenFeature.java]

public class WorldGenFeature implements IWorldGenerator {

private final Feature feature;
private final int[] dimensions;

public WorldGenFeature(Feature feature, int... dimensions) {
	this.feature = feature;
	this.dimensions = dimensions;
}

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
	if (ArrayUtils.contains(dimensions, world.provider.getDimension())) {
		feature.generate(new Random(), world, chunkZ, chunkZ);
	}
}
}

 

 

 

[spoiler=Feature.java]

public abstract class Feature {

protected int count, minY, maxY;

public Feature(int count, int minY, int maxY) {
	this.count = count;
	this.minY = minY;
	this.maxY = maxY;
}

public abstract void generate(Random random, World world, int chunkX, int chunkZ);
}

 

 

 

[spoiler=FeatureOre.java]

public class FeatureOre extends Feature {

private IBlockState blockOre, blockStone;
private int minSize, maxSize;

public FeatureOre(IVariant ore, IBlockState blockStone, int count, int minSize, int maxSize, int minY, int maxY) {
	super(count, minY, maxY);
	this.blockOre = Block.getBlockFromItem(ore.toItemStack(1).getItem()).getStateFromMeta(ore.getMetadata());
	this.blockStone = blockStone;
	this.minSize = minSize;
	this.maxSize = maxSize;
}

public FeatureOre(IVariant ore, Block blockStone, int count, int minSize, int maxSize, int minY, int maxY) {
	this(ore, blockStone.getDefaultState(), count, minSize, maxSize, minY, maxY);
}

@Override
public void generate(Random random, World world, int chunkX, int chunkZ) {
	final BlockPos chunkPos = new BlockPos(chunkX * 16, minY, chunkZ * 16);
	//Copper's size is 8 (both min and max being , like iron.
	int oreVeinSize = minSize + random.nextInt(Math.max(maxSize - minSize, 1));

	//Copper's count is 20, like iron.
	for (int i = 0; i < count; i++) {
		new WorldGenMinable(blockOre, oreVeinSize, BlockMatcher.forBlock(blockStone.getBlock())).generate(world, random, chunkPos.add(random.nextInt(16), random.nextInt(Math.max(maxY - minY, 0)), random.nextInt(16)));
	}	        
}
}

 

 

 

Edit: Something went wrong. Adding the code now.

Here you go.

I try my best, so apologies if I said something obviously stupid!

Posted

I seem to have solved my issues with some random seed trickery; I still have a question for you.

 

The only "problem" left is the slight lag that my (?) world gen causes.

Even though I am just generating one ore, it sometimes says

Can't keep up! Did the system time change ...

in the console. The amount of ticks skipped is not too large, but still quite substantial (peaking at 173 ticks skipped).

 

Does this happen even on vanilla worlds? I could understand if the whole minecraft world generation would be causing this, not just my mod's. (as such errors are prompted when flying through the sky, and on world creation)

I try my best, so apologies if I said something obviously stupid!

Posted

That was my best guess anyways.

Aah, alright, no point in this thread anymore!  ;)

I try my best, so apologies if I said something obviously stupid!

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

    • been getting this error and followed the old tick loop post however i cant figure out what file to delete Description: Exception in server tick loop java.lang.NullPointerException: Cannot invoke "net.minecraft.world.level.LevelAccessor.m_7654_()" because the return value of "net.minecraftforge.event.level.LevelEvent$Unload.getLevel()" is null     at com.lion.graveyard.platform.forge.HordeSpawner.onWorldUnload(HordeSpawner.java:41) ~[The_Graveyard_3.1_(FORGE)_for_1.20.1.jar%23196!/:?] {re:classloading}     at com.lion.graveyard.platform.forge.__HordeSpawner_onWorldUnload_Unload.invoke(.dynamic) ~[The_Graveyard_3.1_(FORGE)_for_1.20.1.jar%23196!/:?] {re:classloading,pl:eventbus:B}     at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.mehvahdjukaar.moonlight.api.platform.forge.PlatHelperImpl.invokeLevelUnload(PlatHelperImpl.java:279) ~[moonlight-1.20-2.13.66-forge.jar%23185!/:?] {re:classloading}     at net.mehvahdjukaar.moonlight.api.platform.PlatHelper.invokeLevelUnload(PlatHelper.java) ~[moonlight-1.20-2.13.66-forge.jar%23185!/:?] {re:mixin,re:classloading}     at net.mehvahdjukaar.moonlight.core.misc.FakeLevelManager.invalidate(FakeLevelManager.java:29) ~[moonlight-1.20-2.13.66-forge.jar%23185!/:?] {re:classloading}     at net.mehvahdjukaar.supplementaries.common.utils.fake_level.BlockTestLevel.invalidate(BlockTestLevel.java:34) ~[supplementaries-1.20-3.1.13.jar%23192!/:?] {re:classloading}     at net.mehvahdjukaar.supplementaries.common.block.faucet.FaucetBehaviorsManager.onReloadWithLevel(FaucetBehaviorsManager.java:129) ~[supplementaries-1.20-3.1.13.jar%23192!/:?] {re:classloading}     at net.mehvahdjukaar.supplementaries.common.events.ServerEvents.onServerStart(ServerEvents.java:160) ~[supplementaries-1.20-3.1.13.jar%23192!/:?] {re:mixin,re:classloading}     at net.mehvahdjukaar.supplementaries.common.events.forge.ServerEventsForge.onServerStart(ServerEventsForge.java:119) ~[supplementaries-1.20-3.1.13.jar%23192!/:?] {re:classloading}     at net.mehvahdjukaar.supplementaries.common.events.forge.__ServerEventsForge_onServerStart_ServerStartedEvent.invoke(.dynamic) ~[supplementaries-1.20-3.1.13.jar%23192!/:?] {re:classloading,pl:eventbus:B}     at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.server.ServerLifecycleHooks.handleServerStarted(ServerLifecycleHooks.java:115) ~[forge-1.20.1-47.3.29-universal.jar%23212!/:?] {re:classloading}     at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:638) ~[server-1.20.1-20230612.114412-srg.jar%23207!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraftserver,xf:fml:xaerominimap:xaero_minecraftserver,re:classloading,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraftserver,xf:fml:xaerominimap:xaero_minecraftserver,pl:mixin:APP:unionlib.mixins.json:MinecraftServerMixin,pl:mixin:APP:citadel.mixins.json:MinecraftServerMixin,pl:mixin:APP:balm.mixins.json:MinecraftServerMixin,pl:mixin:A}     at net.minecraft.server.MinecraftServer.m_206580_(MinecraftServer.java:251) ~[server-1.20.1-20230612.114412-srg.jar%23207!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraftserver,xf:fml:xaerominimap:xaero_minecraftserver,re:classloading,pl:accesstransformer:B,xf:fml:xaeroworldmap:xaero_wm_minecraftserver,xf:fml:xaerominimap:xaero_minecraftserver,pl:mixin:APP:unionlib.mixins.json:MinecraftServerMixin,pl:mixin:APP:citadel.mixins.json:MinecraftServerMixin,pl:mixin:APP:balm.mixins.json:MinecraftServerMixin,pl:mixin:A}     at java.lang.Thread.run(Thread.java:833) ~[?:?] {}  
    • Online forums in general seem to be declining in popularity imo. There’s still value here for certain types of content, such as written tutorials and blog posts which would otherwise get lost in the chat history fairly quickly on Discord. Also for those that prefer the forums format ofc. But for faster support related topics, I agree that the Discord is probably your best bet at the moment. The speed of responses is also down to the ratio of volunteers - the player support forum still seems pretty active, but the coding ones much less so. Once you’re feeling more confident in your modding skills, be the change you want to see
    • try the same link, i swapped logs after sitting in the world for a few minutes then leaving. Lmk if it keeps happening then ill just send a video of the live log on modrinth
    • It is an issue with chimes
  • Topics

×
×
  • Create New...

Important Information

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