atlarge-research / opencraft

Other
4 stars 2 forks source link

Animal swimming feature - [closed] #149

Closed jdonkervliet closed 4 years ago

jdonkervliet commented 4 years ago

In GitLab by @wubero on May 20, 2020, 19:02

Merges feature/animal-swimming -> development

This merge request solves issue #68 Animals and monsters can now swim and float above water. Except for Iron golems, they drown.

jdonkervliet commented 4 years ago

In GitLab by @larsdetombe on May 20, 2020, 19:45

Commented on src/main/java/net/glowstone/entity/GlowLivingEntity.java line 447

Can this be deleted, or do we still need it for something?

jdonkervliet commented 4 years ago

In GitLab by @JimVliet on May 20, 2020, 20:17

Commented on src/main/java/net/glowstone/entity/GlowLivingEntity.java line 447

Pretty sure we need to discuss this with @julian9499 still.

jdonkervliet commented 4 years ago

In GitLab by @JimVliet on May 20, 2020, 20:18

Commented on src/main/java/net/glowstone/entity/GlowLivingEntity.java line 495

As discussed in your other MR, it might be useful to replace these magic numbers with constant variables.

jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 20, 2020, 20:41

Commented on src/main/java/net/glowstone/entity/monster/GlowMonster.java line 38

It may be neater to use a canSwim() method and perform the registration in the constructor.

jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 20, 2020, 20:41

Commented on src/main/java/net/glowstone/entity/monster/GlowMonster.java line 35

Would it be possible to make this method protected?

jdonkervliet commented 4 years ago

In GitLab by @larsdetombe on May 20, 2020, 20:53

Commented on src/main/java/net/glowstone/entity/monster/GlowMonster.java line 38

The sole reason this method was created, was because iron golems can't swim. This method was created so it could be overwritten in the iron golem class. And in the iron golem class we don't want this registration.

jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 20, 2020, 20:54

Commented on src/main/java/net/glowstone/entity/GlowLivingEntity.java line 495

You could also consider reducing the code-duplication a bit by storing the jump height and performing the set only once. I don't think comments or constants are required here. However, I've added some for completeness sake. Something like:

double jumpHeight = 0.0; // Do not jump by default
Block block = location.getBlock();
if (block.isLiquid()) {
    if (block.getRelative(BlockFace.UP).isEmpty()) {
        jumpVelocity.setY(0.1); // Partially submerged
    } else {
        jumpVelocity.setY(0.1); // Fully submerged
    }
} else if (isOnGround()) {
    jumpHeight = 0.42; // On ground
}
velocity.setY(velocity.getY() + jumpHeight);
jdonkervliet commented 4 years ago

In GitLab by @swabbur on May 20, 2020, 20:58

Commented on src/main/java/net/glowstone/entity/monster/GlowMonster.java line 38

I know. It's just that it might be neater to override a canSwim method than a method that 'exposes' an internal operation. The constructor could than use this canSwim method to determine whether or not the register the AI task.

jdonkervliet commented 4 years ago

In GitLab by @JimVliet on May 20, 2020, 21:36

Commented on src/main/java/net/glowstone/entity/monster/GlowMonster.java line 38

Agreed @swabbur. That would be a cleaner solution.

jdonkervliet commented 4 years ago

In GitLab by @julian9499 on May 21, 2020, 11:25

Commented on src/main/java/net/glowstone/entity/GlowLivingEntity.java line 447

It can be deleted!

jdonkervliet commented 4 years ago

In GitLab by @julian9499 on May 21, 2020, 11:32

Commented on src/main/java/net/glowstone/entity/ai/SwimmingTask.java line 29

What does this 0.6 value mean?

jdonkervliet commented 4 years ago

In GitLab by @julian9499 on May 21, 2020, 11:32

Commented on src/main/java/net/glowstone/entity/ai/SwimmingTask.java line 28

You should clone the location

jdonkervliet commented 4 years ago

In GitLab by @julian9499 on May 21, 2020, 11:35

Commented on src/main/java/net/glowstone/entity/monster/GlowIronGolem.java line 23

