mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-25 03:55:30 +01:00
Properly forward slime jump to move controller in 1.17+
This commit is contained in:
parent
8efde00530
commit
1fa3b22c57
@ -86,9 +86,11 @@ public class PlayerControllerMove extends ControllerMove {
|
|||||||
float movement = (float) (this.e * speed.getValue());
|
float movement = (float) (this.e * speed.getValue());
|
||||||
this.a.l(movement);
|
this.a.l(movement);
|
||||||
this.a.bg = movement;
|
this.a.bg = movement;
|
||||||
if (shouldSlimeJump() || ((d2 >= NMS.getStepHeight(a.getBukkitEntity())) && (d0 * d0 + d1 * d1 < 1.0D))) {
|
if (a instanceof EntitySlime && h-- <= 0) {
|
||||||
this.h = cg();
|
this.h = new Random().nextInt(20) + 10;
|
||||||
this.h /= 3;
|
this.h /= 3;
|
||||||
|
((EntityInsentient) this.a).getControllerJump().a();
|
||||||
|
} else if (d2 >= NMS.getStepHeight(a.getBukkitEntity()) && (d0 * d0 + d1 * d1) < 1.0D) {
|
||||||
if (this.a instanceof EntityHumanNPC) {
|
if (this.a instanceof EntityHumanNPC) {
|
||||||
((EntityHumanNPC) this.a).getControllerJump().a();
|
((EntityHumanNPC) this.a).getControllerJump().a();
|
||||||
} else {
|
} else {
|
||||||
@ -114,16 +116,5 @@ public class PlayerControllerMove extends ControllerMove {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double f() {
|
public double f() {
|
||||||
return this.d;
|
return thi
|
||||||
}
|
|
||||||
|
|
||||||
private boolean shouldSlimeJump() {
|
|
||||||
if (!(this.a instanceof EntitySlime)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.h-- <= 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -88,9 +88,11 @@ public class PlayerControllerMove extends ControllerMove {
|
|||||||
float movement = (float) (this.e * speed.getValue());
|
float movement = (float) (this.e * speed.getValue());
|
||||||
this.a.l(movement);
|
this.a.l(movement);
|
||||||
this.a.bf = movement;
|
this.a.bf = movement;
|
||||||
if (shouldSlimeJump() || ((d2 >= NMS.getStepHeight(a.getBukkitEntity())) && (d0 * d0 + d1 * d1 < 1.0D))) {
|
if (a instanceof EntitySlime && h-- <= 0) {
|
||||||
this.h = cg();
|
this.h = new Random().nextInt(20) + 10;
|
||||||
this.h /= 3;
|
this.h /= 3;
|
||||||
|
((EntityInsentient) this.a).getControllerJump().a();
|
||||||
|
} else if (d2 >= NMS.getStepHeight(a.getBukkitEntity()) && (d0 * d0 + d1 * d1) < 1.0D) {
|
||||||
if (this.a instanceof EntityHumanNPC) {
|
if (this.a instanceof EntityHumanNPC) {
|
||||||
((EntityHumanNPC) this.a).getControllerJump().a();
|
((EntityHumanNPC) this.a).getControllerJump().a();
|
||||||
} else {
|
} else {
|
||||||
@ -118,14 +120,4 @@ public class PlayerControllerMove extends ControllerMove {
|
|||||||
public double f() {
|
public double f() {
|
||||||
return this.d;
|
return this.d;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldSlimeJump() {
|
|
||||||
if (!(this.a instanceof EntitySlime)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.h-- <= 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -51,9 +51,11 @@ public class PlayerControllerMove extends ControllerMove {
|
|||||||
float movement = (float) (this.e * speed.getValue());
|
float movement = (float) (this.e * speed.getValue());
|
||||||
this.a.k(movement);
|
this.a.k(movement);
|
||||||
this.a.bg = movement;
|
this.a.bg = movement;
|
||||||
if (shouldSlimeJump() || ((d2 >= NMS.getStepHeight(a.getBukkitEntity())) && (d0 * d0 + d1 * d1 < 1.0D))) {
|
if (a instanceof EntitySlime && h-- <= 0) {
|
||||||
this.h = cg();
|
this.h = new Random().nextInt(20) + 10;
|
||||||
this.h /= 3;
|
this.h /= 3;
|
||||||
|
((EntityInsentient) this.a).getControllerJump().a();
|
||||||
|
} else if (d2 >= NMS.getStepHeight(a.getBukkitEntity()) && (d0 * d0 + d1 * d1) < 1.0D) {
|
||||||
if (this.a instanceof EntityHumanNPC) {
|
if (this.a instanceof EntityHumanNPC) {
|
||||||
((EntityHumanNPC) this.a).getControllerJump().a();
|
((EntityHumanNPC) this.a).getControllerJump().a();
|
||||||
} else {
|
} else {
|
||||||
@ -118,14 +120,4 @@ public class PlayerControllerMove extends ControllerMove {
|
|||||||
public double f() {
|
public double f() {
|
||||||
return this.d;
|
return this.d;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldSlimeJump() {
|
|
||||||
if (!(this.a instanceof EntitySlime)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.h-- <= 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -53,9 +53,11 @@ public class PlayerControllerMove extends ControllerMove {
|
|||||||
float movement = (float) (this.e * speed.getValue());
|
float movement = (float) (this.e * speed.getValue());
|
||||||
this.a.o(movement);
|
this.a.o(movement);
|
||||||
this.a.bj = movement;
|
this.a.bj = movement;
|
||||||
if (shouldSlimeJump() || ((d2 >= NMS.getStepHeight(a.getBukkitEntity())) && (d0 * d0 + d1 * d1 < 1.0D))) {
|
if (a instanceof EntitySlime && h-- <= 0) {
|
||||||
this.h = cg();
|
this.h = new Random().nextInt(20) + 10;
|
||||||
this.h /= 3;
|
this.h /= 3;
|
||||||
|
((EntityInsentient) this.a).getControllerJump().a();
|
||||||
|
} else if (d2 >= NMS.getStepHeight(a.getBukkitEntity()) && (d0 * d0 + d1 * d1) < 1.0D) {
|
||||||
if (this.a instanceof EntityHumanNPC) {
|
if (this.a instanceof EntityHumanNPC) {
|
||||||
((EntityHumanNPC) this.a).getControllerJump().a();
|
((EntityHumanNPC) this.a).getControllerJump().a();
|
||||||
} else {
|
} else {
|
||||||
@ -120,14 +122,4 @@ public class PlayerControllerMove extends ControllerMove {
|
|||||||
public double f() {
|
public double f() {
|
||||||
return this.d;
|
return this.d;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldSlimeJump() {
|
|
||||||
if (!(this.a instanceof EntitySlime)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.h-- <= 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -52,9 +52,11 @@ public class PlayerControllerMove extends ControllerMove {
|
|||||||
float movement = (float) (this.e * speed.getValue());
|
float movement = (float) (this.e * speed.getValue());
|
||||||
this.a.o(movement);
|
this.a.o(movement);
|
||||||
this.a.bd = movement;
|
this.a.bd = movement;
|
||||||
if (shouldSlimeJump() || ((d2 >= NMS.getStepHeight(a.getBukkitEntity())) && (d0 * d0 + d1 * d1 < 1.0D))) {
|
if (a instanceof EntitySlime && h-- <= 0) {
|
||||||
this.h = cg();
|
this.h = new Random().nextInt(20) + 10;
|
||||||
this.h /= 3;
|
this.h /= 3;
|
||||||
|
((EntityInsentient) this.a).getControllerJump().jump();
|
||||||
|
} else if (d2 >= NMS.getStepHeight(a.getBukkitEntity()) && (d0 * d0 + d1 * d1) < 1.0D) {
|
||||||
if (this.a instanceof EntityHumanNPC) {
|
if (this.a instanceof EntityHumanNPC) {
|
||||||
((EntityHumanNPC) this.a).getControllerJump().jump();
|
((EntityHumanNPC) this.a).getControllerJump().jump();
|
||||||
} else {
|
} else {
|
||||||
@ -119,14 +121,4 @@ public class PlayerControllerMove extends ControllerMove {
|
|||||||
public double f() {
|
public double f() {
|
||||||
return this.d;
|
return this.d;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldSlimeJump() {
|
|
||||||
if (!(this.a instanceof EntitySlime)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.h-- <= 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -52,9 +52,11 @@ public class PlayerControllerMove extends ControllerMove {
|
|||||||
float movement = (float) (this.e * speed.getValue());
|
float movement = (float) (this.e * speed.getValue());
|
||||||
this.a.o(movement);
|
this.a.o(movement);
|
||||||
this.a.bb = movement;
|
this.a.bb = movement;
|
||||||
if (shouldSlimeJump() || ((d2 >= NMS.getStepHeight(a.getBukkitEntity())) && (d0 * d0 + d1 * d1 < 1.0D))) {
|
if (a instanceof EntitySlime && h-- <= 0) {
|
||||||
this.h = cg();
|
this.h = new Random().nextInt(20) + 10;
|
||||||
this.h /= 3;
|
this.h /= 3;
|
||||||
|
((EntityInsentient) this.a).getControllerJump().jump();
|
||||||
|
} else if (d2 >= NMS.getStepHeight(a.getBukkitEntity()) && (d0 * d0 + d1 * d1) < 1.0D) {
|
||||||
if (this.a instanceof EntityHumanNPC) {
|
if (this.a instanceof EntityHumanNPC) {
|
||||||
((EntityHumanNPC) this.a).getControllerJump().jump();
|
((EntityHumanNPC) this.a).getControllerJump().jump();
|
||||||
} else {
|
} else {
|
||||||
@ -119,14 +121,4 @@ public class PlayerControllerMove extends ControllerMove {
|
|||||||
public double f() {
|
public double f() {
|
||||||
return this.d;
|
return this.d;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldSlimeJump() {
|
|
||||||
if (!(this.a instanceof EntitySlime)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.h-- <= 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -53,9 +53,13 @@ public class EntityMoveControl extends ControllerMove {
|
|||||||
float movement = (float) (this.e * speed.getValue());
|
float movement = (float) (this.e * speed.getValue());
|
||||||
this.a.q(movement);
|
this.a.q(movement);
|
||||||
this.a.aT = movement;
|
this.a.aT = movement;
|
||||||
if (shouldSlimeJump() || (d2 >= NMS.getStepHeight(a.getBukkitEntity()) && (d0 * d0 + d1 * d1) < 1.0D)) {
|
if (a instanceof EntitySlime && h-- <= 0) {
|
||||||
this.h = cg();
|
this.h = new Random().nextInt(20) + 10;
|
||||||
this.h /= 3;
|
if (((EntitySlime) a).isAggressive()) {
|
||||||
|
this.h /= 3;
|
||||||
|
}
|
||||||
|
ai.getJumpControl().jump();
|
||||||
|
} else if (d2 >= NMS.getStepHeight(a.getBukkitEntity()) && (d0 * d0 + d1 * d1) < 1.0D) {
|
||||||
ai.getJumpControl().jump();
|
ai.getJumpControl().jump();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,14 +120,4 @@ public class EntityMoveControl extends ControllerMove {
|
|||||||
public double f() {
|
public double f() {
|
||||||
return this.d;
|
return this.d;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldSlimeJump() {
|
|
||||||
if (!(this.a instanceof EntitySlime)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.h-- <= 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -86,16 +86,6 @@ public class EntityMoveControl extends MoveControl {
|
|||||||
this.moving = true;
|
this.moving = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldJump() {
|
|
||||||
if (!(this.entity instanceof Slime)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.jumpTicks-- <= 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
this.entity.zza = 0;
|
this.entity.zza = 0;
|
||||||
@ -109,18 +99,27 @@ public class EntityMoveControl extends MoveControl {
|
|||||||
this.entity.zza = 0.0F;
|
this.entity.zza = 0.0F;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dXZ > 0.4) {
|
if (dXZ > 0.4) {
|
||||||
float f = (float) (Mth.atan2(dZ, dX) * 57.2957763671875D) - 90.0F;
|
float f = (float) (Mth.atan2(dZ, dX) * 57.2957763671875D) - 90.0F;
|
||||||
this.entity.setYRot(rotlerp(this.entity.getYRot(), f, 90.0F));
|
this.entity.setYRot(rotlerp(this.entity.getYRot(), f, 90.0F));
|
||||||
NMS.setHeadYaw(entity.getBukkitEntity(), this.entity.getYRot());
|
NMS.setHeadYaw(entity.getBukkitEntity(), this.entity.getYRot());
|
||||||
}
|
}
|
||||||
|
|
||||||
AttributeInstance speed = this.entity.getAttribute(Attributes.MOVEMENT_SPEED);
|
AttributeInstance speed = this.entity.getAttribute(Attributes.MOVEMENT_SPEED);
|
||||||
float movement = (float) (this.speed * speed.getValue());
|
float movement = (float) (this.speed * speed.getValue());
|
||||||
this.entity.setSpeed(movement);
|
this.entity.setSpeed(movement);
|
||||||
this.entity.zza = movement;
|
this.entity.zza = movement;
|
||||||
if (shouldJump() || (dY >= NMS.getStepHeight(entity.getBukkitEntity()) && dXZ < 1.0D)) {
|
if (entity instanceof Slime && jumpTicks-- <= 0) {
|
||||||
this.jumpTicks = jumpTicks();
|
this.jumpTicks = new Random().nextInt(20) + 10;
|
||||||
this.jumpTicks /= 3;
|
if (((Slime) entity).isAggressive()) {
|
||||||
|
this.jumpTicks /= 3;
|
||||||
|
}
|
||||||
|
((Slime) entity).getJumpControl().jump();
|
||||||
|
} else if (dY >= NMS.getStepHeight(entity.getBukkitEntity()) && dXZ < 0.4D) {
|
||||||
|
if (entity instanceof Mob) {
|
||||||
|
((Mob) entity).getJumpControl().jump();
|
||||||
|
}
|
||||||
entity.setJumping(true);
|
entity.setJumping(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,16 +85,6 @@ public class EntityMoveControl extends MoveControl {
|
|||||||
this.moving = true;
|
this.moving = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldJump() {
|
|
||||||
if (!(this.entity instanceof Slime)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.jumpTicks-- <= 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
this.entity.zza = 0;
|
this.entity.zza = 0;
|
||||||
@ -116,9 +106,16 @@ public class EntityMoveControl extends MoveControl {
|
|||||||
float movement = (float) (this.speedMod * this.entity.getAttribute(Attributes.MOVEMENT_SPEED).getValue());
|
float movement = (float) (this.speedMod * this.entity.getAttribute(Attributes.MOVEMENT_SPEED).getValue());
|
||||||
this.entity.setSpeed(movement);
|
this.entity.setSpeed(movement);
|
||||||
this.entity.zza = movement;
|
this.entity.zza = movement;
|
||||||
if (shouldJump() || (dY >= NMS.getStepHeight(entity.getBukkitEntity()) && dXZ < 0.4D)) {
|
if (entity instanceof Slime && jumpTicks-- <= 0) {
|
||||||
this.jumpTicks = jumpTicks();
|
this.jumpTicks = new Random().nextInt(20) + 10;
|
||||||
this.jumpTicks /= 3;
|
if (((Slime) entity).isAggressive()) {
|
||||||
|
this.jumpTicks /= 3;
|
||||||
|
}
|
||||||
|
((Slime) entity).getJumpControl().jump();
|
||||||
|
} else if (dY >= NMS.getStepHeight(entity.getBukkitEntity()) && dXZ < 0.4D) {
|
||||||
|
if (entity instanceof Mob) {
|
||||||
|
((Mob) entity).getJumpControl().jump();
|
||||||
|
}
|
||||||
entity.setJumping(true);
|
entity.setJumping(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,16 +85,6 @@ public class EntityMoveControl extends MoveControl {
|
|||||||
this.moving = true;
|
this.moving = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldJump() {
|
|
||||||
if (!(this.entity instanceof Slime))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (this.jumpTicks-- <= 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
this.entity.zza = 0;
|
this.entity.zza = 0;
|
||||||
@ -116,9 +106,16 @@ public class EntityMoveControl extends MoveControl {
|
|||||||
float movement = (float) (this.speedMod * this.entity.getAttribute(Attributes.MOVEMENT_SPEED).getValue());
|
float movement = (float) (this.speedMod * this.entity.getAttribute(Attributes.MOVEMENT_SPEED).getValue());
|
||||||
this.entity.setSpeed(movement);
|
this.entity.setSpeed(movement);
|
||||||
this.entity.zza = movement;
|
this.entity.zza = movement;
|
||||||
if (shouldJump() || (dY >= NMS.getStepHeight(entity.getBukkitEntity()) && dXZ < 0.4D)) {
|
if (entity instanceof Slime && jumpTicks-- <= 0) {
|
||||||
this.jumpTicks = jumpTicks();
|
this.jumpTicks = new Random().nextInt(20) + 10;
|
||||||
this.jumpTicks /= 3;
|
if (((Slime) entity).isAggressive()) {
|
||||||
|
this.jumpTicks /= 3;
|
||||||
|
}
|
||||||
|
((Slime) entity).getJumpControl().jump();
|
||||||
|
} else if (dY >= NMS.getStepHeight(entity.getBukkitEntity()) && dXZ < 0.4D) {
|
||||||
|
if (entity instanceof Mob) {
|
||||||
|
((Mob) entity).getJumpControl().jump();
|
||||||
|
}
|
||||||
entity.setJumping(true);
|
entity.setJumping(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ import net.citizensnpcs.npc.ai.NPCHolder;
|
|||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
import net.citizensnpcs.util.Util;
|
import net.citizensnpcs.util.Util;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
@ -48,7 +47,6 @@ public class SlimeController extends MobEntityController {
|
|||||||
|
|
||||||
public static class EntitySlimeNPC extends Slime implements NPCHolder {
|
public static class EntitySlimeNPC extends Slime implements NPCHolder {
|
||||||
private final CitizensNPC npc;
|
private final CitizensNPC npc;
|
||||||
|
|
||||||
private MoveControl oldMoveController;
|
private MoveControl oldMoveController;
|
||||||
|
|
||||||
public EntitySlimeNPC(EntityType<? extends Slime> types, Level level) {
|
public EntitySlimeNPC(EntityType<? extends Slime> types, Level level) {
|
||||||
@ -67,17 +65,17 @@ public class SlimeController extends MobEntityController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canRide(Entity entity) {
|
protected boolean canRide(Entity entity) {
|
||||||
if (npc != null && (entity instanceof Boat || entity instanceof AbstractMinecart)) {
|
if (npc != null && (entity instanceof Boat || entity instanceof AbstractMinecart))
|
||||||
return !npc.isProtected();
|
return !npc.isProtected();
|
||||||
}
|
|
||||||
return super.canRide(entity);
|
return super.canRide(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean causeFallDamage(float f, float f1, DamageSource damagesource) {
|
public boolean causeFallDamage(float f, float f1, DamageSource damagesource) {
|
||||||
if (npc == null || !npc.isFlyable()) {
|
if (npc == null || !npc.isFlyable())
|
||||||
return super.causeFallDamage(f, f1, damagesource);
|
return super.causeFallDamage(f, f1, damagesource);
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,10 +54,6 @@ public class EntityMoveControl extends MoveControl {
|
|||||||
return this.moving;
|
return this.moving;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int jumpTicks() {
|
|
||||||
return new Random().nextInt(20) + 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected float rotlerp(float f, float f1, float f2) {
|
protected float rotlerp(float f, float f1, float f2) {
|
||||||
float f3 = Mth.wrapDegrees(f1 - f);
|
float f3 = Mth.wrapDegrees(f1 - f);
|
||||||
@ -85,42 +81,42 @@ public class EntityMoveControl extends MoveControl {
|
|||||||
this.moving = true;
|
this.moving = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldJump() {
|
|
||||||
if (!(this.entity instanceof Slime))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (this.jumpTicks-- <= 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
this.entity.zza = 0;
|
this.entity.zza = 0;
|
||||||
if (this.moving) {
|
if (!this.moving)
|
||||||
this.moving = false;
|
return;
|
||||||
double dX = this.tx - this.entity.getX();
|
|
||||||
double dZ = this.tz - this.entity.getZ();
|
this.moving = false;
|
||||||
double dY = this.ty - this.entity.getY();
|
double dX = this.tx - this.entity.getX();
|
||||||
double dXZ = Math.sqrt(dX * dX + dZ * dZ);
|
double dZ = this.tz - this.entity.getZ();
|
||||||
if (Math.abs(dY) < 1.0 && dXZ < 0.01) {
|
double dY = this.ty - this.entity.getY();
|
||||||
// this.entity.zza = 0.0F;
|
double dXZ = Math.sqrt(dX * dX + dZ * dZ);
|
||||||
return;
|
if (Math.abs(dY) < 1.0 && dXZ < 0.01) {
|
||||||
}
|
// this.entity.zza = 0.0F;
|
||||||
if (dXZ > 0.4) {
|
return;
|
||||||
float f = (float) Math.toDegrees(Mth.atan2(dZ, dX)) - 90.0F;
|
}
|
||||||
this.entity.setYRot(rotlerp(this.entity.getYRot(), f, 90.0F));
|
|
||||||
NMS.setHeadYaw(entity.getBukkitEntity(), this.entity.getYRot());
|
if (dXZ > 0.4) {
|
||||||
}
|
float f = (float) Math.toDegrees(Mth.atan2(dZ, dX)) - 90.0F;
|
||||||
float movement = (float) (this.speedMod * this.entity.getAttribute(Attributes.MOVEMENT_SPEED).getValue());
|
this.entity.setYRot(rotlerp(this.entity.getYRot(), f, 90.0F));
|
||||||
this.entity.setSpeed(movement);
|
NMS.setHeadYaw(entity.getBukkitEntity(), this.entity.getYRot());
|
||||||
this.entity.zza = movement;
|
}
|
||||||
if (shouldJump() || (dY >= NMS.getStepHeight(entity.getBukkitEntity()) && dXZ < 0.4D)) {
|
|
||||||
this.jumpTicks = jumpTicks();
|
float movement = (float) (this.speedMod * this.entity.getAttribute(Attributes.MOVEMENT_SPEED).getValue());
|
||||||
|
this.entity.setSpeed(movement);
|
||||||
|
this.entity.zza = movement;
|
||||||
|
if (entity instanceof Slime && jumpTicks-- <= 0) {
|
||||||
|
this.jumpTicks = new Random().nextInt(20) + 10;
|
||||||
|
if (((Slime) entity).isAggressive()) {
|
||||||
this.jumpTicks /= 3;
|
this.jumpTicks /= 3;
|
||||||
entity.setJumping(true);
|
|
||||||
}
|
}
|
||||||
|
((Slime) entity).getJumpControl().jump();
|
||||||
|
} else if (dY >= NMS.getStepHeight(entity.getBukkitEntity()) && dXZ < 0.4D) {
|
||||||
|
if (entity instanceof Mob) {
|
||||||
|
((Mob) entity).getJumpControl().jump();
|
||||||
|
}
|
||||||
|
entity.setJumping(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -86,9 +86,11 @@ public class PlayerControllerMove extends ControllerMove {
|
|||||||
float movement = (float) (this.e * speed.getValue());
|
float movement = (float) (this.e * speed.getValue());
|
||||||
this.a.k(movement);
|
this.a.k(movement);
|
||||||
this.a.ba = movement;
|
this.a.ba = movement;
|
||||||
if (shouldSlimeJump() || ((dY >= NMS.getStepHeight(a.getBukkitEntity())) && dXZ < 0.4)) {
|
if (a instanceof EntitySlime && h-- <= 0) {
|
||||||
this.h = cg();
|
this.h = new Random().nextInt(20) + 10;
|
||||||
this.h /= 3;
|
this.h /= 3;
|
||||||
|
((EntityInsentient) this.a).getControllerJump().a();
|
||||||
|
} else if (dY >= NMS.getStepHeight(a.getBukkitEntity()) && (dXZ) < 0.4D) {
|
||||||
if (this.a instanceof EntityHumanNPC) {
|
if (this.a instanceof EntityHumanNPC) {
|
||||||
((EntityHumanNPC) this.a).getControllerJump().a();
|
((EntityHumanNPC) this.a).getControllerJump().a();
|
||||||
} else {
|
} else {
|
||||||
@ -115,14 +117,4 @@ public class PlayerControllerMove extends ControllerMove {
|
|||||||
public double f() {
|
public double f() {
|
||||||
return this.d;
|
return this.d;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldSlimeJump() {
|
|
||||||
if (!(this.a instanceof EntitySlime)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.h-- <= 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user