mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Entity Jump API
== AT == public net.minecraft.world.entity.LivingEntity jumping
This commit is contained in:
parent
4e20691d59
commit
0dd8044178
4 changed files with 110 additions and 59 deletions
|
@ -162,18 +162,19 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEquipItem(EquipmentSlot slot, ItemStack oldStack, ItemStack newStack) {
|
public void onEquipItem(EquipmentSlot slot, ItemStack oldStack, ItemStack newStack) {
|
||||||
|
- if (!this.level().isClientSide() && !this.isSpectator()) {
|
||||||
|
- boolean flag = newStack.isEmpty() && oldStack.isEmpty();
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ this.onEquipItem(slot, oldStack, newStack, false);
|
+ this.onEquipItem(slot, oldStack, newStack, false);
|
||||||
+ }
|
+ }
|
||||||
+
|
|
||||||
+ public void onEquipItem(EquipmentSlot enumitemslot, ItemStack itemstack, ItemStack itemstack1, boolean silent) {
|
|
||||||
+ // CraftBukkit end
|
|
||||||
if (!this.level().isClientSide() && !this.isSpectator()) {
|
|
||||||
- boolean flag = newStack.isEmpty() && oldStack.isEmpty();
|
|
||||||
+ boolean flag = itemstack1.isEmpty() && itemstack.isEmpty();
|
|
||||||
|
|
||||||
- if (!flag && !ItemStack.isSameItemSameComponents(oldStack, newStack) && !this.firstTick) {
|
- if (!flag && !ItemStack.isSameItemSameComponents(oldStack, newStack) && !this.firstTick) {
|
||||||
- Equippable equippable = (Equippable) newStack.get(DataComponents.EQUIPPABLE);
|
- Equippable equippable = (Equippable) newStack.get(DataComponents.EQUIPPABLE);
|
||||||
|
+ public void onEquipItem(EquipmentSlot enumitemslot, ItemStack itemstack, ItemStack itemstack1, boolean silent) {
|
||||||
|
+ // CraftBukkit end
|
||||||
|
+ if (!this.level().isClientSide() && !this.isSpectator()) {
|
||||||
|
+ boolean flag = itemstack1.isEmpty() && itemstack.isEmpty();
|
||||||
|
+
|
||||||
+ if (!flag && !ItemStack.isSameItemSameComponents(itemstack, itemstack1) && !this.firstTick) {
|
+ if (!flag && !ItemStack.isSameItemSameComponents(itemstack, itemstack1) && !this.firstTick) {
|
||||||
+ Equippable equippable = (Equippable) itemstack1.get(DataComponents.EQUIPPABLE);
|
+ Equippable equippable = (Equippable) itemstack1.get(DataComponents.EQUIPPABLE);
|
||||||
|
|
||||||
|
@ -265,10 +266,14 @@
|
||||||
boolean flag = scoreboardteam != null && scoreboard.addPlayerToTeam(this.getStringUUID(), scoreboardteam);
|
boolean flag = scoreboardteam != null && scoreboard.addPlayerToTeam(this.getStringUUID(), scoreboardteam);
|
||||||
|
|
||||||
if (!flag) {
|
if (!flag) {
|
||||||
@@ -819,9 +906,32 @@
|
@@ -815,13 +902,36 @@
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (nbt.contains("Brain", 10)) {
|
||||||
|
this.brain = this.makeBrain(new Dynamic(NbtOps.INSTANCE, nbt.get("Brain")));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
+
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ private boolean isTickingEffects = false;
|
+ private boolean isTickingEffects = false;
|
||||||
+ private List<ProcessableEffect> effectsToProcess = Lists.newArrayList();
|
+ private List<ProcessableEffect> effectsToProcess = Lists.newArrayList();
|
||||||
|
@ -282,15 +287,15 @@
|
||||||
+ private ProcessableEffect(MobEffectInstance effect, EntityPotionEffectEvent.Cause cause) {
|
+ private ProcessableEffect(MobEffectInstance effect, EntityPotionEffectEvent.Cause cause) {
|
||||||
+ this.effect = effect;
|
+ this.effect = effect;
|
||||||
+ this.cause = cause;
|
+ this.cause = cause;
|
||||||
+ }
|
}
|
||||||
+
|
|
||||||
+ private ProcessableEffect(Holder<MobEffect> type, EntityPotionEffectEvent.Cause cause) {
|
+ private ProcessableEffect(Holder<MobEffect> type, EntityPotionEffectEvent.Cause cause) {
|
||||||
+ this.type = type;
|
+ this.type = type;
|
||||||
+ this.cause = cause;
|
+ this.cause = cause;
|
||||||
+ }
|
+ }
|
||||||
+ }
|
}
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
+
|
|
||||||
protected void tickEffects() {
|
protected void tickEffects() {
|
||||||
Iterator<Holder<MobEffect>> iterator = this.activeEffects.keySet().iterator();
|
Iterator<Holder<MobEffect>> iterator = this.activeEffects.keySet().iterator();
|
||||||
|
|
||||||
|
@ -454,8 +459,8 @@
|
||||||
public MobEffectInstance removeEffectNoUpdate(Holder<MobEffect> effect) {
|
public MobEffectInstance removeEffectNoUpdate(Holder<MobEffect> effect) {
|
||||||
- return (MobEffectInstance) this.activeEffects.remove(effect);
|
- return (MobEffectInstance) this.activeEffects.remove(effect);
|
||||||
+ return this.removeEffectNoUpdate(effect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN);
|
+ return this.removeEffectNoUpdate(effect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN);
|
||||||
}
|
+ }
|
||||||
|
+
|
||||||
+ @Nullable
|
+ @Nullable
|
||||||
+ public MobEffectInstance removeEffectNoUpdate(Holder<MobEffect> holder, EntityPotionEffectEvent.Cause cause) {
|
+ public MobEffectInstance removeEffectNoUpdate(Holder<MobEffect> holder, EntityPotionEffectEvent.Cause cause) {
|
||||||
+ if (this.isTickingEffects) {
|
+ if (this.isTickingEffects) {
|
||||||
|
@ -474,8 +479,8 @@
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ return (MobEffectInstance) this.activeEffects.remove(holder);
|
+ return (MobEffectInstance) this.activeEffects.remove(holder);
|
||||||
+ }
|
}
|
||||||
+
|
|
||||||
public boolean removeEffect(Holder<MobEffect> effect) {
|
public boolean removeEffect(Holder<MobEffect> effect) {
|
||||||
- MobEffectInstance mobeffect = this.removeEffectNoUpdate(effect);
|
- MobEffectInstance mobeffect = this.removeEffectNoUpdate(effect);
|
||||||
+ return this.removeEffect(effect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN);
|
+ return this.removeEffect(effect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN);
|
||||||
|
@ -1227,26 +1232,27 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public CombatTracker getCombatTracker() {
|
public CombatTracker getCombatTracker() {
|
||||||
@@ -1935,8 +2487,18 @@
|
@@ -1935,9 +2487,19 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setArrowCount(int stuckArrowCount) {
|
public final void setArrowCount(int stuckArrowCount) {
|
||||||
- this.entityData.set(LivingEntity.DATA_ARROW_COUNT_ID, stuckArrowCount);
|
- this.entityData.set(LivingEntity.DATA_ARROW_COUNT_ID, stuckArrowCount);
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ this.setArrowCount(stuckArrowCount, false);
|
+ this.setArrowCount(stuckArrowCount, false);
|
||||||
+ }
|
}
|
||||||
+
|
|
||||||
+ public final void setArrowCount(int i, boolean flag) {
|
+ public final void setArrowCount(int i, boolean flag) {
|
||||||
+ ArrowBodyCountChangeEvent event = CraftEventFactory.callArrowBodyCountChangeEvent(this, this.getArrowCount(), i, flag);
|
+ ArrowBodyCountChangeEvent event = CraftEventFactory.callArrowBodyCountChangeEvent(this, this.getArrowCount(), i, flag);
|
||||||
+ if (event.isCancelled()) {
|
+ if (event.isCancelled()) {
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
+ this.entityData.set(LivingEntity.DATA_ARROW_COUNT_ID, event.getNewAmount());
|
+ this.entityData.set(LivingEntity.DATA_ARROW_COUNT_ID, event.getNewAmount());
|
||||||
}
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
+
|
||||||
public final int getStingerCount() {
|
public final int getStingerCount() {
|
||||||
return (Integer) this.entityData.get(LivingEntity.DATA_STINGER_COUNT_ID);
|
return (Integer) this.entityData.get(LivingEntity.DATA_STINGER_COUNT_ID);
|
||||||
|
}
|
||||||
@@ -1999,7 +2561,7 @@
|
@@ -1999,7 +2561,7 @@
|
||||||
this.playSound(soundeffect, this.getSoundVolume(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
|
this.playSound(soundeffect, this.getSoundVolume(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
|
||||||
}
|
}
|
||||||
|
@ -1256,19 +1262,19 @@
|
||||||
this.setHealth(0.0F);
|
this.setHealth(0.0F);
|
||||||
this.die(this.damageSources().generic());
|
this.die(this.damageSources().generic());
|
||||||
}
|
}
|
||||||
@@ -2181,6 +2743,12 @@
|
@@ -2182,6 +2744,12 @@
|
||||||
public abstract Iterable<ItemStack> getArmorSlots();
|
|
||||||
|
|
||||||
public abstract ItemStack getItemBySlot(EquipmentSlot slot);
|
public abstract ItemStack getItemBySlot(EquipmentSlot slot);
|
||||||
+
|
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ public void setItemSlot(EquipmentSlot enumitemslot, ItemStack itemstack, boolean silent) {
|
+ public void setItemSlot(EquipmentSlot enumitemslot, ItemStack itemstack, boolean silent) {
|
||||||
+ this.setItemSlot(enumitemslot, itemstack);
|
+ this.setItemSlot(enumitemslot, itemstack);
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
+
|
||||||
public abstract void setItemSlot(EquipmentSlot slot, ItemStack stack);
|
public abstract void setItemSlot(EquipmentSlot slot, ItemStack stack);
|
||||||
|
|
||||||
|
public Iterable<ItemStack> getHandSlots() {
|
||||||
@@ -2494,7 +3062,7 @@
|
@@ -2494,7 +3062,7 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1351,7 +1357,18 @@
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
map = Maps.newEnumMap(EquipmentSlot.class);
|
map = Maps.newEnumMap(EquipmentSlot.class);
|
||||||
}
|
}
|
||||||
@@ -3000,7 +3575,7 @@
|
@@ -2974,8 +3549,10 @@
|
||||||
|
} else if (this.isInLava() && (!this.onGround() || d3 > d4)) {
|
||||||
|
this.jumpInLiquid(FluidTags.LAVA);
|
||||||
|
} else if ((this.onGround() || flag && d3 <= d4) && this.noJumpDelay == 0) {
|
||||||
|
+ if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper - Entity Jump API
|
||||||
|
this.jumpFromGround();
|
||||||
|
this.noJumpDelay = 10;
|
||||||
|
+ } else { this.setJumping(false); } // Paper - Entity Jump API; setJumping(false) stops a potential loop
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.noJumpDelay = 0;
|
||||||
|
@@ -3000,7 +3577,7 @@
|
||||||
{
|
{
|
||||||
LivingEntity entityliving = this.getControllingPassenger();
|
LivingEntity entityliving = this.getControllingPassenger();
|
||||||
|
|
||||||
|
@ -1360,7 +1377,7 @@
|
||||||
if (this.isAlive()) {
|
if (this.isAlive()) {
|
||||||
this.travelRidden(entityhuman, vec3d1);
|
this.travelRidden(entityhuman, vec3d1);
|
||||||
break label112;
|
break label112;
|
||||||
@@ -3063,6 +3638,7 @@
|
@@ -3063,6 +3640,7 @@
|
||||||
this.checkSlowFallDistance();
|
this.checkSlowFallDistance();
|
||||||
if (!this.level().isClientSide) {
|
if (!this.level().isClientSide) {
|
||||||
if (!this.canGlide()) {
|
if (!this.canGlide()) {
|
||||||
|
@ -1368,7 +1385,7 @@
|
||||||
this.setSharedFlag(7, false);
|
this.setSharedFlag(7, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -3113,7 +3689,7 @@
|
@@ -3113,7 +3691,7 @@
|
||||||
Level world = this.level();
|
Level world = this.level();
|
||||||
|
|
||||||
if (!(world instanceof ServerLevel worldserver)) {
|
if (!(world instanceof ServerLevel worldserver)) {
|
||||||
|
@ -1377,7 +1394,7 @@
|
||||||
} else {
|
} else {
|
||||||
List list = this.level().getEntities((Entity) this, this.getBoundingBox(), EntitySelector.pushableBy(this));
|
List list = this.level().getEntities((Entity) this, this.getBoundingBox(), EntitySelector.pushableBy(this));
|
||||||
|
|
||||||
@@ -3138,10 +3714,12 @@
|
@@ -3138,10 +3716,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator iterator1 = list.iterator();
|
Iterator iterator1 = list.iterator();
|
||||||
|
@ -1392,7 +1409,7 @@
|
||||||
this.doPush(entity1);
|
this.doPush(entity1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3190,9 +3768,15 @@
|
@@ -3190,9 +3770,15 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopRiding() {
|
public void stopRiding() {
|
||||||
|
@ -1409,7 +1426,7 @@
|
||||||
if (entity != null && entity != this.getVehicle() && !this.level().isClientSide) {
|
if (entity != null && entity != this.getVehicle() && !this.level().isClientSide) {
|
||||||
this.dismountVehicle(entity);
|
this.dismountVehicle(entity);
|
||||||
}
|
}
|
||||||
@@ -3305,15 +3889,22 @@
|
@@ -3305,15 +3891,22 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPickable() {
|
public boolean isPickable() {
|
||||||
|
@ -1434,7 +1451,7 @@
|
||||||
public float getYHeadRot() {
|
public float getYHeadRot() {
|
||||||
return this.yHeadRot;
|
return this.yHeadRot;
|
||||||
}
|
}
|
||||||
@@ -3342,7 +3933,7 @@
|
@@ -3342,7 +3935,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setAbsorptionAmount(float absorptionAmount) {
|
public final void setAbsorptionAmount(float absorptionAmount) {
|
||||||
|
@ -1443,7 +1460,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void internalSetAbsorptionAmount(float absorptionAmount) {
|
protected void internalSetAbsorptionAmount(float absorptionAmount) {
|
||||||
@@ -3410,9 +4001,14 @@
|
@@ -3410,9 +4003,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startUsingItem(InteractionHand hand) {
|
public void startUsingItem(InteractionHand hand) {
|
||||||
|
@ -1459,7 +1476,7 @@
|
||||||
this.useItem = itemstack;
|
this.useItem = itemstack;
|
||||||
this.useItemRemaining = itemstack.getUseDuration(this);
|
this.useItemRemaining = itemstack.getUseDuration(this);
|
||||||
if (!this.level().isClientSide) {
|
if (!this.level().isClientSide) {
|
||||||
@@ -3483,13 +4079,49 @@
|
@@ -3483,13 +4081,49 @@
|
||||||
this.releaseUsingItem();
|
this.releaseUsingItem();
|
||||||
} else {
|
} else {
|
||||||
if (!this.useItem.isEmpty() && this.isUsingItem()) {
|
if (!this.useItem.isEmpty() && this.isUsingItem()) {
|
||||||
|
@ -1473,7 +1490,7 @@
|
||||||
+ org.bukkit.inventory.EquipmentSlot hand = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(enumhand);
|
+ org.bukkit.inventory.EquipmentSlot hand = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(enumhand);
|
||||||
+ event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem, hand); // Paper
|
+ event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem, hand); // Paper
|
||||||
+ this.level().getCraftServer().getPluginManager().callEvent(event);
|
+ this.level().getCraftServer().getPluginManager().callEvent(event);
|
||||||
+
|
|
||||||
+ if (event.isCancelled()) {
|
+ if (event.isCancelled()) {
|
||||||
+ // Update client
|
+ // Update client
|
||||||
+ Consumable consumable = this.useItem.get(DataComponents.CONSUMABLE);
|
+ Consumable consumable = this.useItem.get(DataComponents.CONSUMABLE);
|
||||||
|
@ -1484,7 +1501,7 @@
|
||||||
+ entityPlayer.getBukkitEntity().updateScaledHealth();
|
+ entityPlayer.getBukkitEntity().updateScaledHealth();
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
+ itemstack = (craftItem.equals(event.getItem())) ? this.useItem.finishUsingItem(this.level(), this) : CraftItemStack.asNMSCopy(event.getItem()).finishUsingItem(this.level(), this);
|
+ itemstack = (craftItem.equals(event.getItem())) ? this.useItem.finishUsingItem(this.level(), this) : CraftItemStack.asNMSCopy(event.getItem()).finishUsingItem(this.level(), this);
|
||||||
+ } else {
|
+ } else {
|
||||||
+ itemstack = this.useItem.finishUsingItem(this.level(), this);
|
+ itemstack = this.useItem.finishUsingItem(this.level(), this);
|
||||||
|
@ -1510,7 +1527,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3544,12 +4176,69 @@
|
@@ -3544,12 +4178,69 @@
|
||||||
if (this.isUsingItem() && !this.useItem.isEmpty()) {
|
if (this.isUsingItem() && !this.useItem.isEmpty()) {
|
||||||
Item item = this.useItem.getItem();
|
Item item = this.useItem.getItem();
|
||||||
|
|
||||||
|
@ -1518,14 +1535,14 @@
|
||||||
+ return item.getUseAnimation(this.useItem) != ItemUseAnimation.BLOCK ? null : (item.getUseDuration(this.useItem, this) - this.useItemRemaining < getShieldBlockingDelay() ? null : this.useItem); // Paper - Make shield blocking delay configurable
|
+ return item.getUseAnimation(this.useItem) != ItemUseAnimation.BLOCK ? null : (item.getUseDuration(this.useItem, this) - this.useItemRemaining < getShieldBlockingDelay() ? null : this.useItem); // Paper - Make shield blocking delay configurable
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
+ }
|
}
|
||||||
+ }
|
}
|
||||||
+
|
|
||||||
+ // Paper start - Make shield blocking delay configurable
|
+ // Paper start - Make shield blocking delay configurable
|
||||||
+ public HitResult getRayTrace(int maxDistance, ClipContext.Fluid fluidCollisionOption) {
|
+ public HitResult getRayTrace(int maxDistance, ClipContext.Fluid fluidCollisionOption) {
|
||||||
+ if (maxDistance < 1 || maxDistance > 120) {
|
+ if (maxDistance < 1 || maxDistance > 120) {
|
||||||
+ throw new IllegalArgumentException("maxDistance must be between 1-120");
|
+ throw new IllegalArgumentException("maxDistance must be between 1-120");
|
||||||
}
|
+ }
|
||||||
+
|
+
|
||||||
+ Vec3 start = new Vec3(getX(), getY() + getEyeHeight(), getZ());
|
+ Vec3 start = new Vec3(getX(), getY() + getEyeHeight(), getZ());
|
||||||
+ org.bukkit.util.Vector dir = getBukkitEntity().getLocation().getDirection().multiply(maxDistance);
|
+ org.bukkit.util.Vector dir = getBukkitEntity().getLocation().getDirection().multiply(maxDistance);
|
||||||
|
@ -1533,8 +1550,8 @@
|
||||||
+ ClipContext raytrace = new ClipContext(start, end, ClipContext.Block.OUTLINE, fluidCollisionOption, this);
|
+ ClipContext raytrace = new ClipContext(start, end, ClipContext.Block.OUTLINE, fluidCollisionOption, this);
|
||||||
+
|
+
|
||||||
+ return this.level().clip(raytrace);
|
+ return this.level().clip(raytrace);
|
||||||
}
|
+ }
|
||||||
|
+
|
||||||
+ public @Nullable net.minecraft.world.phys.EntityHitResult getTargetEntity(int maxDistance) {
|
+ public @Nullable net.minecraft.world.phys.EntityHitResult getTargetEntity(int maxDistance) {
|
||||||
+ if (maxDistance < 1 || maxDistance > 120) {
|
+ if (maxDistance < 1 || maxDistance > 120) {
|
||||||
+ throw new IllegalArgumentException("maxDistance must be between 1-120");
|
+ throw new IllegalArgumentException("maxDistance must be between 1-120");
|
||||||
|
@ -1581,7 +1598,7 @@
|
||||||
public boolean isSuppressingSlidingDownLadder() {
|
public boolean isSuppressingSlidingDownLadder() {
|
||||||
return this.isShiftKeyDown();
|
return this.isShiftKeyDown();
|
||||||
}
|
}
|
||||||
@@ -3568,12 +4257,18 @@
|
@@ -3568,12 +4259,18 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean randomTeleport(double x, double y, double z, boolean particleEffects) {
|
public boolean randomTeleport(double x, double y, double z, boolean particleEffects) {
|
||||||
|
@ -1602,7 +1619,7 @@
|
||||||
Level world = this.level();
|
Level world = this.level();
|
||||||
|
|
||||||
if (world.hasChunkAt(blockposition)) {
|
if (world.hasChunkAt(blockposition)) {
|
||||||
@@ -3592,18 +4287,43 @@
|
@@ -3592,18 +4289,43 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag2) {
|
if (flag2) {
|
||||||
|
@ -1614,7 +1631,7 @@
|
||||||
+ this.setPos(d0, d6, d2);
|
+ this.setPos(d0, d6, d2);
|
||||||
if (world.noCollision((Entity) this) && !world.containsAnyLiquid(this.getBoundingBox())) {
|
if (world.noCollision((Entity) this) && !world.containsAnyLiquid(this.getBoundingBox())) {
|
||||||
flag1 = true;
|
flag1 = true;
|
||||||
}
|
+ }
|
||||||
+ // now revert and call event if the teleport place is valid
|
+ // now revert and call event if the teleport place is valid
|
||||||
+ this.setPos(d3, d4, d5);
|
+ this.setPos(d3, d4, d5);
|
||||||
+
|
+
|
||||||
|
@ -1634,7 +1651,7 @@
|
||||||
+ return Optional.empty();
|
+ return Optional.empty();
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ }
|
}
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1650,7 +1667,7 @@
|
||||||
world.broadcastEntityEvent(this, (byte) 46);
|
world.broadcastEntityEvent(this, (byte) 46);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3613,7 +4333,7 @@
|
@@ -3613,7 +4335,7 @@
|
||||||
entitycreature.getNavigation().stop();
|
entitycreature.getNavigation().stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1659,7 +1676,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3706,7 +4426,7 @@
|
@@ -3706,7 +4428,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopSleeping() {
|
public void stopSleeping() {
|
||||||
|
@ -1668,7 +1685,7 @@
|
||||||
Level world = this.level();
|
Level world = this.level();
|
||||||
|
|
||||||
java.util.Objects.requireNonNull(world);
|
java.util.Objects.requireNonNull(world);
|
||||||
@@ -3718,9 +4438,9 @@
|
@@ -3718,9 +4440,9 @@
|
||||||
|
|
||||||
this.level().setBlock(blockposition, (BlockState) iblockdata.setValue(BedBlock.OCCUPIED, false), 3);
|
this.level().setBlock(blockposition, (BlockState) iblockdata.setValue(BedBlock.OCCUPIED, false), 3);
|
||||||
Vec3 vec3d = (Vec3) BedBlock.findStandUpPosition(this.getType(), this.level(), blockposition, enumdirection, this.getYRot()).orElseGet(() -> {
|
Vec3 vec3d = (Vec3) BedBlock.findStandUpPosition(this.getType(), this.level(), blockposition, enumdirection, this.getYRot()).orElseGet(() -> {
|
||||||
|
@ -1680,7 +1697,7 @@
|
||||||
});
|
});
|
||||||
Vec3 vec3d1 = Vec3.atBottomCenterOf(blockposition).subtract(vec3d).normalize();
|
Vec3 vec3d1 = Vec3.atBottomCenterOf(blockposition).subtract(vec3d).normalize();
|
||||||
float f = (float) Mth.wrapDegrees(Mth.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
|
float f = (float) Mth.wrapDegrees(Mth.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
|
||||||
@@ -3740,7 +4460,7 @@
|
@@ -3740,7 +4462,7 @@
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Direction getBedOrientation() {
|
public Direction getBedOrientation() {
|
||||||
|
@ -1689,7 +1706,7 @@
|
||||||
|
|
||||||
return blockposition != null ? BedBlock.getBedOrientation(this.level(), blockposition) : null;
|
return blockposition != null ? BedBlock.getBedOrientation(this.level(), blockposition) : null;
|
||||||
}
|
}
|
||||||
@@ -3905,7 +4625,7 @@
|
@@ -3905,7 +4627,7 @@
|
||||||
public float maxUpStep() {
|
public float maxUpStep() {
|
||||||
float f = (float) this.getAttributeValue(Attributes.STEP_HEIGHT);
|
float f = (float) this.getAttributeValue(Attributes.STEP_HEIGHT);
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,17 @@
|
||||||
|
|
||||||
public class Panda extends Animal {
|
public class Panda extends Animal {
|
||||||
|
|
||||||
@@ -541,14 +546,14 @@
|
@@ -525,7 +530,9 @@
|
||||||
|
Panda entitypanda = (Panda) iterator.next();
|
||||||
|
|
||||||
|
if (!entitypanda.isBaby() && entitypanda.onGround() && !entitypanda.isInWater() && entitypanda.canPerformAction()) {
|
||||||
|
+ if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper - Entity Jump API
|
||||||
|
entitypanda.jumpFromGround();
|
||||||
|
+ } else { this.setJumping(false); } // Paper - Entity Jump API; setJumping(false) stops a potential loop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -541,14 +548,14 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void pickUpItem(ServerLevel world, ItemEntity itemEntity) {
|
protected void pickUpItem(ServerLevel world, ItemEntity itemEntity) {
|
||||||
|
@ -29,7 +39,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -772,7 +777,7 @@
|
@@ -772,7 +779,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Panda.Gene byName(String name) {
|
public static Panda.Gene byName(String name) {
|
||||||
|
@ -38,7 +48,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Panda.Gene getRandom(RandomSource random) {
|
public static Panda.Gene getRandom(RandomSource random) {
|
||||||
@@ -876,10 +881,10 @@
|
@@ -876,10 +883,10 @@
|
||||||
private final Panda panda;
|
private final Panda panda;
|
||||||
|
|
||||||
public PandaAvoidGoal(Panda panda, Class<T> fleeFromType, float distance, double slowSpeed, double fastSpeed) {
|
public PandaAvoidGoal(Panda panda, Class<T> fleeFromType, float distance, double slowSpeed, double fastSpeed) {
|
||||||
|
@ -52,7 +62,7 @@
|
||||||
this.panda = panda;
|
this.panda = panda;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1116,7 +1121,7 @@
|
@@ -1116,7 +1123,7 @@
|
||||||
@Override
|
@Override
|
||||||
protected void alertOther(Mob mob, LivingEntity target) {
|
protected void alertOther(Mob mob, LivingEntity target) {
|
||||||
if (mob instanceof Panda && mob.isAggressive()) {
|
if (mob instanceof Panda && mob.isAggressive()) {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
public class Ravager extends Raider {
|
public class Ravager extends Raider {
|
||||||
|
|
||||||
@@ -158,6 +161,11 @@
|
@@ -158,12 +161,19 @@
|
||||||
Block block = iblockdata.getBlock();
|
Block block = iblockdata.getBlock();
|
||||||
|
|
||||||
if (block instanceof LeavesBlock) {
|
if (block instanceof LeavesBlock) {
|
||||||
|
@ -22,7 +22,15 @@
|
||||||
flag = worldserver.destroyBlock(blockposition, true, this) || flag;
|
flag = worldserver.destroyBlock(blockposition, true, this) || flag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -281,7 +289,7 @@
|
|
||||||
|
if (!flag && this.onGround()) {
|
||||||
|
+ if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper - Entity Jump API
|
||||||
|
this.jumpFromGround();
|
||||||
|
+ } else { this.setJumping(false); } // Paper - Entity Jump API; setJumping(false) stops a potential loop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -281,7 +291,7 @@
|
||||||
double d1 = entity.getZ() - this.getZ();
|
double d1 = entity.getZ() - this.getZ();
|
||||||
double d2 = Math.max(d0 * d0 + d1 * d1, 0.001D);
|
double d2 = Math.max(d0 * d0 + d1 * d1, 0.001D);
|
||||||
|
|
||||||
|
|
|
@ -993,4 +993,20 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||||
return org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(this.getHandle().getUsedItemHand());
|
return org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(this.getHandle().getUsedItemHand());
|
||||||
}
|
}
|
||||||
// Paper end - active item API
|
// Paper end - active item API
|
||||||
|
|
||||||
|
// Paper start - entity jump API
|
||||||
|
@Override
|
||||||
|
public boolean isJumping() {
|
||||||
|
return getHandle().jumping;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setJumping(boolean jumping) {
|
||||||
|
getHandle().setJumping(jumping);
|
||||||
|
if (jumping && getHandle() instanceof Mob) {
|
||||||
|
// this is needed to actually make a mob jump
|
||||||
|
((Mob) getHandle()).getJumpControl().jump();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Paper end - entity jump API
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue