Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hi.

Im looking for a code to make a Instant structure.

Ive been searching everywhere.

So maybe somebody here does know a tutorial our code?

 

greetz Chris || Thanks in advance!

  • Author

Instant structure? Like if you click somewhere a building appears?

Yes if you place the block there comes a structure.

  • Author

Look at vanilla villages or schematics. You basically just need to call world.setBlock until your structure is built.

I will try , but i dont think its easy !

  • Author

Look at vanilla villages or schematics. You basically just need to call world.setBlock until your structure is built.

Nope , thats not it. Somebody another method?

  • Author

coolAlias' suggestion is the correct method. Tells us what you tried (show your code) and tell us went wrong and we'll probably be able to help you.

i did delete the code , but the problem is i dont get what i should do with "You basically just need to call world.setBlock until your structure is built."

 

what does he means?

 

 

  • Author

When your mod block is placed, you call World#setBlock for all of the blocks in your structure.

So i need to built the structure in codes (kinda?)

  • Author

When your mod block is placed, you call World#setBlock for all of the blocks in your structure.

 

Im new in the advanced modding but i want to learn.

So i need to built the structure in codes (kinda?)

 

Yes. Structures are not magic.

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.

So i need to built the structure in codes (kinda?)

 

Yes.

 

Im new in the advanced modding but i want to learn.

 

Sticking "PAYED IF HELPED" in your titles isn't a good way to learn.

 

 

nobody :'( im willing to pay money

 

Be patient, not everybody can spend all day on forums helping people. We have real lives too.

 

 

P.S. "paid" is the past tense of "pay", not "payed".

Don't make mods if you don't know Java.

Check out my website: http://shadowfacts.net

Developer of many mods

  • Author

Sorry if im annoying you , im so hyper.

But i will search it again on myself.

 

Thought that people can just give tips.

 

  • Author

So i need to built the structure in codes (kinda?)

 

Yes.

 

Im new in the advanced modding but i want to learn.

 

Sticking "PAYED IF HELPED" in your titles isn't a good way to learn.

 

 

nobody :'( im willing to pay money

 

Be patient, not everybody can spend all day on forums helping people. We have real lives too.

 

Sorry for the annoying part , im now finding out that is works with schematics & MCEdit.

P.S. "paid" is the past tense of "pay", not "payed".

  • Author

How much pay?

15?

 

Im now doing it by myself , using schematics & MCEdit

 

I repeat, you're not going to learn if you just pay someone to do it for you.

  • Author

How much pay?

15?

 

I repeat, you're not going to learn if you just pay someone to do it for you.

 

Im doing/trying in on myself*

When / where should the structure generate? During world gen, when using an item, or somewhere else? That makes a big difference in how you initiate the execution of your code, i.e. where you get your variables from, but once you have that, it literally is just #setBlock.

 

You need to take the time to plan out your structure, though, and figure out where each block needs to be in relation to some point of origin, or you can get fancier and allow your structure to rotate - again, look at vanilla village structures for some fine examples of how to do it, and look especially at the various helper methods they have created e.g. fillWithBlocks - these make your life MUCH easier.

 

Pseudocode example creating a cube filled with air, i.e. a basic 'room'-like structure, assuming you have written a method named 'fillWithBlocks' that sets every block within an area relative to a BlockPos to a specific block:

// method you make sure is called from somewhere
public boolean generate(World world, BlockPos pos) {
  fillWithBlocks(world, pos, 0, 0, 0, 5, 5, 5, Blocks.cobblestone);
  fillWithBlocks(world, pos, 1, 1, 1, 4, 4, 4, Blocks.air); // leave 1 block on all sides
  BlockPos doorPos = pos.east(2).up(); // 2 blocks to the east and 1 block up should be in the center of the south wall
  world.setBlockState(doorPos, Blocks.air.getDefaultState(), 2); // just an open-air doorway for now
  world.setBlockState(doorPos.up(), Blocks.air.getDefaultState(), 2);
}

Now all you have to do is figure out how to write a method 'fillWithBlocks' like I described (shouldn't be that difficult) or figure out how to use the vanilla StructureComponent class and methods, and you can have yourself a cobblestone hut.

 

More complicated structures are obviously more difficult, even more so if you have blocks that care about metadata / rotation, or you want your structure to face in random directions, or you want to add loot and other things, but at the core of it all is world#setBlock (or, in 1.8, world#setBlockState).

  • Author

When / where should the structure generate? During world gen, when using an item, or somewhere else? That makes a big difference in how you initiate the execution of your code, i.e. where you get your variables from, but once you have that, it literally is just #setBlock.

 

You need to take the time to plan out your structure, though, and figure out where each block needs to be in relation to some point of origin, or you can get fancier and allow your structure to rotate - again, look at vanilla village structures for some fine examples of how to do it, and look especially at the various helper methods they have created e.g. fillWithBlocks - these make your life MUCH easier.

 

Pseudocode example creating a cube filled with air, i.e. a basic 'room'-like structure, assuming you have written a method named 'fillWithBlocks' that sets every block within an area relative to a BlockPos to a specific block:

// method you make sure is called from somewhere
public boolean generate(World world, BlockPos pos) {
  fillWithBlocks(world, pos, 0, 0, 0, 5, 5, 5, Blocks.cobblestone);
  fillWithBlocks(world, pos, 1, 1, 1, 4, 4, 4, Blocks.air); // leave 1 block on all sides
  BlockPos doorPos = pos.east(2).up(); // 2 blocks to the east and 1 block up should be in the center of the south wall
  world.setBlockState(doorPos, Blocks.air.getDefaultState(), 2); // just an open-air doorway for now
  world.setBlockState(doorPos.up(), Blocks.air.getDefaultState(), 2);
}

Now all you have to do is figure out how to write a method 'fillWithBlocks' like I described (shouldn't be that difficult) or figure out how to use the vanilla StructureComponent class and methods, and you can have yourself a cobblestone hut.

 

More complicated structures are obviously more difficult, even more so if you have blocks that care about metadata / rotation, or you want your structure to face in random directions, or you want to add loot and other things, but at the core of it all is world#setBlock (or, in 1.8, world#setBlockState).

 

Thanks for all that information im getting it now!

I just need to build the structure in codes & figure out how i let it spawn in by placing a block!

  • Author

When / where should the structure generate? During world gen, when using an item, or somewhere else? That makes a big difference in how you initiate the execution of your code, i.e. where you get your variables from, but once you have that, it literally is just #setBlock.

 

You need to take the time to plan out your structure, though, and figure out where each block needs to be in relation to some point of origin, or you can get fancier and allow your structure to rotate - again, look at vanilla village structures for some fine examples of how to do it, and look especially at the various helper methods they have created e.g. fillWithBlocks - these make your life MUCH easier.

 

Pseudocode example creating a cube filled with air, i.e. a basic 'room'-like structure, assuming you have written a method named 'fillWithBlocks' that sets every block within an area relative to a BlockPos to a specific block:

// method you make sure is called from somewhere
public boolean generate(World world, BlockPos pos) {
  fillWithBlocks(world, pos, 0, 0, 0, 5, 5, 5, Blocks.cobblestone);
  fillWithBlocks(world, pos, 1, 1, 1, 4, 4, 4, Blocks.air); // leave 1 block on all sides
  BlockPos doorPos = pos.east(2).up(); // 2 blocks to the east and 1 block up should be in the center of the south wall
  world.setBlockState(doorPos, Blocks.air.getDefaultState(), 2); // just an open-air doorway for now
  world.setBlockState(doorPos.up(), Blocks.air.getDefaultState(), 2);
}

Now all you have to do is figure out how to write a method 'fillWithBlocks' like I described (shouldn't be that difficult) or figure out how to use the vanilla StructureComponent class and methods, and you can have yourself a cobblestone hut.

 

More complicated structures are obviously more difficult, even more so if you have blocks that care about metadata / rotation, or you want your structure to face in random directions, or you want to add loot and other things, but at the core of it all is world#setBlock (or, in 1.8, world#setBlockState).

 

ahhh , i see you can use onBlockActivated to make it spawn when i place the block ;)

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.