echurchill / CityWorld

Minecraft/Bukkit world generator
62 stars 36 forks source link

Method to identify type of plot with another plugin #16

Closed keenerb closed 7 years ago

keenerb commented 9 years ago

I'd like some way to be able to identify, with another plugin, which type of plot a player is currently standing in.

Any suggestions? I know with a normal cityworld you can use biome to check, but obviously that doesn't work in one of your desert/snow worlds.

What I ended up doing in an old fork of your plugin was hide specific types of wool in the bedrock layer; each chunk's 1,0,1 block was a specific color of wool capped with another bedrock block, and I just checked the damage value for the 1,0,1 block every time I needed to know what "type" of cityworld chunk I was in.

If you can think of something better or more elegant than this I'd really like to know. I have a chat-based minimap that uses colored characters to indicate nearby plot types, it's quite good and I tie in other indicators as well like the chunk's radioactivity and mob count and etc.

echurchill commented 9 years ago

Do you mean something akin to what /CityInfo returns?

keenerb commented 9 years ago

Yeah precisely. Is there like an APi for cityworld or anything?

coaster3000 commented 9 years ago

Yea there is an api HERE

I am not liking the looks of it to tell the truth. There are some stuff that can cause exceptions that are not being caught here. Including unchecked casting and more...

EDIT: @keenerb

echurchill commented 9 years ago

Alas that code was written by another contributor and I can't speak to its robustness/stability. Sorry.

As for making it more resilient, I would rather trash it and create from fresh. :-)

coaster3000 commented 9 years ago

Is your current code somewhat stable? I could probably lend some time once the previous issue is fixed with git's line ending problem.

echurchill commented 9 years ago

The code is a stable and fully checked in right now. Nothing in flight.

echurchill commented 9 years ago

I am curious what would you like the API to look like? Should it simply return the plot class name as a string for a particular player name? Or something nuttier like return the plat type reference/pointer? I have to admit without knowing a little more info it is hard to contemplate what the code should look like.

keenerb commented 9 years ago

For my purposes, I'd like to be able to tell what type of plat/chunk I'm in; wilderness, road, city, and maybe the buiding type (highrise, unfinished, farm, mountain cabin/radio tower lot, bunker present, etc.). I am hoping to have a nice integration with a new server I've been tinkering with.

For example, I have loot chests that appear and I'd like to have the items in the chests tailored to the plat type; wilderness chests would have raw materials, farm chests would have food stores, highrise/houses would have finished materials, bunkers would have weapons/armor/etc.

Spiders and creepers would be more numerous in wilderness, zombies in city, maybe even have an occasional villager spawn in cabins and whatnot.

echurchill commented 9 years ago

Once I get the Spigot/Bukkit switchover dealt with I will take a look.

coaster3000 commented 9 years ago

I would like the PlatLot object accessible if possible. It is one of the things I wanted to contribute to the api. (Including fixing it up a bit)

echurchill commented 9 years ago

I plan to look at this weekend. Sorry for the delay

keenerb commented 9 years ago

Ideally this would be in a 1.7.10 compatible build, for what it's worth. If that's even possible now.

echurchill commented 9 years ago

Sorry, I have been off line due to an injury. I hope to get back to this next weekend.

keenerb commented 9 years ago

No worries. Get to it when (or IF) you have the time, it's nothing earth-shattering. I could just do one or two neat things wtih the feature...

keenerb commented 7 years ago

I finally found a way to do this, for my very particular circumstances anyway, using the Skript plugin.

I set the underlying bedrock layer to 2 blocks rather than 1, and essentially turned the bottom layer into a bitmapped data set.

I added a bit of code to the very end of each plot's GenerateActualBlocks method that sets block 1, 1, 1 in a chunk to a colored block where the data value stores which plat type (Astral/Floating/Nature/Urban/etc.) the chunk belongs to:

chunk.setBlockTypeAndColor(1, 1, 1, Material.STAINED_CLAY, DyeColor.GRAY);

Using wool/clay/glass gives me 48 possible values for each block in the bottom layer, which means I can technically store 768 bits of data this way.

Block 1, 1, 2 is set to a colored block where data value 1 = farm plot, 2 = barn plot, 3 = road plot, etc. etc.

Block 1, 1, 3 is a colored block that contains the generator type that was in use when the chunk was created.

And so on and so forth. With Skript I have a small routine that I can use to identify particular information about a chunk and use that in my script logic for a number of purposes, like equipping zombies with hoes/axes/leather helmets (hard hats) if they spawn in farmland/forests/unfinished building lots.