Disable Scoreboards for non players by default

Entities collision is checking for scoreboards setting.
This is very heavy to do map lookups for every collision to check
this setting.

So avoid looking up scoreboards and short circuit to the "not on a team"
logic which is most likely to be true.
This commit is contained in:
Aikar
2016-03-08 23:25:45 -05:00
parent 68979dd492
commit 5764c71185
2 changed files with 118 additions and 102 deletions

View File

@@ -294,23 +294,22 @@
this.setYRot(yaw % 360.0F); this.setYRot(yaw % 360.0F);
this.setXRot(pitch % 360.0F); this.setXRot(pitch % 360.0F);
} }
@@ -460,7 +635,16 @@ @@ -462,6 +637,15 @@
public void tick() {
this.baseTick(); this.baseTick();
+ } }
+
+ // CraftBukkit start + // CraftBukkit start
+ public void postTick() { + public void postTick() {
+ // No clean way to break out of ticking once the entity has been copied to a new world, so instead we move the portalling later in the tick cycle + // No clean way to break out of ticking once the entity has been copied to a new world, so instead we move the portalling later in the tick cycle
+ if (!(this instanceof ServerPlayer)) { + if (!(this instanceof ServerPlayer)) {
+ this.handlePortal(); + this.handlePortal();
+ } + }
} + }
+ // CraftBukkit end + // CraftBukkit end
+
public void baseTick() { public void baseTick() {
ProfilerFiller gameprofilerfiller = Profiler.get(); ProfilerFiller gameprofilerfiller = Profiler.get();
@@ -475,7 +659,7 @@ @@ -475,7 +659,7 @@
--this.boardingCooldown; --this.boardingCooldown;
} }
@@ -388,15 +387,15 @@
} }
} }
@@ -587,9 +796,25 @@ @@ -587,7 +796,23 @@
} }
public final void igniteForSeconds(float seconds) { public final void igniteForSeconds(float seconds) {
- this.igniteForTicks(Mth.floor(seconds * 20.0F)); - this.igniteForTicks(Mth.floor(seconds * 20.0F));
+ // CraftBukkit start + // CraftBukkit start
+ this.igniteForSeconds(seconds, true); + this.igniteForSeconds(seconds, true);
} + }
+
+ public final void igniteForSeconds(float f, boolean callEvent) { + public final void igniteForSeconds(float f, boolean callEvent) {
+ if (callEvent) { + if (callEvent) {
+ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), f); + EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), f);
@@ -410,11 +409,9 @@
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ this.igniteForTicks(Mth.floor(f * 20.0F)); + this.igniteForTicks(Mth.floor(f * 20.0F));
+ } }
+
public void igniteForTicks(int ticks) { public void igniteForTicks(int ticks) {
if (this.remainingFireTicks < ticks) {
this.setRemainingFireTicks(ticks);
@@ -610,7 +835,7 @@ @@ -610,7 +835,7 @@
} }
@@ -455,7 +452,7 @@
if (!this.level().isClientSide() || this.isControlledByLocalInstance()) { if (!this.level().isClientSide() || this.isControlledByLocalInstance()) {
Entity.MovementEmission entity_movementemission = this.getMovementEmission(); Entity.MovementEmission entity_movementemission = this.getMovementEmission();
@@ -1131,7 +1378,21 @@ @@ -1131,8 +1378,22 @@
protected SoundEvent getSwimHighSpeedSplashSound() { protected SoundEvent getSwimHighSpeedSplashSound() {
return SoundEvents.GENERIC_SPLASH; return SoundEvents.GENERIC_SPLASH;
@@ -468,15 +465,16 @@
+ +
+ public SoundEvent getSwimSplashSound0() { + public SoundEvent getSwimSplashSound0() {
+ return this.getSwimSplashSound(); + return this.getSwimSplashSound();
+ } }
+
+ public SoundEvent getSwimHighSpeedSplashSound0() { + public SoundEvent getSwimHighSpeedSplashSound0() {
+ return this.getSwimHighSpeedSplashSound(); + return this.getSwimHighSpeedSplashSound();
} + }
+ // CraftBukkit end + // CraftBukkit end
+
public void recordMovementThroughBlocks(Vec3 oldPos, Vec3 newPos) { public void recordMovementThroughBlocks(Vec3 oldPos, Vec3 newPos) {
this.movementThisTick.add(new Entity.Movement(oldPos, newPos)); this.movementThisTick.add(new Entity.Movement(oldPos, newPos));
}
@@ -1609,6 +1870,7 @@ @@ -1609,6 +1870,7 @@
this.yo = y; this.yo = y;
this.zo = d4; this.zo = d4;
@@ -485,19 +483,20 @@
} }
public void moveTo(Vec3 pos) { public void moveTo(Vec3 pos) {
@@ -1861,6 +2123,12 @@ @@ -1859,7 +2121,13 @@
return false;
}
public boolean isPushable() {
return false;
+ }
+
+ // CraftBukkit start - collidable API + // CraftBukkit start - collidable API
+ public boolean canCollideWithBukkit(Entity entity) { + public boolean canCollideWithBukkit(Entity entity) {
+ return this.isPushable(); + return this.isPushable();
+ } }
+ // CraftBukkit end + // CraftBukkit end
+
public void awardKillScore(Entity entityKilled, DamageSource damageSource) { public void awardKillScore(Entity entityKilled, DamageSource damageSource) {
if (entityKilled instanceof ServerPlayer) { if (entityKilled instanceof ServerPlayer) {
CriteriaTriggers.ENTITY_KILLED_PLAYER.trigger((ServerPlayer) entityKilled, this, damageSource);
@@ -1889,16 +2157,22 @@ @@ -1889,16 +2157,22 @@
} }
@@ -691,10 +690,11 @@
} catch (Throwable throwable) { } catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Entity being saved"); CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Entity being saved");
@@ -2080,6 +2412,64 @@ @@ -2079,7 +2411,65 @@
}
} else { } else {
throw new IllegalStateException("Entity has invalid position"); throw new IllegalStateException("Entity has invalid position");
} + }
+ +
+ // CraftBukkit start + // CraftBukkit start
+ // Spigot start + // Spigot start
@@ -730,7 +730,7 @@
+ } + }
+ +
+ ((ServerPlayer) this).setLevel(bworld == null ? null : ((CraftWorld) bworld).getHandle()); + ((ServerPlayer) this).setLevel(bworld == null ? null : ((CraftWorld) bworld).getHandle());
+ } }
+ this.getBukkitEntity().readBukkitValues(nbt); + this.getBukkitEntity().readBukkitValues(nbt);
+ if (nbt.contains("Bukkit.invisible")) { + if (nbt.contains("Bukkit.invisible")) {
+ boolean bukkitInvisible = nbt.getBoolean("Bukkit.invisible"); + boolean bukkitInvisible = nbt.getBoolean("Bukkit.invisible");
@@ -978,7 +978,15 @@
this.setSharedFlag(4, swimming); this.setSharedFlag(4, swimming);
} }
@@ -2624,8 +3103,12 @@ @@ -2609,6 +3088,7 @@
@Nullable
public PlayerTeam getTeam() {
+ if (!this.level().paperConfig().scoreboards.allowNonPlayerEntitiesOnScoreboards && !(this instanceof Player)) { return null; } // Paper - Perf: Disable Scoreboards for non players by default
return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName());
}
@@ -2624,8 +3104,12 @@
return this.getTeam() != null ? this.getTeam().isAlliedTo(team) : false; return this.getTeam() != null ? this.getTeam().isAlliedTo(team) : false;
} }
@@ -992,7 +1000,7 @@
} }
public boolean getSharedFlag(int index) { public boolean getSharedFlag(int index) {
@@ -2644,7 +3127,7 @@ @@ -2644,7 +3128,7 @@
} }
public int getMaxAirSupply() { public int getMaxAirSupply() {
@@ -1001,7 +1009,7 @@
} }
public int getAirSupply() { public int getAirSupply() {
@@ -2652,7 +3135,18 @@ @@ -2652,7 +3136,18 @@
} }
public void setAirSupply(int air) { public void setAirSupply(int air) {
@@ -1021,7 +1029,7 @@
} }
public int getTicksFrozen() { public int getTicksFrozen() {
@@ -2679,11 +3173,40 @@ @@ -2679,11 +3174,40 @@
public void thunderHit(ServerLevel world, LightningBolt lightning) { public void thunderHit(ServerLevel world, LightningBolt lightning) {
this.setRemainingFireTicks(this.remainingFireTicks + 1); this.setRemainingFireTicks(this.remainingFireTicks + 1);
@@ -1064,7 +1072,7 @@
} }
public void onAboveBubbleCol(boolean drag) { public void onAboveBubbleCol(boolean drag) {
@@ -2713,7 +3236,7 @@ @@ -2713,7 +3237,7 @@
this.resetFallDistance(); this.resetFallDistance();
} }
@@ -1073,7 +1081,7 @@
return true; return true;
} }
@@ -2852,6 +3375,18 @@ @@ -2852,6 +3376,18 @@
if (world instanceof ServerLevel worldserver) { if (world instanceof ServerLevel worldserver) {
if (!this.isRemoved()) { if (!this.isRemoved()) {
@@ -1092,7 +1100,7 @@
ServerLevel worldserver1 = teleportTarget.newLevel(); ServerLevel worldserver1 = teleportTarget.newLevel();
boolean flag = worldserver1.dimension() != worldserver.dimension(); boolean flag = worldserver1.dimension() != worldserver.dimension();
@@ -2920,8 +3455,12 @@ @@ -2920,8 +3456,12 @@
} else { } else {
entity.restoreFrom(this); entity.restoreFrom(this);
this.removeAfterChangingDimensions(); this.removeAfterChangingDimensions();
@@ -1106,7 +1114,7 @@
Iterator iterator1 = list1.iterator(); Iterator iterator1 = list1.iterator();
while (iterator1.hasNext()) { while (iterator1.hasNext()) {
@@ -2947,7 +3486,7 @@ @@ -2947,7 +3487,7 @@
} }
private void sendTeleportTransitionToRidingPlayers(TeleportTransition teleportTarget) { private void sendTeleportTransitionToRidingPlayers(TeleportTransition teleportTarget) {
@@ -1115,7 +1123,7 @@
Iterator iterator = this.getIndirectPassengers().iterator(); Iterator iterator = this.getIndirectPassengers().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
@@ -2995,8 +3534,9 @@ @@ -2995,8 +3535,9 @@
} }
protected void removeAfterChangingDimensions() { protected void removeAfterChangingDimensions() {
@@ -1126,7 +1134,7 @@
leashable.removeLeash(); leashable.removeLeash();
} }
@@ -3006,6 +3546,20 @@ @@ -3006,6 +3547,20 @@
return PortalShape.getRelativePosition(portalRect, portalAxis, this.position(), this.getDimensions(this.getPose())); return PortalShape.getRelativePosition(portalRect, portalAxis, this.position(), this.getDimensions(this.getPose()));
} }
@@ -1147,7 +1155,7 @@
public boolean canUsePortal(boolean allowVehicles) { public boolean canUsePortal(boolean allowVehicles) {
return (allowVehicles || !this.isPassenger()) && this.isAlive(); return (allowVehicles || !this.isPassenger()) && this.isAlive();
} }
@@ -3134,10 +3688,16 @@ @@ -3134,10 +3689,16 @@
return (Boolean) this.entityData.get(Entity.DATA_CUSTOM_NAME_VISIBLE); return (Boolean) this.entityData.get(Entity.DATA_CUSTOM_NAME_VISIBLE);
} }
@@ -1167,7 +1175,7 @@
return entity != null; return entity != null;
} }
@@ -3187,7 +3747,7 @@ @@ -3187,7 +3748,7 @@
/** @deprecated */ /** @deprecated */
@Deprecated @Deprecated
protected void fixupDimensions() { protected void fixupDimensions() {
@@ -1176,7 +1184,7 @@
EntityDimensions entitysize = this.getDimensions(entitypose); EntityDimensions entitysize = this.getDimensions(entitypose);
this.dimensions = entitysize; this.dimensions = entitysize;
@@ -3196,7 +3756,7 @@ @@ -3196,7 +3757,7 @@
public void refreshDimensions() { public void refreshDimensions() {
EntityDimensions entitysize = this.dimensions; EntityDimensions entitysize = this.dimensions;
@@ -1185,7 +1193,7 @@
EntityDimensions entitysize1 = this.getDimensions(entitypose); EntityDimensions entitysize1 = this.getDimensions(entitypose);
this.dimensions = entitysize1; this.dimensions = entitysize1;
@@ -3258,10 +3818,29 @@ @@ -3258,10 +3819,29 @@
} }
public final void setBoundingBox(AABB boundingBox) { public final void setBoundingBox(AABB boundingBox) {
@@ -1217,7 +1225,7 @@
return this.getDimensions(pose).eyeHeight(); return this.getDimensions(pose).eyeHeight();
} }
@@ -3335,7 +3914,7 @@ @@ -3335,7 +3915,7 @@
} }
@Nullable @Nullable
@@ -1226,7 +1234,7 @@
return null; return null;
} }
@@ -3435,7 +4014,7 @@ @@ -3435,7 +4015,7 @@
} }
public boolean isControlledByLocalInstance() { public boolean isControlledByLocalInstance() {
@@ -1235,7 +1243,7 @@
if (entityliving instanceof Player entityhuman) { if (entityliving instanceof Player entityhuman) {
return entityhuman.isLocalPlayer(); return entityhuman.isLocalPlayer();
@@ -3445,7 +4024,7 @@ @@ -3445,7 +4025,7 @@
} }
public boolean isControlledByClient() { public boolean isControlledByClient() {
@@ -1244,7 +1252,7 @@
return entityliving != null && entityliving.isControlledByClient(); return entityliving != null && entityliving.isControlledByClient();
} }
@@ -3463,7 +4042,7 @@ @@ -3463,7 +4043,7 @@
return new Vec3((double) f1 * d2 / (double) f3, 0.0D, (double) f2 * d2 / (double) f3); return new Vec3((double) f1 * d2 / (double) f3, 0.0D, (double) f2 * d2 / (double) f3);
} }
@@ -1253,7 +1261,7 @@
return new Vec3(this.getX(), this.getBoundingBox().maxY, this.getZ()); return new Vec3(this.getX(), this.getBoundingBox().maxY, this.getZ());
} }
@@ -3489,8 +4068,37 @@ @@ -3489,8 +4069,37 @@
return 1; return 1;
} }
@@ -1292,7 +1300,7 @@
} }
public void lookAt(EntityAnchorArgument.Anchor anchorPoint, Vec3 target) { public void lookAt(EntityAnchorArgument.Anchor anchorPoint, Vec3 target) {
@@ -3551,6 +4159,11 @@ @@ -3551,6 +4160,11 @@
vec3d = vec3d.add(vec3d1); vec3d = vec3d.add(vec3d1);
++k1; ++k1;
} }
@@ -1304,7 +1312,7 @@
} }
} }
} }
@@ -3613,7 +4226,7 @@ @@ -3613,7 +4227,7 @@
return new ClientboundAddEntityPacket(this, entityTrackerEntry); return new ClientboundAddEntityPacket(this, entityTrackerEntry);
} }
@@ -1313,7 +1321,7 @@
return this.type.getDimensions(); return this.type.getDimensions();
} }
@@ -3818,8 +4431,16 @@ @@ -3818,8 +4432,16 @@
@Override @Override
public final void setRemoved(Entity.RemovalReason reason) { public final void setRemoved(Entity.RemovalReason reason) {
@@ -1331,7 +1339,7 @@
} }
if (this.removalReason.shouldDestroy()) { if (this.removalReason.shouldDestroy()) {
@@ -3827,8 +4448,8 @@ @@ -3827,8 +4449,8 @@
} }
this.getPassengers().forEach(Entity::stopRiding); this.getPassengers().forEach(Entity::stopRiding);
@@ -1342,7 +1350,7 @@
} }
public void unsetRemoved() { public void unsetRemoved() {
@@ -3887,7 +4508,7 @@ @@ -3887,7 +4509,7 @@
} }
public Vec3 getKnownMovement() { public Vec3 getKnownMovement() {

View File

@@ -242,7 +242,15 @@
if (nbt.contains("Health", 99)) { if (nbt.contains("Health", 99)) {
this.setHealth(nbt.getFloat("Health")); this.setHealth(nbt.getFloat("Health"));
} }
@@ -819,9 +898,32 @@ @@ -792,6 +871,7 @@
String s = nbt.getString("Team");
Scoreboard scoreboard = this.level().getScoreboard();
PlayerTeam scoreboardteam = scoreboard.getPlayerTeam(s);
+ if (!this.level().paperConfig().scoreboards.allowNonPlayerEntitiesOnScoreboards && !(this instanceof net.minecraft.world.entity.player.Player)) { scoreboardteam = null; } // Paper - Perf: Disable Scoreboards for non players by default
boolean flag = scoreboardteam != null && scoreboard.addPlayerToTeam(this.getStringUUID(), scoreboardteam);
if (!flag) {
@@ -819,9 +899,32 @@
} }
@@ -275,7 +283,7 @@
try { try {
while (iterator.hasNext()) { while (iterator.hasNext()) {
Holder<MobEffect> holder = (Holder) iterator.next(); Holder<MobEffect> holder = (Holder) iterator.next();
@@ -831,6 +933,12 @@ @@ -831,6 +934,12 @@
this.onEffectUpdated(mobeffect, true, (Entity) null); this.onEffectUpdated(mobeffect, true, (Entity) null);
})) { })) {
if (!this.level().isClientSide) { if (!this.level().isClientSide) {
@@ -288,7 +296,7 @@
iterator.remove(); iterator.remove();
this.onEffectsRemoved(List.of(mobeffect)); this.onEffectsRemoved(List.of(mobeffect));
} }
@@ -841,6 +949,17 @@ @@ -841,6 +950,17 @@
} catch (ConcurrentModificationException concurrentmodificationexception) { } catch (ConcurrentModificationException concurrentmodificationexception) {
; ;
} }
@@ -306,7 +314,7 @@
if (this.effectsDirty) { if (this.effectsDirty) {
if (!this.level().isClientSide) { if (!this.level().isClientSide) {
@@ -921,7 +1040,7 @@ @@ -921,7 +1041,7 @@
} }
public boolean canAttack(LivingEntity target) { public boolean canAttack(LivingEntity target) {
@@ -315,7 +323,7 @@
} }
public boolean canBeSeenAsEnemy() { public boolean canBeSeenAsEnemy() {
@@ -952,17 +1071,36 @@ @@ -952,17 +1072,36 @@
this.entityData.set(LivingEntity.DATA_EFFECT_PARTICLES, List.of()); this.entityData.set(LivingEntity.DATA_EFFECT_PARTICLES, List.of());
} }
@@ -356,7 +364,7 @@
} }
} }
@@ -987,24 +1125,55 @@ @@ -987,24 +1126,55 @@
return this.addEffect(effect, (Entity) null); return this.addEffect(effect, (Entity) null);
} }
@@ -420,7 +428,7 @@
return flag; return flag;
} }
} }
@@ -1031,14 +1200,40 @@ @@ -1031,14 +1201,40 @@
return this.getType().is(EntityTypeTags.INVERTED_HEALING_AND_HARM); return this.getType().is(EntityTypeTags.INVERTED_HEALING_AND_HARM);
} }
@@ -463,7 +471,7 @@
if (mobeffect != null) { if (mobeffect != null) {
this.onEffectsRemoved(List.of(mobeffect)); this.onEffectsRemoved(List.of(mobeffect));
return true; return true;
@@ -1142,20 +1337,55 @@ @@ -1142,20 +1338,55 @@
} }
@@ -520,7 +528,7 @@
this.entityData.set(LivingEntity.DATA_HEALTH_ID, Mth.clamp(health, 0.0F, this.getMaxHealth())); this.entityData.set(LivingEntity.DATA_HEALTH_ID, Mth.clamp(health, 0.0F, this.getMaxHealth()));
} }
@@ -1167,7 +1397,7 @@ @@ -1167,7 +1398,7 @@
public boolean hurtServer(ServerLevel world, DamageSource source, float amount) { public boolean hurtServer(ServerLevel world, DamageSource source, float amount) {
if (this.isInvulnerableTo(world, source)) { if (this.isInvulnerableTo(world, source)) {
return false; return false;
@@ -529,7 +537,7 @@
return false; return false;
} else if (source.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { } else if (source.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) {
return false; return false;
@@ -1182,10 +1412,11 @@ @@ -1182,10 +1413,11 @@
} }
float f1 = amount; float f1 = amount;
@@ -543,7 +551,7 @@
this.hurtCurrentlyUsedShield(amount); this.hurtCurrentlyUsedShield(amount);
f2 = amount; f2 = amount;
amount = 0.0F; amount = 0.0F;
@@ -1202,15 +1433,26 @@ @@ -1202,15 +1434,26 @@
flag = true; flag = true;
} }
@@ -572,7 +580,7 @@
this.walkAnimation.setSpeed(1.5F); this.walkAnimation.setSpeed(1.5F);
if (Float.isNaN(amount) || Float.isInfinite(amount)) { if (Float.isNaN(amount) || Float.isInfinite(amount)) {
amount = Float.MAX_VALUE; amount = Float.MAX_VALUE;
@@ -1218,18 +1460,27 @@ @@ -1218,18 +1461,27 @@
boolean flag1 = true; boolean flag1 = true;
@@ -604,7 +612,7 @@
this.hurtDuration = 10; this.hurtDuration = 10;
this.hurtTime = this.hurtDuration; this.hurtTime = this.hurtDuration;
} }
@@ -1243,7 +1494,7 @@ @@ -1243,7 +1495,7 @@
world.broadcastDamageEvent(this, source); world.broadcastDamageEvent(this, source);
} }
@@ -613,7 +621,7 @@
this.markHurt(); this.markHurt();
} }
@@ -1263,7 +1514,7 @@ @@ -1263,7 +1515,7 @@
d1 = source.getSourcePosition().z() - this.getZ(); d1 = source.getSourcePosition().z() - this.getZ();
} }
@@ -622,7 +630,7 @@
if (!flag) { if (!flag) {
this.indicateDamage(d0, d1); this.indicateDamage(d0, d1);
} }
@@ -1282,7 +1533,7 @@ @@ -1282,7 +1534,7 @@
this.playHurtSound(source); this.playHurtSound(source);
} }
@@ -631,7 +639,7 @@
if (flag2) { if (flag2) {
this.lastDamageSource = source; this.lastDamageSource = source;
@@ -1329,10 +1580,10 @@ @@ -1329,10 +1581,10 @@
} }
@Nullable @Nullable
@@ -644,7 +652,7 @@
this.lastHurtByPlayerTime = 100; this.lastHurtByPlayerTime = 100;
this.lastHurtByPlayer = entityhuman; this.lastHurtByPlayer = entityhuman;
return entityhuman; return entityhuman;
@@ -1342,8 +1593,8 @@ @@ -1342,8 +1594,8 @@
this.lastHurtByPlayerTime = 100; this.lastHurtByPlayerTime = 100;
LivingEntity entityliving = entitywolf.getOwner(); LivingEntity entityliving = entitywolf.getOwner();
@@ -655,7 +663,7 @@
this.lastHurtByPlayer = entityhuman1; this.lastHurtByPlayer = entityhuman1;
} else { } else {
@@ -1363,7 +1614,7 @@ @@ -1363,7 +1615,7 @@
} }
protected void blockedByShield(LivingEntity target) { protected void blockedByShield(LivingEntity target) {
@@ -664,7 +672,7 @@
} }
private boolean checkTotemDeathProtection(DamageSource source) { private boolean checkTotemDeathProtection(DamageSource source) {
@@ -1375,20 +1626,33 @@ @@ -1375,20 +1627,33 @@
InteractionHand[] aenumhand = InteractionHand.values(); InteractionHand[] aenumhand = InteractionHand.values();
int i = aenumhand.length; int i = aenumhand.length;
@@ -702,7 +710,7 @@
ServerPlayer entityplayer = (ServerPlayer) this; ServerPlayer entityplayer = (ServerPlayer) this;
entityplayer.awardStat(Stats.ITEM_USED.get(itemstack.getItem())); entityplayer.awardStat(Stats.ITEM_USED.get(itemstack.getItem()));
@@ -1477,7 +1741,7 @@ @@ -1477,7 +1742,7 @@
} }
if (!this.level().isClientSide && this.hasCustomName()) { if (!this.level().isClientSide && this.hasCustomName()) {
@@ -711,7 +719,7 @@
} }
this.dead = true; this.dead = true;
@@ -1512,14 +1776,22 @@ @@ -1512,14 +1777,22 @@
BlockState iblockdata = Blocks.WITHER_ROSE.defaultBlockState(); BlockState iblockdata = Blocks.WITHER_ROSE.defaultBlockState();
if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) { if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) {
@@ -736,7 +744,7 @@
this.level().addFreshEntity(entityitem); this.level().addFreshEntity(entityitem);
} }
} }
@@ -1530,24 +1802,39 @@ @@ -1530,24 +1803,39 @@
protected void dropAllDeathLoot(ServerLevel world, DamageSource damageSource) { protected void dropAllDeathLoot(ServerLevel world, DamageSource damageSource) {
boolean flag = this.lastHurtByPlayerTime > 0; boolean flag = this.lastHurtByPlayerTime > 0;
@@ -780,7 +788,7 @@
protected void dropCustomDeathLoot(ServerLevel world, DamageSource source, boolean causedByPlayer) {} protected void dropCustomDeathLoot(ServerLevel world, DamageSource source, boolean causedByPlayer) {}
public long getLootTableSeed() { public long getLootTableSeed() {
@@ -1612,19 +1899,31 @@ @@ -1612,19 +1900,31 @@
} }
public void knockback(double strength, double x, double z) { public void knockback(double strength, double x, double z) {
@@ -819,7 +827,7 @@
} }
} }
@@ -1683,6 +1982,20 @@ @@ -1683,6 +1983,20 @@
return new LivingEntity.Fallsounds(SoundEvents.GENERIC_SMALL_FALL, SoundEvents.GENERIC_BIG_FALL); return new LivingEntity.Fallsounds(SoundEvents.GENERIC_SMALL_FALL, SoundEvents.GENERIC_BIG_FALL);
} }
@@ -840,7 +848,7 @@
public Optional<BlockPos> getLastClimbablePos() { public Optional<BlockPos> getLastClimbablePos() {
return this.lastClimbablePos; return this.lastClimbablePos;
} }
@@ -1757,9 +2070,14 @@ @@ -1757,9 +2071,14 @@
int i = this.calculateFallDamage(fallDistance, damageMultiplier); int i = this.calculateFallDamage(fallDistance, damageMultiplier);
if (i > 0) { if (i > 0) {
@@ -856,7 +864,7 @@
return true; return true;
} else { } else {
return flag; return flag;
@@ -1830,7 +2148,7 @@ @@ -1830,7 +2149,7 @@
protected float getDamageAfterArmorAbsorb(DamageSource source, float amount) { protected float getDamageAfterArmorAbsorb(DamageSource source, float amount) {
if (!source.is(DamageTypeTags.BYPASSES_ARMOR)) { if (!source.is(DamageTypeTags.BYPASSES_ARMOR)) {
@@ -865,7 +873,7 @@
amount = CombatRules.getDamageAfterAbsorb(this, amount, source, (float) this.getArmorValue(), (float) this.getAttributeValue(Attributes.ARMOR_TOUGHNESS)); amount = CombatRules.getDamageAfterAbsorb(this, amount, source, (float) this.getArmorValue(), (float) this.getAttributeValue(Attributes.ARMOR_TOUGHNESS));
} }
@@ -1841,7 +2159,8 @@ @@ -1841,7 +2160,8 @@
if (source.is(DamageTypeTags.BYPASSES_EFFECTS)) { if (source.is(DamageTypeTags.BYPASSES_EFFECTS)) {
return amount; return amount;
} else { } else {
@@ -875,7 +883,7 @@
int i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5; int i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5;
int j = 25 - i; int j = 25 - i;
float f1 = amount * (float) j; float f1 = amount * (float) j;
@@ -1884,18 +2203,144 @@ @@ -1884,18 +2204,144 @@
} }
} }
@@ -1029,7 +1037,7 @@
if (entity instanceof ServerPlayer) { if (entity instanceof ServerPlayer) {
ServerPlayer entityplayer = (ServerPlayer) entity; ServerPlayer entityplayer = (ServerPlayer) entity;
@@ -1904,13 +2349,48 @@ @@ -1904,13 +2350,48 @@
} }
} }
@@ -1082,7 +1090,7 @@
} }
public CombatTracker getCombatTracker() { public CombatTracker getCombatTracker() {
@@ -1935,9 +2415,19 @@ @@ -1935,9 +2416,19 @@
} }
public final void setArrowCount(int stuckArrowCount) { public final void setArrowCount(int stuckArrowCount) {
@@ -1103,7 +1111,7 @@
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 +2489,7 @@ @@ -1999,7 +2490,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);
} }
@@ -1112,7 +1120,7 @@
this.setHealth(0.0F); this.setHealth(0.0F);
this.die(this.damageSources().generic()); this.die(this.damageSources().generic());
} }
@@ -2182,6 +2672,12 @@ @@ -2182,6 +2673,12 @@
public abstract ItemStack getItemBySlot(EquipmentSlot slot); public abstract ItemStack getItemBySlot(EquipmentSlot slot);
@@ -1125,7 +1133,7 @@
public abstract void setItemSlot(EquipmentSlot slot, ItemStack stack); public abstract void setItemSlot(EquipmentSlot slot, ItemStack stack);
public Iterable<ItemStack> getHandSlots() { public Iterable<ItemStack> getHandSlots() {
@@ -2494,7 +2990,7 @@ @@ -2494,7 +2991,7 @@
} }
@@ -1134,7 +1142,7 @@
Vec3 vec3d1 = this.getRiddenInput(controllingPlayer, movementInput); Vec3 vec3d1 = this.getRiddenInput(controllingPlayer, movementInput);
this.tickRidden(controllingPlayer, vec3d1); this.tickRidden(controllingPlayer, vec3d1);
@@ -2507,13 +3003,13 @@ @@ -2507,13 +3004,13 @@
} }
@@ -1151,7 +1159,7 @@
return this.getSpeed(); return this.getSpeed();
} }
@@ -2571,7 +3067,7 @@ @@ -2571,7 +3068,7 @@
double d1 = Mth.clamp(motion.z, -0.15000000596046448D, 0.15000000596046448D); double d1 = Mth.clamp(motion.z, -0.15000000596046448D, 0.15000000596046448D);
double d2 = Math.max(motion.y, -0.15000000596046448D); double d2 = Math.max(motion.y, -0.15000000596046448D);
@@ -1160,7 +1168,7 @@
d2 = 0.0D; d2 = 0.0D;
} }
@@ -2586,7 +3082,7 @@ @@ -2586,7 +3083,7 @@
} }
protected float getFlyingSpeed() { protected float getFlyingSpeed() {
@@ -1169,7 +1177,7 @@
} }
public float getSpeed() { public float getSpeed() {
@@ -2634,7 +3130,7 @@ @@ -2634,7 +3131,7 @@
} }
} }
@@ -1178,7 +1186,7 @@
if (this.tickCount % 20 == 0) { if (this.tickCount % 20 == 0) {
this.getCombatTracker().recheckStatus(); this.getCombatTracker().recheckStatus();
} }
@@ -2741,7 +3237,7 @@ @@ -2741,7 +3238,7 @@
this.elytraAnimationState.tick(); this.elytraAnimationState.tick();
} }
@@ -1187,7 +1195,7 @@
Map<EquipmentSlot, ItemStack> map = this.collectEquipmentChanges(); Map<EquipmentSlot, ItemStack> map = this.collectEquipmentChanges();
if (map != null) { if (map != null) {
@@ -3000,7 +3496,7 @@ @@ -3000,7 +3497,7 @@
{ {
LivingEntity entityliving = this.getControllingPassenger(); LivingEntity entityliving = this.getControllingPassenger();
@@ -1196,7 +1204,7 @@
if (this.isAlive()) { if (this.isAlive()) {
this.travelRidden(entityhuman, vec3d1); this.travelRidden(entityhuman, vec3d1);
break label112; break label112;
@@ -3063,6 +3559,7 @@ @@ -3063,6 +3560,7 @@
this.checkSlowFallDistance(); this.checkSlowFallDistance();
if (!this.level().isClientSide) { if (!this.level().isClientSide) {
if (!this.canGlide()) { if (!this.canGlide()) {
@@ -1204,7 +1212,7 @@
this.setSharedFlag(7, false); this.setSharedFlag(7, false);
return; return;
} }
@@ -3113,7 +3610,7 @@ @@ -3113,7 +3611,7 @@
Level world = this.level(); Level world = this.level();
if (!(world instanceof ServerLevel worldserver)) { if (!(world instanceof ServerLevel worldserver)) {
@@ -1213,7 +1221,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));
@@ -3305,15 +3802,22 @@ @@ -3305,15 +3803,22 @@
@Override @Override
public boolean isPickable() { public boolean isPickable() {
@@ -1238,7 +1246,7 @@
public float getYHeadRot() { public float getYHeadRot() {
return this.yHeadRot; return this.yHeadRot;
} }
@@ -3483,8 +3987,31 @@ @@ -3483,8 +3988,31 @@
this.releaseUsingItem(); this.releaseUsingItem();
} else { } else {
if (!this.useItem.isEmpty() && this.isUsingItem()) { if (!this.useItem.isEmpty() && this.isUsingItem()) {
@@ -1271,7 +1279,7 @@
if (itemstack != this.useItem) { if (itemstack != this.useItem) {
this.setItemInHand(enumhand, itemstack); this.setItemInHand(enumhand, itemstack);
} }
@@ -3568,12 +4095,18 @@ @@ -3568,12 +4096,18 @@
} }
public boolean randomTeleport(double x, double y, double z, boolean particleEffects) { public boolean randomTeleport(double x, double y, double z, boolean particleEffects) {
@@ -1292,7 +1300,7 @@
Level world = this.level(); Level world = this.level();
if (world.hasChunkAt(blockposition)) { if (world.hasChunkAt(blockposition)) {
@@ -3592,18 +4125,43 @@ @@ -3592,18 +4126,43 @@
} }
if (flag2) { if (flag2) {
@@ -1340,7 +1348,7 @@
world.broadcastEntityEvent(this, (byte) 46); world.broadcastEntityEvent(this, (byte) 46);
} }
@@ -3613,7 +4171,7 @@ @@ -3613,7 +4172,7 @@
entitycreature.getNavigation().stop(); entitycreature.getNavigation().stop();
} }
@@ -1349,7 +1357,7 @@
} }
} }
@@ -3706,7 +4264,7 @@ @@ -3706,7 +4265,7 @@
} }
public void stopSleeping() { public void stopSleeping() {
@@ -1358,7 +1366,7 @@
Level world = this.level(); Level world = this.level();
java.util.Objects.requireNonNull(world); java.util.Objects.requireNonNull(world);
@@ -3718,9 +4276,9 @@ @@ -3718,9 +4277,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(() -> {
@@ -1370,7 +1378,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 +4298,7 @@ @@ -3740,7 +4299,7 @@
@Nullable @Nullable
public Direction getBedOrientation() { public Direction getBedOrientation() {
@@ -1379,7 +1387,7 @@
return blockposition != null ? BedBlock.getBedOrientation(this.level(), blockposition) : null; return blockposition != null ? BedBlock.getBedOrientation(this.level(), blockposition) : null;
} }
@@ -3905,7 +4463,7 @@ @@ -3905,7 +4464,7 @@
public float maxUpStep() { public float maxUpStep() {
float f = (float) this.getAttributeValue(Attributes.STEP_HEIGHT); float f = (float) this.getAttributeValue(Attributes.STEP_HEIGHT);