GlowstoneMC / Glowstone

A fast, customizable and compatible open source server for Minecraft: Java Edition
https://glowstone.net
Other
1.88k stars 271 forks source link

General concept for Animals? #362

Closed valleydev closed 7 years ago

valleydev commented 7 years ago

I am not sure if animals are currently implemented. Currently they are not spawning on my test server.

This is the class hierarchy of the wolf which i found in source code

GlowEntity (Entity) GlowLivingEntity GlowCreature GlowAgeable net.glowstone.entity.passive.GlowAnimal net.glowstone.entity.passive.GlowTameable net.glowstone.entity.passive.GlowWolf

How can i spawn an entity?

Please correct me if i am wrong: GlowWolf wolf = new GlowWolf(); [instance of GlowWorld].entities.register( wolf );

Anything else need to be done?

Which class is responsible for making the animals move?

pulse? tick?

_Suggestion for a concept for the behaviour of animals in swarms. _

  1. Asyncronous planning of movement and actions
  2. position, rotation and velocity update
  3. Quene for replanning when movement or action is obstructed or completed

Sample concept for Wolf-Pack

Variables Dehydration Hunger Hideoutposition

States Hide at Day Come out at dawn Finding water source for drinking Finding a delicous chicken Hunting chicken Eating Chicken: On Success Breeding

Sample concept for Cow and Sheep

Variables Dehydration Hunger

States Finding water source for drinking Finding and eat grass Move away from danger Breeding

mastercoms commented 7 years ago

AI/movement design has not been decided on yet so there is no class or place yet but pulse seems like the best idea.

Mobs don't automatically spawn. You can use a spawn egg or the spawnEntity() method in GlowWorld.

valleydev commented 7 years ago

Thanks for your response. I will have a look at the GlowWorld.spawnEntity function and the Pulse quene.

Further questions: Is there dangermap (dangerous areas = high value) or A* pathfinding implemented?

aramperes commented 7 years ago

There is no AI per say in Glowstone, and mob spawning is not implemented in world generation. I have an A* pathfinding library repo on my account, but it would need some tweaking for 3D environments.

mastercoms commented 7 years ago

The closest to a dangermap is canSpawn() in the generator classes (GlowChunkGenerator, NetherGenerator, TheEndGenerator). But it's not really an actual solution.

valleydev commented 7 years ago

Some strange behaviour:

i put

if (true) return false;

in the first line of function

GlowCow.entityInteract

but i am still able to milk the cow in survival mode.

Where is the milk etc. logic implemented??

valleydev commented 7 years ago

i noticed that killing an animal (spawned by an egg) does not drop anything.

mastercoms commented 7 years ago

Log out and back in and see if the bucket is still milk. It may be a client issue expecting to be able to milk the cow, and it then desyncs from the server, because GlowCow.entityInteract() is where the milking functionality is located.

There are no entity death drops implemented.

valleydev commented 7 years ago

dropping for cow implemented.

any suggestions on how to make a pull request? do i need to create a new branch first?

mastercoms commented 7 years ago

Here's where you can find everything you need to know about helping with Glowstone's development:

https://github.com/GlowstoneMC/Glowstone/wiki/How-to-Help#developing. Make sure you also read the Contributing and PR Handling pages linked at the bottom of the section, please.

Also, our Contribution policy explains some more details about our contribution process. It's not a CLA or anything you have to agree to, just how contributions are managed.

aramperes commented 7 years ago

**Also hop on our Discord if you want to chat about development!

valleydev commented 7 years ago

i have created a pull request. (so far some animals are dropping items) Missing: Dropping Experience Missing: Dropping grilled Chicken flesh anfter animal has been ignited

Room for improvement.

Any idea how to move an animal from the pulse function? Just set the position?

mastercoms commented 7 years ago

Closing in favor of #390.