Make a structure appear from "seed"

Started by Namu3l on Mon, 06/01/2020 - 18:38

Topic category: Help with modding (Java Edition)

Last seen on 19:10, 19. Jun 2020
Joined Apr 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • Comments:
Make a structure appear from "seed"
Mon, 06/01/2020 - 18:38

I am creating a "Fairy Tales" inspired Mod. I would like to plant a bean and make a structure appear up to the sky (Like Jack and the Beanstalk). Any ideas? Thanks!

Last seen on 02:07, 13. Jul 2020
Joined Sep 2019
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • Comments:
Do you want it to be…
Mon, 06/01/2020 - 19:07

Do you want it to be bonemeal-able?

If not you can just simply do this;

1.  Create a timer that's random

2. Then use this code,

        if (!worldIn.isRemote) {
            ServerWorld worldServer = (ServerWorld) worldIn;
            PlacementSettings settings = (new PlacementSettings()).setChunk(null).setIgnoreEntities(false).setMirror(Mirror.NONE).setRotation(Rotation.NONE);

            TemplateManager manager = worldServer.getStructureTemplateManager();
            ResourceLocation location = new ResourceLocation(YourModID, YourStructureName);
            Template template = manager.getTemplateDefaulted(location);

            template.addBlocksToWorldChunk(worldIn, block.getPosition(), settings);
        }

 

Last seen on 19:10, 19. Jun 2020
Joined Apr 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • Comments:
I think I understand it more…
Tue, 06/02/2020 - 09:45

I think I understand it more or less. but it is not entirely clear to me. Where do you suggest I apply this code? I understand the code but am still getting familiar with it. I'm sure it will help me. Thank you very much for your explanation.

Last seen on 02:07, 13. Jul 2020
Joined Sep 2019
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • Comments:
Well, since blocks don't…
Tue, 06/02/2020 - 13:07

Well, since blocks don't really have a tick method. I would suggest you create a tile entity. We would put this code in the tick tile entity method with more conditions. There is a lot that would go into that block, but if you are up for it I am happy to help.

 

Alternatively, we could implement IGrowable and do what a sapling does. This would allow us to use bonemeal and other functionality. I actually prefer this method, I believe it is a "better" method.

Last seen on 19:10, 19. Jun 2020
Joined Apr 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • Comments:
Of course! I am open to any…
Tue, 06/02/2020 - 18:49

Of course! I am open to any possibility. We can try anything you suggest to me. In the end it's about learning!

Last seen on 19:10, 19. Jun 2020
Joined Apr 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • Comments:
I've finally decided not to…
Wed, 06/03/2020 - 22:36

I've finally decided not to get too complicated. I have created a special block which places a row of blocks on top of itself by interacting with it. Those blocks (plants) apply the levitate effect to you. If the block is activated by having an object (magic seeds) in hand, it would already be. How about? It's functional :P

It would be ideal to get the plant to grow little by little instead of appearing suddenly. If there was some way to introduce a "delay" in each iteration of the loop...

Last seen on 19:10, 19. Jun 2020
Joined Apr 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • Comments:
That's my procedure. Very…
Wed, 06/03/2020 - 22:42

That's my procedure. Very simple: 

code

Last seen on 22:23, 5. Jul 2020
Joined Jun 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • Comments:
Cant you make it a plant…
Thu, 06/04/2020 - 02:59

Cant you make it a plant based block that grows over time? then once it has grown enough you could probably make a detection for that "grown piece" with a replace block into a new block/what you want.

or you could possibly make it so that each bonemeal grows it by 1-3 levels instead of all of it at once

Last seen on 19:10, 19. Jun 2020
Joined Apr 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • Comments:
That could be fine. Can you…
Thu, 06/04/2020 - 11:53

That could be fine. Can you make an example to see it better? Thank you!