Conversation
- the old API is fully usable in api.structure.* but deprecated and mark for removal - the new API is located in api.structures.* and it would be the new way to create structures - the new API works with 2 types of structures: LocatedStructure and RelativeStructure - LocatedStructure is a structure that is generated at a specific location and it can be placed without specifying a location, it is already located - RelativeStructure is a structure that is generated relative to a location and it can be placed to any location, it is not located - each of them uses a PlacebleStructure (either LocatedPlacebleStructure or RelativePlacebleStructure) to build the structure and place it. - to make a new Structure, you need to extend either of them, and implement the build() method to return the correct type of PlacebleStructure - they use custom placeble blocks (LocatedBlock, RelativeBlock), they can also override the place function for custom behavior - then implementing the GenerableStructure interface is optional, it allows the structure to have the function needed to be generated in the world, if used by a chunk generator. THIS IS NOT A FINAL IMPLEMENTATION, IT IS STILL IN DEVELOPMENT AND MAY CHANGE IN THE FUTURE.
colbster937
left a comment
There was a problem hiding this comment.
i have requested all the changes i want (i'll fix what i can). i would also like to keep the package the same as the old api as to keep it consistent (singular words, not plural).
|
it would also be a good idea to rename some classes (e.g. "Block") to not be the same as a bukkit class name, so they can be used in classes that already import bukkit classes |
What about, it might be redundant but: PlaceableBlock. |
39388bb to
c58e3b6
Compare
- introduce the new abstract structure base and instance registry - update located/relative/placeable structure types - remove legacy structure entry and align command/test usages - added new exemple of structure
|
i think its finished tell me if it is then i wont change it until merge with upstream |
resurfacing this 4 day old comment |
resurfacing me resurfacing this comment 5 days ago |
the package is api.structure.* and internal.structure.* |
|
notice im not done reorganizing but its near to be completed |
colbster937
left a comment
There was a problem hiding this comment.
sorry if this is coming off as rude, but what exactly is the usecase for this major refactor? i get the ability to use it in a chunkgenerator, but i also liked the simplicity of the previous impl. it was just an idea i came up with while walking to class and implemented it in a simple way so that it would be easy to use.
| if (material == null) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
flip the condition and dont return
| if (chunk instanceof org.bukkit.Chunk liveChunk) { | ||
| if (loc.getWorld() == liveChunk.getWorld() | ||
| && loc.getBlockX() >> 4 == liveChunk.getX() | ||
| && loc.getBlockZ() >> 4 == liveChunk.getZ()) { | ||
| this.place(loc); | ||
| } | ||
| return; | ||
| } |
There was a problem hiding this comment.
flip the condition and dont return
| } | ||
|
|
||
| protected void place(Location loc, Object chunk) { | ||
| if (chunk instanceof org.bukkit.Chunk liveChunk) { |
There was a problem hiding this comment.
import the class, dont use the fqpn
| if (loc.getBlockX() >> 4 != builderChunk.x() | ||
| || loc.getBlockZ() >> 4 != builderChunk.z()) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
flip the condition and dont return
| if (material == null) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
flip the condition and dont return
| public static BaseStructure getTestStructure(Class<?> clazz) { | ||
| for (BaseStructure structure : getStructures()) { | ||
| if (structure.getClass().equals(clazz)) { | ||
| return structure; | ||
| } | ||
| } | ||
|
|
||
| return null; |
There was a problem hiding this comment.
the point of the reflection method was to avoid repeating code like this
| } | ||
|
|
||
| public static Set<String> getStructureNames() { | ||
| final Set<String> names = new HashSet<>(); |
| /dependency-reduced-pom.xml No newline at end of file | ||
| /dependency-reduced-pom.xml | ||
|
|
||
| .vscode No newline at end of file |
There was a problem hiding this comment.
.vscode should be with the existing directory ignores at the top
| - id: vars | ||
| run: | | ||
| echo "JAVA=$(mvn help:evaluate -Dexpression=maven.compiler.release -q -DforceStdout)" >> "$GITHUB_OUTPUT" | ||
| echo "VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> "$GITHUB_OUTPUT" |
There was a problem hiding this comment.
should be "VERS", not "VERSION"
| public static void sendUnknownCommandMessage(CommandSender sender) { | ||
| boolean bool = true; | ||
|
|
||
| final Class<?> clazz = MirrorSafe.getClass("org.spigotmc.SpigotConfig"); | ||
| if (clazz != null) { | ||
| final String msg = MirrorSafe.getFieldValue(clazz, "unknownCommandMessage"); | ||
| if (msg != null) { | ||
| sender.sendMessage(msg); | ||
| bool = false; | ||
| } | ||
| } | ||
|
|
||
| if (bool) { | ||
| sender.sendMessage(ChatColor.RED + "Unknown command."); | ||
| } | ||
| } | ||
|
|
||
| public static void sendOnlyPlayersMessage(CommandSender sender) { | ||
| sender.sendMessage(ChatColor.RED + "This command can only be used by players."); | ||
| } |
There was a problem hiding this comment.
static methods go under instance methods
the goals are:
|
|
I don't get what you mean by the 1st, 2nd, and 3rd, can you elaborate? |
|
look at CoordinateStructure in internal. this structure places black and white concrete depending on the position the structure was placed on (it encodes in binary the coords), im using the AbsoluteStructure to be able to change how the structure is generated, depending on the location, this allows for complex randomnized structure like in vanilla generation. while the RelativeStructure is more like a schematic of a structure you can place anywhere in the world. if you place it at 0,0 or at 10000,10000 it will be the exact same. |
|
sorry, i meant 1st, 2nd, and 4th, not 3rd |
THIS IS NOT A FINAL IMPLEMENTATION, IT IS STILL IN DEVELOPMENT AND MAY CHANGE IN THE FUTURE.