#Need certain structures to not spawn in lost cities.

15 messages · Page 1 of 1 (latest)

outer comet
#
let $ILostChunkInfo = Java.loadClass("mcjty.lostcities.api.ILostChunkInfo")
function rollDice(x) {
    if (x <= 0) {
        throw new Error("The maximum value must be greater than 0.");
    }
    return Math.floor(Math.random() * x) + 1;
}


MoreJSEvents.structureLoad((event) => {
    //need city to be a bool that knows whether or not a city is here
    if (city){
        event.cancel()
    }
})

//Dev posted here with some details
https://www.reddit.com/r/feedthebeast/comments/6oewy3/psa_worldgen_playing_nicely_with_the_lost_cities/

Lost Cities has an issue where structures placed in areas already occupied by cities override each other, creating a huge mess. I want to prevent my structures from spawning in these cities. The problem is, as far as I know, there's no way to get the chunk coordinates (ChunkX and ChunkZ) for the structures, so I can't check them against the locations of Lost Cities' cities.

Reddit

Explore this post and more from the feedthebeast community

devout oliveBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

outer comet
#

@paper wigeon hiya you asked to ping

#

i imaginbe this means making a lookup table of chunk x and z coords when teh cities generate heh and getting the x and z value of the first block in a structure and checking if it is or is not within one of these chunks?

#

SO i basiclaly need to creat e atable of cunk coords, (knowing what has and doesnt have cities) do sometyhing like ```js
// Given position (x, y, z)
int x = // x coordinate; (SOmehow get a position out of the structur eload event)
int z = // z coordinate;
int chunkX = Math.floor(x / 16);
int chunkZ = Math.floor(z / 16);
int targetChunkX = // target chunk x coordinate; (POrobably sav ethis in forgeevent to a globval object
int targetChunkZ = // target chunk z coordinate;
// Check if the position is within the target chunk
if (chunkX == targetChunkX && chunkZ == targetChunkZ) {
// The position is within the specific chunk so cancel event
} else {
// The position is not within the specific chunk
}

#

anyway, nee dto mow the lawn

#

be back in a bit

paper wigeon
# outer comet SO i basiclaly need to creat e atable of cunk coords, (knowing what has and does...

try this,
Startup Scripts: ```js
ForgeEvents.onEvent("mcjty.lostcities.api.LostCityEvent$PostGenCityChunkEvent", event => {
global.recordCityChunk(event);
})
/**

  • @param {Internal.LostCityEvent$PostGenCityChunkEvent} event
    */
    global.recordCityChunk = event => {
    try {
    let chunkX = event.chunkX;
    let chunkZ = event.chunkZ;
    let persistentData = Utils.server.persistentData;
    let chunkList = [];
    if (persistentData.contains("CityChunks")) {
    chunkList = JSON.parse(persistentData.getString("CityChunks"));
    }
    if (!chunkList.some(chunk => chunk.chunkX === chunkX && chunk.chunkZ === chunkZ)) {
    chunkList.push({ chunkX: chunkX, chunkZ: chunkZ });
    persistentData.putString("CityChunks", JSON.stringify(chunkList));
    }
    } catch (error) {
    console.log(error);
    }
    } Server Script:js
    ItemEvents.rightClicked(event => {
    const player = event.player;
    const isInCity = global.isPlayerInCity(player);

    if (isInCity) {
    player.tell("You are inside a city!");
    } else {
    player.tell("You are not inside a city.");
    }
    })
    /**

  • Check if a player is inside a city based on their chunk coordinates.

  • @param {Internal.Player} player - The player to check.

  • @returns {boolean} - True if the player is inside a city, false otherwise.
    */
    global.isPlayerInCity = player => {
    const chunkX = player.chunkPosition().x
    const chunkZ = player.chunkPosition().z
    const persistentData = Utils.server.persistentData;
    let chunkList = [];
    if (persistentData.contains("CityChunks")) {
    chunkList = JSON.parse(persistentData.getString("CityChunks"));
    }
    return chunkList.some(chunk => chunk.chunkX === chunkX && chunk.chunkZ === chunkZ);
    };```

#

so far it seems to be working

#

you may need to delete the chunks from the persistent data after they've been loaded so it doesnt store a huge list forever but other than that it should work

#

as for getting the chunks the structure is spawned in from the structureLoad event im not sure hmmm

outer comet
#

AHh thanks

outer comet
#

Thanks i can figur eit out from here. ALso im tired lol