Jump to content

Recommended Posts

Posted (edited)

Hey, so I was wondering if anyone could help me with making a multiblock structure? My original idea was to find the wither's multiblock structure in the code, but I couldn't. Tried Googling the answer, and all I found was for 1.7.10, which I highly doubt will work. So does anyone here know how to do it, or could at least point me to the wither's code?

Edited by Daring Do
It actually wasn't solved :/

Gne9eza.png

 

"Be patient with me, because I'm an absolute moron half the time."

Posted (edited)

Could you be more specific on what you want the multi block structure to do because it will affect the way you will do things as there are a few different ways you could do it.

Edited by MDW01
  • Like 1
Posted
8 hours ago, MDW01 said:

Could you be more specific on what you want the multi block structure to do because it will affect the way you will do things as there are a few different ways you could do it.

All I need is the way to detect the multiblock upon activating a middle block. But essentially I'm wanting it to do multiple things, depending on the entities in the middle of it. Rituals. If I can get the multiblock detected, then I can likely get the rest of it done as well. 

Gne9eza.png

 

"Be patient with me, because I'm an absolute moron half the time."

Posted

Well what you need to do is make the blocks tile entities and when you place down the main center block have it place the other blocks around it. Then have it check if the center block has been activated and have it set a boolean to true that the other blocks check as well. If one or any of the blocks meet the requirements you set you can then have it move on to your ritual.

Posted
25 minutes ago, MDW01 said:

Well what you need to do is make the blocks tile entities and when you place down the main center block have it place the other blocks around it. Then have it check if the center block has been activated and have it set a boolean to true that the other blocks check as well. If one or any of the blocks meet the requirements you set you can then have it move on to your ritual.

I'm not wanting the middle block to place the other blocks. I'm wanting it to scan a 15x15 area to determine if the other blocks are where they should be for specific rituals. But I assume it's a similar process that you described? Everything being a tile entity?

Gne9eza.png

 

"Be patient with me, because I'm an absolute moron half the time."

Posted
5 minutes ago, MDW01 said:

You just have to make the blocks that you want to be able to check other blocks or entities or preform actions tile entities.

Thanks

Gne9eza.png

 

"Be patient with me, because I'm an absolute moron half the time."

Posted

Well, if it is an actual structure then you can use the chunk providers' isInsideStructure() and getNearestStructure() methods to help you.

 

If you just need a pattern of blocks, then you just have to write the code to look for the pattern. If the pattern is relatively simple, that shouldn't be too hard although you'll have to consider the various rotations possible and check for them all.

  • Like 1

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted
5 hours ago, jabelar said:

Well, if it is an actual structure then you can use the chunk providers' isInsideStructure() and getNearestStructure() methods to help you.

 

If you just need a pattern of blocks, then you just have to write the code to look for the pattern. If the pattern is relatively simple, that shouldn't be too hard although you'll have to consider the various rotations possible and check for them all.

Yeah, uh, just realized that the last guy didn't get what I was asking for originally. But I believe what you've said should work, since I'm not looking to make pregenerated structures.

 

Below is one formation I'm wanting to use. The orange wool is the blocks needing to be detected and the light blue wool is the block you'd right click on to determine if the blocks are there for the ritual.

2017-10-05_17.28.36.png

Gne9eza.png

 

"Be patient with me, because I'm an absolute moron half the time."

Posted (edited)

Since the pattern is symmetrical, it should be pretty easy to detect. Simply in the code (or event handler) for right-clicking on the blue block you would simply look in all the relative locations for the expected orange wool and if any one block is missing consider it a fail to match.

 

So assuming you have the center_x, center_y, center_z location (from the location of the blue block) you'd do something like this (this is psuedo code, you'll have to implement in Java the same logic):

 

if block that is two blocks east and two blocks north is not orange wool then return false;

if block that is three blocks east and two blocks north is not orange wool then return false;

.... check all the positions.

return true; // it will only get to this line if all the block positions checked above were orange_wool

 

Hopefully you get the idea. If you want to get clever it might be possible to use loops but even if you don't use loops, the logic is simple and it isn't that much typing because you can cut & past most of it. Sometimes simply using "brute force" is a valid way -- no need to create complicated JSON files, Template classes, and such if you can just use some simple Java to do the same.

 

Actually, to make it simpler I would probably create an array with the pattern, like an array that is initialized like to contain the data like:

 

[[  0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 ],

 [  0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 ],

 [  0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0 ],

 [  0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0 ],

... and similar for the full pattern.

 

Then you can loop through the array with only a couple lines of code. You could then easily test for other patterns by just having other arrays.

 

Hope that helps. 

Edited by jabelar

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted
3 minutes ago, jabelar said:

Since the pattern is symmetrical, it should be pretty easy to detect. Simply in the code (or event handler) for right-clicking on the blue block you would simply look in all the relative locations for the expected orange wool and if any one block is missing consider it a fail to match.

 

So assuming you have the center_x, center_y, center_z location (from the location of the blue block) you'd do something like this (this is psuedo code, you'll have to implement in Java the same logic):

 

if block that is two blocks east and two blocks north is not orange wool then return false;

if block that is three blocks east and two blocks north is not orange wool then return false;

.... check all the positions.

return true; // it will only get to this line if all the block positions checked above were orange_wool

 

Hopefully you get the idea. If you want to get clever it might be possible to use loops but even if you don't use loops, the logic is simple and it isn't that much typing because you can cut & past most of it. Sometimes simply using "brute force" is a valid way -- no need to create complicated JSON files, Template classes, and such if you can just use some simple Java to do the same.

 

