== AT ==
public net.minecraft.server.level.ServerChunkCache mainThread
public net.minecraft.server.level.ServerLevel chunkSource
public org.bukkit.craftbukkit.inventory.CraftItemStack handle
public net.minecraft.server.level.ChunkMap getVisibleChunkIfPresent(J)Lnet/minecraft/server/level/ChunkHolder;
public net.minecraft.server.level.ServerChunkCache mainThreadProcessor
public net.minecraft.server.level.ServerChunkCache$MainThreadExecutor
public net.minecraft.world.level.chunk.LevelChunkSection states
This commit is contained in:
Aikar
2016-03-28 20:55:47 -04:00
parent a82a09d198
commit b01c811c2f
81 changed files with 6261 additions and 473 deletions

View File

@@ -96,7 +96,7 @@
private static final EntityDataAccessor<Integer> DATA_TICKS_FROZEN = SynchedEntityData.defineId(Entity.class, EntityDataSerializers.INT);
private EntityInLevelCallback levelCallback;
private final VecDeltaCodec packetPositionCodec;
@@ -253,7 +312,38 @@
@@ -253,6 +312,42 @@
private final List<Entity.Movement> movementThisTick;
private final Set<BlockState> blocksInside;
private final LongSet visitedBlocks;
@@ -122,7 +122,7 @@
+ public long activatedTick = Integer.MIN_VALUE;
+ public void inactiveTick() { }
+ // Spigot end
+
+ public float getBukkitYaw() {
+ return this.yRot;
+ }
@@ -131,11 +131,15 @@
+ return this.level.hasChunk((int) Math.floor(this.getX()) >> 4, (int) Math.floor(this.getZ()) >> 4);
+ }
+ // CraftBukkit end
+
+ // Paper start
+ public final AABB getBoundingBoxAt(double x, double y, double z) {
+ return this.dimensions.makeBoundingBox(x, y, z);
+ }
+ // Paper end
public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
this.passengers = ImmutableList.of();
@@ -284,6 +374,13 @@
@@ -284,6 +379,13 @@
this.position = Vec3.ZERO;
this.blockPosition = BlockPos.ZERO;
this.chunkPosition = ChunkPos.ZERO;
@@ -149,7 +153,7 @@
SynchedEntityData.Builder datawatcher_a = new SynchedEntityData.Builder(this);
datawatcher_a.define(Entity.DATA_SHARED_FLAGS_ID, (byte) 0);
@@ -292,7 +389,7 @@
@@ -292,7 +394,7 @@
datawatcher_a.define(Entity.DATA_CUSTOM_NAME, Optional.empty());
datawatcher_a.define(Entity.DATA_SILENT, false);
datawatcher_a.define(Entity.DATA_NO_GRAVITY, false);
@@ -158,7 +162,7 @@
datawatcher_a.define(Entity.DATA_TICKS_FROZEN, 0);
this.defineSynchedData(datawatcher_a);
this.entityData = datawatcher_a.build();
@@ -362,20 +459,36 @@
@@ -362,20 +464,36 @@
}
public void kill(ServerLevel world) {
@@ -197,7 +201,7 @@
public boolean equals(Object object) {
return object instanceof Entity ? ((Entity) object).id == this.id : false;
}
@@ -385,22 +498,34 @@
@@ -385,22 +503,34 @@
}
public void remove(Entity.RemovalReason reason) {
@@ -237,7 +241,7 @@
return this.getPose() == pose;
}
@@ -417,6 +542,33 @@
@@ -417,6 +547,33 @@
}
public void setRot(float yaw, float pitch) {
@@ -271,7 +275,7 @@
this.setYRot(yaw % 360.0F);
this.setXRot(pitch % 360.0F);
}
@@ -462,6 +614,15 @@
@@ -462,6 +619,15 @@
this.baseTick();
}
@@ -287,7 +291,7 @@
public void baseTick() {
ProfilerFiller gameprofilerfiller = Profiler.get();
@@ -475,7 +636,7 @@
@@ -475,7 +641,7 @@
--this.boardingCooldown;
}
@@ -296,7 +300,7 @@
if (this.canSpawnSprintParticle()) {
this.spawnSprintParticle();
}
@@ -514,6 +675,10 @@
@@ -514,6 +680,10 @@
if (this.isInLava()) {
this.lavaHurt();
this.fallDistance *= 0.5F;
@@ -307,7 +311,7 @@
}
this.checkBelowWorld();
@@ -525,7 +690,7 @@
@@ -525,7 +695,7 @@
world = this.level();
if (world instanceof ServerLevel worldserver) {
if (this instanceof Leashable) {
@@ -316,7 +320,7 @@
}
}
@@ -568,15 +733,32 @@
@@ -568,15 +738,32 @@
public void lavaHurt() {
if (!this.fireImmune()) {
@@ -351,7 +355,7 @@
}
}
@@ -587,9 +769,25 @@
@@ -587,9 +774,25 @@
}
public final void igniteForSeconds(float seconds) {
@@ -378,7 +382,7 @@
public void igniteForTicks(int ticks) {
if (this.remainingFireTicks < ticks) {
this.setRemainingFireTicks(ticks);
@@ -610,7 +808,7 @@
@@ -610,7 +813,7 @@
}
protected void onBelowWorld() {
@@ -387,7 +391,7 @@
}
public boolean isFree(double offsetX, double offsetY, double offsetZ) {
@@ -672,6 +870,7 @@
@@ -672,6 +875,7 @@
}
public void move(MoverType type, Vec3 movement) {
@@ -395,10 +399,13 @@
if (this.noPhysics) {
this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z);
} else {
@@ -750,6 +949,28 @@
}
}
@@ -747,8 +951,30 @@
if (movement.y != vec3d1.y) {
block.updateEntityMovementAfterFallOn(this.level(), this);
+ }
+ }
+
+ // CraftBukkit start
+ if (this.horizontalCollision && this.getBukkitEntity() instanceof Vehicle) {
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
@@ -412,19 +419,18 @@
+ bl = bl.getRelative(BlockFace.SOUTH);
+ } else if (movement.z < vec3d1.z) {
+ bl = bl.getRelative(BlockFace.NORTH);
+ }
}
+
+ if (!bl.getType().isAir()) {
+ VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, bl);
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ }
+ }
}
+ // CraftBukkit end
+
if (!this.level().isClientSide() || this.isControlledByLocalInstance()) {
Entity.MovementEmission entity_movementemission = this.getMovementEmission();
@@ -764,6 +985,7 @@
@@ -764,6 +990,7 @@
gameprofilerfiller.pop();
}
}
@@ -432,7 +438,7 @@
}
private void applyMovementEmissionAndPlaySound(Entity.MovementEmission moveEffect, Vec3 movement, BlockPos landingPos, BlockState landingState) {
@@ -1133,6 +1355,20 @@
@@ -1133,6 +1360,20 @@
return SoundEvents.GENERIC_SPLASH;
}
@@ -453,7 +459,7 @@
public void recordMovementThroughBlocks(Vec3 oldPos, Vec3 newPos) {
this.movementThisTick.add(new Entity.Movement(oldPos, newPos));
}
@@ -1609,6 +1845,7 @@
@@ -1609,6 +1850,7 @@
this.yo = y;
this.zo = d4;
this.setPos(d3, y, d4);
@@ -461,7 +467,7 @@
}
public void moveTo(Vec3 pos) {
@@ -1861,6 +2098,12 @@
@@ -1861,6 +2103,12 @@
return false;
}
@@ -474,7 +480,7 @@
public void awardKillScore(Entity entityKilled, DamageSource damageSource) {
if (entityKilled instanceof ServerPlayer) {
CriteriaTriggers.ENTITY_KILLED_PLAYER.trigger((ServerPlayer) entityKilled, this, damageSource);
@@ -1889,16 +2132,22 @@
@@ -1889,16 +2137,22 @@
}
public boolean saveAsPassenger(CompoundTag nbt) {
@@ -500,7 +506,7 @@
return true;
}
}
@@ -1909,54 +2158,98 @@
@@ -1909,54 +2163,98 @@
}
public CompoundTag saveWithoutId(CompoundTag nbt) {
@@ -619,7 +625,7 @@
}
ListTag nbttaglist;
@@ -1972,10 +2265,10 @@
@@ -1972,10 +2270,10 @@
nbttaglist.add(StringTag.valueOf(s));
}
@@ -632,7 +638,7 @@
if (this.isVehicle()) {
nbttaglist = new ListTag();
iterator = this.getPassengers().iterator();
@@ -1984,17 +2277,22 @@
@@ -1984,17 +2282,22 @@
Entity entity = (Entity) iterator.next();
CompoundTag nbttagcompound1 = new CompoundTag();
@@ -658,11 +664,10 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Entity being saved");
@@ -2079,7 +2377,51 @@
}
@@ -2080,6 +2383,50 @@
} else {
throw new IllegalStateException("Entity has invalid position");
+ }
}
+
+ // CraftBukkit start
+ // Spigot start
@@ -698,7 +703,7 @@
+ }
+
+ ((ServerPlayer) this).setLevel(bworld == null ? null : ((CraftWorld) bworld).getHandle());
}
+ }
+ this.getBukkitEntity().readBukkitValues(nbt);
+ if (nbt.contains("Bukkit.invisible")) {
+ boolean bukkitInvisible = nbt.getBoolean("Bukkit.invisible");
@@ -710,7 +715,7 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Entity being loaded");
@@ -2101,6 +2443,12 @@
@@ -2101,6 +2448,12 @@
return entitytypes.canSerialize() && minecraftkey != null ? minecraftkey.toString() : null;
}
@@ -723,7 +728,7 @@
protected abstract void readAdditionalSaveData(CompoundTag nbt);
protected abstract void addAdditionalSaveData(CompoundTag nbt);
@@ -2153,9 +2501,22 @@
@@ -2153,9 +2506,22 @@
if (stack.isEmpty()) {
return null;
} else {
@@ -746,7 +751,7 @@
world.addFreshEntity(entityitem);
return entityitem;
}
@@ -2184,6 +2545,12 @@
@@ -2184,6 +2550,12 @@
if (this.isAlive() && this instanceof Leashable leashable) {
if (leashable.getLeashHolder() == player) {
if (!this.level().isClientSide()) {
@@ -759,7 +764,7 @@
if (player.hasInfiniteMaterials()) {
leashable.removeLeash();
} else {
@@ -2200,6 +2567,13 @@
@@ -2200,6 +2572,13 @@
if (itemstack.is(Items.LEAD) && leashable.canHaveALeashAttachedToIt()) {
if (!this.level().isClientSide()) {
@@ -773,7 +778,7 @@
leashable.setLeashedTo(player, true);
}
@@ -2265,7 +2639,7 @@
@@ -2265,7 +2644,7 @@
}
public boolean showVehicleHealth() {
@@ -782,7 +787,7 @@
}
public boolean startRiding(Entity entity, boolean force) {
@@ -2273,7 +2647,7 @@
@@ -2273,7 +2652,7 @@
return false;
} else if (!entity.couldAcceptPassenger()) {
return false;
@@ -791,7 +796,7 @@
return false;
} else {
for (Entity entity1 = entity; entity1.vehicle != null; entity1 = entity1.vehicle) {
@@ -2285,11 +2659,32 @@
@@ -2285,11 +2664,32 @@
if (!force && (!this.canRide(entity) || !entity.canAddPassenger(this))) {
return false;
} else {
@@ -825,7 +830,7 @@
this.vehicle = entity;
this.vehicle.addPassenger(this);
entity.getIndirectPassengersStream().filter((entity2) -> {
@@ -2318,7 +2713,7 @@
@@ -2318,7 +2718,7 @@
Entity entity = this.vehicle;
this.vehicle = null;
@@ -834,7 +839,7 @@
}
}
@@ -2349,21 +2744,50 @@
@@ -2349,21 +2749,50 @@
}
}
@@ -891,7 +896,7 @@
}
protected boolean canAddPassenger(Entity passenger) {
@@ -2464,7 +2888,7 @@
@@ -2464,7 +2893,7 @@
if (teleporttransition != null) {
ServerLevel worldserver1 = teleporttransition.newLevel();
@@ -900,7 +905,7 @@
this.teleport(teleporttransition);
}
}
@@ -2547,7 +2971,7 @@
@@ -2547,7 +2976,7 @@
}
public boolean isCrouching() {
@@ -909,7 +914,7 @@
}
public boolean isSprinting() {
@@ -2563,7 +2987,7 @@
@@ -2563,7 +2992,7 @@
}
public boolean isVisuallySwimming() {
@@ -918,7 +923,7 @@
}
public boolean isVisuallyCrawling() {
@@ -2571,6 +2995,13 @@
@@ -2571,6 +3000,13 @@
}
public void setSwimming(boolean swimming) {
@@ -932,7 +937,7 @@
this.setSharedFlag(4, swimming);
}
@@ -2624,8 +3055,12 @@
@@ -2624,8 +3060,12 @@
return this.getTeam() != null ? this.getTeam().isAlliedTo(team) : false;
}
@@ -946,7 +951,7 @@
}
public boolean getSharedFlag(int index) {
@@ -2644,7 +3079,7 @@
@@ -2644,7 +3084,7 @@
}
public int getMaxAirSupply() {
@@ -955,7 +960,7 @@
}
public int getAirSupply() {
@@ -2652,7 +3087,18 @@
@@ -2652,7 +3092,18 @@
}
public void setAirSupply(int air) {
@@ -975,7 +980,7 @@
}
public int getTicksFrozen() {
@@ -2679,11 +3125,40 @@
@@ -2679,11 +3130,40 @@
public void thunderHit(ServerLevel world, LightningBolt lightning) {
this.setRemainingFireTicks(this.remainingFireTicks + 1);
@@ -1018,7 +1023,7 @@
}
public void onAboveBubbleCol(boolean drag) {
@@ -2713,7 +3188,7 @@
@@ -2713,7 +3193,7 @@
this.resetFallDistance();
}
@@ -1027,7 +1032,7 @@
return true;
}
@@ -2852,6 +3327,18 @@
@@ -2852,6 +3332,18 @@
if (world instanceof ServerLevel worldserver) {
if (!this.isRemoved()) {
@@ -1046,7 +1051,7 @@
ServerLevel worldserver1 = teleportTarget.newLevel();
boolean flag = worldserver1.dimension() != worldserver.dimension();
@@ -2920,8 +3407,12 @@
@@ -2920,8 +3412,12 @@
} else {
entity.restoreFrom(this);
this.removeAfterChangingDimensions();
@@ -1060,7 +1065,7 @@
Iterator iterator1 = list1.iterator();
while (iterator1.hasNext()) {
@@ -2947,7 +3438,7 @@
@@ -2947,7 +3443,7 @@
}
private void sendTeleportTransitionToRidingPlayers(TeleportTransition teleportTarget) {
@@ -1069,7 +1074,7 @@
Iterator iterator = this.getIndirectPassengers().iterator();
while (iterator.hasNext()) {
@@ -2995,8 +3486,9 @@
@@ -2995,8 +3491,9 @@
}
protected void removeAfterChangingDimensions() {
@@ -1080,7 +1085,7 @@
leashable.removeLeash();
}
@@ -3006,6 +3498,20 @@
@@ -3006,6 +3503,20 @@
return PortalShape.getRelativePosition(portalRect, portalAxis, this.position(), this.getDimensions(this.getPose()));
}
@@ -1101,7 +1106,7 @@
public boolean canUsePortal(boolean allowVehicles) {
return (allowVehicles || !this.isPassenger()) && this.isAlive();
}
@@ -3134,10 +3640,16 @@
@@ -3134,9 +3645,15 @@
return (Boolean) this.entityData.get(Entity.DATA_CUSTOM_NAME_VISIBLE);
}
@@ -1112,16 +1117,15 @@
+ public final boolean teleportTo(ServerLevel world, double destX, double destY, double destZ, Set<Relative> flags, float yaw, float pitch, boolean resetCamera) {
+ return this.teleportTo(world, destX, destY, destZ, flags, yaw, pitch, resetCamera, PlayerTeleportEvent.TeleportCause.UNKNOWN);
+ }
+
+ public boolean teleportTo(ServerLevel worldserver, double d0, double d1, double d2, Set<Relative> set, float f, float f1, boolean flag, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) {
+ float f2 = Mth.clamp(f1, -90.0F, 90.0F);
+ Entity entity = this.teleport(new TeleportTransition(worldserver, new Vec3(d0, d1, d2), Vec3.ZERO, f, f2, set, TeleportTransition.DO_NOTHING, cause));
+ // CraftBukkit end
+
return entity != null;
}
@@ -3187,7 +3699,7 @@
@@ -3187,7 +3704,7 @@
/** @deprecated */
@Deprecated
protected void fixupDimensions() {
@@ -1130,7 +1134,7 @@
EntityDimensions entitysize = this.getDimensions(entitypose);
this.dimensions = entitysize;
@@ -3196,7 +3708,7 @@
@@ -3196,7 +3713,7 @@
public void refreshDimensions() {
EntityDimensions entitysize = this.dimensions;
@@ -1139,7 +1143,7 @@
EntityDimensions entitysize1 = this.getDimensions(entitypose);
this.dimensions = entitysize1;
@@ -3258,10 +3770,29 @@
@@ -3258,10 +3775,29 @@
}
public final void setBoundingBox(AABB boundingBox) {
@@ -1171,7 +1175,7 @@
return this.getDimensions(pose).eyeHeight();
}
@@ -3335,7 +3866,7 @@
@@ -3335,7 +3871,7 @@
}
@Nullable
@@ -1180,7 +1184,7 @@
return null;
}
@@ -3435,7 +3966,7 @@
@@ -3435,7 +3971,7 @@
}
public boolean isControlledByLocalInstance() {
@@ -1189,7 +1193,7 @@
if (entityliving instanceof Player entityhuman) {
return entityhuman.isLocalPlayer();
@@ -3445,7 +3976,7 @@
@@ -3445,7 +3981,7 @@
}
public boolean isControlledByClient() {
@@ -1198,7 +1202,7 @@
return entityliving != null && entityliving.isControlledByClient();
}
@@ -3463,7 +3994,7 @@
@@ -3463,7 +3999,7 @@
return new Vec3((double) f1 * d2 / (double) f3, 0.0D, (double) f2 * d2 / (double) f3);
}
@@ -1207,7 +1211,7 @@
return new Vec3(this.getX(), this.getBoundingBox().maxY, this.getZ());
}
@@ -3489,8 +4020,37 @@
@@ -3489,8 +4025,37 @@
return 1;
}
@@ -1246,7 +1250,7 @@
}
public void lookAt(EntityAnchorArgument.Anchor anchorPoint, Vec3 target) {
@@ -3550,7 +4110,12 @@
@@ -3550,7 +4115,12 @@
vec3d = vec3d.add(vec3d1);
++k1;
@@ -1259,7 +1263,7 @@
}
}
}
@@ -3613,7 +4178,7 @@
@@ -3613,7 +4183,7 @@
return new ClientboundAddEntityPacket(this, entityTrackerEntry);
}
@@ -1268,7 +1272,7 @@
return this.type.getDimensions();
}
@@ -3818,8 +4383,16 @@
@@ -3818,8 +4388,16 @@
@Override
public final void setRemoved(Entity.RemovalReason reason) {
@@ -1286,7 +1290,7 @@
}
if (this.removalReason.shouldDestroy()) {
@@ -3827,8 +4400,8 @@
@@ -3827,8 +4405,8 @@
}
this.getPassengers().forEach(Entity::stopRiding);
@@ -1297,7 +1301,7 @@
}
public void unsetRemoved() {
@@ -3887,7 +4460,7 @@
@@ -3887,7 +4465,7 @@
}
public Vec3 getKnownMovement() {

View File

@@ -68,7 +68,7 @@
public int lastHurtByPlayerTime;
protected boolean dead;
protected int noActionTime;
@@ -260,7 +287,27 @@
@@ -260,6 +287,27 @@
protected boolean skipDropExperience;
private final EnumMap<EquipmentSlot, Reference2ObjectMap<Enchantment, Set<EnchantmentLocationBasedEffect>>> activeLocationDependentEnchantments;
protected float appliedScale;
@@ -79,7 +79,8 @@
+ public boolean collides = true;
+ public Set<UUID> collidableExemptions = new HashSet<>();
+ public boolean bukkitPickUpLoot;
+ public org.bukkit.craftbukkit.entity.CraftLivingEntity getBukkitLivingEntity() { return (org.bukkit.craftbukkit.entity.CraftLivingEntity) super.getBukkitEntity(); } // Paper
+
+ @Override
+ public float getBukkitYaw() {
+ return this.getYHeadRot();
@@ -92,11 +93,10 @@
+ ++this.noActionTime; // Above all the floats
+ }
+ // Spigot end
+
protected LivingEntity(EntityType<? extends LivingEntity> type, Level world) {
super(type, world);
this.lastHandItemStacks = NonNullList.withSize(2, ItemStack.EMPTY);
@@ -276,7 +323,9 @@
@@ -276,7 +324,9 @@
this.activeLocationDependentEnchantments = new EnumMap(EquipmentSlot.class);
this.appliedScale = 1.0F;
this.attributes = new AttributeMap(DefaultAttributes.getSupplier(type));
@@ -107,7 +107,7 @@
this.blocksBuilding = true;
this.rotA = (float) ((Math.random() + 1.0D) * 0.009999999776482582D);
this.reapplyPosition();
@@ -356,7 +405,13 @@
@@ -356,7 +406,13 @@
double d8 = Math.min((double) (0.2F + f / 15.0F), 2.5D);
int i = (int) (150.0D * d8);
@@ -122,7 +122,7 @@
}
}
}
@@ -402,7 +457,7 @@
@@ -402,7 +458,7 @@
}
if (this.isAlive()) {
@@ -131,7 +131,7 @@
Level world1 = this.level();
ServerLevel worldserver1;
double d0;
@@ -424,7 +479,7 @@
@@ -424,7 +480,7 @@
}
if (this.isEyeInFluid(FluidTags.WATER) && !this.level().getBlockState(BlockPos.containing(this.getX(), this.getEyeY(), this.getZ())).is(Blocks.BUBBLE_COLUMN)) {
@@ -140,7 +140,7 @@
if (flag1) {
this.setAirSupply(this.decreaseAirSupply(this.getAirSupply()));
@@ -573,7 +628,7 @@
@@ -573,7 +629,7 @@
++this.deathTime;
if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved()) {
this.level().broadcastEntityEvent(this, (byte) 60);
@@ -149,7 +149,7 @@
}
}
@@ -629,7 +684,7 @@
@@ -629,7 +685,7 @@
return this.lastHurtByMobTimestamp;
}
@@ -158,25 +158,26 @@
this.lastHurtByPlayer = attacking;
this.lastHurtByPlayerTime = this.tickCount;
}
@@ -679,17 +734,23 @@
@@ -679,17 +735,23 @@
}
public void onEquipItem(EquipmentSlot slot, ItemStack oldStack, ItemStack newStack) {
- if (!this.level().isClientSide() && !this.isSpectator()) {
- boolean flag = newStack.isEmpty() && oldStack.isEmpty();
-
- if (!flag && !ItemStack.isSameItemSameComponents(oldStack, newStack) && !this.firstTick) {
- Equippable equippable = (Equippable) newStack.get(DataComponents.EQUIPPABLE);
+ // CraftBukkit start
+ this.onEquipItem(slot, oldStack, newStack, false);
+ }
- if (!flag && !ItemStack.isSameItemSameComponents(oldStack, newStack) && !this.firstTick) {
- Equippable equippable = (Equippable) newStack.get(DataComponents.EQUIPPABLE);
- if (!this.isSilent() && equippable != null && slot == equippable.slot()) {
- this.level().playSeededSound((Player) null, this.getX(), this.getY(), this.getZ(), equippable.equipSound(), this.getSoundSource(), 1.0F, 1.0F, this.random.nextLong());
+ 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 (!this.isSilent() && equippable != null && slot == equippable.slot()) {
- this.level().playSeededSound((Player) null, this.getX(), this.getY(), this.getZ(), equippable.equipSound(), this.getSoundSource(), 1.0F, 1.0F, this.random.nextLong());
+
+ if (!flag && !ItemStack.isSameItemSameComponents(itemstack, itemstack1) && !this.firstTick) {
+ Equippable equippable = (Equippable) itemstack1.get(DataComponents.EQUIPPABLE);
+
@@ -189,7 +190,7 @@
this.gameEvent(equippable != null ? GameEvent.EQUIP : GameEvent.UNEQUIP);
}
@@ -699,17 +760,24 @@
@@ -699,17 +761,24 @@
@Override
public void remove(Entity.RemovalReason reason) {
@@ -217,7 +218,7 @@
this.brain.clearMemories();
}
@@ -722,6 +790,7 @@
@@ -722,6 +791,7 @@
mobeffect.onMobRemoved(world, this, reason);
}
@@ -225,7 +226,7 @@
this.activeEffects.clear();
}
@@ -781,6 +850,17 @@
@@ -781,6 +851,17 @@
}
}
@@ -243,7 +244,7 @@
if (nbt.contains("Health", 99)) {
this.setHealth(nbt.getFloat("Health"));
}
@@ -819,9 +899,32 @@
@@ -819,9 +900,32 @@
}
@@ -276,7 +277,7 @@
try {
while (iterator.hasNext()) {
Holder<MobEffect> holder = (Holder) iterator.next();
@@ -831,6 +934,12 @@
@@ -831,6 +935,12 @@
this.onEffectUpdated(mobeffect, true, (Entity) null);
})) {
if (!this.level().isClientSide) {
@@ -289,7 +290,7 @@
iterator.remove();
this.onEffectsRemoved(List.of(mobeffect));
}
@@ -841,6 +950,17 @@
@@ -841,6 +951,17 @@
} catch (ConcurrentModificationException concurrentmodificationexception) {
;
}
@@ -307,7 +308,7 @@
if (this.effectsDirty) {
if (!this.level().isClientSide) {
@@ -921,7 +1041,7 @@
@@ -921,7 +1042,7 @@
}
public boolean canAttack(LivingEntity target) {
@@ -316,7 +317,7 @@
}
public boolean canBeSeenAsEnemy() {
@@ -952,17 +1072,36 @@
@@ -952,17 +1073,36 @@
this.entityData.set(LivingEntity.DATA_EFFECT_PARTICLES, List.of());
}
@@ -357,7 +358,7 @@
}
}
@@ -987,24 +1126,55 @@
@@ -987,24 +1127,55 @@
return this.addEffect(effect, (Entity) null);
}
@@ -421,7 +422,7 @@
return flag;
}
}
@@ -1031,14 +1201,40 @@
@@ -1031,14 +1202,40 @@
return this.getType().is(EntityTypeTags.INVERTED_HEALING_AND_HARM);
}
@@ -464,7 +465,7 @@
if (mobeffect != null) {
this.onEffectsRemoved(List.of(mobeffect));
return true;
@@ -1142,20 +1338,55 @@
@@ -1142,20 +1339,55 @@
}
@@ -521,7 +522,7 @@
this.entityData.set(LivingEntity.DATA_HEALTH_ID, Mth.clamp(health, 0.0F, this.getMaxHealth()));
}
@@ -1167,7 +1398,7 @@
@@ -1167,7 +1399,7 @@
public boolean hurtServer(ServerLevel world, DamageSource source, float amount) {
if (this.isInvulnerableTo(world, source)) {
return false;
@@ -530,7 +531,7 @@
return false;
} else if (source.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) {
return false;
@@ -1182,10 +1413,11 @@
@@ -1182,10 +1414,11 @@
}
float f1 = amount;
@@ -544,7 +545,7 @@
this.hurtCurrentlyUsedShield(amount);
f2 = amount;
amount = 0.0F;
@@ -1202,15 +1434,26 @@
@@ -1202,15 +1435,26 @@
flag = true;
}
@@ -573,7 +574,7 @@
this.walkAnimation.setSpeed(1.5F);
if (Float.isNaN(amount) || Float.isInfinite(amount)) {
amount = Float.MAX_VALUE;
@@ -1218,18 +1461,27 @@
@@ -1218,18 +1462,27 @@
boolean flag1 = true;
@@ -605,7 +606,7 @@
this.hurtDuration = 10;
this.hurtTime = this.hurtDuration;
}
@@ -1243,7 +1495,7 @@
@@ -1243,7 +1496,7 @@
world.broadcastDamageEvent(this, source);
}
@@ -614,7 +615,7 @@
this.markHurt();
}
@@ -1263,7 +1515,7 @@
@@ -1263,7 +1516,7 @@
d1 = source.getSourcePosition().z() - this.getZ();
}
@@ -623,7 +624,7 @@
if (!flag) {
this.indicateDamage(d0, d1);
}
@@ -1282,7 +1534,7 @@
@@ -1282,7 +1535,7 @@
this.playHurtSound(source);
}
@@ -632,7 +633,7 @@
if (flag2) {
this.lastDamageSource = source;
@@ -1329,10 +1581,10 @@
@@ -1329,10 +1582,10 @@
}
@Nullable
@@ -645,7 +646,7 @@
this.lastHurtByPlayerTime = 100;
this.lastHurtByPlayer = entityhuman;
return entityhuman;
@@ -1342,8 +1594,8 @@
@@ -1342,8 +1595,8 @@
this.lastHurtByPlayerTime = 100;
LivingEntity entityliving = entitywolf.getOwner();
@@ -656,7 +657,7 @@
this.lastHurtByPlayer = entityhuman1;
} else {
@@ -1363,7 +1615,7 @@
@@ -1363,7 +1616,7 @@
}
protected void blockedByShield(LivingEntity target) {
@@ -665,7 +666,7 @@
}
private boolean checkTotemDeathProtection(DamageSource source) {
@@ -1375,20 +1627,33 @@
@@ -1375,20 +1628,33 @@
InteractionHand[] aenumhand = InteractionHand.values();
int i = aenumhand.length;
@@ -703,7 +704,7 @@
ServerPlayer entityplayer = (ServerPlayer) this;
entityplayer.awardStat(Stats.ITEM_USED.get(itemstack.getItem()));
@@ -1477,7 +1742,7 @@
@@ -1477,7 +1743,7 @@
}
if (!this.level().isClientSide && this.hasCustomName()) {
@@ -712,7 +713,7 @@
}
this.dead = true;
@@ -1512,14 +1777,22 @@
@@ -1512,14 +1778,22 @@
BlockState iblockdata = Blocks.WITHER_ROSE.defaultBlockState();
if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) {
@@ -737,7 +738,7 @@
this.level().addFreshEntity(entityitem);
}
}
@@ -1530,24 +1803,39 @@
@@ -1530,22 +1804,37 @@
protected void dropAllDeathLoot(ServerLevel world, DamageSource damageSource) {
boolean flag = this.lastHurtByPlayerTime > 0;
@@ -767,8 +768,8 @@
}
+ return 0; // CraftBukkit
}
+ }
+
+ protected void dropExperience(ServerLevel world, @Nullable Entity attacker) {
+ // CraftBukkit start - Update getExpReward() above if the removed if() changes!
+ if (!(this instanceof net.minecraft.world.entity.boss.enderdragon.EnderDragon)) { // CraftBukkit - SPIGOT-2420: Special case ender dragon will drop the xp over time
@@ -776,12 +777,10 @@
+ this.expToDrop = 0;
+ }
+ // CraftBukkit end
+ }
+
protected void dropCustomDeathLoot(ServerLevel world, DamageSource source, boolean causedByPlayer) {}
}
public long getLootTableSeed() {
@@ -1612,19 +1900,31 @@
protected void dropCustomDeathLoot(ServerLevel world, DamageSource source, boolean causedByPlayer) {}
@@ -1612,19 +1901,31 @@
}
public void knockback(double strength, double x, double z) {
@@ -820,7 +819,7 @@
}
}
@@ -1683,6 +1983,20 @@
@@ -1683,6 +1984,20 @@
return new LivingEntity.Fallsounds(SoundEvents.GENERIC_SMALL_FALL, SoundEvents.GENERIC_BIG_FALL);
}
@@ -841,7 +840,7 @@
public Optional<BlockPos> getLastClimbablePos() {
return this.lastClimbablePos;
}
@@ -1757,9 +2071,14 @@
@@ -1757,9 +2072,14 @@
int i = this.calculateFallDamage(fallDistance, damageMultiplier);
if (i > 0) {
@@ -857,7 +856,7 @@
return true;
} else {
return flag;
@@ -1830,7 +2149,7 @@
@@ -1830,7 +2150,7 @@
protected float getDamageAfterArmorAbsorb(DamageSource source, float amount) {
if (!source.is(DamageTypeTags.BYPASSES_ARMOR)) {
@@ -866,7 +865,7 @@
amount = CombatRules.getDamageAfterAbsorb(this, amount, source, (float) this.getArmorValue(), (float) this.getAttributeValue(Attributes.ARMOR_TOUGHNESS));
}
@@ -1841,7 +2160,8 @@
@@ -1841,7 +2161,8 @@
if (source.is(DamageTypeTags.BYPASSES_EFFECTS)) {
return amount;
} else {
@@ -876,7 +875,7 @@
int i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5;
int j = 25 - i;
float f1 = amount * (float) j;
@@ -1884,18 +2204,144 @@
@@ -1884,18 +2205,144 @@
}
}
@@ -1030,7 +1029,7 @@
if (entity instanceof ServerPlayer) {
ServerPlayer entityplayer = (ServerPlayer) entity;
@@ -1904,13 +2350,48 @@
@@ -1904,13 +2351,48 @@
}
}
@@ -1083,7 +1082,7 @@
}
public CombatTracker getCombatTracker() {
@@ -1935,8 +2416,18 @@
@@ -1935,8 +2417,18 @@
}
public final void setArrowCount(int stuckArrowCount) {
@@ -1103,7 +1102,7 @@
public final int getStingerCount() {
return (Integer) this.entityData.get(LivingEntity.DATA_STINGER_COUNT_ID);
@@ -1999,7 +2490,7 @@
@@ -1999,7 +2491,7 @@
this.playSound(soundeffect, this.getSoundVolume(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
}
@@ -1112,7 +1111,7 @@
this.setHealth(0.0F);
this.die(this.damageSources().generic());
}
@@ -2182,6 +2673,12 @@
@@ -2182,6 +2674,12 @@
public abstract ItemStack getItemBySlot(EquipmentSlot slot);
@@ -1125,7 +1124,7 @@
public abstract void setItemSlot(EquipmentSlot slot, ItemStack stack);
public Iterable<ItemStack> getHandSlots() {
@@ -2494,7 +2991,7 @@
@@ -2494,7 +2992,7 @@
}
@@ -1134,7 +1133,7 @@
Vec3 vec3d1 = this.getRiddenInput(controllingPlayer, movementInput);
this.tickRidden(controllingPlayer, vec3d1);
@@ -2507,13 +3004,13 @@
@@ -2507,13 +3005,13 @@
}
@@ -1151,7 +1150,7 @@
return this.getSpeed();
}
@@ -2571,7 +3068,7 @@
@@ -2571,7 +3069,7 @@
double d1 = Mth.clamp(motion.z, -0.15000000596046448D, 0.15000000596046448D);
double d2 = Math.max(motion.y, -0.15000000596046448D);
@@ -1160,7 +1159,7 @@
d2 = 0.0D;
}
@@ -2586,7 +3083,7 @@
@@ -2586,7 +3084,7 @@
}
protected float getFlyingSpeed() {
@@ -1169,7 +1168,7 @@
}
public float getSpeed() {
@@ -2604,6 +3101,7 @@
@@ -2604,6 +3102,7 @@
@Override
public void tick() {
@@ -1177,7 +1176,7 @@
super.tick();
this.updatingUsingItem();
this.updateSwimAmount();
@@ -2634,7 +3132,7 @@
@@ -2634,7 +3133,7 @@
}
}
@@ -1186,7 +1185,7 @@
if (this.tickCount % 20 == 0) {
this.getCombatTracker().recheckStatus();
}
@@ -2645,7 +3143,9 @@
@@ -2645,7 +3144,9 @@
}
if (!this.isRemoved()) {
@@ -1196,7 +1195,7 @@
}
double d0 = this.getX() - this.xo;
@@ -2739,9 +3239,10 @@
@@ -2739,9 +3240,10 @@
}
this.elytraAnimationState.tick();
@@ -1208,7 +1207,7 @@
Map<EquipmentSlot, ItemStack> map = this.collectEquipmentChanges();
if (map != null) {
@@ -2945,6 +3446,7 @@
@@ -2945,6 +3447,7 @@
ProfilerFiller gameprofilerfiller = Profiler.get();
gameprofilerfiller.push("ai");
@@ -1216,7 +1215,7 @@
if (this.isImmobile()) {
this.jumping = false;
this.xxa = 0.0F;
@@ -2954,6 +3456,7 @@
@@ -2954,6 +3457,7 @@
this.serverAiStep();
gameprofilerfiller.pop();
}
@@ -1224,7 +1223,7 @@
gameprofilerfiller.pop();
gameprofilerfiller.push("jump");
@@ -2996,11 +3499,12 @@
@@ -2996,11 +3500,12 @@
this.resetFallDistance();
}
@@ -1238,7 +1237,7 @@
if (this.isAlive()) {
this.travelRidden(entityhuman, vec3d1);
break label112;
@@ -3009,6 +3513,7 @@
@@ -3009,6 +3514,7 @@
this.travel(vec3d1);
}
@@ -1246,7 +1245,7 @@
if (!this.level().isClientSide() || this.isControlledByLocalInstance()) {
this.applyEffectsFromBlocks();
@@ -3044,7 +3549,9 @@
@@ -3044,7 +3550,9 @@
this.checkAutoSpinAttack(axisalignedbb, this.getBoundingBox());
}
@@ -1256,7 +1255,7 @@
gameprofilerfiller.pop();
world = this.level();
if (world instanceof ServerLevel worldserver) {
@@ -3063,6 +3570,7 @@
@@ -3063,6 +3571,7 @@
this.checkSlowFallDistance();
if (!this.level().isClientSide) {
if (!this.canGlide()) {
@@ -1264,7 +1263,7 @@
this.setSharedFlag(7, false);
return;
}
@@ -3113,7 +3621,7 @@
@@ -3113,7 +3622,7 @@
Level world = this.level();
if (!(world instanceof ServerLevel worldserver)) {
@@ -1273,7 +1272,7 @@
} else {
List list = this.level().getEntities((Entity) this, this.getBoundingBox(), EntitySelector.pushableBy(this));
@@ -3305,15 +3813,22 @@
@@ -3305,15 +3814,22 @@
@Override
public boolean isPickable() {
@@ -1298,7 +1297,7 @@
public float getYHeadRot() {
return this.yHeadRot;
}
@@ -3483,8 +3998,31 @@
@@ -3483,8 +3999,31 @@
this.releaseUsingItem();
} else {
if (!this.useItem.isEmpty() && this.isUsingItem()) {
@@ -1331,7 +1330,7 @@
if (itemstack != this.useItem) {
this.setItemInHand(enumhand, itemstack);
}
@@ -3568,12 +4106,18 @@
@@ -3568,12 +4107,18 @@
}
public boolean randomTeleport(double x, double y, double z, boolean particleEffects) {
@@ -1352,7 +1351,7 @@
Level world = this.level();
if (world.hasChunkAt(blockposition)) {
@@ -3592,18 +4136,43 @@
@@ -3592,18 +4137,43 @@
}
if (flag2) {
@@ -1400,7 +1399,7 @@
world.broadcastEntityEvent(this, (byte) 46);
}
@@ -3613,7 +4182,7 @@
@@ -3613,7 +4183,7 @@
entitycreature.getNavigation().stop();
}
@@ -1409,7 +1408,7 @@
}
}
@@ -3706,7 +4275,7 @@
@@ -3706,7 +4276,7 @@
}
public void stopSleeping() {
@@ -1418,7 +1417,7 @@
Level world = this.level();
java.util.Objects.requireNonNull(world);
@@ -3718,9 +4287,9 @@
@@ -3718,9 +4288,9 @@
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(() -> {
@@ -1430,7 +1429,7 @@
});
Vec3 vec3d1 = Vec3.atBottomCenterOf(blockposition).subtract(vec3d).normalize();
float f = (float) Mth.wrapDegrees(Mth.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
@@ -3740,7 +4309,7 @@
@@ -3740,7 +4310,7 @@
@Nullable
public Direction getBedOrientation() {
@@ -1439,7 +1438,7 @@
return blockposition != null ? BedBlock.getBedOrientation(this.level(), blockposition) : null;
}
@@ -3905,7 +4474,7 @@
@@ -3905,7 +4475,7 @@
public float maxUpStep() {
float f = (float) this.getAttributeValue(Attributes.STEP_HEIGHT);