Jump to content

Search the Community

Showing results for tags 'worldgen'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Minecraft Forge
    • Releases
    • Support & Bug Reports
    • Suggestions
    • General Discussion
  • Mod Developer Central
    • Modder Support
    • User Submitted Tutorials
  • Non-Forge
    • Site News (non-forge)
    • Minecraft General
    • Off-topic
  • Forge Mods
    • Mods

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


XMPP/GTalk


Gender


URL


Location


ICQ


AIM


Yahoo IM


MSN Messenger


Personal Text

Found 6 results

  1. So i have a custom ore and, arround the ore, a bunch of randomly placed custom stone blocks should be placed. After applying it, i've found that it causes moderate to extreme world generation lag (new chunks refusing to load after moving for a while, height slices of the same chunk appearing and disappearing as I get into them instead of the usual long continous chunk, new chunks generating extremely close to me instead of to the set render distance...) I've been debugging for a while and I know for a fact this is causing the lag (and sometimes freeze of the world loading screen on a new world and/or the saving world screen when quitting), since comenting it just makes the worldgen work as usual and I want to see if its really that computationally expensive, if there are other ways of doing it or if the process can be simplfied or optimized. I've tried a lot of combinations for the same code but I am just stuck. Is it some kind of generation cascading im missing? Here is the code for the class. The code inside the if (placed) is the one causing this mess. I can see that the code might not be the most optimized thing, but it does what's supposed to... but at the cost of causing all this. Any tips? package es.nullbyte.relativedimensions.worldgen.oregen.oreplacements; import es.nullbyte.relativedimensions.blocks.BlockInit; import es.nullbyte.relativedimensions.blocks.ModBlockTags; import net.minecraft.core.BlockPos; import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; import net.minecraft.world.level.levelgen.feature.OreFeature; import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration; import java.util.Optional; public class AberrantOreFeature extends OreFeature { public AberrantOreFeature() { super(OreConfiguration.CODEC); } @Override public boolean place(FeaturePlaceContext<OreConfiguration> ctx) { // Get the world and the position from the context WorldGenLevel world = ctx.level(); BlockPos origin = ctx.origin(); // Offset the origin by 8 in the x and z directions to avoid cascading chunk generation BlockPos offsetOrigin = origin.offset(8, 0, 8); // Create a new context with the offset origin FeaturePlaceContext<OreConfiguration> offsetCtx = new FeaturePlaceContext<>( Optional.empty(), world, ctx.chunkGenerator(), ctx.random(), offsetOrigin, ctx.config() ); // Generate the entire vein of ore at the offset origin boolean placed = super.place(offsetCtx); // If the vein was generated successfully if (placed) { // Define the block to replace surrounding blocks with BlockState surroundingBlockState = BlockInit.ABERRANT_MINERALOID.get().defaultBlockState(); // Generate a random size for the area of corruption int areaSizeX = ctx.random().nextInt(3) + 1; // between 1 and 4 int areaSizeY = ctx.random().nextInt(3) + 1; // between 1 and 4 int areaSizeZ = ctx.random().nextInt(3) + 1; // between 1 and 4 // Calculate the number of blocks to be corrupted based on the area size double numBlocksToCorrupt = (areaSizeX + areaSizeY + areaSizeZ / 2.0) ; // Counter for the number of blocks corrupted int numBlocksCorrupted = 0; // Loop for each block to be corrupted while (numBlocksCorrupted < numBlocksToCorrupt) { // Generate a random position within the area, using the offset origin BlockPos randomPos = offsetOrigin.offset( ctx.random().nextInt(2 * areaSizeX + 1) - areaSizeX, // between -areaSize and areaSize ctx.random().nextInt(2 * areaSizeY + 1) - areaSizeY, ctx.random().nextInt(2 * areaSizeZ + 1) - areaSizeZ ); // If the block at the random position is in the IS_ORE_ABERRANTABLE tag, replace it if (world.getBlockState(randomPos).is(ModBlockTags.STONE_ABERRANTABLE)) { world.setBlock(randomPos, surroundingBlockState, 2); numBlocksCorrupted++; } } } return placed; } }
  2. Hello, I want to create an item that when used, generates a structure. (structure don't generates naturally in world) Now I am having trouble generating a structure (jigsaw). The code below works, BUT the structure does not appear in the world until I re-enter it. This is a significant flaw that I would like to get rid of. My current code: public class MineshaftSpawnerItem extends Item { public MineshaftSpawnerItem(Properties pProperties) { super(pProperties); } @Override public @NotNull InteractionResult useOn(UseOnContext pContext) { Level pLevel = pContext.getLevel(); Player pPlayer = pContext.getPlayer(); BlockPos pBlockPos = pContext.getClickedPos(); ItemStack item = pContext.getItemInHand(); if (!pLevel.isClientSide()) { assert pPlayer != null; item.setCount(0); String command = MessageFormat.format("place structure weirdoitems:mineshaft {0} {1} {2}", pBlockPos.getX(), pBlockPos.getY(), pBlockPos.getZ()); System.out.println(command); try { Objects.requireNonNull(pLevel.getServer()).getCommands().getDispatcher().execute(command, pLevel.getServer().createCommandSourceStack()); } catch (CommandSyntaxException e) { throw new RuntimeException(e); } } return InteractionResult.PASS; } } I know about the PlaceCommand.placeStructure() method, but I can't figure out how to use it, and I can't find any documentation or examples of how to use it on the internet. Edit: I searched and tried normal options to solve this problem for a very long time, but nothing. I ended up doing it like this. And it works (in my case). @Override public @NotNull InteractionResult useOn(UseOnContext pContext) { Level pLevel = pContext.getLevel(); BlockPos pBlockPos = pContext.getClickedPos(); ItemStack item = pContext.getItemInHand(); if (!pLevel.isClientSide()) { item.setCount(0); JigsawBlockEntity jigsawBlockEntity = new JigsawBlockEntity(pBlockPos, Blocks.JIGSAW.defaultBlockState()); jigsawBlockEntity.setPool(Pools.createKey("weirdoitems:mineshaft/tunnels")); jigsawBlockEntity.setName(new ResourceLocation("weirdoitems:tunnel")); jigsawBlockEntity.setTarget(new ResourceLocation("weirdoitems:tunnel")); jigsawBlockEntity.setFinalState("minecraft:oak_planks"); jigsawBlockEntity.generate((ServerLevel) pLevel, 7, false); } return InteractionResult.CONSUME; }
  3. When I create a new world, after having configured the new biome using Citadel's ExpandedBiomes, it is not generated. I have decided to take the map code from Alex Caves, just for testing purposes, then I will delete it. This map can't find it either. But, in locate the biome appears, even if it cannot be found and when generating a world with a single biome, I can choose the biome and it "generates" it. I don't know where I could have made a mistake. Github repository Any help is welcome. Thank you all in advance, for helping or taking the time to read.
  4. I have been practicing modding minecraft, and I needed to make a pine forest biome, but my game crashes whenever I try to either load into, or generate, a world. I have no idea why. I will upload my crash report and pine_forest.json files. I do have some java knowledge, but I am still fairly out of my depth here. Here is the tutorial I used: Forge Modding Tutorial - Minecraft 1.20.1: CUSTOM BIOMES | #43
  5. Hallo I am working on a fantasy rpg mod for 1.20.1. In this mod I want to create my own dimension which will generate a continent that we have already decided on how it should look, so the biomes should generate on the places we want them to generate instead of random like it does in vanilla minecraft. I know it should be posible since the LOTR mod has this done as well.
×
×
  • Create New...

Important Information

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