Set step height attribute on spawn centrally instead of locally

This commit is contained in:
fullwall 2024-09-29 16:18:09 +08:00
parent e78499f6ca
commit 59534df8c0
15 changed files with 5 additions and 15 deletions

View File

@ -9,6 +9,7 @@ import java.util.function.Consumer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.attribute.Attribute;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -46,6 +47,7 @@ import net.citizensnpcs.api.util.DataKey;
import net.citizensnpcs.api.util.Messaging; import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.npc.ai.CitizensNavigator; import net.citizensnpcs.npc.ai.CitizensNavigator;
import net.citizensnpcs.npc.skin.SkinnableEntity; import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.AttributeTrait;
import net.citizensnpcs.trait.CurrentLocation; import net.citizensnpcs.trait.CurrentLocation;
import net.citizensnpcs.trait.Gravity; import net.citizensnpcs.trait.Gravity;
import net.citizensnpcs.trait.HologramTrait; import net.citizensnpcs.trait.HologramTrait;
@ -390,7 +392,9 @@ public class CitizensNPC extends AbstractNPC {
LivingEntity entity = (LivingEntity) getEntity(); LivingEntity entity = (LivingEntity) getEntity();
entity.setRemoveWhenFarAway(false); entity.setRemoveWhenFarAway(false);
if (NMS.getStepHeight(entity) < 1) { if ((!hasTrait(AttributeTrait.class)
|| !getTrait(AttributeTrait.class).hasAttribute(Attribute.GENERIC_STEP_HEIGHT))
&& (type == EntityType.PLAYER || Util.isHorse(type))) {
NMS.setStepHeight(entity, 1); NMS.setStepHeight(entity, 1);
} }
if (type == EntityType.PLAYER) { if (type == EntityType.PLAYER) {

View File

@ -241,7 +241,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
controllerMove = new PlayerControllerMove(this); controllerMove = new PlayerControllerMove(this);
navigation = new PlayerNavigation(this, world); navigation = new PlayerNavigation(this, world);
invulnerableTicks = 0; invulnerableTicks = 0;
NMS.setStepHeight(getBukkitEntity(), 1); // the default (0) breaks step climbing setSkinFlags((byte) 0xFF);
} }
@Override @Override

View File

@ -218,7 +218,6 @@ public class HorseController extends MobEntityController {
e.printStackTrace(); e.printStackTrace();
} }
} }
NMS.setStepHeight(getBukkitEntity(), 1);
npc.update(); npc.update();
} }
} }

View File

@ -270,7 +270,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
controllerMove = new PlayerControllerMove(this); controllerMove = new PlayerControllerMove(this);
navigation = new PlayerNavigation(this, world); navigation = new PlayerNavigation(this, world);
invulnerableTicks = 0; invulnerableTicks = 0;
NMS.setStepHeight(getBukkitEntity(), 1); // the default (0) breaks step climbing setSkinFlags((byte) 0xFF);
} }
@Override @Override

View File

@ -278,7 +278,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
controllerMove = new PlayerControllerMove(this); controllerMove = new PlayerControllerMove(this);
navigation = new PlayerNavigation(this, world); navigation = new PlayerNavigation(this, world);
invulnerableTicks = 0; invulnerableTicks = 0;
NMS.setStepHeight(getBukkitEntity(), 1); // the default (0) breaks step climbing
setSkinFlags((byte) 0xFF); setSkinFlags((byte) 0xFF);
} }

View File

@ -268,7 +268,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
controllerMove = new PlayerControllerMove(this); controllerMove = new PlayerControllerMove(this);
navigation = new PlayerNavigation(this, world); navigation = new PlayerNavigation(this, world);
invulnerableTicks = 0; invulnerableTicks = 0;
NMS.setStepHeight(getBukkitEntity(), 1); // the default (0) breaks step climbing
setSkinFlags((byte) 0xFF); setSkinFlags((byte) 0xFF);
} }

View File

@ -270,7 +270,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
controllerMove = new PlayerControllerMove(this); controllerMove = new PlayerControllerMove(this);
navigation = new PlayerNavigation(this, world); navigation = new PlayerNavigation(this, world);
invulnerableTicks = 0; invulnerableTicks = 0;
NMS.setStepHeight(getBukkitEntity(), 1); // the default (0) breaks step climbing
setSkinFlags((byte) 0xFF); setSkinFlags((byte) 0xFF);
} }

View File

@ -270,7 +270,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
controllerMove = new PlayerControllerMove(this); controllerMove = new PlayerControllerMove(this);
navigation = new PlayerNavigation(this, world); navigation = new PlayerNavigation(this, world);
invulnerableTicks = 0; invulnerableTicks = 0;
NMS.setStepHeight(getBukkitEntity(), 1); // the default (0) breaks step climbing
setSkinFlags((byte) 0xFF); setSkinFlags((byte) 0xFF);
} }

View File

@ -242,7 +242,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
} catch (IOException e) { } catch (IOException e) {
} }
invulnerableTicks = 0; invulnerableTicks = 0;
NMS.setStepHeight(getBukkitEntity(), 1); // the default (0) breaks step climbing
setSkinFlags((byte) 0xFF); setSkinFlags((byte) 0xFF);
} }

View File

@ -261,7 +261,6 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
// swallow // swallow
} }
this.invulnerableTime = 0; this.invulnerableTime = 0;
NMS.setStepHeight(getBukkitEntity(), 1); // the default (0) breaks step climbing
setSkinFlags((byte) 0xFF); setSkinFlags((byte) 0xFF);
} }

View File

@ -261,7 +261,6 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
} catch (IOException e) { } catch (IOException e) {
} }
this.invulnerableTime = 0; this.invulnerableTime = 0;
NMS.setStepHeight(getBukkitEntity(), 1); // the default (0) breaks step climbing
setSkinFlags((byte) 0xFF); setSkinFlags((byte) 0xFF);
} }

View File

@ -265,7 +265,6 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
} catch (IOException e) { } catch (IOException e) {
} }
this.invulnerableTime = 0; this.invulnerableTime = 0;
NMS.setStepHeight(getBukkitEntity(), 1); // the default (0) breaks step climbing
setSkinFlags((byte) 0xFF); setSkinFlags((byte) 0xFF);
} }

View File

@ -268,7 +268,6 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
e.printStackTrace(); e.printStackTrace();
} }
this.invulnerableTime = 0; this.invulnerableTime = 0;
NMS.setStepHeight(getBukkitEntity(), 1); // the default (0) breaks step climbing
setSkinFlags((byte) 0xFF); setSkinFlags((byte) 0xFF);
} }

View File

@ -267,7 +267,6 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
e.printStackTrace(); e.printStackTrace();
} }
this.invulnerableTime = 0; this.invulnerableTime = 0;
NMS.setStepHeight(getBukkitEntity(), 1); // the default (0) breaks step climbing
setSkinFlags((byte) 0xFF); setSkinFlags((byte) 0xFF);
} }

View File

@ -242,7 +242,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
controllerMove = new PlayerControllerMove(this); controllerMove = new PlayerControllerMove(this);
navigation = new PlayerNavigation(this, world); navigation = new PlayerNavigation(this, world);
invulnerableTicks = 0; invulnerableTicks = 0;
NMS.setStepHeight(getBukkitEntity(), 1); // the default (0) breaks step climbing setSkinFlags((byte) 0xFF);
} }
public boolean isNavigating() { public boolean isNavigating() {