== 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

@@ -112,7 +112,7 @@
@Nullable
private Vec3 startingToFallPosition;
@Nullable
@@ -258,6 +291,22 @@
@@ -258,6 +291,23 @@
private final CommandSource commandSource;
private int containerCounter;
public boolean wonGame;
@@ -132,10 +132,11 @@
+ public boolean sentListPacket = false;
+ public String kickLeaveMessage = null; // SPIGOT-3034: Forward leave message to PlayerQuitEvent
+ // CraftBukkit end
+ public boolean isRealPlayer; // Paper
public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile, ClientInformation clientOptions) {
super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile);
@@ -340,6 +389,13 @@
@@ -340,6 +390,13 @@
public void sendSystemMessage(Component message) {
ServerPlayer.this.sendSystemMessage(message);
}
@@ -149,7 +150,7 @@
};
this.textFilter = server.createTextFilterForPlayer(this);
this.gameMode = server.createGameModeForPlayer(this);
@@ -352,14 +408,67 @@
@@ -352,14 +409,67 @@
this.moveTo(this.adjustSpawnLocation(world, world.getSharedSpawnPos()).getBottomCenter(), 0.0F, 0.0F);
this.updateOptions(clientOptions);
this.object = null;
@@ -218,7 +219,7 @@
int i = Math.max(0, this.server.getSpawnRadius(world));
int j = Mth.floor(world.getWorldBorder().getDistanceToBorder((double) basePos.getX(), (double) basePos.getZ()));
@@ -395,14 +504,20 @@
@@ -395,14 +505,20 @@
Objects.requireNonNull(basePos);
crashreportsystemdetails.setDetail("Origin", basePos::toString);
@@ -241,7 +242,7 @@
});
throw new ReportedException(crashreport);
}
@@ -440,7 +555,7 @@
@@ -440,7 +556,7 @@
dataresult = WardenSpawnTracker.CODEC.parse(new Dynamic(NbtOps.INSTANCE, nbt.get("warden_spawn_tracker")));
logger = ServerPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -250,7 +251,7 @@
this.wardenSpawnTracker = wardenspawntracker;
});
}
@@ -457,17 +572,26 @@
@@ -457,17 +573,26 @@
return this.server.getRecipeManager().byKey(resourcekey).isPresent();
});
}
@@ -278,7 +279,7 @@
Logger logger1 = ServerPlayer.LOGGER;
Objects.requireNonNull(logger1);
@@ -482,7 +606,7 @@
@@ -482,7 +607,7 @@
dataresult = BlockPos.CODEC.parse(NbtOps.INSTANCE, nbtbase);
logger = ServerPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -287,7 +288,7 @@
this.raidOmenPosition = blockposition;
});
}
@@ -492,7 +616,7 @@
@@ -492,7 +617,7 @@
@Override
public void addAdditionalSaveData(CompoundTag nbt) {
super.addAdditionalSaveData(nbt);
@@ -296,7 +297,7 @@
Logger logger = ServerPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -526,6 +650,7 @@
@@ -526,6 +651,7 @@
nbt.put("SpawnDimension", nbtbase);
});
}
@@ -304,7 +305,7 @@
nbt.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall);
if (this.raidOmenPosition != null) {
@@ -544,7 +669,20 @@
@@ -544,7 +670,20 @@
Entity entity = this.getRootVehicle();
Entity entity1 = this.getVehicle();
@@ -326,7 +327,7 @@
CompoundTag nbttagcompound1 = new CompoundTag();
CompoundTag nbttagcompound2 = new CompoundTag();
@@ -598,12 +736,12 @@
@@ -598,12 +737,12 @@
if (!this.isPassenger()) {
ServerPlayer.LOGGER.warn("Couldn't reattach entity to player");
@@ -341,7 +342,7 @@
}
}
}
@@ -625,7 +763,7 @@
@@ -625,7 +764,7 @@
CompoundTag nbttagcompound1 = new CompoundTag();
entityenderpearl.save(nbttagcompound1);
@@ -350,7 +351,7 @@
Logger logger = ServerPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -651,7 +789,7 @@
@@ -651,7 +790,7 @@
nbttaglist.forEach((nbtbase1) -> {
if (nbtbase1 instanceof CompoundTag nbttagcompound) {
if (nbttagcompound.contains("ender_pearl_dimension")) {
@@ -359,7 +360,7 @@
Logger logger = ServerPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -684,7 +822,30 @@
@@ -684,7 +823,30 @@
}
}
@@ -390,7 +391,7 @@
public void setExperiencePoints(int points) {
float f = (float) this.getXpNeededForNextLevel();
@@ -744,6 +905,11 @@
@@ -744,6 +906,11 @@
@Override
public void tick() {
@@ -402,7 +403,7 @@
this.tickClientLoadTimeout();
this.gameMode.tick();
this.wardenSpawnTracker.tick();
@@ -820,7 +986,7 @@
@@ -820,7 +987,7 @@
}
if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) {
@@ -411,7 +412,7 @@
this.lastSentHealth = this.getHealth();
this.lastSentFood = this.foodData.getFoodLevel();
this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F;
@@ -851,6 +1017,12 @@
@@ -851,6 +1018,12 @@
this.updateScoreForCriteria(ObjectiveCriteria.EXPERIENCE, Mth.ceil((float) this.lastRecordedExperience));
}
@@ -424,17 +425,15 @@
if (this.experienceLevel != this.lastRecordedLevel) {
this.lastRecordedLevel = this.experienceLevel;
this.updateScoreForCriteria(ObjectiveCriteria.LEVEL, Mth.ceil((float) this.lastRecordedLevel));
@@ -863,8 +1035,22 @@
if (this.tickCount % 20 == 0) {
@@ -865,6 +1038,20 @@
CriteriaTriggers.LOCATION.trigger(this);
+ }
+
}
+ // CraftBukkit start - initialize oldLevel, fire PlayerLevelChangeEvent, and tick client-sided world border
+ if (this.oldLevel == -1) {
+ this.oldLevel = this.experienceLevel;
}
+ }
+
+ if (this.oldLevel != this.experienceLevel) {
+ CraftEventFactory.callPlayerLevelChangeEvent(this.getBukkitEntity(), this.oldLevel, this.experienceLevel);
+ this.oldLevel = this.experienceLevel;
@@ -447,7 +446,7 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player");
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Player being ticked");
@@ -893,7 +1079,7 @@
@@ -893,7 +1080,7 @@
if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.serverLevel().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
if (this.tickCount % 20 == 0) {
if (this.getHealth() < this.getMaxHealth()) {
@@ -456,7 +455,7 @@
}
float f = this.foodData.getSaturationLevel();
@@ -946,7 +1132,8 @@
@@ -946,7 +1133,8 @@
}
private void updateScoreForCriteria(ObjectiveCriteria criterion, int score) {
@@ -466,7 +465,7 @@
scoreaccess.set(score);
});
}
@@ -955,10 +1142,48 @@
@@ -955,9 +1143,47 @@
public void die(DamageSource damageSource) {
this.gameEvent(GameEvent.ENTITY_DIE);
boolean flag = this.serverLevel().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
@@ -489,7 +488,7 @@
+ // SPIGOT-5071: manually add player loot tables (SPIGOT-5195 - ignores keepInventory rule)
+ this.dropFromLootTable(this.serverLevel(), damageSource, this.lastHurtByPlayerTime > 0);
+ this.dropCustomDeathLoot(this.serverLevel(), damageSource, flag);
+
+ loot.addAll(this.drops);
+ this.drops.clear(); // SPIGOT-5188: make sure to clear
+
@@ -513,11 +512,10 @@
+ } else {
+ ichatbasecomponent = org.bukkit.craftbukkit.util.CraftChatMessage.fromStringOrNull(deathMessage);
+ }
+
this.connection.send(new ClientboundPlayerCombatKillPacket(this.getId(), ichatbasecomponent), PacketSendListener.exceptionallySend(() -> {
boolean flag1 = true;
String s = ichatbasecomponent.getString(256);
@@ -988,12 +1213,18 @@
@@ -988,12 +1214,18 @@
if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) {
this.tellNeutralMobsThatIDied();
}
@@ -540,7 +538,7 @@
LivingEntity entityliving = this.getKillCredit();
if (entityliving != null) {
@@ -1028,10 +1259,12 @@
@@ -1028,10 +1260,12 @@
public void awardKillScore(Entity entityKilled, DamageSource damageSource) {
if (entityKilled != this) {
super.awardKillScore(entityKilled, damageSource);
@@ -556,7 +554,7 @@
} else {
this.awardStat(Stats.MOB_KILLS);
}
@@ -1049,7 +1282,8 @@
@@ -1049,7 +1283,8 @@
int i = scoreboardteam.getColor().getId();
if (i >= 0 && i < criterions.length) {
@@ -566,7 +564,7 @@
}
}
@@ -1062,8 +1296,8 @@
@@ -1062,8 +1297,8 @@
} else {
Entity entity = source.getEntity();
@@ -577,7 +575,7 @@
if (!this.canHarmPlayer(entityhuman)) {
return false;
@@ -1074,8 +1308,8 @@
@@ -1074,8 +1309,8 @@
AbstractArrow entityarrow = (AbstractArrow) entity;
Entity entity1 = entityarrow.getOwner();
@@ -588,7 +586,7 @@
if (!this.canHarmPlayer(entityhuman1)) {
return false;
@@ -1088,33 +1322,63 @@
@@ -1088,33 +1323,63 @@
}
@Override
@@ -659,7 +657,7 @@
}
public static Optional<ServerPlayer.RespawnPosAngle> findRespawnAndUseSpawnBlock(ServerLevel world, BlockPos pos, float spawnAngle, boolean spawnForced, boolean alive) {
@@ -1129,11 +1393,11 @@
@@ -1129,11 +1394,11 @@
}
return optional.map((vec3d) -> {
@@ -673,7 +671,7 @@
});
} else if (!spawnForced) {
return Optional.empty();
@@ -1142,7 +1406,7 @@
@@ -1142,7 +1407,7 @@
BlockState iblockdata1 = world.getBlockState(pos.above());
boolean flag3 = iblockdata1.getBlock().isPossibleToRespawnInThis(iblockdata1);
@@ -682,7 +680,7 @@
}
}
@@ -1160,6 +1424,7 @@
@@ -1160,6 +1425,7 @@
@Nullable
@Override
public ServerPlayer teleport(TeleportTransition teleportTarget) {
@@ -690,7 +688,7 @@
if (this.isRemoved()) {
return null;
} else {
@@ -1169,39 +1434,73 @@
@@ -1169,39 +1435,73 @@
ServerLevel worldserver = teleportTarget.newLevel();
ServerLevel worldserver1 = this.serverLevel();
@@ -772,7 +770,7 @@
this.connection.resetPosition();
worldserver.addDuringTeleport(this);
gameprofilerfiller.pop();
@@ -1215,12 +1514,30 @@
@@ -1215,12 +1515,30 @@
this.lastSentExp = -1;
this.lastSentHealth = -1.0F;
this.lastSentFood = -1;
@@ -803,7 +801,7 @@
public void forceSetRotation(float yaw, float pitch) {
this.connection.send(new ClientboundPlayerRotationPacket(yaw, pitch));
}
@@ -1228,13 +1545,21 @@
@@ -1228,13 +1546,21 @@
public void triggerDimensionChangeTriggers(ServerLevel origin) {
ResourceKey<Level> resourcekey = origin.dimension();
ResourceKey<Level> resourcekey1 = this.level().dimension();
@@ -828,7 +826,7 @@
this.enteredNetherPosition = null;
}
@@ -1251,36 +1576,63 @@
@@ -1251,36 +1577,63 @@
this.containerMenu.broadcastChanges();
}
@@ -907,7 +905,7 @@
this.awardStat(Stats.SLEEP_IN_BED);
CriteriaTriggers.SLEPT_IN_BED.trigger(this);
});
@@ -1293,9 +1645,8 @@
@@ -1293,9 +1646,8 @@
return either;
}
}
@@ -918,7 +916,7 @@
}
@Override
@@ -1322,13 +1673,31 @@
@@ -1322,13 +1674,31 @@
@Override
public void stopSleepInBed(boolean skipSleepTimer, boolean updateSleepingPlayers) {
@@ -951,7 +949,7 @@
}
}
@@ -1387,8 +1756,9 @@
@@ -1387,8 +1757,9 @@
this.connection.send(new ClientboundOpenSignEditorPacket(sign.getBlockPos(), front));
}
@@ -962,7 +960,7 @@
}
@Override
@@ -1396,13 +1766,35 @@
@@ -1396,13 +1767,35 @@
if (factory == null) {
return OptionalInt.empty();
} else {
@@ -998,7 +996,7 @@
if (container == null) {
if (this.isSpectator()) {
this.displayClientMessage(Component.translatable("container.spectatorCantOpen").withStyle(ChatFormatting.RED), true);
@@ -1410,9 +1802,11 @@
@@ -1410,9 +1803,11 @@
return OptionalInt.empty();
} else {
@@ -1012,7 +1010,7 @@
return OptionalInt.of(this.containerCounter);
}
}
@@ -1425,15 +1819,26 @@
@@ -1425,15 +1820,26 @@
@Override
public void openHorseInventory(AbstractHorse horse, Container inventory) {
@@ -1041,7 +1039,7 @@
this.initMenu(this.containerMenu);
}
@@ -1456,6 +1861,7 @@
@@ -1456,6 +1862,7 @@
@Override
public void closeContainer() {
@@ -1049,7 +1047,7 @@
this.connection.send(new ClientboundContainerClosePacket(this.containerMenu.containerId));
this.doCloseContainer();
}
@@ -1485,19 +1891,19 @@
@@ -1485,19 +1892,19 @@
i = Math.round((float) Math.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ) * 100.0F);
if (i > 0) {
this.awardStat(Stats.SWIM_ONE_CM, i);
@@ -1072,7 +1070,7 @@
}
} else if (this.onClimbable()) {
if (deltaY > 0.0D) {
@@ -1508,13 +1914,13 @@
@@ -1508,13 +1915,13 @@
if (i > 0) {
if (this.isSprinting()) {
this.awardStat(Stats.SPRINT_ONE_CM, i);
@@ -1089,7 +1087,7 @@
}
}
} else if (this.isFallFlying()) {
@@ -1557,7 +1963,7 @@
@@ -1557,7 +1964,7 @@
@Override
public void awardStat(Stat<?> stat, int amount) {
this.stats.increment(this, stat, amount);
@@ -1098,7 +1096,7 @@
scoreaccess.add(amount);
});
}
@@ -1565,7 +1971,7 @@
@@ -1565,7 +1972,7 @@
@Override
public void resetStat(Stat<?> stat) {
this.stats.setValue(this, stat, 0);
@@ -1107,7 +1105,7 @@
}
@Override
@@ -1597,9 +2003,9 @@
@@ -1597,9 +2004,9 @@
super.jumpFromGround();
this.awardStat(Stats.JUMP);
if (this.isSprinting()) {
@@ -1119,7 +1117,7 @@
}
}
@@ -1625,6 +2031,7 @@
@@ -1625,6 +2032,7 @@
public void resetSentInfo() {
this.lastSentHealth = -1.0E8F;
@@ -1127,7 +1125,7 @@
}
@Override
@@ -1661,7 +2068,7 @@
@@ -1661,7 +2069,7 @@
this.onUpdateAbilities();
if (alive) {
this.getAttributes().assignBaseValues(oldPlayer.getAttributes());
@@ -1136,7 +1134,7 @@
this.setHealth(oldPlayer.getHealth());
this.foodData = oldPlayer.foodData;
Iterator iterator = oldPlayer.getActiveEffects().iterator();
@@ -1669,7 +2076,7 @@
@@ -1669,7 +2077,7 @@
while (iterator.hasNext()) {
MobEffectInstance mobeffect = (MobEffectInstance) iterator.next();
@@ -1145,7 +1143,7 @@
}
this.getInventory().replaceWith(oldPlayer.getInventory());
@@ -1680,7 +2087,7 @@
@@ -1680,7 +2088,7 @@
this.portalProcess = oldPlayer.portalProcess;
} else {
this.getAttributes().assignBaseValues(oldPlayer.getAttributes());
@@ -1154,7 +1152,7 @@
if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || oldPlayer.isSpectator()) {
this.getInventory().replaceWith(oldPlayer.getInventory());
this.experienceLevel = oldPlayer.experienceLevel;
@@ -1696,7 +2103,7 @@
@@ -1696,7 +2104,7 @@
this.lastSentExp = -1;
this.lastSentHealth = -1.0F;
this.lastSentFood = -1;
@@ -1163,7 +1161,7 @@
this.seenCredits = oldPlayer.seenCredits;
this.enteredNetherPosition = oldPlayer.enteredNetherPosition;
this.chunkTrackingView = oldPlayer.chunkTrackingView;
@@ -1752,19 +2159,19 @@
@@ -1752,19 +2160,19 @@
}
@Override
@@ -1187,7 +1185,7 @@
}
return flag1;
@@ -1878,6 +2285,16 @@
@@ -1878,6 +2286,16 @@
}
public void updateOptions(ClientInformation clientOptions) {
@@ -1204,7 +1202,7 @@
this.language = clientOptions.language();
this.requestedViewDistance = clientOptions.viewDistance();
this.chatVisibility = clientOptions.chatVisibility();
@@ -1962,7 +2379,7 @@
@@ -1962,7 +2380,7 @@
if (world instanceof ServerLevel) {
ServerLevel worldserver = (ServerLevel) world;
@@ -1213,7 +1211,7 @@
}
if (entity != null) {
@@ -1999,11 +2416,11 @@
@@ -1999,11 +2417,11 @@
@Nullable
public Component getTabListDisplayName() {
@@ -1227,7 +1225,7 @@
}
@Override
@@ -2046,17 +2463,43 @@
@@ -2046,17 +2464,43 @@
}
public void setRespawnPosition(ResourceKey<Level> dimension, @Nullable BlockPos pos, float angle, boolean forced, boolean sendMessage) {
@@ -1278,7 +1276,7 @@
} else {
this.respawnPosition = null;
this.respawnDimension = Level.OVERWORLD;
@@ -2088,18 +2531,44 @@
@@ -2088,18 +2532,44 @@
}
@Override
@@ -1327,7 +1325,7 @@
}
this.awardStat(Stats.DROP);
@@ -2375,16 +2844,160 @@
@@ -2375,16 +2845,160 @@
return TicketType.ENDER_PEARL.timeout();
}