Skip to content

Commit

Permalink
Reduce default movement speed on 1.15 villagers
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Feb 14, 2020
1 parent ade25b2 commit 8d6b56d
Showing 1 changed file with 24 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import net.minecraft.server.v1_15_R1.EntityTypes;
import net.minecraft.server.v1_15_R1.EntityVillager;
import net.minecraft.server.v1_15_R1.EnumHand;
import net.minecraft.server.v1_15_R1.GenericAttributes;
import net.minecraft.server.v1_15_R1.IBlockData;
import net.minecraft.server.v1_15_R1.MerchantRecipe;
import net.minecraft.server.v1_15_R1.NBTTagCompound;
Expand Down Expand Up @@ -60,6 +61,7 @@ public EntityVillagerNPC(EntityTypes<? extends EntityVillager> types, World worl
this.npc = (CitizensNPC) npc;
if (npc != null) {
NMSImpl.clearGoals(goalSelector, targetSelector);
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.3);
}
}

Expand Down Expand Up @@ -154,28 +156,6 @@ public void enderTeleportTo(double d0, double d1, double d2) {
}
}

@Override
public void h(double x, double y, double z) {
if (npc == null) {
super.h(x, y, z);
return;
}
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
super.h(x, y, z);
return;
}
Vector vector = new Vector(x, y, z);
NPCPushEvent event = Util.callPushEvent(npc, vector);
if (!event.isCancelled()) {
vector = event.getCollisionVector();
super.h(vector.getX(), vector.getY(), vector.getZ());
}
// when another entity collides, this method is called to push the
// NPC so we prevent it from doing anything if the event is
// cancelled.
}

@Override
public CraftEntity getBukkitEntity() {
if (npc != null && !(super.getBukkitEntity() instanceof NPCHolder)) {
Expand Down Expand Up @@ -204,6 +184,28 @@ protected SoundEffect getSoundHurt(DamageSource damagesource) {
return NMSImpl.getSoundEffect(npc, super.getSoundHurt(damagesource), NPC.HURT_SOUND_METADATA);
}

@Override
public void h(double x, double y, double z) {
if (npc == null) {
super.h(x, y, z);
return;
}
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
super.h(x, y, z);
return;
}
Vector vector = new Vector(x, y, z);
NPCPushEvent event = Util.callPushEvent(npc, vector);
if (!event.isCancelled()) {
vector = event.getCollisionVector();
super.h(vector.getX(), vector.getY(), vector.getZ());
}
// when another entity collides, this method is called to push the
// NPC so we prevent it from doing anything if the event is
// cancelled.
}

public boolean isBlockingTrades() {
return blockTrades;
}
Expand Down

0 comments on commit 8d6b56d

Please sign in to comment.