Jump to content

[1.19.2] Align Jigsaw structure to hill walls


Skyriis

Recommended Posts

Generally, this would be the responsibility of the world carver, but there are ways to get around it. You could do something where you check if the entire placement area is within blocks and the opening to the cave is touching some other air block. In general though, you would need to program most of your logic from scratch since I don't believe Minecraft does anything like this itself. The closest I can recommend as an example would probably be the GeodeFeature, though I don't think that's gonna get you anywhere to close to what you would need.

Link to comment
Share on other sites

1 hour ago, Skyriis said:

How would i check that area?

You should have access within the structure to some form of the level that allows you to read the blocks in the area. As for checking the entire area, it depends on how much you want to check or optimize. In general, you could probably get away with only checking the borders. If you really don't care how much spawns outside a mountain, you just need to check the corners.

Link to comment
Share on other sites

So, after a quick read up, you're better of making your structure a feature to generate. The only terrain adaption which makes sense for you is the bury one which would fail for air. You could attempt to set the `project_start_to_heightmap` field to the world surface and see it that gives a better chance for it to spawn connected to the air. Otherwise, you would have to generate the pieces manually similar to how buried treasure works if you wanted to keep a structure or a custom feature which could then correctly check the sides to see if it is touching air.

Link to comment
Share on other sites

how would i make a jigsaw structure a feature? or... how would i make a feature 1.19 anyway 

How would i generate the nbt files (like a jigsaw structure would do it) and then check the size and blocks around?

Edited by Skyriis
Link to comment
Share on other sites

2 hours ago, Skyriis said:

how would i make a jigsaw structure a feature? or... how would i make a feature 1.19 anyway 

How would i generate the nbt files (like a jigsaw structure would do it) and then check the size and blocks around?

This tutorial might be helpful to you:

https://misode.github.io/guides/adding-custom-structures/

As for saving the NBT file for the structure itself, you can just use the structure blocks in game to save your structure in the generated folder of your world map.

Link to comment
Share on other sites

Apologies for the poor explanation on my part. If you want to use a feature, you can't easily use a template. You would need to get it through the StructureTemplateManager through the ServerLevel through the WorldGenLevel, load the data, and then generate it. TelepathicGrunt does have a tutorial on creating a custom structure through which you could use to add an extra spawn check if there is air around you. Though, imo, you're still better off with a feature since you should be able to more safely check whether you can replace the block there.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

alright so... i got this as my feature:

@Override
    public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> pContext) {
        BlockPos origin = pContext.origin();
        ServerLevel level = pContext.level().getLevel();
        StructureTemplateManager templateManager = level.getStructureManager();
        // Get structure parts
        StructureTemplate entranceTemplate = templateManager.getOrCreate(ENTRANCE);
        StructureTemplate understairTemplate = templateManager.getOrCreate(UNDERSTAIR);
        StructureTemplate roomTemplate = templateManager.getOrCreate(ROOMS[level.getRandom().nextIntBetweenInclusive(0, ROOMS.length - 1)]);


        Vec3i entranceSize = entranceTemplate.getSize();
        // Check top and bottom entrance
        for (int i = -1; i < entranceSize.getX(); i++) {
            BlockState bottomState = level.getBlockState(origin.offset(i, -1, 0));
            BlockState topState = level.getBlockState(origin.offset(i, entranceSize.getY(), 0));
            // Exit if air
            if (bottomState.isAir() || topState.isAir()) return false;
        }

        // check left and right entrance
        for (int i = -1; i < entranceSize.getY(); i++) {
            BlockState leftState = level.getBlockState(origin.offset(-1, i, 0));
            BlockState rightState = level.getBlockState(origin.offset(entranceSize.getX(), i, 0));
            //Exit if air
            if (leftState.isAir() || rightState.isAir()) return false;
        }

        // Ensure air is in front of the cave entrance
        for (int x = 1; x < entranceSize.getX() - 1; x++) {
            for (int y = 1; y < entranceSize.getY() - 1; y++) {
                if (!level.getBlockState(origin.offset(x, y, -1)).isAir()) return false;
            }
        }

        boolean entrancePlaceSuccess = entranceTemplate.placeInWorld(level, origin, origin, new StructurePlaceSettings(), level.getRandom(), 2);

        return false;
    }

and the place method get's invoked (i checked that with a break point and the intellij debugger) problem is that the world gen get's stuck :S When i create a new world it get's stuck here:

image.png

 

Any ideas what cause this?

Link to comment
Share on other sites

