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.Location;
import org.bukkit.attribute.Attribute;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
@ -46,6 +47,7 @@ import net.citizensnpcs.api.util.DataKey;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.npc.ai.CitizensNavigator;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.AttributeTrait;
import net.citizensnpcs.trait.CurrentLocation;
import net.citizensnpcs.trait.Gravity;
import net.citizensnpcs.trait.HologramTrait;
@ -390,7 +392,9 @@ public class CitizensNPC extends AbstractNPC {
LivingEntity entity = (LivingEntity) getEntity();
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);
}
if (type == EntityType.PLAYER) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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