Fix players not jumping in newer minecraft versions

This commit is contained in:
fullwall 2024-06-22 13:21:21 +08:00
parent ee9c67fc0c
commit 20ea3e8723
12 changed files with 125 additions and 73 deletions

View File

@ -3,7 +3,6 @@ package net.citizensnpcs.nms.v1_16_R3.util;
import java.util.Random; import java.util.Random;
import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.NMS;
import net.minecraft.server.v1_16_R3.AttributeModifiable;
import net.minecraft.server.v1_16_R3.ControllerMove; import net.minecraft.server.v1_16_R3.ControllerMove;
import net.minecraft.server.v1_16_R3.EntityInsentient; import net.minecraft.server.v1_16_R3.EntityInsentient;
import net.minecraft.server.v1_16_R3.EntityLiving; import net.minecraft.server.v1_16_R3.EntityLiving;

View File

@ -3,6 +3,9 @@ package net.citizensnpcs.nms.v1_17_R1.util;
import java.util.Random; import java.util.Random;
import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.NMS;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction.Axis;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
@ -10,6 +13,8 @@ import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.control.MoveControl; import net.minecraft.world.entity.ai.control.MoveControl;
import net.minecraft.world.entity.monster.Slime; import net.minecraft.world.entity.monster.Slime;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.VoxelShape;
public class EntityMoveControl extends MoveControl { public class EntityMoveControl extends MoveControl {
protected LivingEntity entity; protected LivingEntity entity;
@ -94,27 +99,32 @@ public class EntityMoveControl extends MoveControl {
double dZ = this.tz - this.entity.getZ(); double dZ = this.tz - this.entity.getZ();
double dY = this.ty - this.entity.getY(); double dY = this.ty - this.entity.getY();
double dXZ = Math.sqrt(dX * dX + dZ * dZ); double dXZ = Math.sqrt(dX * dX + dZ * dZ);
if (Math.abs(dY) < 1.0 && dXZ < 0.01) { double dXYZ = Math.sqrt(dX * dX + dY * dY + dZ * dZ);
this.entity.zza = 0.0F; if (dXYZ < 2.500000277905201E-7) {
// 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) Math.toDegrees(Mth.atan2(dZ, dX)) - 90.0F;
this.entity.setYRot(rotlerp(this.entity.getYRot(), f, 90.0F)); entity.setYRot(rotlerp(this.entity.getYRot(), f, 90.0F));
NMS.setHeadYaw(entity.getBukkitEntity(), this.entity.getYRot()); NMS.setHeadYaw(entity.getBukkitEntity(), entity.getYRot());
} }
this.entity.zza = (float) (this.speed * this.entity.getAttribute(Attributes.MOVEMENT_SPEED).getValue()); this.entity.zza = (float) (this.speed * entity.getAttribute(Attributes.MOVEMENT_SPEED).getValue());
if (entity instanceof Slime && jumpTicks-- <= 0) { if (entity instanceof Slime && jumpTicks-- <= 0) {
this.jumpTicks = new Random().nextInt(20) + 10; this.jumpTicks = new Random().nextInt(20) + 10;
if (((Slime) entity).isAggressive()) { if (((Slime) entity).isAggressive()) {
this.jumpTicks /= 3; this.jumpTicks /= 3;
} }
((Slime) entity).getJumpControl().jump(); ((Slime) entity).getJumpControl().jump();
} else if (dY >= NMS.getStepHeight(entity.getBukkitEntity()) && dXZ < 0.4D) { return;
if (entity instanceof Mob) { }
((Mob) entity).getJumpControl().jump(); BlockPos pos = entity.blockPosition();
} BlockState bs = entity.level.getBlockState(pos);
entity.setJumping(true); VoxelShape vs = bs.getCollisionShape(entity.level, pos);
if (dY >= entity.maxUpStep && dXZ < Math.max(1.0F, entity.getBbWidth())
|| !vs.isEmpty() && entity.getY() < vs.max(Axis.Y) + pos.getY() && !bs.is(BlockTags.DOORS)
&& !bs.is(BlockTags.FENCES)) {
NMS.setShouldJump(entity.getBukkitEntity());
} }
} }
} }

