Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.17] How do I make a placed block create a structure?


askod333
 Share

Recommended Posts

Hi everyone,

 

I am almost done with my mod that I only need for myself, I just can't grasp how to code one thing.

I need to code it so when a block is placed by a player, a structure appears instead of the block. I suppose I am meant to use the onBlockAdded method, but I can't understand, how it works. Could someone show me how to code it please? Also, how do I map the structure? Do i use XYZ coordinates?

It would be really helpful if you could give me an example of such code and I would change the values to match the structure. Again, this mod is for my purposes only, I will not upload it anywhere if you are afraid of you doing someone else's work.

Thank you for the response!

Link to comment
Share on other sites

You have two options. You could manually create the structure by placing blocks individually based on the location of the player-placed block (Yes using x, y, z coordinates). Or you could load the structure using an nbt structure file based on the location of the player-placed block. I suppose it mostly depends on how large and complex the structure is. If it is fairly complex or large, Id go with the second option.

Link to comment
Share on other sites

2 hours ago, ForgetFunsize said:

You have two options. You could manually create the structure by placing blocks individually based on the location of the player-placed block (Yes using x, y, z coordinates). Or you could load the structure using an nbt structure file based on the location of the player-placed block. I suppose it mostly depends on how large and complex the structure is. If it is fairly complex or large, Id go with the second option.

It's not large or complex at all, so the first option works for me. Could you show me how to code that? Or explain in detail?

Link to comment
Share on other sites

1 hour ago, askod333 said:

It's not large or complex at all, so the first option works for me. Could you show me how to code that? Or explain in detail?

