LemADEC / WarpDrive

A warp drive mod for minecraft
70 stars 40 forks source link

Procedurally add planets to space dimension #138

Open StargateMC opened 8 years ago

StargateMC commented 8 years ago

It would be great for all loaded dimensions in game to be automatically assigned a random position in the space dimension and the config to be used as an override setting.

A new config for world size in space and min distance between planets would be required and that's it.

I've got code that should work, I just don't seem to be able to trigger a serverFullyStarted event... Can't find the equivalent of what I want in the forge events..... Maybe we can chat about this in this issue?

New to modding haha

StargateMC commented 8 years ago

By server fully started I mean all dimensions are loaded and the server is ready for players.

LemADEC commented 8 years ago

Dimensions are added dynamically by mods, so you need to define equations to populate those planets coordinates and call it whenever a new dimension is found. In other words, I would suggest to trigger on dimension loaded event (or whatever the name is).

StargateMC commented 8 years ago

Ah! genius.

Would there be any issue in updating WarpDriveConfig.PLANETS while the server is running?

StargateMC commented 8 years ago

I'll give you a code example tonight of what I'm trying to do :) If it is what you'd be happy doing I'll submit a pull request

CaptainMegavolt commented 8 years ago

If this gets implemented, can the old way of adding planets by hand be kept in (or maybe some way of defining planets with a creative tool like the worldedit wand ingame?)

--Supernova Industries Supreme Chairman Megavolt

On Mon, Feb 29, 2016 at 5:52 PM, DraksterAU notifications@github.com wrote:

I'll give you a code example tonight of what I'm trying to do :) If it is what you'd be happy doing I'll submit a pull request

— Reply to this email directly or view it on GitHub https://github.com/LemADEC/WarpDrive/issues/138#issuecomment-190454444.

StargateMC commented 8 years ago

@supernovaco The config would remain as an override to the procedural generation.

So if you define the location of a planet in config, it will not be dynamically added elsewhere.

I'm mainly investigating this as I have 100 worlds (size limited) and this grows with the number of players.

StargateMC commented 8 years ago

@supernovaco I'll also see if I can create a command for ops to use at the same time :)

StargateMC commented 8 years ago

@lemadec Would you be keen on that? The command idea that is.

I'm just throwing ideas (and hopefully some decent pull requests) in the ring :P

CaptainMegavolt commented 8 years ago

Gotcha! This whole idea of procedural adding of planets is great!

--Supernova Industries Supreme Chairman Megavolt

On Mon, Feb 29, 2016 at 8:00 PM, DraksterAU notifications@github.com wrote:

@lemadec https://github.com/lemadec Would you be keen on that? The command idea that is.

I'm just throwing ideas (and hopefully some decent pull requests) in the ring :P

— Reply to this email directly or view it on GitHub https://github.com/LemADEC/WarpDrive/issues/138#issuecomment-190493491.

LemADEC commented 8 years ago

Remember to keep it in main thread. The PLANETS structure isn't multithread safe.

StargateMC commented 8 years ago

any complaints if I register two events;

OnDimensionLoad

This event will randomly place a planet if it doesn't already exist in the PLANETS list. It assumes that the config is loaded before the dimensions are.

OnDimensionUnload

This event will remove a planet that is unloaded from the list. This logic will catch static planets too. Any way you think I could skip them @lemadec?

CaptainMegavolt commented 8 years ago

Is there any way to determine if the dimension is 'cavelike' (i.e. like the Nether) to determine if it should be used? Just asking if it is possible and feasible to do that when OnDimensionLoad is tripped.

--Supernova Industries Supreme Chairman Megavolt

On Mon, Feb 29, 2016 at 9:34 PM, DraksterAU notifications@github.com wrote:

any complaints if I register two events;

OnDimensionLoad

This event will randomly place a planet if it doesn't already exist in the PLANETS list. It assumes that the config is loaded before the dimensions are.

OnDimensionUnload

This event will remove a planet that is unloaded from the list. This logic will catch static planets too. Any way you think I could skip them @lemadec https://github.com/lemadec?