View File

@ -1512,6 +1512,9 @@ public class NMSImpl implements NMSBridge {
if (ai != null) { if (ai != null) {
ai.getJumpControl().jump(); ai.getJumpControl().jump();
} }
if (handle instanceof LivingEntity) {
((LivingEntity) handle).setJumping(true);
}
} }
@Override @Override

View File

@ -3,6 +3,9 @@ package net.citizensnpcs.nms.v1_18_R2.util;
import java.util.Random; import java.util.Random;
import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.NMS;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction.Axis;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
@ -10,6 +13,8 @@ import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.control.MoveControl; import net.minecraft.world.entity.ai.control.MoveControl;
import net.minecraft.world.entity.monster.Slime; import net.minecraft.world.entity.monster.Slime;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.VoxelShape;
public class EntityMoveControl extends MoveControl { public class EntityMoveControl extends MoveControl {
protected LivingEntity entity; protected LivingEntity entity;
@ -94,26 +99,32 @@ public class EntityMoveControl extends MoveControl {
double dZ = this.tz - this.entity.getZ(); double dZ = this.tz - this.entity.getZ();
double dY = this.ty - this.entity.getY(); double dY = this.ty - this.entity.getY();
double dXZ = Math.sqrt(dX * dX + dZ * dZ); double dXZ = Math.sqrt(dX * dX + dZ * dZ);
if (Math.abs(dY) < 1.0 && dXZ < 0.01) double dXYZ = Math.sqrt(dX * dX + dY * dY + dZ * dZ);
if (dXYZ < 2.500000277905201E-7) {
// this.entity.zza = 0.0F; // this.entity.zza = 0.0F;
return; return;
}
if (dXZ > 0.4) { if (dXZ > 0.4) {
float f = (float) Math.toDegrees(Mth.atan2(dZ, dX)) - 90.0F; float f = (float) Math.toDegrees(Mth.atan2(dZ, dX)) - 90.0F;
this.entity.setYRot(rotlerp(this.entity.getYRot(), f, 90.0F)); entity.setYRot(rotlerp(this.entity.getYRot(), f, 90.0F));
NMS.setHeadYaw(entity.getBukkitEntity(), this.entity.getYRot()); NMS.setHeadYaw(entity.getBukkitEntity(), entity.getYRot());
} }
this.entity.zza = (float) (this.speedMod * this.entity.getAttribute(Attributes.MOVEMENT_SPEED).getValue()); this.entity.zza = (float) (this.speedMod * entity.getAttribute(Attributes.MOVEMENT_SPEED).getValue());
if (entity instanceof Slime && jumpTicks-- <= 0) { if (entity instanceof Slime && jumpTicks-- <= 0) {
this.jumpTicks = new Random().nextInt(20) + 10; this.jumpTicks = new Random().nextInt(20) + 10;
if (((Slime) entity).isAggressive()) { if (((Slime) entity).isAggressive()) {
this.jumpTicks /= 3; this.jumpTicks /= 3;
} }
((Slime) entity).getJumpControl().jump(); ((Slime) entity).getJumpControl().jump();
} else if (dY >= NMS.getStepHeight(entity.getBukkitEntity()) && dXZ < 0.4D) { return;
if (entity instanceof Mob) { }
((Mob) entity).getJumpControl().jump(); BlockPos pos = entity.blockPosition();
} BlockState bs = entity.level.getBlockState(pos);
entity.setJumping(true); VoxelShape vs = bs.getCollisionShape(entity.level, pos);
if (dY >= entity.maxUpStep && dXZ < Math.max(1.0F, entity.getBbWidth())
|| !vs.isEmpty() && entity.getY() < vs.max(Axis.Y) + pos.getY() && !bs.is(BlockTags.DOORS)
&& !bs.is(BlockTags.FENCES)) {
NMS.setShouldJump(entity.getBukkitEntity());
} }
} }
} }

View File

