mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-28 21:55:29 +01:00
Extend fixes to other horse types
This commit is contained in:
parent
7cb7b36507
commit
79ab0b4cba
@ -14,12 +14,14 @@ import net.citizensnpcs.api.npc.NPC;
|
|||||||
import net.citizensnpcs.nms.v1_13_R2.util.NMSImpl;
|
import net.citizensnpcs.nms.v1_13_R2.util.NMSImpl;
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
|
import net.citizensnpcs.trait.Controllable;
|
||||||
import net.citizensnpcs.trait.HorseModifiers;
|
import net.citizensnpcs.trait.HorseModifiers;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
import net.minecraft.server.v1_13_R2.BlockPosition;
|
import net.minecraft.server.v1_13_R2.BlockPosition;
|
||||||
import net.minecraft.server.v1_13_R2.DamageSource;
|
import net.minecraft.server.v1_13_R2.DamageSource;
|
||||||
import net.minecraft.server.v1_13_R2.EntityHorseDonkey;
|
import net.minecraft.server.v1_13_R2.EntityHorseDonkey;
|
||||||
|
import net.minecraft.server.v1_13_R2.GenericAttributes;
|
||||||
import net.minecraft.server.v1_13_R2.IBlockData;
|
import net.minecraft.server.v1_13_R2.IBlockData;
|
||||||
import net.minecraft.server.v1_13_R2.NBTTagCompound;
|
import net.minecraft.server.v1_13_R2.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_13_R2.SoundEffect;
|
import net.minecraft.server.v1_13_R2.SoundEffect;
|
||||||
@ -42,8 +44,12 @@ public class HorseDonkeyController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class EntityHorseDonkeyNPC extends EntityHorseDonkey implements NPCHolder {
|
public static class EntityHorseDonkeyNPC extends EntityHorseDonkey implements NPCHolder {
|
||||||
|
private double baseMovementSpeed;
|
||||||
|
|
||||||
private final CitizensNPC npc;
|
private final CitizensNPC npc;
|
||||||
|
|
||||||
|
private boolean riding;
|
||||||
|
|
||||||
public EntityHorseDonkeyNPC(World world) {
|
public EntityHorseDonkeyNPC(World world) {
|
||||||
this(world, null);
|
this(world, null);
|
||||||
}
|
}
|
||||||
@ -54,6 +60,7 @@ public class HorseDonkeyController extends MobEntityController {
|
|||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||||
((Donkey) getBukkitEntity()).setDomestication(((Donkey) getBukkitEntity()).getMaxDomestication());
|
((Donkey) getBukkitEntity()).setDomestication(((Donkey) getBukkitEntity()).getMaxDomestication());
|
||||||
|
baseMovementSpeed = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,8 +92,18 @@ public class HorseDonkeyController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SoundEffect cs() {
|
public boolean bT() {
|
||||||
return NMSImpl.getSoundEffect(npc, super.cs(), NPC.DEATH_SOUND_METADATA);
|
if (npc != null && riding) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.bT();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void c(float f, float f1) {
|
||||||
|
if (npc == null || !npc.isFlyable()) {
|
||||||
|
super.c(f, f1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -99,6 +116,11 @@ public class HorseDonkeyController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SoundEffect cs() {
|
||||||
|
return NMSImpl.getSoundEffect(npc, super.cs(), NPC.DEATH_SOUND_METADATA);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SoundEffect d(DamageSource damagesource) {
|
protected SoundEffect d(DamageSource damagesource) {
|
||||||
return NMSImpl.getSoundEffect(npc, super.d(damagesource), NPC.HURT_SOUND_METADATA);
|
return NMSImpl.getSoundEffect(npc, super.d(damagesource), NPC.HURT_SOUND_METADATA);
|
||||||
@ -110,10 +132,8 @@ public class HorseDonkeyController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void c(float f, float f1) {
|
protected SoundEffect D() {
|
||||||
if (npc == null || !npc.isFlyable()) {
|
return NMSImpl.getSoundEffect(npc, super.D(), NPC.AMBIENT_SOUND_METADATA);
|
||||||
super.c(f, f1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -151,11 +171,6 @@ public class HorseDonkeyController extends MobEntityController {
|
|||||||
// cancelled.
|
// cancelled.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected SoundEffect D() {
|
|
||||||
return NMSImpl.getSoundEffect(npc, super.D(), NPC.AMBIENT_SOUND_METADATA);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftEntity getBukkitEntity() {
|
public CraftEntity getBukkitEntity() {
|
||||||
if (npc != null && !(bukkitEntity instanceof NPCHolder)) {
|
if (npc != null && !(bukkitEntity instanceof NPCHolder)) {
|
||||||
@ -169,6 +184,13 @@ public class HorseDonkeyController extends MobEntityController {
|
|||||||
return npc;
|
return npc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void I() {
|
||||||
|
if (npc == null) {
|
||||||
|
super.I();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLeashed() {
|
public boolean isLeashed() {
|
||||||
if (npc == null)
|
if (npc == null)
|
||||||
@ -182,17 +204,20 @@ public class HorseDonkeyController extends MobEntityController {
|
|||||||
return false; // shouldLeash
|
return false; // shouldLeash
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void I() {
|
|
||||||
if (npc == null) {
|
|
||||||
super.I();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mobTick() {
|
public void mobTick() {
|
||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
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) {
|
||||||
|
d(4, true); // datawatcher method
|
||||||
|
}
|
||||||
NMS.setStepHeight(getBukkitEntity(), 1);
|
NMS.setStepHeight(getBukkitEntity(), 1);
|
||||||
npc.update();
|
npc.update();
|
||||||
}
|
}
|
||||||
|
@ -14,12 +14,14 @@ import net.citizensnpcs.api.npc.NPC;
|
|||||||
import net.citizensnpcs.nms.v1_13_R2.util.NMSImpl;
|
import net.citizensnpcs.nms.v1_13_R2.util.NMSImpl;
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
|
import net.citizensnpcs.trait.Controllable;
|
||||||
import net.citizensnpcs.trait.HorseModifiers;
|
import net.citizensnpcs.trait.HorseModifiers;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
import net.minecraft.server.v1_13_R2.BlockPosition;
|
import net.minecraft.server.v1_13_R2.BlockPosition;
|
||||||
import net.minecraft.server.v1_13_R2.DamageSource;
|
import net.minecraft.server.v1_13_R2.DamageSource;
|
||||||
import net.minecraft.server.v1_13_R2.EntityHorseMule;
|
import net.minecraft.server.v1_13_R2.EntityHorseMule;
|
||||||
|
import net.minecraft.server.v1_13_R2.GenericAttributes;
|
||||||
import net.minecraft.server.v1_13_R2.IBlockData;
|
import net.minecraft.server.v1_13_R2.IBlockData;
|
||||||
import net.minecraft.server.v1_13_R2.NBTTagCompound;
|
import net.minecraft.server.v1_13_R2.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_13_R2.SoundEffect;
|
import net.minecraft.server.v1_13_R2.SoundEffect;
|
||||||
@ -42,8 +44,12 @@ public class HorseMuleController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class EntityHorseMuleNPC extends EntityHorseMule implements NPCHolder {
|
public static class EntityHorseMuleNPC extends EntityHorseMule implements NPCHolder {
|
||||||
|
private double baseMovementSpeed;
|
||||||
|
|
||||||
private final CitizensNPC npc;
|
private final CitizensNPC npc;
|
||||||
|
|
||||||
|
private boolean riding;
|
||||||
|
|
||||||
public EntityHorseMuleNPC(World world) {
|
public EntityHorseMuleNPC(World world) {
|
||||||
this(world, null);
|
this(world, null);
|
||||||
}
|
}
|
||||||
@ -54,6 +60,7 @@ public class HorseMuleController extends MobEntityController {
|
|||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||||
((Mule) getBukkitEntity()).setDomestication(((Mule) getBukkitEntity()).getMaxDomestication());
|
((Mule) getBukkitEntity()).setDomestication(((Mule) getBukkitEntity()).getMaxDomestication());
|
||||||
|
baseMovementSpeed = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,8 +92,18 @@ public class HorseMuleController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SoundEffect cs() {
|
public boolean bT() {
|
||||||
return NMSImpl.getSoundEffect(npc, super.cs(), NPC.DEATH_SOUND_METADATA);
|
if (npc != null && riding) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.bT();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void c(float f, float f1) {
|
||||||
|
if (npc == null || !npc.isFlyable()) {
|
||||||
|
super.c(f, f1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -99,6 +116,11 @@ public class HorseMuleController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SoundEffect cs() {
|
||||||
|
return NMSImpl.getSoundEffect(npc, super.cs(), NPC.DEATH_SOUND_METADATA);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SoundEffect d(DamageSource damagesource) {
|
protected SoundEffect d(DamageSource damagesource) {
|
||||||
return NMSImpl.getSoundEffect(npc, super.d(damagesource), NPC.HURT_SOUND_METADATA);
|
return NMSImpl.getSoundEffect(npc, super.d(damagesource), NPC.HURT_SOUND_METADATA);
|
||||||
@ -110,10 +132,8 @@ public class HorseMuleController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void c(float f, float f1) {
|
protected SoundEffect D() {
|
||||||
if (npc == null || !npc.isFlyable()) {
|
return NMSImpl.getSoundEffect(npc, super.D(), NPC.AMBIENT_SOUND_METADATA);
|
||||||
super.c(f, f1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -151,11 +171,6 @@ public class HorseMuleController extends MobEntityController {
|
|||||||
// cancelled.
|
// cancelled.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected SoundEffect D() {
|
|
||||||
return NMSImpl.getSoundEffect(npc, super.D(), NPC.AMBIENT_SOUND_METADATA);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftEntity getBukkitEntity() {
|
public CraftEntity getBukkitEntity() {
|
||||||
if (npc != null && !(bukkitEntity instanceof NPCHolder)) {
|
if (npc != null && !(bukkitEntity instanceof NPCHolder)) {
|
||||||
@ -169,6 +184,13 @@ public class HorseMuleController extends MobEntityController {
|
|||||||
return npc;
|
return npc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void I() {
|
||||||
|
if (npc == null) {
|
||||||
|
super.I();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLeashed() {
|
public boolean isLeashed() {
|
||||||
if (npc == null)
|
if (npc == null)
|
||||||
@ -182,17 +204,20 @@ public class HorseMuleController extends MobEntityController {
|
|||||||
return false; // shouldLeash
|
return false; // shouldLeash
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void I() {
|
|
||||||
if (npc == null) {
|
|
||||||
super.I();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mobTick() {
|
public void mobTick() {
|
||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
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) {
|
||||||
|
d(4, true); // datawatcher method
|
||||||
|
}
|
||||||
NMS.setStepHeight(getBukkitEntity(), 1);
|
NMS.setStepHeight(getBukkitEntity(), 1);
|
||||||
npc.update();
|
npc.update();
|
||||||
}
|
}
|
||||||
|
@ -14,12 +14,14 @@ import net.citizensnpcs.api.npc.NPC;
|
|||||||
import net.citizensnpcs.nms.v1_13_R2.util.NMSImpl;
|
import net.citizensnpcs.nms.v1_13_R2.util.NMSImpl;
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
|
import net.citizensnpcs.trait.Controllable;
|
||||||
import net.citizensnpcs.trait.HorseModifiers;
|
import net.citizensnpcs.trait.HorseModifiers;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
import net.minecraft.server.v1_13_R2.BlockPosition;
|
import net.minecraft.server.v1_13_R2.BlockPosition;
|
||||||
import net.minecraft.server.v1_13_R2.DamageSource;
|
import net.minecraft.server.v1_13_R2.DamageSource;
|
||||||
import net.minecraft.server.v1_13_R2.EntityHorseSkeleton;
|
import net.minecraft.server.v1_13_R2.EntityHorseSkeleton;
|
||||||
|
import net.minecraft.server.v1_13_R2.GenericAttributes;
|
||||||
import net.minecraft.server.v1_13_R2.IBlockData;
|
import net.minecraft.server.v1_13_R2.IBlockData;
|
||||||
import net.minecraft.server.v1_13_R2.NBTTagCompound;
|
import net.minecraft.server.v1_13_R2.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_13_R2.SoundEffect;
|
import net.minecraft.server.v1_13_R2.SoundEffect;
|
||||||
@ -42,8 +44,12 @@ public class HorseSkeletonController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class EntityHorseSkeletonNPC extends EntityHorseSkeleton implements NPCHolder {
|
public static class EntityHorseSkeletonNPC extends EntityHorseSkeleton implements NPCHolder {
|
||||||
|
private double baseMovementSpeed;
|
||||||
|
|
||||||
private final CitizensNPC npc;
|
private final CitizensNPC npc;
|
||||||
|
|
||||||
|
private boolean riding;
|
||||||
|
|
||||||
public EntityHorseSkeletonNPC(World world) {
|
public EntityHorseSkeletonNPC(World world) {
|
||||||
this(world, null);
|
this(world, null);
|
||||||
}
|
}
|
||||||
@ -55,6 +61,7 @@ public class HorseSkeletonController extends MobEntityController {
|
|||||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||||
((SkeletonHorse) getBukkitEntity())
|
((SkeletonHorse) getBukkitEntity())
|
||||||
.setDomestication(((SkeletonHorse) getBukkitEntity()).getMaxDomestication());
|
.setDomestication(((SkeletonHorse) getBukkitEntity()).getMaxDomestication());
|
||||||
|
baseMovementSpeed = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,8 +93,18 @@ public class HorseSkeletonController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SoundEffect cs() {
|
public boolean bT() {
|
||||||
return NMSImpl.getSoundEffect(npc, super.cs(), NPC.DEATH_SOUND_METADATA);
|
if (npc != null && riding) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.bT();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void c(float f, float f1) {
|
||||||
|
if (npc == null || !npc.isFlyable()) {
|
||||||
|
super.c(f, f1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -100,6 +117,11 @@ public class HorseSkeletonController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SoundEffect cs() {
|
||||||
|
return NMSImpl.getSoundEffect(npc, super.cs(), NPC.DEATH_SOUND_METADATA);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SoundEffect d(DamageSource damagesource) {
|
protected SoundEffect d(DamageSource damagesource) {
|
||||||
return NMSImpl.getSoundEffect(npc, super.d(damagesource), NPC.HURT_SOUND_METADATA);
|
return NMSImpl.getSoundEffect(npc, super.d(damagesource), NPC.HURT_SOUND_METADATA);
|
||||||
@ -111,10 +133,8 @@ public class HorseSkeletonController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void c(float f, float f1) {
|
protected SoundEffect D() {
|
||||||
if (npc == null || !npc.isFlyable()) {
|
return NMSImpl.getSoundEffect(npc, super.D(), NPC.AMBIENT_SOUND_METADATA);
|
||||||
super.c(f, f1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -152,11 +172,6 @@ public class HorseSkeletonController extends MobEntityController {
|
|||||||
// cancelled.
|
// cancelled.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected SoundEffect D() {
|
|
||||||
return NMSImpl.getSoundEffect(npc, super.D(), NPC.AMBIENT_SOUND_METADATA);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftEntity getBukkitEntity() {
|
public CraftEntity getBukkitEntity() {
|
||||||
if (npc != null && !(bukkitEntity instanceof NPCHolder)) {
|
if (npc != null && !(bukkitEntity instanceof NPCHolder)) {
|
||||||
@ -170,6 +185,13 @@ public class HorseSkeletonController extends MobEntityController {
|
|||||||
return npc;
|
return npc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void I() {
|
||||||
|
if (npc == null) {
|
||||||
|
super.I();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLeashed() {
|
public boolean isLeashed() {
|
||||||
if (npc == null)
|
if (npc == null)
|
||||||
@ -183,17 +205,20 @@ public class HorseSkeletonController extends MobEntityController {
|
|||||||
return false; // shouldLeash
|
return false; // shouldLeash
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void I() {
|
|
||||||
if (npc == null) {
|
|
||||||
super.I();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mobTick() {
|
public void mobTick() {
|
||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
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) {
|
||||||
|
d(4, true); // datawatcher method
|
||||||
|
}
|
||||||
NMS.setStepHeight(getBukkitEntity(), 1);
|
NMS.setStepHeight(getBukkitEntity(), 1);
|
||||||
npc.update();
|
npc.update();
|
||||||
}
|
}
|
||||||
|
@ -14,12 +14,14 @@ import net.citizensnpcs.api.npc.NPC;
|
|||||||
import net.citizensnpcs.nms.v1_13_R2.util.NMSImpl;
|
import net.citizensnpcs.nms.v1_13_R2.util.NMSImpl;
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
|
import net.citizensnpcs.trait.Controllable;
|
||||||
import net.citizensnpcs.trait.HorseModifiers;
|
import net.citizensnpcs.trait.HorseModifiers;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
import net.minecraft.server.v1_13_R2.BlockPosition;
|
import net.minecraft.server.v1_13_R2.BlockPosition;
|
||||||
import net.minecraft.server.v1_13_R2.DamageSource;
|
import net.minecraft.server.v1_13_R2.DamageSource;
|
||||||
import net.minecraft.server.v1_13_R2.EntityHorseZombie;
|
import net.minecraft.server.v1_13_R2.EntityHorseZombie;
|
||||||
|
import net.minecraft.server.v1_13_R2.GenericAttributes;
|
||||||
import net.minecraft.server.v1_13_R2.IBlockData;
|
import net.minecraft.server.v1_13_R2.IBlockData;
|
||||||
import net.minecraft.server.v1_13_R2.NBTTagCompound;
|
import net.minecraft.server.v1_13_R2.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_13_R2.SoundEffect;
|
import net.minecraft.server.v1_13_R2.SoundEffect;
|
||||||
@ -42,8 +44,12 @@ public class HorseZombieController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class EntityHorseZombieNPC extends EntityHorseZombie implements NPCHolder {
|
public static class EntityHorseZombieNPC extends EntityHorseZombie implements NPCHolder {
|
||||||
|
private double baseMovementSpeed;
|
||||||
|
|
||||||
private final CitizensNPC npc;
|
private final CitizensNPC npc;
|
||||||
|
|
||||||
|
private boolean riding;
|
||||||
|
|
||||||
public EntityHorseZombieNPC(World world) {
|
public EntityHorseZombieNPC(World world) {
|
||||||
this(world, null);
|
this(world, null);
|
||||||
}
|
}
|
||||||
@ -55,6 +61,7 @@ public class HorseZombieController extends MobEntityController {
|
|||||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||||
((ZombieHorse) getBukkitEntity())
|
((ZombieHorse) getBukkitEntity())
|
||||||
.setDomestication(((ZombieHorse) getBukkitEntity()).getMaxDomestication());
|
.setDomestication(((ZombieHorse) getBukkitEntity()).getMaxDomestication());
|
||||||
|
baseMovementSpeed = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,8 +93,18 @@ public class HorseZombieController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SoundEffect cs() {
|
public boolean bT() {
|
||||||
return NMSImpl.getSoundEffect(npc, super.cs(), NPC.DEATH_SOUND_METADATA);
|
if (npc != null && riding) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.bT();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void c(float f, float f1) {
|
||||||
|
if (npc == null || !npc.isFlyable()) {
|
||||||
|
super.c(f, f1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -100,6 +117,11 @@ public class HorseZombieController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SoundEffect cs() {
|
||||||
|
return NMSImpl.getSoundEffect(npc, super.cs(), NPC.DEATH_SOUND_METADATA);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SoundEffect d(DamageSource damagesource) {
|
protected SoundEffect d(DamageSource damagesource) {
|
||||||
return NMSImpl.getSoundEffect(npc, super.d(damagesource), NPC.HURT_SOUND_METADATA);
|
return NMSImpl.getSoundEffect(npc, super.d(damagesource), NPC.HURT_SOUND_METADATA);
|
||||||
@ -111,10 +133,8 @@ public class HorseZombieController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void c(float f, float f1) {
|
protected SoundEffect D() {
|
||||||
if (npc == null || !npc.isFlyable()) {
|
return NMSImpl.getSoundEffect(npc, super.D(), NPC.AMBIENT_SOUND_METADATA);
|
||||||
super.c(f, f1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -152,11 +172,6 @@ public class HorseZombieController extends MobEntityController {
|
|||||||
// cancelled.
|
// cancelled.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected SoundEffect D() {
|
|
||||||
return NMSImpl.getSoundEffect(npc, super.D(), NPC.AMBIENT_SOUND_METADATA);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CraftEntity getBukkitEntity() {
|
public CraftEntity getBukkitEntity() {
|
||||||
if (npc != null && !(bukkitEntity instanceof NPCHolder)) {
|
if (npc != null && !(bukkitEntity instanceof NPCHolder)) {
|
||||||
@ -170,6 +185,13 @@ public class HorseZombieController extends MobEntityController {
|
|||||||
return npc;
|
return npc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void I() {
|
||||||
|
if (npc == null) {
|
||||||
|
super.I();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLeashed() {
|
public boolean isLeashed() {
|
||||||
if (npc == null)
|
if (npc == null)
|
||||||
@ -183,17 +205,20 @@ public class HorseZombieController extends MobEntityController {
|
|||||||
return false; // shouldLeash
|
return false; // shouldLeash
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void I() {
|
|
||||||
if (npc == null) {
|
|
||||||
super.I();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mobTick() {
|
public void mobTick() {
|
||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
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) {
|
||||||
|
d(4, true); // datawatcher method
|
||||||
|
}
|
||||||
NMS.setStepHeight(getBukkitEntity(), 1);
|
NMS.setStepHeight(getBukkitEntity(), 1);
|
||||||
npc.update();
|
npc.update();
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import net.citizensnpcs.api.npc.NPC;
|
|||||||
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
|
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
|
import net.citizensnpcs.trait.Controllable;
|
||||||
import net.citizensnpcs.trait.HorseModifiers;
|
import net.citizensnpcs.trait.HorseModifiers;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -22,6 +23,7 @@ import net.minecraft.server.v1_14_R1.DamageSource;
|
|||||||
import net.minecraft.server.v1_14_R1.DataWatcherObject;
|
import net.minecraft.server.v1_14_R1.DataWatcherObject;
|
||||||
import net.minecraft.server.v1_14_R1.EntityHorseDonkey;
|
import net.minecraft.server.v1_14_R1.EntityHorseDonkey;
|
||||||
import net.minecraft.server.v1_14_R1.EntityTypes;
|
import net.minecraft.server.v1_14_R1.EntityTypes;
|
||||||
|
import net.minecraft.server.v1_14_R1.GenericAttributes;
|
||||||
import net.minecraft.server.v1_14_R1.IBlockData;
|
import net.minecraft.server.v1_14_R1.IBlockData;
|
||||||
import net.minecraft.server.v1_14_R1.NBTTagCompound;
|
import net.minecraft.server.v1_14_R1.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_14_R1.SoundEffect;
|
import net.minecraft.server.v1_14_R1.SoundEffect;
|
||||||
@ -45,10 +47,13 @@ public class HorseDonkeyController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class EntityHorseDonkeyNPC extends EntityHorseDonkey implements NPCHolder {
|
public static class EntityHorseDonkeyNPC extends EntityHorseDonkey implements NPCHolder {
|
||||||
|
private double baseMovementSpeed;
|
||||||
boolean calledNMSHeight = false;
|
boolean calledNMSHeight = false;
|
||||||
|
|
||||||
private final CitizensNPC npc;
|
private final CitizensNPC npc;
|
||||||
|
|
||||||
|
private boolean riding;
|
||||||
|
|
||||||
public EntityHorseDonkeyNPC(EntityTypes<? extends EntityHorseDonkey> types, World world) {
|
public EntityHorseDonkeyNPC(EntityTypes<? extends EntityHorseDonkey> types, World world) {
|
||||||
this(types, world, null);
|
this(types, world, null);
|
||||||
}
|
}
|
||||||
@ -59,6 +64,7 @@ public class HorseDonkeyController extends MobEntityController {
|
|||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||||
((Donkey) getBukkitEntity()).setDomestication(((Donkey) getBukkitEntity()).getMaxDomestication());
|
((Donkey) getBukkitEntity()).setDomestication(((Donkey) getBukkitEntity()).getMaxDomestication());
|
||||||
|
baseMovementSpeed = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,6 +93,14 @@ public class HorseDonkeyController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean ca() {
|
||||||
|
if (npc != null && riding) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.ca();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void checkDespawn() {
|
protected void checkDespawn() {
|
||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
@ -207,6 +221,16 @@ public class HorseDonkeyController extends MobEntityController {
|
|||||||
public void mobTick() {
|
public void mobTick() {
|
||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
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) {
|
||||||
|
d(4, true); // datawatcher method
|
||||||
|
}
|
||||||
NMS.setStepHeight(getBukkitEntity(), 1);
|
NMS.setStepHeight(getBukkitEntity(), 1);
|
||||||
npc.update();
|
npc.update();
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import net.citizensnpcs.api.npc.NPC;
|
|||||||
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
|
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
|
import net.citizensnpcs.trait.Controllable;
|
||||||
import net.citizensnpcs.trait.HorseModifiers;
|
import net.citizensnpcs.trait.HorseModifiers;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -22,6 +23,7 @@ import net.minecraft.server.v1_14_R1.DamageSource;
|
|||||||
import net.minecraft.server.v1_14_R1.DataWatcherObject;
|
import net.minecraft.server.v1_14_R1.DataWatcherObject;
|
||||||
import net.minecraft.server.v1_14_R1.EntityHorseMule;
|
import net.minecraft.server.v1_14_R1.EntityHorseMule;
|
||||||
import net.minecraft.server.v1_14_R1.EntityTypes;
|
import net.minecraft.server.v1_14_R1.EntityTypes;
|
||||||
|
import net.minecraft.server.v1_14_R1.GenericAttributes;
|
||||||
import net.minecraft.server.v1_14_R1.IBlockData;
|
import net.minecraft.server.v1_14_R1.IBlockData;
|
||||||
import net.minecraft.server.v1_14_R1.NBTTagCompound;
|
import net.minecraft.server.v1_14_R1.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_14_R1.SoundEffect;
|
import net.minecraft.server.v1_14_R1.SoundEffect;
|
||||||
@ -45,9 +47,10 @@ public class HorseMuleController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class EntityHorseMuleNPC extends EntityHorseMule implements NPCHolder {
|
public static class EntityHorseMuleNPC extends EntityHorseMule implements NPCHolder {
|
||||||
|
private double baseMovementSpeed;
|
||||||
boolean calledNMSHeight = false;
|
boolean calledNMSHeight = false;
|
||||||
|
|
||||||
private final CitizensNPC npc;
|
private final CitizensNPC npc;
|
||||||
|
private boolean riding;
|
||||||
|
|
||||||
public EntityHorseMuleNPC(EntityTypes<? extends EntityHorseMule> types, World world) {
|
public EntityHorseMuleNPC(EntityTypes<? extends EntityHorseMule> types, World world) {
|
||||||
this(types, world, null);
|
this(types, world, null);
|
||||||
@ -59,6 +62,7 @@ public class HorseMuleController extends MobEntityController {
|
|||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||||
((Mule) getBukkitEntity()).setDomestication(((Mule) getBukkitEntity()).getMaxDomestication());
|
((Mule) getBukkitEntity()).setDomestication(((Mule) getBukkitEntity()).getMaxDomestication());
|
||||||
|
baseMovementSpeed = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,6 +91,14 @@ public class HorseMuleController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean ca() {
|
||||||
|
if (npc != null && riding) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.ca();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void checkDespawn() {
|
protected void checkDespawn() {
|
||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
@ -207,6 +219,16 @@ public class HorseMuleController extends MobEntityController {
|
|||||||
public void mobTick() {
|
public void mobTick() {
|
||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
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) {
|
||||||
|
d(4, true); // datawatcher method
|
||||||
|
}
|
||||||
NMS.setStepHeight(getBukkitEntity(), 1);
|
NMS.setStepHeight(getBukkitEntity(), 1);
|
||||||
npc.update();
|
npc.update();
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import net.citizensnpcs.api.npc.NPC;
|
|||||||
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
|
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
|
import net.citizensnpcs.trait.Controllable;
|
||||||
import net.citizensnpcs.trait.HorseModifiers;
|
import net.citizensnpcs.trait.HorseModifiers;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -22,6 +23,7 @@ import net.minecraft.server.v1_14_R1.DamageSource;
|
|||||||
import net.minecraft.server.v1_14_R1.DataWatcherObject;
|
import net.minecraft.server.v1_14_R1.DataWatcherObject;
|
||||||
import net.minecraft.server.v1_14_R1.EntityHorseSkeleton;
|
import net.minecraft.server.v1_14_R1.EntityHorseSkeleton;
|
||||||
import net.minecraft.server.v1_14_R1.EntityTypes;
|
import net.minecraft.server.v1_14_R1.EntityTypes;
|
||||||
|
import net.minecraft.server.v1_14_R1.GenericAttributes;
|
||||||
import net.minecraft.server.v1_14_R1.IBlockData;
|
import net.minecraft.server.v1_14_R1.IBlockData;
|
||||||
import net.minecraft.server.v1_14_R1.NBTTagCompound;
|
import net.minecraft.server.v1_14_R1.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_14_R1.SoundEffect;
|
import net.minecraft.server.v1_14_R1.SoundEffect;
|
||||||
@ -45,10 +47,14 @@ public class HorseSkeletonController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class EntityHorseSkeletonNPC extends EntityHorseSkeleton implements NPCHolder {
|
public static class EntityHorseSkeletonNPC extends EntityHorseSkeleton implements NPCHolder {
|
||||||
|
private double baseMovementSpeed;
|
||||||
|
|
||||||
boolean calledNMSHeight = false;
|
boolean calledNMSHeight = false;
|
||||||
|
|
||||||
private final CitizensNPC npc;
|
private final CitizensNPC npc;
|
||||||
|
|
||||||
|
private boolean riding;
|
||||||
|
|
||||||
public EntityHorseSkeletonNPC(EntityTypes<? extends EntityHorseSkeleton> types, World world) {
|
public EntityHorseSkeletonNPC(EntityTypes<? extends EntityHorseSkeleton> types, World world) {
|
||||||
this(types, world, null);
|
this(types, world, null);
|
||||||
}
|
}
|
||||||
@ -60,6 +66,7 @@ public class HorseSkeletonController extends MobEntityController {
|
|||||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||||
((SkeletonHorse) getBukkitEntity())
|
((SkeletonHorse) getBukkitEntity())
|
||||||
.setDomestication(((SkeletonHorse) getBukkitEntity()).getMaxDomestication());
|
.setDomestication(((SkeletonHorse) getBukkitEntity()).getMaxDomestication());
|
||||||
|
baseMovementSpeed = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,6 +95,14 @@ public class HorseSkeletonController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean ca() {
|
||||||
|
if (npc != null && riding) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.ca();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void checkDespawn() {
|
protected void checkDespawn() {
|
||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
@ -208,6 +223,16 @@ public class HorseSkeletonController extends MobEntityController {
|
|||||||
public void mobTick() {
|
public void mobTick() {
|
||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
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) {
|
||||||
|
d(4, true); // datawatcher method
|
||||||
|
}
|
||||||
NMS.setStepHeight(getBukkitEntity(), 1);
|
NMS.setStepHeight(getBukkitEntity(), 1);
|
||||||
npc.update();
|
npc.update();
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import net.citizensnpcs.api.npc.NPC;
|
|||||||
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
|
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
|
||||||
import net.citizensnpcs.npc.CitizensNPC;
|
import net.citizensnpcs.npc.CitizensNPC;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
|
import net.citizensnpcs.trait.Controllable;
|
||||||
import net.citizensnpcs.trait.HorseModifiers;
|
import net.citizensnpcs.trait.HorseModifiers;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
@ -22,6 +23,7 @@ import net.minecraft.server.v1_14_R1.DamageSource;
|
|||||||
import net.minecraft.server.v1_14_R1.DataWatcherObject;
|
import net.minecraft.server.v1_14_R1.DataWatcherObject;
|
||||||
import net.minecraft.server.v1_14_R1.EntityHorseZombie;
|
import net.minecraft.server.v1_14_R1.EntityHorseZombie;
|
||||||
import net.minecraft.server.v1_14_R1.EntityTypes;
|
import net.minecraft.server.v1_14_R1.EntityTypes;
|
||||||
|
import net.minecraft.server.v1_14_R1.GenericAttributes;
|
||||||
import net.minecraft.server.v1_14_R1.IBlockData;
|
import net.minecraft.server.v1_14_R1.IBlockData;
|
||||||
import net.minecraft.server.v1_14_R1.NBTTagCompound;
|
import net.minecraft.server.v1_14_R1.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_14_R1.SoundEffect;
|
import net.minecraft.server.v1_14_R1.SoundEffect;
|
||||||
@ -45,10 +47,14 @@ public class HorseZombieController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class EntityHorseZombieNPC extends EntityHorseZombie implements NPCHolder {
|
public static class EntityHorseZombieNPC extends EntityHorseZombie implements NPCHolder {
|
||||||
|
private double baseMovementSpeed;
|
||||||
|
|
||||||
boolean calledNMSHeight = false;
|
boolean calledNMSHeight = false;
|
||||||
|
|
||||||
private final CitizensNPC npc;
|
private final CitizensNPC npc;
|
||||||
|
|
||||||
|
private boolean riding;
|
||||||
|
|
||||||
public EntityHorseZombieNPC(EntityTypes<? extends EntityHorseZombie> types, World world) {
|
public EntityHorseZombieNPC(EntityTypes<? extends EntityHorseZombie> types, World world) {
|
||||||
this(types, world, null);
|
this(types, world, null);
|
||||||
}
|
}
|
||||||
@ -60,6 +66,7 @@ public class HorseZombieController extends MobEntityController {
|
|||||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||||
((ZombieHorse) getBukkitEntity())
|
((ZombieHorse) getBukkitEntity())
|
||||||
.setDomestication(((ZombieHorse) getBukkitEntity()).getMaxDomestication());
|
.setDomestication(((ZombieHorse) getBukkitEntity()).getMaxDomestication());
|
||||||
|
baseMovementSpeed = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,6 +95,14 @@ public class HorseZombieController extends MobEntityController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean ca() {
|
||||||
|
if (npc != null && riding) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.ca();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void checkDespawn() {
|
protected void checkDespawn() {
|
||||||
if (npc == null) {
|
if (npc == null) {
|
||||||
@ -208,6 +223,16 @@ public class HorseZombieController extends MobEntityController {
|
|||||||
public void mobTick() {
|
public void mobTick() {
|
||||||
super.mobTick();
|
super.mobTick();
|
||||||
if (npc != null) {
|
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) {
|
||||||
|
d(4, true); // datawatcher method
|
||||||
|
}
|
||||||
NMS.setStepHeight(getBukkitEntity(), 1);
|
NMS.setStepHeight(getBukkitEntity(), 1);
|
||||||
npc.update();
|
npc.update();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user