— Reply to this email directly or view it on GitHub https://github.com/LemADEC/WarpDrive/issues/138#issuecomment-190523519.

LemADEC commented 8 years ago

Why would we remove them on the OnDimensionUnload, that doesn't make sense to me?

StargateMC commented 8 years ago

Will create a static exclude dimension Id list @supernovaco. In addition to this, any world that is a nether will be excluded.... at least I'll be doing that by default.

@lemadec if we don't remove worlds that are not loaded in PLANETS is going to get out of hand.... And increasing amounts of space within the space dimension will become unusable. Unless you can think of a reason why they should be kept?

StargateMC commented 8 years ago

Unusable for new planets*

StargateMC commented 8 years ago

actually if we generate two lists on startup that would be easiest.

PLANETS _STATIC and PLANETS

On dimension unload if the planet is in planets but not static planets, we will remove it. If not, we leave it there.

Sound ok? The static list isn't actually used as anything more than a reference point for the unload and load functions.

StargateMC commented 8 years ago

@LemADEC

Can you take a look at https://github.com/StargateMC/WarpDrive/commit/06ac494a00fde6c8658f9ace52d5777d9e5ca889

This is very rough, but what I'm trying to achieve and I understand the planets will not be very well placed... Any tips?

LemADEC commented 8 years ago

All worlds are unloaded by default. Furthermore, if you keep on removing and re-adding them, it'll be a mess for players as they'll keep on moving around. First rule of design: everything that's duplicated is erroneous, or will be shortly. In other words, keep a single list of planets.

As for your exemple:

StargateMC commented 8 years ago

The idea behind the removing and adding is longer term they will be added based on a formula, which results in a planet with the same dimension id being added back to the same place.

This way if we have a planet that is unloaded for some reason, its no longer in space (this happens a lot with Thermos servers using a bukkit world provider).

For the "Duplicate" solution... how about an additional field which states whether or not a world is static? Have the configuration file loader append this to the planet object being imported and set it to something like 'static'.

Then when dynamic worlds are loaded, we can set the same attribute to 'dynamic' and only load/unload these worlds.

What do you think?

LemADEC commented 8 years ago

World unloading is normal, in vanilla. Thermos and bukkit have nothing to do with it. The world ID won't change for a given save, there's really no point to delete that planet. Furthermore, you need those planet entries to report them to the radar or navigation code.

StargateMC commented 8 years ago

@LemADEC If you are using a Thermos / bukkit server, multiworld ( and likewise plugins) will use the next available dimension id for new planets. You can literally create/destroy world 'saves' with commands.... which is why I'm keen on doing it this way. Every time a world is loaded it might have a new name etc. Still think its a bad idea?

LemADEC commented 8 years ago

You're missing the point about plain Forge loading and unloading dimensions dynamically, and the requirement for those planets to always be defined in the mod configuration for WarpDrive to works properly.

Soyaro666 commented 7 years ago

having worlds being added as planets (un/stable mystcraft worlds being accessible through space) would be really awesome. but what if personal worlds (galacticraft Space stations, Dimdoors personal pocket dimensions) aren't supposed to be added? A blacklist would be needed... something like "ive blacklisted "pocketdim" so everything thats name fits "pocketdim" is ignored"...

StargateMC commented 7 years ago

Fantastic idea. It would likely need to include support for blacklisting any netherworld, underground or space station dimensions.

StargateMC commented 7 years ago

Ps lemadec I will give this a go. I've been mia a long time.

Soyaro666 commented 7 years ago

iirc there's a mod that requires you to access nethers "roof" so maybe you shouldn't assume nether to be blacklisted... but yes, nether would be a common candidate for the blacklist. just like the end or some private dims like random things' specte room maybe

StargateMC commented 7 years ago

There's no reason for a warp drive ship to land on top of the bedrock roof, but yep, all configurable.

LemADEC commented 7 years ago

I think we need 2 forms of blacklists. First one by plain old dimensionIds, second one by world generation class name. If a dimension is already defined, it should remains 'as is'. New dimensions should skip positions overlapping other existing planets.

Try something simple for a start @Bysokar .