@ -1519,7 +1519,12 @@ public class NMSImpl implements NMSBridge {
if (handle == null) if (handle == null)
return; return;
MobAI ai = MobAI.from(handle); MobAI ai = MobAI.from(handle);
ai.getJumpControl().jump(); if (ai != null) {
ai.getJumpControl().jump();
}
if (handle instanceof LivingEntity) {
((LivingEntity) handle).setJumping(true);
}
} }
@Override @Override

View File

@ -3,6 +3,9 @@ package net.citizensnpcs.nms.v1_19_R3.util;
import java.util.Random; import java.util.Random;
import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.NMS;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction.Axis;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
@ -10,6 +13,8 @@ import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.control.MoveControl; import net.minecraft.world.entity.ai.control.MoveControl;
import net.minecraft.world.entity.monster.Slime; import net.minecraft.world.entity.monster.Slime;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.VoxelShape;
public class EntityMoveControl extends MoveControl { public class EntityMoveControl extends MoveControl {
protected LivingEntity entity; protected LivingEntity entity;
@ -94,26 +99,32 @@ public class EntityMoveControl extends MoveControl {
double dZ = this.tz - this.entity.getZ(); double dZ = this.tz - this.entity.getZ();
double dY = this.ty - this.entity.getY(); double dY = this.ty - this.entity.getY();
double dXZ = Math.sqrt(dX * dX + dZ * dZ); double dXZ = Math.sqrt(dX * dX + dZ * dZ);
if (Math.abs(dY) < 1.0 && dXZ < 0.01) double dXYZ = Math.sqrt(dX * dX + dY * dY + dZ * dZ);
if (dXYZ < 2.500000277905201E-7) {
// this.entity.zza = 0.0F; // this.entity.zza = 0.0F;
return; return;
}
if (dXZ > 0.4) { if (dXZ > 0.4) {
float f = (float) Math.toDegrees(Mth.atan2(dZ, dX)) - 90.0F; float f = (float) Math.toDegrees(Mth.atan2(dZ, dX)) - 90.0F;
this.entity.setYRot(rotlerp(this.entity.getYRot(), f, 90.0F)); entity.setYRot(rotlerp(this.entity.getYRot(), f, 90.0F));
NMS.setHeadYaw(entity.getBukkitEntity(), this.entity.getYRot()); NMS.setHeadYaw(entity.getBukkitEntity(), entity.getYRot());
} }
this.entity.zza = (float) (this.speedMod * this.entity.getAttribute(Attributes.MOVEMENT_SPEED).getValue()); this.entity.zza = (float) (this.speedMod * entity.getAttribute(Attributes.MOVEMENT_SPEED).getValue());
if (entity instanceof Slime && jumpTicks-- <= 0) { if (entity instanceof Slime && jumpTicks-- <= 0) {
this.jumpTicks = new Random().nextInt(20) + 10; this.jumpTicks = new Random().nextInt(20) + 10;
if (((Slime) entity).isAggressive()) { if (((Slime) entity).isAggressive()) {
this.jumpTicks /= 3; this.jumpTicks /= 3;
} }
((Slime) entity).getJumpControl().jump(); ((Slime) entity).getJumpControl().jump();
} else if (dY >= NMS.getStepHeight(entity.getBukkitEntity()) && dXZ < 0.4D) { return;
if (entity instanceof Mob) { }
((Mob) entity).getJumpControl().jump(); BlockPos pos = entity.blockPosition();
} BlockState bs = entity.level.getBlockState(pos);
entity.setJumping(true); VoxelShape vs = bs.getCollisionShape(entity.level, pos);
if (dY >= entity.maxUpStep() && dXZ < Math.max(1.0F, entity.getBbWidth())
|| !vs.isEmpty() && entity.getY() < vs.max(Axis.Y) + pos.getY() && !bs.is(BlockTags.DOORS)
&& !bs.is(BlockTags.FENCES)) {
NMS.setShouldJump(entity.getBukkitEntity());
} }
} }
} }

View File