alright so i've changed my place method to this:

    @Override
    public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> pContext) {
        BlockPos origin = pContext.origin();
        WorldGenLevel level = pContext.level();
        StructureTemplateManager templateManager = level.getServer().getStructureManager();
        BulkSectionAccess sectionAccess = new BulkSectionAccess(level);
        // Get structure parts
        StructureTemplate entranceTemplate = templateManager.getOrCreate(ENTRANCE);
        StructureTemplate understairTemplate = templateManager.getOrCreate(UNDERSTAIR);
        StructureTemplate roomTemplate = templateManager.getOrCreate(ROOMS[level.getRandom().nextIntBetweenInclusive(0, ROOMS.length - 1)]);

        Vec3i entranceSize = entranceTemplate.getSize();

        // Ensure we can write in the entrance structure area
        for (int x = 0; x < entranceSize.getX(); x++) {
            for (int y = 0; y < entranceSize.getY(); y++) {
                for (int z = 0; z < entranceSize.getZ(); z++) {
                    if (!level.ensureCanWrite(origin.offset(x, y, z))) return false;
                }
            }
        }

        // Check top and bottom (front) is covered
        for (int i = -1; i < entranceSize.getX(); i++) {
            if (safeBlockStateCheck(sectionAccess, origin.offset(i, -1, 0), BlockBehaviour.BlockStateBase::isAir, true)) return false;
            if (safeBlockStateCheck(sectionAccess, origin.offset(i, entranceSize.getY(), 0), BlockBehaviour.BlockStateBase::isAir, true)) return false;
        }

        // check left and right (front) is covered
        for (int i = -1; i < entranceSize.getY(); i++) {
            if (safeBlockStateCheck(sectionAccess, origin.offset(-1, i, 0), BlockBehaviour.BlockStateBase::isAir, true)) return false;
            if (safeBlockStateCheck(sectionAccess, origin.offset(entranceSize.getX(), i, 0), BlockBehaviour.BlockStateBase::isAir, true)) return false;
        }

        // Ensure air is in front of the cave entrance
        for (int x = 2; x < entranceSize.getX() - 2; x++) {
            for (int y = 2; y < entranceSize.getY() - 2; y++) {
                if (safeBlockStateCheck(sectionAccess, origin.offset(x, y, 0), blockState -> !blockState.isAir())) return false;
            }
        }

        boolean entrancePlaceSuccess = entranceTemplate.placeInWorld(level, origin, origin, new StructurePlaceSettings(), level.getRandom(), 2);

        return false;
    }

    private boolean safeBlockStateCheck(BulkSectionAccess sectionAccess, BlockPos pos, Predicate<BlockState> check) {
        return safeBlockStateCheck(sectionAccess, pos, check, false);
    }

    private boolean safeBlockStateCheck(BulkSectionAccess sectionAccess, BlockPos pos, Predicate<BlockState> check, boolean resultWhenInaccessible) {
        LevelChunkSection chunkSection = sectionAccess.getSection(pos);
        // Ensure chunk section exists
        if (chunkSection == null) return resultWhenInaccessible;
        // Get target block state
        BlockState targetState = chunkSection.getBlockState(
            SectionPos.sectionRelative(pos.getX()),
            SectionPos.sectionRelative(pos.getY()),
            SectionPos.sectionRelative(pos.getZ())
        );
        // Return test result
        return check.test(targetState);
    }

and now i'm getting those errors in the first for loop (the ensure write thing):

image.png

 

why is that?

Link to comment
Share on other sites

19 hours ago, Skyriis said:

why is that?

Well, features can only generate at most one chunk away from where they spawned. So, typically they are at most 16x16x256. Structures don't have this limitation. At a glance, it looked like your structure template fit into this, so that's why I recommended it.

Link to comment
Share on other sites

On 2/2/2023 at 8:46 PM, ChampionAsh5357 said:

Generally, this would be the responsibility of the world carver, but there are ways to get around it. You could do something where you check if the entire placement area is within blocks and the opening to the cave is touching some other air block. In general though, you would need to program most of your logic from scratch since I don't believe Minecraft does anything like this itself. The closest I can recommend as an example would probably be the GeodeFeature, though I don't think that's gonna get you anywhere to close to what you would need.
 

Thanks, I will try it and if I still face this problem, then I will message you.