Hope that helps. 

Thanks, it does. I was hoping maybe there would be a faster way, by checking for a schematic, but it's not necessary. But given I'll have to write this out... about 20 times, I was hoping there might've been a faster method.

Gne9eza.png

 

"Be patient with me, because I'm an absolute moron half the time."

Posted
8 minutes ago, Daring Do said:

Thanks, it does. I was hoping maybe there would be a faster way, by checking for a schematic, but it's not necessary. But given I'll have to write this out... about 20 times, I was hoping there might've been a faster method.

If you think about it, the array I mentioned above really is a "schematic". You can of course do it in some JSON file or other format, but if all you're doing is checking for relative positions of simple blocks, the array is a very quick way. You can pretty much just "draw" the pattern in the array. There is nothing magical about a "schematic", it is just any method for specifying locations of blocks.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted
Just now, jabelar said:

If you think about it, the array I mentioned above really is a "schematic". You can of course do it in some JSON file or other format, but if all you're doing is checking for relative positions of simple blocks, the array is a very quick way. You can pretty much just "draw" the pattern in the array. There is nothing magical about a "schematic", it is just any method for specifying locations of blocks.

I just know of a way to get a schematic easily, but according to the guy who is working with me, schematics are no longer used. But yeah, I can just write out the array by hand. Thanks again.

Gne9eza.png

 

"Be patient with me, because I'm an absolute moron half the time."

Posted
20 hours ago, Daring Do said:

I just know of a way to get a schematic easily, but according to the guy who is working with me, schematics are no longer used. But yeah, I can just write out the array by hand. Thanks again.

Well the term "schematic" just really means a specification indicating how something is built. There were 3rd party tools like MCCreator that used a file format with file extension = .schematic which was NBT-based. However, the Structure Block introduced another type of "schematic" file with file extension = .nbt which is also NBT-based but different. So that is probably what your friend meant by "schematics" no longer being used -- he means that .schematic files aren't be used but other types of "schematics" are now becoming mainstream.

 

Like anything in coding there are many ways to solve a problem. For example, the array I explained above is pretty easy but technically if your structure is "sparse" (mostly air) then it could be more efficient to simply have a list with each block type and relative position. Or you could create a compressed array where every bit represents a location. 

 

My main point is that as long as you figure out a way to identify block positions, it is all good.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted
2 minutes ago, jabelar said:

Well the term "schematic" just really means a specification indicating how something is built. There were 3rd party tools like MCCreator that used a file format with file extension = .schematic which was NBT-based. However, the Structure Block introduced another type of "schematic" file with file extension = .nbt which is also NBT-based but different. So that is probably what your friend meant by "schematics" no longer being used -- he means that .schematic files aren't be used but other types of "schematics" are now becoming mainstream.

 

Like anything in coding there are many ways to solve a problem. For example, the array I explained above is pretty easy but technically if your structure is "sparse" (mostly air) then it could be more efficient to simply have a list with each block type and relative position. Or you could create a compressed array where every bit represents a location. 

 

My main point is that as long as you figure out a way to identify block positions, it is all good.

I assume by compressed array, you mean something similar to how making a crafting recipe works? Where you define a block with a letter? 

 

Also, quick question, is there a way to detect entities already in the code, or will I have to create that myself? 

Gne9eza.png

 

"Be patient with me, because I'm an absolute moron half the time."

Posted
3 minutes ago, Daring Do said:

I assume by compressed array, you mean something similar to how making a crafting recipe works? Where you define a block with a letter? 

 

Also, quick question, is there a way to detect entities already in the code, or will I have to create that myself? 

Yeah, by compression I mean any scheme where you reduce the actual data stored. So having an "A" to represent all the cobblestone blocks saves space instead of saving "minecraft:cobblestone" every time.

 

I think both world class and maybe player class have methods for getEntitiesInAABB() sort of thing. The exact names may be different, and some can exclude things (like you probably want to exclude the player), but just look at the type hierarchy for the world and player classes. Or you could look at the Structure Block code and copy how it does it.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted
4 minutes ago, jabelar said:

Yeah, by compression I mean any scheme where you reduce the actual data stored. So having an "A" to represent all the cobblestone blocks saves space instead of saving "minecraft:cobblestone" every time.

 

I think both world class and maybe player class have methods for getEntitiesInAABB() sort of thing. The exact names may be different, and some can exclude things (like you probably want to exclude the player), but just look at the type hierarchy for the world and player classes. Or you could look at the Structure Block code and copy how it does it.

Okay, thanks. I'm planning on having it detect specific entities, if possible. If not, it's not too important. But again, thanks. As soon as I get these blocks added to the game, I can test the first ritual. If it works, then I'll mark the thread as solved. 

Gne9eza.png

 

"Be patient with me, because I'm an absolute moron half the time."

Posted
11 minutes ago, Daring Do said:

Okay, thanks. I'm planning on having it detect specific entities, if possible. If not, it's not too important. But again, thanks. As soon as I get these blocks added to the game, I can test the first ritual. If it works, then I'll mark the thread as solved. 

The world getEntitiesWithinAABBExcludingEntity() method can take an entity selector parameter to help filter the results. In any case, all the related methods return a list and you can simply go through that list and remove any entities that don't match your requirements.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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

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

Announcements



×
×
  • Create New...

Important Information

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