@ -308,7 +308,6 @@ import net.minecraft.world.entity.ai.attributes.AttributeMap;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.control.FlyingMoveControl; import net.minecraft.world.entity.ai.control.FlyingMoveControl;
import net.minecraft.world.entity.ai.control.JumpControl;
import net.minecraft.world.entity.ai.control.LookControl; import net.minecraft.world.entity.ai.control.LookControl;
import net.minecraft.world.entity.ai.control.MoveControl; import net.minecraft.world.entity.ai.control.MoveControl;
import net.minecraft.world.entity.ai.goal.GoalSelector; import net.minecraft.world.entity.ai.goal.GoalSelector;
@ -1663,10 +1662,11 @@ public class NMSImpl implements NMSBridge {
Entity handle = getHandle(entity); Entity handle = getHandle(entity);
if (handle == null) if (handle == null)
return; return;
if (handle instanceof Mob) { MobAI ai = MobAI.from(handle);
JumpControl controller = ((Mob) handle).getJumpControl(); if (ai != null) {
controller.jump(); ai.getJumpControl().jump();
} else { }
if (handle instanceof LivingEntity) {
((LivingEntity) handle).setJumping(true); ((LivingEntity) handle).setJumping(true);
} }
} }

View File

@ -3,6 +3,9 @@ package net.citizensnpcs.nms.v1_20_R4.util;
import java.util.Random; import java.util.Random;
import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.NMS;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction.Axis;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
@ -10,6 +13,8 @@ import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.control.MoveControl; import net.minecraft.world.entity.ai.control.MoveControl;
import net.minecraft.world.entity.monster.Slime; import net.minecraft.world.entity.monster.Slime;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.VoxelShape;
public class EntityMoveControl extends MoveControl { public class EntityMoveControl extends MoveControl {
protected LivingEntity entity; protected LivingEntity entity;
@ -92,27 +97,31 @@ public class EntityMoveControl extends MoveControl {
double dZ = this.tz - this.entity.getZ(); double dZ = this.tz - this.entity.getZ();
double dY = this.ty - this.entity.getY(); double dY = this.ty - this.entity.getY();
double dXZ = Math.sqrt(dX * dX + dZ * dZ); double dXZ = Math.sqrt(dX * dX + dZ * dZ);
if (Math.abs(dY) < 1.0 && dXZ < 0.01) double dXYZ = Math.sqrt(dX * dX + dY * dY + dZ * dZ);
if (dXYZ < 2.500000277905201E-7) {
// this.entity.zza = 0.0F; // this.entity.zza = 0.0F;
return; return;
}
if (dXZ > 0.4) { if (dXZ > 0.4) {
float f = (float) Math.toDegrees(Mth.atan2(dZ, dX)) - 90.0F; float f = (float) Math.toDegrees(Mth.atan2(dZ, dX)) - 90.0F;
this.entity.setYRot(rotlerp(this.entity.getYRot(), f, 90.0F)); entity.setYRot(rotlerp(this.entity.getYRot(), f, 90.0F));
NMS.setHeadYaw(entity.getBukkitEntity(), this.entity.getYRot()); NMS.setHeadYaw(entity.getBukkitEntity(), entity.getYRot());
} }
this.entity.zza = (float) (this.speedMod * this.entity.getAttribute(Attributes.MOVEMENT_SPEED).getValue()); this.entity.zza = (float) (this.speedMod * entity.getAttribute(Attributes.MOVEMENT_SPEED).getValue());
if (entity instanceof Slime && jumpTicks-- <= 0) { if (entity instanceof Slime && jumpTicks-- <= 0) {
this.jumpTicks = new Random().nextInt(20) + 10; this.jumpTicks = new Random().nextInt(20) + 10;
if (((Slime) entity).isAggressive()) { if (((Slime) entity).isAggressive()) {
this.jumpTicks /= 3; this.jumpTicks /= 3;
} }
((Slime) entity).getJumpControl().jump(); ((Slime) entity).getJumpControl().jump();
} else if (dY >= NMS.getStepHeight(entity.getBukkitEntity()) && dXZ < 0.4D) { return;
if (entity instanceof Mob) { }
((Mob) entity).getJumpControl().jump(); BlockPos pos = entity.blockPosition();
} BlockState bs = entity.level().getBlockState(pos);
entity.setJumping(true); VoxelShape vs = bs.getCollisionShape(entity.level(), pos);
if (dY >= entity.maxUpStep() && dXZ < Math.max(1.0F, entity.getBbWidth()) || !vs.isEmpty()
&& entity.getY() < vs.max(Axis.Y) + pos.getY() && !bs.is(BlockTags.DOORS) && !bs.is(BlockTags.FENCES)) {
NMS.setShouldJump(entity.getBukkitEntity());
} }
} }
} }

