mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-23 15:51:30 +01:00
Avoid setting NPC.COLLIDABLE_METADATA on Player NPCs
This commit is contained in:
parent
b5a2c30476
commit
7683516d62
@ -1197,6 +1197,7 @@ public class NPCCommands {
|
||||
key = NPC.Metadata.valueOf(key.toUpperCase()).getKey();
|
||||
} catch (IllegalArgumentException e) {
|
||||
}
|
||||
|
||||
if (command.equals("set")) {
|
||||
if (args.argsLength() != 4)
|
||||
throw new CommandException();
|
||||
|
@ -275,6 +275,7 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
|
||||
|
||||
vel = vel.setX(dXcos * speed * speedMod).setZ(dXsin * speed * speedMod);
|
||||
}
|
||||
|
||||
vel = vel.add(new Vector(
|
||||
passenger.getVelocity().getX() * speedMod * Setting.CONTROLLABLE_GROUND_DIRECTION_MODIFIER.asDouble(),
|
||||
0D,
|
||||
@ -317,9 +318,8 @@ public class Controllable extends Trait implements Toggleable, CommandConfigurab
|
||||
boolean onGround = NMS.isOnGround(npc.getEntity());
|
||||
float speedMod = npc.getNavigator().getDefaultParameters()
|
||||
.modifiedSpeed((onGround ? GROUND_SPEED : AIR_SPEED));
|
||||
if (!Util.isHorse(npc.getEntity().getType()) || npc.getEntity().getType().name().equals("LLAMA")
|
||||
|| npc.getEntity().getType().name().equals("TRADER_LLAMA")) {
|
||||
// just use minecraft horse physics
|
||||
if (!Util.isHorse(npc.getEntity().getType())) {
|
||||
// use minecraft horse physics
|
||||
speed = updateHorizontalSpeed(npc.getEntity(), rider, speed, speedMod);
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class Util {
|
||||
return new Vector(x, y, z);
|
||||
}
|
||||
boolean allowed = !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)
|
||||
|| (npc.data().has(NPC.COLLIDABLE_METADATA) && npc.data().get(NPC.COLLIDABLE_METADATA, true));
|
||||
|| (npc.data().has(NPC.COLLIDABLE_METADATA) && npc.data().<Boolean> get(NPC.COLLIDABLE_METADATA));
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
return allowed ? new Vector(x, y, z) : null;
|
||||
}
|
||||
|
@ -266,7 +266,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return npc == null ? super.isCollidable() : npc.data().get(NPC.COLLIDABLE_METADATA, true);
|
||||
return npc == null ? super.isCollidable()
|
||||
: npc.data().has(NPC.COLLIDABLE_METADATA) ? npc.data().<Boolean> get(NPC.COLLIDABLE_METADATA)
|
||||
: !npc.isProtected();
|
||||
}
|
||||
|
||||
public boolean isNavigating() {
|
||||
|
@ -293,7 +293,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return npc == null ? super.isCollidable() : npc.data().get(NPC.COLLIDABLE_METADATA, true);
|
||||
return npc == null ? super.isCollidable()
|
||||
: npc.data().has(NPC.COLLIDABLE_METADATA) ? npc.data().<Boolean> get(NPC.COLLIDABLE_METADATA)
|
||||
: !npc.isProtected();
|
||||
}
|
||||
|
||||
public boolean isNavigating() {
|
||||
|
@ -320,7 +320,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return npc == null ? super.isCollidable() : npc.data().get(NPC.COLLIDABLE_METADATA, true);
|
||||
return npc == null ? super.isCollidable()
|
||||
: npc.data().has(NPC.COLLIDABLE_METADATA) ? npc.data().<Boolean> get(NPC.COLLIDABLE_METADATA)
|
||||
: !npc.isProtected();
|
||||
}
|
||||
|
||||
public boolean isNavigating() {
|
||||
|
@ -303,7 +303,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return npc == null ? super.isCollidable() : npc.data().get(NPC.COLLIDABLE_METADATA, true);
|
||||
return npc == null ? super.isCollidable()
|
||||
: npc.data().has(NPC.COLLIDABLE_METADATA) ? npc.data().<Boolean> get(NPC.COLLIDABLE_METADATA)
|
||||
: !npc.isProtected();
|
||||
}
|
||||
|
||||
public boolean isNavigating() {
|
||||
|
@ -299,7 +299,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return npc == null ? super.isCollidable() : npc.data().get(NPC.COLLIDABLE_METADATA, true);
|
||||
return npc == null ? super.isCollidable()
|
||||
: npc.data().has(NPC.COLLIDABLE_METADATA) ? npc.data().<Boolean> get(NPC.COLLIDABLE_METADATA)
|
||||
: !npc.isProtected();
|
||||
}
|
||||
|
||||
public boolean isNavigating() {
|
||||
|
@ -300,7 +300,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return npc == null ? super.isCollidable() : npc.data().get(NPC.COLLIDABLE_METADATA, true);
|
||||
return npc == null ? super.isCollidable()
|
||||
: npc.data().has(NPC.COLLIDABLE_METADATA) ? npc.data().<Boolean> get(NPC.COLLIDABLE_METADATA)
|
||||
: !npc.isProtected();
|
||||
}
|
||||
|
||||
public boolean isNavigating() {
|
||||
|
@ -330,7 +330,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return npc == null ? super.isCollidable() : npc.data().get(NPC.COLLIDABLE_METADATA, true);
|
||||
return npc == null ? super.isCollidable()
|
||||
: npc.data().has(NPC.COLLIDABLE_METADATA) ? npc.data().<Boolean> get(NPC.COLLIDABLE_METADATA)
|
||||
: !npc.isProtected();
|
||||
}
|
||||
|
||||
public boolean isNavigating() {
|
||||
|
@ -371,7 +371,9 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||
|
||||
@Override
|
||||
public boolean isPushable() {
|
||||
return npc == null ? super.isPushable() : npc.data().get(NPC.COLLIDABLE_METADATA, true);
|
||||
return npc == null ? super.isPushable()
|
||||
: npc.data().has(NPC.COLLIDABLE_METADATA) ? npc.data().<Boolean> get(NPC.COLLIDABLE_METADATA)
|
||||
: !npc.isProtected();
|
||||
}
|
||||
|
||||
private void moveOnCurrentHeading() {
|
||||
|
@ -375,7 +375,9 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||
|
||||
@Override
|
||||
public boolean isPushable() {
|
||||
return npc == null ? super.isPushable() : npc.data().get(NPC.COLLIDABLE_METADATA, true);
|
||||
return npc == null ? super.isPushable()
|
||||
: npc.data().has(NPC.COLLIDABLE_METADATA) ? npc.data().<Boolean> get(NPC.COLLIDABLE_METADATA)
|
||||
: !npc.isProtected();
|
||||
}
|
||||
|
||||
private void moveOnCurrentHeading() {
|
||||
|
@ -54,6 +54,13 @@ public class RavagerController extends MobEntityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeControlledByRider() {
|
||||
return (npc == null || npc.data().<Boolean> get(NPC.Metadata.USE_MINECRAFT_AI, false))
|
||||
? super.canBeControlledByRider()
|
||||
: false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canRide(Entity entity) {
|
||||
if (npc != null && (entity instanceof Boat || entity instanceof AbstractMinecart)) {
|
||||
|
@ -101,7 +101,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
|
||||
@Override
|
||||
public boolean ae() {
|
||||
return npc == null ? super.ae() : npc.data().get(NPC.COLLIDABLE_METADATA, true);
|
||||
return npc == null ? super.ae()
|
||||
: npc.data().has(NPC.COLLIDABLE_METADATA) ? npc.data().<Boolean> get(NPC.COLLIDABLE_METADATA)
|
||||
: !npc.isProtected();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user