In your EntityPlaceEvent, you would manually place the blocks for your structure based on the placed block position. Such as world.setBlockAndUpdate(pos, Blocks.WHATEVER_BLOCK.defaultBlockState());. pos being the position you want to set the block. You would call this for as many blocks as you need until your structure is complete.

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.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • I also cannot get Minecraft to launch with Forge.  I've tried with both the vaniila launcher and GDLauncher.  I can run  vanilla Minecraft just fine with either launcher and I can run Fabric just fine in either.  I am running the latest versions of everything. With the vanilla launcher I get exit code 0 with the following log and I don't appear to be getting any crash logs:   [03Dec2021 16:28:26.950] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, HoJoWie, --version, 1.18-forge-38.0.6, --gameDir, C:\Users\digit\AppData\Roaming\.minecraft, --assetsDir, C:\Users\digit\AppData\Roaming\.minecraft\assets, --assetIndex, 1.18, --uuid, d94c314b28584da7a37b29cf8927801c, --accessToken, ????????, --clientId, MTE3MzljYTItN2U5My00ZjBjLTg5ODAtMjIwMDI1ZmVhZjdl, --xuid, 2535413743449610, --userType, msa, --versionType, release, --launchTarget, forgeclient, --fml.forgeVersion, 38.0.6, --fml.mcVersion, 1.18, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20211130.085255] [03Dec2021 16:28:26.960] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 9.0.7+91+master.8569cdf starting: java version 17.0.1 by Microsoft [03Dec2021 16:28:27.513] [main/INFO] [optifine.OptiFineTransformationService/]: OptiFineTransformationService.onLoad [03Dec2021 16:28:27.515] [main/INFO] [optifine.OptiFineTransformationService/]: OptiFine ZIP file URL: union:/C:/Users/digit/AppData/Roaming/.minecraft/mods/preview_OptiFine_1.18.pre1_HD_U_H3_pre1.jar%2352! [03Dec2021 16:28:27.522] [main/INFO] [optifine.OptiFineTransformationService/]: OptiFine ZIP file: C:\Users\digit\AppData\Roaming\.minecraft\mods\preview_OptiFine_1.18.pre1_HD_U_H3_pre1.jar [03Dec2021 16:28:27.524] [main/INFO] [optifine.OptiFineTransformer/]: Target.PRE_CLASS is available [03Dec2021 16:28:27.592] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=union:/C:/Users/digit/AppData/Roaming/.minecraft/libraries/org/spongepowered/mixin/0.8.5/mixin-0.8.5.jar%2318! Service=ModLauncher Env=CLIENT [03Dec2021 16:28:27.599] [main/INFO] [optifine.OptiFineTransformationService/]: OptiFineTransformationService.initialize [03Dec2021 16:28:28.603] [main/INFO] [optifine.OptiFineTransformationService/]: OptiFineTransformationService.transformers [03Dec2021 16:28:28.609] [main/INFO] [optifine.OptiFineTransformer/]: Targets: 338 [03Dec2021 16:28:28.896] [main/INFO] [optifine.OptiFineTransformationService/]: additionalClassesLocator: [optifine., net.optifine.] [03Dec2021 16:28:29.153] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'forgeclient' with arguments [--version, 1.18-forge-38.0.6, --gameDir, C:\Users\digit\AppData\Roaming\.minecraft, --assetsDir, C:\Users\digit\AppData\Roaming\.minecraft\assets, --uuid, d94c314b28584da7a37b29cf8927801c, --username, HoJoWie, --assetIndex, 1.18, --accessToken, ????????, --clientId, MTE3MzljYTItN2U5My00ZjBjLTg5ODAtMjIwMDI1ZmVhZjdl, --xuid, 2535413743449610, --userType, msa, --versionType, release] With GDLauncher I get exit code 1 with the following output in it's console:   instrument.ts:130 ps stderr: Exception in thread "main" java.io.UncheckedIOException: java.io.IOException: Invalid paths argument, contained no existing paths: [..\..\datastore\libraries\net\minecraft\client\1.18-20211130.085255\client-1.18-20211130.085255-srg.jar, ..\..\datastore\libraries\net\minecraft\client\1.18-20211130.085255\client-1.18-20211130.085255-extra.jar, ..\..\datastore\libraries\net\minecraftforge\forge\1.18-38.0.12\forge-1.18-38.0.12-client.jar] (anonymous) @ instrument.ts:130 instrument.ts:130 ps stderr: at cpw.mods.securejarhandler@0.9.54/cpw.mods.jarhandling.impl.Jar.<init>(Jar.java:74) at cpw.mods.securejarhandler@0.9.54/cpw.mods.jarhandling.SecureJar.from(SecureJar.java:58) at MC-BOOTSTRAP/fmlloader@1.18-38.0.12/net.minecraftforge.fml.loading.moddiscovery.ModJarMetadata.buildFile(ModJarMetadata.java:36) at MC-BOOTSTRAP/fmlloader@1.18-38.0.12/net.minecraftforge.fml.loading.moddiscovery.MinecraftLocator.scanMods(MinecraftLocator.java:28) at MC-BOOTSTRAP/fmlloader@1.18-38.0.12/net.minecraftforge.fml.loading.moddiscovery.ModDiscoverer.discoverMods(ModDiscoverer.java:64) at MC-BOOTSTRAP/fmlloader@1.18-38.0.12/net.minecraftforge.fml.loading.FMLLoader.beginModScan(FMLLoader.java:180) at MC-BOOTSTRAP/fmlloader@1.18-38.0.12/net.minecraftforge.fml.loading.FMLServiceProvider.beginScanning(FMLServiceProvider.java:100) at MC-BOOTSTRAP/cpw.mods.modlauncher@9.0.7/cpw.mods.modlauncher.TransformationServiceDecorator.runScan(TransformationServiceDecorator.java:113) at MC-BOOTSTRAP/cpw.mods.modlauncher@9.0.7/cpw.mods.modlauncher.TransformationServicesHandler.lambda$runScanningTransformationServices$8(TransformationServicesHandler.java:101) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1779) (anonymous) @ instrument.ts:130 instrument.ts:130 ps stderr: at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575) at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260) at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616) at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622) at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627) at MC-BOOTSTRAP/cpw.mods.modlauncher@9.0.7/cpw.mods.modlauncher.TransformationServicesHandler.runScanningTransformationServices(TransformationServicesHandler.java:103) at MC-BOOTSTRAP/cpw.mods.modlauncher@9.0.7/cpw.mods.modlauncher.TransformationServicesHandler.initializeTransformationServices(TransformationServicesHandler.java:56) at MC-BOOTSTRAP/cpw.mods.modlauncher@9.0.7/cpw.mods.modlauncher.Launcher.run(Launcher.java:87) (anonymous) @ instrument.ts:130 instrument.ts:130 ps stderr: at MC-BOOTSTRAP/cpw.mods.modlauncher@9.0.7/cpw.mods.modlauncher.Launcher.main(Launcher.java:77) at MC-BOOTSTRAP/cpw.mods.modlauncher@9.0.7/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) at MC-BOOTSTRAP/cpw.mods.modlauncher@9.0.7/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) at cpw.mods.bootstraplauncher@0.1.17/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:90) (anonymous) @ instrument.ts:130 instrument.ts:130 ps stderr: Caused by: java.io.IOException: Invalid paths argument, contained no existing paths: [..\..\datastore\libraries\net\minecraft\client\1.18-20211130.085255\client-1.18-20211130.085255-srg.jar, ..\..\datastore\libraries\net\minecraft\client\1.18-20211130.085255\client-1.18-20211130.085255-extra.jar, ..\..\datastore\libraries\net\minecraftforge\forge\1.18-38.0.12\forge-1.18-38.0.12-client.jar] ... 25 more (anonymous) @ instrument.ts:130 instrument.ts:130 Process exited with code 1. Not too good.. (anonymous) @ instrument.ts:130  
    • In 1.15 and before, you could get the item being held/dragged by the cursor using PlayerInventory#getItemStack. This no longer seems to be the case. How do we do this now?
    • I created a particle using  public class NukeParticle extends BasicParticleType implements IParticleData { public NukeParticle(boolean alwaysShow) { super(alwaysShow); } @Override public BasicParticleType getType() { return ParticleTypes.LARGE_SMOKE; } @Override public String getParameters() { return ParticleTypes.LARGE_SMOKE.getParameters(); } } and when I register it using  public class ParticlesReg { public static final RegistryObject<NukeParticle> YELLOW_PART = Regist.PARTICLES.register("yellow_particle", ()-> new NukeParticle(true)); public static void Register() { } } it just seems to crash anyone got an idea to what is going on the crash log is  ---- Minecraft Crash Report ---- // Shall we play a game? Time: 12/3/21 4:19 PM Description: Rendering overlay java.lang.IllegalStateException: Redundant texture list for particle lndfmod:yellow_particle at net.minecraft.client.particle.ParticleManager.loadTextureLists(ParticleManager.java:217) ~[forge:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.particle.ParticleManager.lambda$null$0(ParticleManager.java:169) ~[forge:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1640) ~[?:1.8.0_311] {} at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1632) ~[?:1.8.0_311] {} at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) ~[?:1.8.0_311] {} at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1067) ~[?:1.8.0_311] {} at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1703) ~[?:1.8.0_311] {} at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:172) ~[?:1.8.0_311] {} A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Render thread Stacktrace: at net.minecraft.client.renderer.GameRenderer.updateCameraAndRender(GameRenderer.java:495) ~[forge:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} -- Overlay render details -- Details: Overlay name: net.minecraft.client.gui.ResourceLoadProgressGui Stacktrace: at net.minecraft.client.renderer.GameRenderer.updateCameraAndRender(GameRenderer.java:495) ~[forge-1.16.4-35.1.37_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1002) ~[forge-1.16.4-35.1.37_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.run(Minecraft.java:612) ~[forge-1.16.4-35.1.37_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:184) ~[forge-1.16.4-35.1.37_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_311] {} at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_311] {} at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_311] {} at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_311] {} at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:52) ~[forge-1.16.4-35.1.37_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.0.9.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.0.9.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.0.9.jar:?] {} at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.0.9.jar:?] {} at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.0.9.jar:?] {} at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:105) [forge-1.16.4-35.1.37_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {} -- System Details -- Details: Minecraft Version: 1.16.4 Minecraft Version ID: 1.16.4 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_311, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 1848128352 bytes (1762 MB) / 3042443264 bytes (2901 MB) up to 7622623232 bytes (7269 MB) CPUs: 12 JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump ModLauncher: 8.0.9+86+master.3cf110c ModLauncher launch target: fmluserdevclient ModLauncher naming: mcp ModLauncher services: /mixin-0.8.2.jar mixin PLUGINSERVICE /eventbus-4.0.0.jar eventbus PLUGINSERVICE /forge-1.16.4-35.1.37_mapped_snapshot_20201028-1.16.3-launcher.jar object_holder_definalize PLUGINSERVICE /forge-1.16.4-35.1.37_mapped_snapshot_20201028-1.16.3-launcher.jar runtime_enum_extender PLUGINSERVICE /accesstransformers-3.0.1.jar accesstransformer PLUGINSERVICE /forge-1.16.4-35.1.37_mapped_snapshot_20201028-1.16.3-launcher.jar capability_inject_definalize PLUGINSERVICE /forge-1.16.4-35.1.37_mapped_snapshot_20201028-1.16.3-launcher.jar runtimedistcleaner PLUGINSERVICE /mixin-0.8.2.jar mixin TRANSFORMATIONSERVICE /forge-1.16.4-35.1.37_mapped_snapshot_20201028-1.16.3-launcher.jar fml TRANSFORMATIONSERVICE FML: 35.1 Forge: net.minecraftforge:35.1.37 FML Language Providers: javafml@35.1 minecraft@1 Mod List: client-extra.jar |Minecraft |minecraft |1.16.4 |ENQUEUE_IM|a1:d4:5e:04:4f:d3:d6:e0:7b:37:97:cf:77:b0:de:ad:4a:47:ce:8c:96:49:5f:0a:cf:8c:ae:b2:6d:4b:8a:3f forge-1.16.4-35.1.37_mapped_snapshot_20201028-1.16|Forge |forge |35.1.37 |ENQUEUE_IM|NOSIGNATURE main |The Ladon Fr*** Mod 1.16.4 |lndfmod |NONE |SIDED_SETU|NOSIGNATURE Crash Report UUID: 734f5cd3-7a52-470e-ab9e-c51bffee2944 Launched Version: MOD_DEV Backend library: LWJGL version 3.2.2 build 10 Backend API: NVIDIA GeForce GTX 1080/PCIe/SSE2 GL version 4.6.0 NVIDIA 510.10, NVIDIA Corporation GL Caps: Using framebuffer using OpenGL 3.0 Using VBOs: Yes Is Modded: Definitely; Client brand changed to 'forge' Type: Client (map_client.txt) Graphics mode: fancy Resource Packs: Current Language: English (US) CPU: 12x Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz  
    • Alright, so, I have a question. Is it possible to display multiple cameras when spectating as an entity? How would I achieve that? I know ServerPlayer handles the spectating of entities and accepts a single camera but Platin told me it might be possible to have multiple cameras displaying at once.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.