View File

@ -305,7 +305,6 @@ import net.minecraft.world.entity.ai.attributes.AttributeMap;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.control.FlyingMoveControl; import net.minecraft.world.entity.ai.control.FlyingMoveControl;
import net.minecraft.world.entity.ai.control.JumpControl;
import net.minecraft.world.entity.ai.control.LookControl; import net.minecraft.world.entity.ai.control.LookControl;
import net.minecraft.world.entity.ai.control.MoveControl; import net.minecraft.world.entity.ai.control.MoveControl;
import net.minecraft.world.entity.ai.goal.GoalSelector; import net.minecraft.world.entity.ai.goal.GoalSelector;
@ -1662,10 +1661,11 @@ public class NMSImpl implements NMSBridge {
Entity handle = getHandle(entity); Entity handle = getHandle(entity);
if (handle == null) if (handle == null)
return; return;
if (handle instanceof Mob) { MobAI ai = MobAI.from(handle);
JumpControl controller = ((Mob) handle).getJumpControl(); if (ai != null) {
controller.jump(); ai.getJumpControl().jump();
} else { }
if (handle instanceof LivingEntity) {
((LivingEntity) handle).setJumping(true); ((LivingEntity) handle).setJumping(true);
} }
} }

View File

@ -3,6 +3,9 @@ package net.citizensnpcs.nms.v1_21_R1.util;
import java.util.Random; import java.util.Random;
import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.NMS;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction.Axis;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
@ -10,6 +13,8 @@ import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.control.MoveControl; import net.minecraft.world.entity.ai.control.MoveControl;
import net.minecraft.world.entity.monster.Slime; import net.minecraft.world.entity.monster.Slime;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.VoxelShape;
public class EntityMoveControl extends MoveControl { public class EntityMoveControl extends MoveControl {
protected LivingEntity entity; protected LivingEntity entity;
@ -92,27 +97,31 @@ public class EntityMoveControl extends MoveControl {
double dZ = this.tz - this.entity.getZ(); double dZ = this.tz - this.entity.getZ();
double dY = this.ty - this.entity.getY(); double dY = this.ty - this.entity.getY();
double dXZ = Math.sqrt(dX * dX + dZ * dZ); double dXZ = Math.sqrt(dX * dX + dZ * dZ);
if (Math.abs(dY) < 1.0 && dXZ < 0.01) double dXYZ = Math.sqrt(dX * dX + dY * dY + dZ * dZ);
if (dXYZ < 2.500000277905201E-7) {
// this.entity.zza = 0.0F; // this.entity.zza = 0.0F;
return; return;
}
if (dXZ > 0.4) { if (dXZ > 0.4) {
float f = (float) Math.toDegrees(Mth.atan2(dZ, dX)) - 90.0F; float f = (float) Math.toDegrees(Mth.atan2(dZ, dX)) - 90.0F;
this.entity.setYRot(rotlerp(this.entity.getYRot(), f, 90.0F)); entity.setYRot(rotlerp(this.entity.getYRot(), f, 90.0F));
NMS.setHeadYaw(entity.getBukkitEntity(), this.entity.getYRot()); NMS.setHeadYaw(entity.getBukkitEntity(), entity.getYRot());
} }
this.entity.zza = (float) (this.speedMod * this.entity.getAttribute(Attributes.MOVEMENT_SPEED).getValue()); this.entity.zza = (float) (this.speedMod * entity.getAttribute(Attributes.MOVEMENT_SPEED).getValue());
if (entity instanceof Slime && jumpTicks-- <= 0) { if (entity instanceof Slime && jumpTicks-- <= 0) {
this.jumpTicks = new Random().nextInt(20) + 10; this.jumpTicks = new Random().nextInt(20) + 10;
if (((Slime) entity).isAggressive()) { if (((Slime) entity).isAggressive()) {
this.jumpTicks /= 3; this.jumpTicks /= 3;
} }
((Slime) entity).getJumpControl().jump(); ((Slime) entity).getJumpControl().jump();
} else if (dY >= NMS.getStepHeight(entity.getBukkitEntity()) && dXZ < 0.4D) { return;
if (entity instanceof Mob) { }
((Mob) entity).getJumpControl().jump(); BlockPos pos = entity.blockPosition();
} BlockState bs = entity.level().getBlockState(pos);
entity.setJumping(true); VoxelShape vs = bs.getCollisionShape(entity.level(), pos);
if (dY >= entity.maxUpStep() && dXZ < Math.max(1.0F, entity.getBbWidth()) || !vs.isEmpty()
&& entity.getY() < vs.max(Axis.Y) + pos.getY() && !bs.is(BlockTags.DOORS) && !bs.is(BlockTags.FENCES)) {
NMS.setShouldJump(entity.getBukkitEntity());
} }
} }
} }

