[Bug]: Placing a space station on an existing station deletes that station
ICY105 opened this issue ยท 2 comments
Bug Description
There are currently no limits to where a Space Station can be placed, which allows placing a station on top of an existing station. Generating a new station is forced, overriding the old station (as if generated from a structure block).
How to Reproduce?
No response
Expected Behavior
No response
Version
1.12.1
Mod Loader Version
1.19.2-0.14.12
Mod Loader
Fabric
Logs or additional context
No response
A (albeit somewhat janky) solution is to store the locations of Space Stations somewhere, and check if the location overlaps. If not, land at that station. Psuedo-code (from here):
if (level instanceof ServerLevel serverWorld) {
ServerLevel targetWorld = serverWorld.getServer().getLevel(ResourceKey.create(Registries.DIMENSION, packet.targetWorld));
if (targetWorld == null) return;
// Create the Space Station from the nbt file
if !(pos in listOfSpaceStationPositionsThatWeGotFromSomeWhereIGuess){
StructureTemplate structure = targetWorld.getStructureManager().getOrCreate(new ResourceLocation(AdAstra.MOD_ID, "space_station"));
BlockPos pos = new BlockPos(player.getX() - (structure.getSize().getX() / 2.0f), 100, player.getZ() - (structure.getSize().getZ() / 2.0f));
targetWorld.getChunkSource().addRegionTicket(TicketType.PORTAL, new ChunkPos(pos), 1, pos);
structure.placeInWorld(targetWorld, pos, pos, new StructurePlaceSettings(), targetWorld.random, 2);
}
};
Obviously, there would be some kinda calculation to figure out if it overlapped, but that's my idea.