Skip to content

Commit

Permalink
Backport fixes to 1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Jul 1, 2019
1 parent 79ab0b4 commit 7e58db8
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
import net.citizensnpcs.nms.v1_12_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.trait.Controllable;
import net.citizensnpcs.trait.HorseModifiers;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_12_R1.BlockPosition;
import net.minecraft.server.v1_12_R1.DamageSource;
import net.minecraft.server.v1_12_R1.EntityHorse;
import net.minecraft.server.v1_12_R1.GenericAttributes;
import net.minecraft.server.v1_12_R1.IBlockData;
import net.minecraft.server.v1_12_R1.NBTTagCompound;
import net.minecraft.server.v1_12_R1.SoundEffect;
Expand All @@ -42,7 +44,9 @@ public void spawn(Location at, NPC npc) {
}

public static class EntityHorseNPC extends EntityHorse implements NPCHolder {
private double baseMovementSpeed;
private final CitizensNPC npc;
private boolean riding;

public EntityHorseNPC(World world) {
this(world, null);
Expand All @@ -54,6 +58,7 @@ public EntityHorseNPC(World world, NPC npc) {
if (npc != null) {
NMSImpl.clearGoals(goalSelector, targetSelector);
((Horse) getBukkitEntity()).setDomestication(((Horse) getBukkitEntity()).getMaxDomestication());
baseMovementSpeed = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue();
}
}

Expand Down Expand Up @@ -99,6 +104,14 @@ public void collide(net.minecraft.server.v1_12_R1.Entity entity) {
}
}

@Override
public boolean cV() {
if (npc != null && riding) {
return true;
}
return super.cV();
}

@Override
protected SoundEffect d(DamageSource damagesource) {
return NMSImpl.getSoundEffect(npc, super.d(damagesource), NPC.HURT_SOUND_METADATA);
Expand Down Expand Up @@ -193,6 +206,16 @@ protected void L() {
public void M() {
super.M();
if (npc != null) {
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
riding = getBukkitEntity().getPassengers().size() > 0;
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
} else {
riding = false;
}
if (riding) {
c(4, true); // datawatcher method
}
NMS.setStepHeight(getBukkitEntity(), 1);
npc.update();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
import net.citizensnpcs.nms.v1_12_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.trait.Controllable;
import net.citizensnpcs.trait.HorseModifiers;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_12_R1.BlockPosition;
import net.minecraft.server.v1_12_R1.DamageSource;
import net.minecraft.server.v1_12_R1.EntityHorseDonkey;
import net.minecraft.server.v1_12_R1.GenericAttributes;
import net.minecraft.server.v1_12_R1.IBlockData;
import net.minecraft.server.v1_12_R1.NBTTagCompound;
import net.minecraft.server.v1_12_R1.SoundEffect;
Expand All @@ -42,7 +44,9 @@ public void spawn(Location at, NPC npc) {
}

public static class EntityHorseDonkeyNPC extends EntityHorseDonkey implements NPCHolder {
private double baseMovementSpeed;
private final CitizensNPC npc;
private boolean riding;

public EntityHorseDonkeyNPC(World world) {
this(world, null);
Expand All @@ -54,6 +58,7 @@ public EntityHorseDonkeyNPC(World world, NPC npc) {
if (npc != null) {
NMSImpl.clearGoals(goalSelector, targetSelector);
((Donkey) getBukkitEntity()).setDomestication(((Donkey) getBukkitEntity()).getMaxDomestication());
baseMovementSpeed = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue();
}
}

Expand Down Expand Up @@ -99,6 +104,14 @@ public void collide(net.minecraft.server.v1_12_R1.Entity entity) {
}
}

@Override
public boolean cV() {
if (npc != null && riding) {
return true;
}
return super.cV();
}

@Override
protected SoundEffect d(DamageSource damagesource) {
return NMSImpl.getSoundEffect(npc, super.d(damagesource), NPC.HURT_SOUND_METADATA);
Expand Down Expand Up @@ -193,6 +206,16 @@ protected void L() {
public void M() {
super.M();
if (npc != null) {
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
riding = getBukkitEntity().getPassengers().size() > 0;
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
} else {
riding = false;
}
if (riding) {
c(4, true); // datawatcher method
}
NMS.setStepHeight(getBukkitEntity(), 1);
npc.update();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
import net.citizensnpcs.nms.v1_12_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.trait.Controllable;
import net.citizensnpcs.trait.HorseModifiers;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_12_R1.BlockPosition;
import net.minecraft.server.v1_12_R1.DamageSource;
import net.minecraft.server.v1_12_R1.EntityHorseMule;
import net.minecraft.server.v1_12_R1.GenericAttributes;
import net.minecraft.server.v1_12_R1.IBlockData;
import net.minecraft.server.v1_12_R1.NBTTagCompound;
import net.minecraft.server.v1_12_R1.SoundEffect;
Expand All @@ -42,7 +44,9 @@ public void spawn(Location at, NPC npc) {
}

public static class EntityHorseMuleNPC extends EntityHorseMule implements NPCHolder {
private double baseMovementSpeed;
private final CitizensNPC npc;
private boolean riding;

public EntityHorseMuleNPC(World world) {
this(world, null);
Expand All @@ -54,6 +58,7 @@ public EntityHorseMuleNPC(World world, NPC npc) {
if (npc != null) {
NMSImpl.clearGoals(goalSelector, targetSelector);
((Mule) getBukkitEntity()).setDomestication(((Mule) getBukkitEntity()).getMaxDomestication());
baseMovementSpeed = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue();
}
}

Expand Down Expand Up @@ -99,6 +104,14 @@ public void collide(net.minecraft.server.v1_12_R1.Entity entity) {
}
}

@Override
public boolean cV() {
if (npc != null && riding) {
return true;
}
return super.cV();
}

@Override
protected SoundEffect d(DamageSource damagesource) {
return NMSImpl.getSoundEffect(npc, super.d(damagesource), NPC.HURT_SOUND_METADATA);
Expand Down Expand Up @@ -193,6 +206,16 @@ protected void L() {
public void M() {
super.M();
if (npc != null) {
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
riding = getBukkitEntity().getPassengers().size() > 0;
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
} else {
riding = false;
}
if (riding) {
c(4, true); // datawatcher method
}
NMS.setStepHeight(getBukkitEntity(), 1);
npc.update();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
import net.citizensnpcs.nms.v1_12_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.trait.Controllable;
import net.citizensnpcs.trait.HorseModifiers;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_12_R1.BlockPosition;
import net.minecraft.server.v1_12_R1.DamageSource;
import net.minecraft.server.v1_12_R1.EntityHorseSkeleton;
import net.minecraft.server.v1_12_R1.GenericAttributes;
import net.minecraft.server.v1_12_R1.IBlockData;
import net.minecraft.server.v1_12_R1.NBTTagCompound;
import net.minecraft.server.v1_12_R1.SoundEffect;
Expand All @@ -42,8 +44,12 @@ public void spawn(Location at, NPC npc) {
}

public static class EntityHorseSkeletonNPC extends EntityHorseSkeleton implements NPCHolder {
private double baseMovementSpeed;

private final CitizensNPC npc;

private boolean riding;

public EntityHorseSkeletonNPC(World world) {
this(world, null);
}
Expand All @@ -55,6 +61,7 @@ public EntityHorseSkeletonNPC(World world, NPC npc) {
NMSImpl.clearGoals(goalSelector, targetSelector);
((SkeletonHorse) getBukkitEntity())
.setDomestication(((SkeletonHorse) getBukkitEntity()).getMaxDomestication());
baseMovementSpeed = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue();
}
}

Expand Down Expand Up @@ -100,6 +107,14 @@ public void collide(net.minecraft.server.v1_12_R1.Entity entity) {
}
}

@Override
public boolean cV() {
if (npc != null && riding) {
return true;
}
return super.cV();
}

@Override
protected SoundEffect d(DamageSource damagesource) {
return NMSImpl.getSoundEffect(npc, super.d(damagesource), NPC.HURT_SOUND_METADATA);
Expand Down Expand Up @@ -194,6 +209,16 @@ protected void L() {
public void M() {
super.M();
if (npc != null) {
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
riding = getBukkitEntity().getPassengers().size() > 0;
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
} else {
riding = false;
}
if (riding) {
c(4, true); // datawatcher method
}
NMS.setStepHeight(getBukkitEntity(), 1);
npc.update();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
import net.citizensnpcs.nms.v1_12_R1.util.NMSImpl;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.trait.Controllable;
import net.citizensnpcs.trait.HorseModifiers;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_12_R1.BlockPosition;
import net.minecraft.server.v1_12_R1.DamageSource;
import net.minecraft.server.v1_12_R1.EntityHorseZombie;
import net.minecraft.server.v1_12_R1.GenericAttributes;
import net.minecraft.server.v1_12_R1.IBlockData;
import net.minecraft.server.v1_12_R1.NBTTagCompound;
import net.minecraft.server.v1_12_R1.SoundEffect;
Expand All @@ -42,8 +44,12 @@ public void spawn(Location at, NPC npc) {
}

public static class EntityHorseZombieNPC extends EntityHorseZombie implements NPCHolder {
private double baseMovementSpeed;

private final CitizensNPC npc;

private boolean riding;

public EntityHorseZombieNPC(World world) {
this(world, null);
}
Expand All @@ -55,6 +61,7 @@ public EntityHorseZombieNPC(World world, NPC npc) {
NMSImpl.clearGoals(goalSelector, targetSelector);
((ZombieHorse) getBukkitEntity())
.setDomestication(((ZombieHorse) getBukkitEntity()).getMaxDomestication());
baseMovementSpeed = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue();
}
}

Expand Down Expand Up @@ -100,6 +107,14 @@ public void collide(net.minecraft.server.v1_12_R1.Entity entity) {
}
}

@Override
public boolean cV() {
if (npc != null && riding) {
return true;
}
return super.cV();
}

@Override
protected SoundEffect d(DamageSource damagesource) {
return NMSImpl.getSoundEffect(npc, super.d(damagesource), NPC.HURT_SOUND_METADATA);
Expand Down Expand Up @@ -194,6 +209,16 @@ protected void L() {
public void M() {
super.M();
if (npc != null) {
if (npc.hasTrait(Controllable.class) && npc.getTrait(Controllable.class).isEnabled()) {
riding = getBukkitEntity().getPassengers().size() > 0;
getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
.setValue(baseMovementSpeed * npc.getNavigator().getDefaultParameters().speedModifier());
} else {
riding = false;
}
if (riding) {
c(4, true); // datawatcher method
}
NMS.setStepHeight(getBukkitEntity(), 1);
npc.update();
}
Expand Down

0 comments on commit 7e58db8

Please sign in to comment.