Slimes can not swim as well

jdonkervliet commented 4 years ago

In GitLab by @wubero on May 21, 2020, 11:39

Commented on src/main/java/net/glowstone/entity/GlowLivingEntity.java line 447

changed this line in version 2 of the diff

jdonkervliet commented 4 years ago

In GitLab by @wubero on May 21, 2020, 11:39

Commented on src/main/java/net/glowstone/entity/GlowLivingEntity.java line 495

changed this line in version 2 of the diff

jdonkervliet commented 4 years ago

In GitLab by @wubero on May 21, 2020, 11:39

Commented on src/main/java/net/glowstone/entity/monster/GlowMonster.java line 38

changed this line in version 2 of the diff

jdonkervliet commented 4 years ago

In GitLab by @wubero on May 21, 2020, 11:39

Commented on src/main/java/net/glowstone/entity/monster/GlowMonster.java line 35

changed this line in version 2 of the diff

jdonkervliet commented 4 years ago

In GitLab by @wubero on May 21, 2020, 11:39

Commented on src/main/java/net/glowstone/entity/monster/GlowIronGolem.java line 23

changed this line in version 2 of the diff

jdonkervliet commented 4 years ago

In GitLab by @wubero on May 21, 2020, 11:39

added 43 commits

Compare with previous version

jdonkervliet commented 4 years ago

In GitLab by @julian9499 on May 21, 2020, 11:39

Commented on src/main/java/net/glowstone/entity/ai/SwimmingTask.java line 29

Maybe change this to getting the center of the entity boundingbox.

jdonkervliet commented 4 years ago

In GitLab by @wubero on May 21, 2020, 11:39

Commented on src/main/java/net/glowstone/entity/GlowLivingEntity.java line 495

Changed this.

jdonkervliet commented 4 years ago

In GitLab by @wubero on May 21, 2020, 11:56

Commented on src/main/java/net/glowstone/entity/ai/SwimmingTask.java line 29

changed this line in version 3 of the diff

jdonkervliet commented 4 years ago

In GitLab by @wubero on May 21, 2020, 11:56

Commented on src/main/java/net/glowstone/entity/ai/SwimmingTask.java line 28

changed this line in version 3 of the diff

jdonkervliet commented 4 years ago

In GitLab by @wubero on May 21, 2020, 11:56

added 1 commit

Compare with previous version

jdonkervliet commented 4 years ago

In GitLab by @wubero on May 21, 2020, 11:57

resolved all threads

jdonkervliet commented 4 years ago

In GitLab by @julian9499 on May 22, 2020, 10:27

added 2 commits

Compare with previous version

jdonkervliet commented 4 years ago

In GitLab by @julian9499 on May 26, 2020, 16:18

added 84 commits

Compare with previous version

jdonkervliet commented 4 years ago

In GitLab by @julian9499 on May 26, 2020, 16:18

marked as a Work In Progress from 05e0f4939d2b783655b27c6926437aad26861b57

jdonkervliet commented 4 years ago

In GitLab by @julian9499 on May 26, 2020, 16:43

unmarked as a Work In Progress

jdonkervliet commented 4 years ago

In GitLab by @julian9499 on May 26, 2020, 16:43

changed the description

jdonkervliet commented 4 years ago

In GitLab by @larsdetombe on May 26, 2020, 16:58

Somehow when I spawned villagers they did not seem to want to swim. Even after reloading no villager seems to be able to swim.

The same happened with cows at first, however they seemed to update their behaviour after I spawned a few more.

I tested it with other animals as well, it seems that the first animal I spawn does not seem to swim, when I spawn more after that they do swim.

image

jdonkervliet commented 4 years ago

In GitLab by @larsdetombe on May 26, 2020, 17:03

I don't know if it is related to this MR, but squids seem to drown underwater. I understand that the swimming mechanic of squids is different from other land mobs, however they should not be able to drown underwater.

jdonkervliet commented 4 years ago

In GitLab by @julian9499 on Jun 2, 2020, 15:51

closed