View File

@ -306,7 +306,6 @@ import net.minecraft.world.entity.ai.attributes.AttributeMap;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.control.FlyingMoveControl; import net.minecraft.world.entity.ai.control.FlyingMoveControl;
import net.minecraft.world.entity.ai.control.JumpControl;
import net.minecraft.world.entity.ai.control.LookControl; import net.minecraft.world.entity.ai.control.LookControl;
import net.minecraft.world.entity.ai.control.MoveControl; import net.minecraft.world.entity.ai.control.MoveControl;
import net.minecraft.world.entity.ai.goal.GoalSelector; import net.minecraft.world.entity.ai.goal.GoalSelector;
@ -1641,10 +1640,11 @@ public class NMSImpl implements NMSBridge {
Entity handle = getHandle(entity); Entity handle = getHandle(entity);
if (handle == null) if (handle == null)
return; return;
if (handle instanceof Mob) { MobAI ai = MobAI.from(handle);
JumpControl controller = ((Mob) handle).getJumpControl(); if (ai != null) {
controller.jump(); ai.getJumpControl().jump();
} else { }
if (handle instanceof LivingEntity) {
((LivingEntity) handle).setJumping(true); ((LivingEntity) handle).setJumping(true);
} }
} }

View File

@ -2,7 +2,6 @@ package net.citizensnpcs.nms.v1_8_R3.util;
import java.util.Random; import java.util.Random;
import net.citizensnpcs.nms.v1_8_R3.entity.EntityHumanNPC;
import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.NMS;
import net.minecraft.server.v1_8_R3.ControllerMove; import net.minecraft.server.v1_8_R3.ControllerMove;
import net.minecraft.server.v1_8_R3.EntityInsentient; import net.minecraft.server.v1_8_R3.EntityInsentient;
@ -86,12 +85,8 @@ public class PlayerControllerMove extends ControllerMove {
this.h = new Random().nextInt(20) + 10; this.h = new Random().nextInt(20) + 10;
this.h /= 3; this.h /= 3;
((EntityInsentient) this.a).getControllerJump().a(); ((EntityInsentient) this.a).getControllerJump().a();
} else if (dY >= NMS.getStepHeight(a.getBukkitEntity()) && dXZ < 0.4D) { } else if (dY > NMS.getStepHeight(a.getBukkitEntity()) && dXZ < 0.4D) {
if (this.a instanceof EntityHumanNPC) { NMS.setShouldJump(a.getBukkitEntity());
((EntityHumanNPC) this.a).getControllerJump().a();
} else {
((EntityInsentient) this.a).getControllerJump().a();
}
} }
} }