Edited by CraigDesir
Link to comment
Share on other sites

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
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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • every time I try to load forge version 1. 12. 2 with the blockbuster mod the mclib and the metamorphs mod The game crashed and this is the crash m whilst there was a severe problem during mod loading that has caused the game to fail Error: net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Blockbuster (blockbuster)
    • Join the Ultimate EarthSMP - [RiftMC SMP] play.riftmc.net https://riftmc.net/ Join Our Discord     Are you ready to embark on a Minecraft adventure like no other? Look no further than RiftMC! With our server, you'll be transported to a world of endless possibilities, where your imagination can run wild.   Have you ever dreamed of building your own kingdom, or exploring vast landscapes with your friends? At RiftMC, you can do just that and more. With multiple gameplay options, including survival, earthsmp, and PvP gameplay, you'll never run out of things to do.   Are you looking for a challenge? Our survival mode will test your skills as you brave the dangers of the wilderness. Or, if you're feeling creative, our custom world is the perfect canvas for you to unleash your imagination and build whatever your heart desires.   Do you thrive on competition? Our PvP arenas are the perfect place for you to battle it out with other players for supremacy. Or, if you prefer a more cooperative experience, join up with other players to form communities and build sprawling cities.   But that's not all - we also have a thriving economic system, where you can buy and sell goods with other players and even start your own businesses. And with our friendly and dedicated staff, you can rest assured that you'll always have the help and support you need.   So, what are you waiting for? Are you ready to experience the adventure of a lifetime? Join the thousands of players who have already discovered the magic of RiftMC! Simply connect to play.riftmc.net and let the journey begin. Are you ready to dive in?  
    • I want a sword that will kill all hostile mobs with one hit, so is there any way to do that?
    • I have that error when i started my forge server, can anyone help me? C:\Users\orden\Desktop\Servidor MC>REM Forge requires a configured set of both JVM and program arguments. C:\Users\orden\Desktop\Servidor MC>REM Add custom JVM arguments to the user_jvm_args.txt C:\Users\orden\Desktop\Servidor MC>REM Add custom program arguments {such as nogui} to this file in the next line before the  or C:\Users\orden\Desktop\Servidor MC>REM  pass them to this script directly C:\Users\orden\Desktop\Servidor MC>java @user_jvm_args.txt @libraries/net/minecraftforge/forge/1.18.2-40.1.57/win_args.txt 2023-04-01 21:15:43,376 main WARN Advanced terminal features are not available in this environment [21:15:43] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher running: args [--launchTarget, forgeserver, --fml.forgeVersion, 40.1.57, --fml.mcVersion, 1.18.2, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20220404.173914, -nogui] [21:15:43] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher 9.1.3+9.1.3+main.9b69c82a starting: java version 20 by Oracle Corporation [21:15:43] [main/INFO] [op.OptiFineTransformationService/]: OptiFineTransformationService.onLoad [21:15:43] [main/INFO] [op.OptiFineTransformationService/]: OptiFine ZIP file URL: union:/C:/Users/orden/Desktop/Servidor%20MC/mods/OptiFine-1.18.2_HD_U_H7.jar%2338!/ [21:15:43] [main/INFO] [op.OptiFineTransformationService/]: OptiFine ZIP file: C:\Users\orden\Desktop\Servidor MC\mods\OptiFine-1.18.2_HD_U_H7.jar [21:15:43] [main/INFO] [op.OptiFineTransformer/]: Target.PRE_CLASS is available [21:15:43] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=union:/C:/Users/orden/Desktop/Servidor%20MC/libraries/org/spongepowered/mixin/0.8.5/mixin-0.8.5.jar%2314!/ Service=ModLauncher Env=SERVER [21:15:43] [main/INFO] [op.OptiFineTransformationService/]: OptiFineTransformationService.initialize [21:15:45] [main/INFO] [op.OptiFineTransformationService/]: OptiFineTransformationService.transformers [21:15:45] [main/INFO] [op.OptiFineTransformer/]: Targets: 350 [21:15:45] [main/INFO] [op.OptiFineTransformationService/]: additionalClassesLocator: [optifine., net.optifine.] [21:15:47] [main/INFO] [mixin/]: Compatibility level set to JAVA_17 [21:15:47] [main/INFO] [mixin/]: Successfully loaded Mixin Connector [de.maxhenkel.camera.MixinConnector] [21:15:47] [main/INFO] [mixin/]: Successfully loaded Mixin Connector [tictim.paraglider.MixinConnector] [21:15:47] [main/INFO] [cp.mo.mo.LaunchServiceHandler/MODLAUNCHER]: Launching target 'forgeserver' with arguments [-nogui] [21:15:47] [main/WARN] [mixin/]: Error loading class: net/minecraft/server/level/ChunkMap (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: @Mixin target net.minecraft.server.level.ChunkMap was not found securitycraft.mixins.json:camera.ChunkMapMixin [21:15:47] [main/WARN] [mixin/]: Error loading class: de/maxhenkel/gravestone/events/DeathEvents (java.lang.ClassNotFoundException: de.maxhenkel.gravestone.events.DeathEvents) [21:15:47] [main/WARN] [mixin/]: Error loading class: net/minecraft/world/item/ItemStack (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: @Mixin target net.minecraft.world.item.ItemStack was not found tombstone.mixins.json:ItemStackMixin [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/lang/invoke/MethodHandles$Lookup (java.lang.IllegalArgumentException: Unsupported class file major version 64) [21:15:47] [main/WARN] [mixin/]: Error loading class: java/util/concurrent/CompletableFuture (java.lang.IllegalArgumentException: Unsupported class file major version 64) Exception in thread "main" org.spongepowered.asm.mixin.transformer.throwables.MixinTransformerError: An unexpected critical error was encountered         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:392)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinTransformer.transformClass(MixinTransformer.java:250)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.service.modlauncher.MixinTransformationHandler.processClass(MixinTransformationHandler.java:131)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.launch.MixinLaunchPluginLegacy.processClass(MixinLaunchPluginLegacy.java:131)         at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.serviceapi.ILaunchPluginService.processClassWithFlags(ILaunchPluginService.java:156)         at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.LaunchPluginHandler.offerClassNodeToPlugins(LaunchPluginHandler.java:88)         at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.ClassTransformer.transform(ClassTransformer.java:120)         at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.TransformingClassLoader.maybeTransformClassBytes(TransformingClassLoader.java:50)         at cpw.mods.securejarhandler@1.0.3/cpw.mods.cl.ModuleClassLoader.readerToClass(ModuleClassLoader.java:110)         at cpw.mods.securejarhandler@1.0.3/cpw.mods.cl.ModuleClassLoader.lambda$findClass$16(ModuleClassLoader.java:216)         at cpw.mods.securejarhandler@1.0.3/cpw.mods.cl.ModuleClassLoader.loadFromModule(ModuleClassLoader.java:226)         at cpw.mods.securejarhandler@1.0.3/cpw.mods.cl.ModuleClassLoader.findClass(ModuleClassLoader.java:216)         at cpw.mods.securejarhandler@1.0.3/cpw.mods.cl.ModuleClassLoader.loadClass(ModuleClassLoader.java:132)         at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)         at java.base/java.lang.Class.getDeclaredMethods0(Native Method)         at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3502)         at java.base/java.lang.Class.getMethodsRecursive(Class.java:3643)         at java.base/java.lang.Class.getMethod0(Class.java:3629)         at java.base/java.lang.Class.getMethod(Class.java:2319)         at MC-BOOTSTRAP/fmlloader@1.18.2-40.1.57/net.minecraftforge.fml.loading.targets.CommonServerLaunchHandler.lambda$launchService$0(CommonServerLaunchHandler.java:32)         at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37)         at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53)         at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71)         at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.Launcher.run(Launcher.java:106)         at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.Launcher.main(Launcher.java:77)         at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26)         at MC-BOOTSTRAP/cpw.mods.modlauncher@9.1.3/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23)         at cpw.mods.bootstraplauncher@1.0.0/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:149) Caused by: org.spongepowered.asm.mixin.throwables.ClassMetadataNotFoundException: java.util.concurrent.CompletableFuture         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.transformMethod(MixinPreProcessorStandard.java:754)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.transform(MixinPreProcessorStandard.java:739)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.attach(MixinPreProcessorStandard.java:310)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinPreProcessorStandard.createContextFor(MixinPreProcessorStandard.java:280)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinInfo.createContextFor(MixinInfo.java:1288)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinApplicatorStandard.apply(MixinApplicatorStandard.java:292)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.TargetClassContext.apply(TargetClassContext.java:383)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.TargetClassContext.applyMixins(TargetClassContext.java:365)         at MC-BOOTSTRAP/org.spongepowered.mixin/org.spongepowered.asm.mixin.transformer.MixinProcessor.applyMixins(MixinProcessor.java:363)         ... 27 more C:\Users\orden\Desktop\Servidor MC>pause Presione una tecla para continuar . . .
  • Topics

×
×
  • Create New...

Important Information

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