From 517b195b5e2b1d8e08740208dacff34063126e59 Mon Sep 17 00:00:00 2001 From: GoldenStack Date: Sat, 7 Oct 2023 13:49:16 -0500 Subject: [PATCH] hollow-cube/remove-default-damage-behaviour (#64) * Remove automatic void damage * Remove automatic fire damage --- .../net/minestom/server/entity/Entity.java | 12 ---------- .../minestom/server/entity/LivingEntity.java | 24 ++----------------- .../minestom/server/instance/Instance.java | 4 +--- 3 files changed, 3 insertions(+), 37 deletions(-) diff --git a/src/main/java/net/minestom/server/entity/Entity.java b/src/main/java/net/minestom/server/entity/Entity.java index 7e6ea1c66..36cb4d7a8 100644 --- a/src/main/java/net/minestom/server/entity/Entity.java +++ b/src/main/java/net/minestom/server/entity/Entity.java @@ -558,8 +558,6 @@ public class Entity implements Viewable, Tickable, Schedulable, Snapshotable, Ev // handle block contacts touchTick(); - handleVoid(); - // Call the abstract update method update(time); @@ -747,16 +745,6 @@ public class Entity implements Viewable, Tickable, Schedulable, Snapshotable, Ev return ticks; } - /** - * How does this entity handle being in the void? - */ - protected void handleVoid() { - // Kill if in void - if (getInstance().isInVoid(this.position)) { - remove(); - } - } - /** * Each entity has an unique id (server-wide) which will change after a restart. * diff --git a/src/main/java/net/minestom/server/entity/LivingEntity.java b/src/main/java/net/minestom/server/entity/LivingEntity.java index fae28391b..9d558c289 100644 --- a/src/main/java/net/minestom/server/entity/LivingEntity.java +++ b/src/main/java/net/minestom/server/entity/LivingEntity.java @@ -63,11 +63,6 @@ public class LivingEntity extends Entity implements EquipmentHandler { */ private long fireExtinguishTime; - /** - * Last time the fire damage was applied - */ - private long lastFireDamageTime; - /** * Period, in ms, between two fire damage applications */ @@ -189,15 +184,8 @@ public class LivingEntity extends Entity implements EquipmentHandler { @Override public void update(long time) { - if (isOnFire()) { - if (time > fireExtinguishTime) { - setOnFire(false); - } else { - if (time - lastFireDamageTime > fireDamagePeriod) { - damage(DamageType.ON_FIRE, 1.0f); - lastFireDamageTime = time; - } - } + if (isOnFire() && time > fireExtinguishTime) { + setOnFire(false); } // Items picking @@ -582,14 +570,6 @@ public class LivingEntity extends Entity implements EquipmentHandler { return new EntityPropertiesPacket(getEntityId(), List.copyOf(attributeModifiers.values())); } - @Override - protected void handleVoid() { - // Kill if in void - if (getInstance().isInVoid(this.position)) { - damage(DamageType.VOID, 10f); - } - } - /** * Gets the time in ms between two fire damage applications. * diff --git a/src/main/java/net/minestom/server/instance/Instance.java b/src/main/java/net/minestom/server/instance/Instance.java index 44383b540..4cf9bbb9e 100644 --- a/src/main/java/net/minestom/server/instance/Instance.java +++ b/src/main/java/net/minestom/server/instance/Instance.java @@ -367,9 +367,7 @@ public abstract class Instance implements Block.Getter, Block.Setter, public abstract boolean hasEnabledAutoChunkLoad(); /** - * Determines whether a position in the void. If true, entities should take damage and die. - *

- * Always returning false allow entities to survive in the void. + * Determines whether a position in the void. * * @param point the point in the world * @return true if the point is inside the void