Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Point of interest #5379

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open

Conversation

Persson-dev
Copy link
Contributor

I started to implement villages. Since it's a big thing, you can already tell me if i should change some things so i don't waste too much time doing it again. It can then allow iron golems to spawn and villager to breed.

@tigerw
Copy link
Member

tigerw commented Jan 6, 2022

Villages went through a rework in 1.14 and seems to have been simplified, i.e. much less state storage. The village.dat format got replaced with Point of Interest and it seems village mechanics are much more driven by villager/iron golem entities instead of a village object.

So if we upgrade cVillage into something more generic, PointOfInterest maybe, it'll handle not only village stuff but all the other points of interest like portals and beehives.

@Persson-dev
Copy link
Contributor Author

I was trying to implement the old village mechanics (pre 1.14) to have a coherence with the targeted version of Cuberite.
But if you want the new villages mechanics, I can add them too and try something with Point of Interest (which is new for me).

@tigerw
Copy link
Member

tigerw commented Jan 7, 2022

Somewhere in the doddering old 1.12 Cuberite there's a fresh young 1.18 compatible Cuberite struggling to emerge. Let's help it on it's way!

@ZefenDEV
Copy link

ZefenDEV commented Jan 7, 2022

Somewhere in the doddering old 1.12 Cuberite there's a fresh young 1.18 compatible Cuberite struggling to emerge. Let's help it on it's way!

yes, it would not hurt to make support for 1.18, but I think it will be difficult

@Persson-dev
Copy link
Contributor Author

If we implement POI, we would also have to change the villagers since their jobs will also depend of POI.
A village is defined by beds or a bell but bells are introduced in 1.14 so maybe we have to ignore them.
Last thing, I can't find a proper list of all POI types so if someone can find that, I could start working on it :)

@tigerw
Copy link
Member

tigerw commented Jan 14, 2022

Found this: poi corresponding to blocks

Guess poies are simply a list of blocks, supplied by the generator, updated with SetBlocks, and saved to disk.

I can't find end portals in there, maybe they aren't stored, but are looked up based on the current seed?

@Persson-dev
Copy link
Contributor Author

Implementing poies was simplier than i thought. I just added the poi object to see if it's fine and then i will implement them in the world.
I don't know what to do for villager professions because for now, with the available blocks (pre 1.14), we can only get Cleric and Leatherworkers.
Should i keep professions random (as it is) or make them depend on poies ?

@Persson-dev Persson-dev marked this pull request as ready for review February 15, 2022 08:43
@Persson-dev
Copy link
Contributor Author

Now, the poies are created when a poi block is placed (or removed when it has been replaced). The only thing remaining is the storage. And then, i will be able to start working on villages if everything is good.

@Persson-dev
Copy link
Contributor Author

Persson-dev commented Apr 6, 2022

Poies are stored in the poi folder instead of the region one with the official server.
I don't know where to start changing things in Cuberite. Can someone give me advices ?

@bearbin bearbin requested a review from tigerw April 7, 2022 21:03
@12xx12 12xx12 self-requested a review October 17, 2022 10:32
Copy link
Member

@12xx12 12xx12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your work. Sorry for the long wait.

Maybe the title of the PR is misleading :D

In total I Thing this is ready to merge beside some comments I made.

src/ChunkData.cpp Outdated Show resolved Hide resolved
src/PointOfInterest.cpp Outdated Show resolved Hide resolved
src/PointOfInterest.cpp Show resolved Hide resolved
src/PointOfInterest.cpp Outdated Show resolved Hide resolved
src/PointOfInterest.h Outdated Show resolved Hide resolved
src/PointOfInterest.cpp Outdated Show resolved Hide resolved
src/PointOfInterest.h Outdated Show resolved Hide resolved
src/ChunkData.h Outdated Show resolved Hide resolved
@Persson-dev Persson-dev changed the title Add working villages Add Point of interest Oct 18, 2022
@Persson-dev
Copy link
Contributor Author

It has been a very long time. I almost forgot this PR. Right now, i don't have time to continue working on it because of my studies. I will probably work on this PR during computer classes if I'm too bored xD

@Persson-dev
Copy link
Contributor Author

While we were learning how to use char arrays, I applied your suggestions, it should be good. For now, this PR is kind of useless because the poies are not stored in disk. I didn't do that because i didn't know which file to edit to make this work.
Where should I start to save/load the poies on disk?

@12xx12
Copy link
Member

12xx12 commented Oct 20, 2022

The wiki is quite straightforward

https://minecraft.fandom.com/wiki/Java_Edition_level_format#poi_format

@Persson-dev
Copy link
Contributor Author

I meant in Cuberite because poies are not stored in region files but in other files.

@12xx12
Copy link
Member

12xx12 commented Oct 24, 2022

Any writing to disk is done in src/WorldStorage. The actual call is done in a async way. I suggest looking in cWorld or check where the code from src/WorldStorage is called.

I think the POIs should be stored at the same point in time the world is stored

Edit: the thread that stores stuff is in src/WorldStorage/WorldStorage.h

@Persson-dev
Copy link
Contributor Author

6 months after, I'm back.
I found this easier to store poies within the region files instead of doing the "Vanilla" way. So they are stored in chunk sections. It looks something like this :
image
The code is far from being perfect but it works for now.
Hope it helps.

@12xx12
Copy link
Member

12xx12 commented Apr 9, 2023

Thank your for the effort.

The goal is to be like vanilla Minecraft is. So loading and saving POIs should be done in the same way Mojang does

@Persson-dev
Copy link
Contributor Author

I tried to replicate the storage of Vanilla Minecraft as much as possible. The official one looks something like this :
image

The thing is that pois are not stored in the region directory but in another one called poi (the files have the same name and it's stored a bit like regions) and I have no idea on how to do that in Cuberite. I found this easier to just put everything in the region files. So if you know how to do that, you can reuse some of my code

@12xx12
Copy link
Member

12xx12 commented Apr 10, 2023

I see. I did some poking around in the storage code, and it's not very friendly for this kind of modification. Next PR here I come

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants