Update to Minecraft 1.20.3

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2023-12-06 03:40:00 +11:00
parent afdb1d9bc3
commit 8398e12b34
256 changed files with 2745 additions and 1911 deletions

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/EntityPlayer.java
+++ b/net/minecraft/server/level/EntityPlayer.java
@@ -151,6 +151,37 @@
@@ -157,6 +157,38 @@
import net.minecraft.world.scores.criteria.IScoreboardCriteria;
import org.slf4j.Logger;
@@ -23,6 +23,7 @@
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.craftbukkit.util.CraftDimensionUtil;
+import org.bukkit.craftbukkit.util.CraftLocation;
+import org.bukkit.event.entity.EntityExhaustionEvent;
+import org.bukkit.event.player.PlayerBedLeaveEvent;
+import org.bukkit.event.player.PlayerChangedMainHandEvent;
+import org.bukkit.event.player.PlayerChangedWorldEvent;
@@ -38,7 +39,7 @@
public class EntityPlayer extends EntityHuman {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -185,7 +216,7 @@
@@ -192,7 +224,7 @@
private int levitationStartTime;
private boolean disconnected;
private int requestedViewDistance;
@@ -47,7 +48,7 @@
@Nullable
private Vec3D startingToFallPosition;
@Nullable
@@ -210,6 +241,20 @@
@@ -217,6 +249,20 @@
private int containerCounter;
public boolean wonGame;
@@ -68,7 +69,7 @@
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, ClientInformation clientinformation) {
super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile);
this.chatVisibility = EnumChatVisibility.FULL;
@@ -276,12 +321,56 @@
@@ -283,12 +329,56 @@
this.setMaxUpStep(1.0F);
this.fudgeSpawnLocation(worldserver);
this.updateOptions(clientinformation);
@@ -77,8 +78,8 @@
+ this.displayName = this.getScoreboardName();
+ this.bukkitPickUpLoot = true;
+ this.maxHealthCache = this.getMaxHealth();
}
+ }
+
+ // Yes, this doesn't match Vanilla, but it's the best we can do for now.
+ // If this is an issue, PRs are welcome
+ public final BlockPosition getSpawnPoint(WorldServer worldserver) {
@@ -115,9 +116,9 @@
+ }
+
+ return blockposition;
+ }
}
+ // CraftBukkit end
+
private void fudgeSpawnLocation(WorldServer worldserver) {
BlockPosition blockposition = worldserver.getSharedSpawnPos();
@@ -126,7 +127,7 @@
int i = Math.max(0, this.server.getSpawnRadius(worldserver));
int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ()));
@@ -330,7 +419,7 @@
@@ -337,7 +427,7 @@
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.readAdditionalSaveData(nbttagcompound);
if (nbttagcompound.contains("warden_spawn_tracker", 10)) {
@@ -135,7 +136,7 @@
Logger logger = EntityPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -349,17 +438,26 @@
@@ -356,17 +446,26 @@
if (nbttagcompound.contains("recipeBook", 10)) {
this.recipeBook.fromNbt(nbttagcompound.getCompound("recipeBook"), this.server.getRecipeManager());
}
@@ -163,7 +164,7 @@
Logger logger1 = EntityPlayer.LOGGER;
Objects.requireNonNull(logger1);
@@ -372,7 +470,7 @@
@@ -379,7 +478,7 @@
@Override
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.addAdditionalSaveData(nbttagcompound);
@@ -172,7 +173,7 @@
Logger logger = EntityPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -393,7 +491,20 @@
@@ -400,7 +499,20 @@
Entity entity = this.getRootVehicle();
Entity entity1 = this.getVehicle();
@@ -194,7 +195,7 @@
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
NBTTagCompound nbttagcompound3 = new NBTTagCompound();
@@ -418,8 +529,32 @@
@@ -425,8 +537,32 @@
nbttagcompound.put("SpawnDimension", nbtbase);
});
}
@@ -227,7 +228,7 @@
public void setExperiencePoints(int i) {
float f = (float) this.getXpNeededForNextLevel();
@@ -479,6 +614,11 @@
@@ -486,6 +622,11 @@
@Override
public void tick() {
@@ -239,7 +240,7 @@
this.gameMode.tick();
this.wardenSpawnTracker.tick();
--this.spawnInvulnerableTime;
@@ -535,7 +675,7 @@
@@ -542,7 +683,7 @@
}
if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) {
@@ -248,7 +249,7 @@
this.lastSentHealth = this.getHealth();
this.lastSentFood = this.foodData.getFoodLevel();
this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F;
@@ -566,6 +706,12 @@
@@ -573,6 +714,12 @@
this.updateScoreForCriteria(IScoreboardCriteria.EXPERIENCE, MathHelper.ceil((float) this.lastRecordedExperience));
}
@@ -261,7 +262,7 @@
if (this.experienceLevel != this.lastRecordedLevel) {
this.lastRecordedLevel = this.experienceLevel;
this.updateScoreForCriteria(IScoreboardCriteria.LEVEL, MathHelper.ceil((float) this.lastRecordedLevel));
@@ -580,6 +726,20 @@
@@ -587,6 +734,20 @@
CriterionTriggers.LOCATION.trigger(this);
}
@@ -282,17 +283,17 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player");
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Player being ticked");
@@ -622,7 +782,8 @@
@@ -629,7 +790,8 @@
}
private void updateScoreForCriteria(IScoreboardCriteria iscoreboardcriteria, int i) {
- this.getScoreboard().forAllObjectives(iscoreboardcriteria, this.getScoreboardName(), (scoreboardscore) -> {
- this.getScoreboard().forAllObjectives(iscoreboardcriteria, this, (scoreaccess) -> {
+ // CraftBukkit - Use our scores instead
+ this.level().getCraftServer().getScoreboardManager().getScoreboardScores(iscoreboardcriteria, this.getScoreboardName(), (scoreboardscore) -> {
scoreboardscore.setScore(i);
+ this.level().getCraftServer().getScoreboardManager().forAllObjectives(iscoreboardcriteria, this, (scoreaccess) -> {
scoreaccess.set(i);
});
}
@@ -631,9 +792,47 @@
@@ -638,9 +800,47 @@
public void die(DamageSource damagesource) {
this.gameEvent(GameEvent.ENTITY_DIE);
boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
@@ -342,7 +343,7 @@
this.connection.send(new ClientboundPlayerCombatKillPacket(this.getId(), ichatbasecomponent), PacketSendListener.exceptionallySend(() -> {
boolean flag1 = true;
@@ -664,12 +863,18 @@
@@ -671,12 +871,18 @@
if (this.level().getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) {
this.tellNeutralMobsThatIDied();
}
@@ -356,41 +357,41 @@
+ this.getInventory().clearContent();
}
- this.getScoreboard().forAllObjectives(IScoreboardCriteria.DEATH_COUNT, this.getScoreboardName(), ScoreboardScore::increment);
- this.getScoreboard().forAllObjectives(IScoreboardCriteria.DEATH_COUNT, this, ScoreAccess::increment);
+ this.setCamera(this); // Remove spectated target
+ // CraftBukkit end
+
+ // CraftBukkit - Get our scores instead
+ this.level().getCraftServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.DEATH_COUNT, this.getScoreboardName(), ScoreboardScore::increment);
+ this.level().getCraftServer().getScoreboardManager().forAllObjectives(IScoreboardCriteria.DEATH_COUNT, this, ScoreAccess::increment);
EntityLiving entityliving = this.getKillCredit();
if (entityliving != null) {
@@ -707,10 +912,12 @@
String s = this.getScoreboardName();
String s1 = entity.getScoreboardName();
- this.getScoreboard().forAllObjectives(IScoreboardCriteria.KILL_COUNT_ALL, s, ScoreboardScore::increment);
@@ -711,10 +917,12 @@
if (entity != this) {
super.awardKillScore(entity, i, damagesource);
this.increaseScore(i);
- this.getScoreboard().forAllObjectives(IScoreboardCriteria.KILL_COUNT_ALL, this, ScoreAccess::increment);
+ // CraftBukkit - Get our scores instead
+ this.level().getCraftServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.KILL_COUNT_ALL, s, ScoreboardScore::increment);
+ this.level().getCraftServer().getScoreboardManager().forAllObjectives(IScoreboardCriteria.KILL_COUNT_ALL, this, ScoreAccess::increment);
if (entity instanceof EntityHuman) {
this.awardStat(StatisticList.PLAYER_KILLS);
- this.getScoreboard().forAllObjectives(IScoreboardCriteria.KILL_COUNT_PLAYERS, s, ScoreboardScore::increment);
- this.getScoreboard().forAllObjectives(IScoreboardCriteria.KILL_COUNT_PLAYERS, this, ScoreAccess::increment);
+ // CraftBukkit - Get our scores instead
+ this.level().getCraftServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.KILL_COUNT_PLAYERS, s, ScoreboardScore::increment);
+ this.level().getCraftServer().getScoreboardManager().forAllObjectives(IScoreboardCriteria.KILL_COUNT_PLAYERS, this, ScoreAccess::increment);
} else {
this.awardStat(StatisticList.MOB_KILLS);
}
@@ -728,7 +935,8 @@
@@ -732,7 +940,8 @@
int i = scoreboardteam.getColor().getId();
if (i >= 0 && i < aiscoreboardcriteria.length) {
- this.getScoreboard().forAllObjectives(aiscoreboardcriteria[i], s, ScoreboardScore::increment);
- this.getScoreboard().forAllObjectives(aiscoreboardcriteria[i], scoreholder, ScoreAccess::increment);
+ // CraftBukkit - Get our scores instead
+ this.level().getCraftServer().getScoreboardManager().getScoreboardScores(aiscoreboardcriteria[i], s, ScoreboardScore::increment);
+ this.level().getCraftServer().getScoreboardManager().forAllObjectives(aiscoreboardcriteria[i], scoreholder, ScoreAccess::increment);
}
}
@@ -778,18 +986,20 @@
@@ -782,18 +991,20 @@
}
private boolean isPvpAllowed() {
@@ -414,7 +415,7 @@
} else {
return shapedetectorshape;
}
@@ -798,11 +1008,20 @@
@@ -802,11 +1013,20 @@
@Nullable
@Override
public Entity changeDimension(WorldServer worldserver) {
@@ -438,7 +439,7 @@
this.unRide();
this.serverLevel().removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
if (!this.wonGame) {
@@ -813,6 +1032,8 @@
@@ -817,6 +1037,8 @@
return this;
} else {
@@ -447,7 +448,7 @@
WorldData worlddata = worldserver.getLevelData();
this.connection.send(new PacketPlayOutRespawn(this.createCommonSpawnInfo(worldserver), (byte) 3));
@@ -822,20 +1043,50 @@
@@ -826,20 +1048,50 @@
playerlist.sendPlayerPermissionLevel(this);
worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
this.unsetRemoved();
@@ -503,7 +504,7 @@
this.connection.resetPosition();
worldserver.addDuringPortalTeleport(this);
worldserver1.getProfiler().pop();
@@ -855,39 +1106,66 @@
@@ -859,39 +1111,66 @@
this.lastSentExp = -1;
this.lastSentHealth = -1.0F;
this.lastSentFood = -1;
@@ -576,7 +577,7 @@
}
return optional1;
@@ -897,13 +1175,21 @@
@@ -901,13 +1180,21 @@
public void triggerDimensionChangeTriggers(WorldServer worldserver) {
ResourceKey<World> resourcekey = worldserver.dimension();
ResourceKey<World> resourcekey1 = this.level().dimension();
@@ -601,7 +602,7 @@
this.enteredNetherPosition = null;
}
@@ -920,19 +1206,17 @@
@@ -924,19 +1211,17 @@
this.containerMenu.broadcastChanges();
}
@@ -625,7 +626,7 @@
if (this.level().isDay()) {
return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_NOW);
} else {
@@ -949,7 +1233,36 @@
@@ -953,7 +1238,36 @@
}
}
@@ -663,7 +664,7 @@
this.awardStat(StatisticList.SLEEP_IN_BED);
CriterionTriggers.SLEPT_IN_BED.trigger(this);
});
@@ -962,9 +1275,8 @@
@@ -966,9 +1280,8 @@
return either;
}
}
@@ -674,7 +675,7 @@
}
@Override
@@ -991,13 +1303,31 @@
@@ -995,13 +1308,31 @@
@Override
public void stopSleepInBed(boolean flag, boolean flag1) {
@@ -707,7 +708,7 @@
}
}
@@ -1039,8 +1369,9 @@
@@ -1051,8 +1382,9 @@
this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos(), flag));
}
@@ -718,7 +719,7 @@
}
@Override
@@ -1048,13 +1379,35 @@
@@ -1060,13 +1392,35 @@
if (itileinventory == null) {
return OptionalInt.empty();
} else {
@@ -754,7 +755,7 @@
if (container == null) {
if (this.isSpectator()) {
this.displayClientMessage(IChatBaseComponent.translatable("container.spectatorCantOpen").withStyle(EnumChatFormat.RED), true);
@@ -1062,9 +1415,11 @@
@@ -1074,9 +1428,11 @@
return OptionalInt.empty();
} else {
@@ -768,7 +769,7 @@
return OptionalInt.of(this.containerCounter);
}
}
@@ -1077,13 +1432,24 @@
@@ -1089,13 +1445,24 @@
@Override
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
@@ -795,7 +796,7 @@
this.initMenu(this.containerMenu);
}
@@ -1106,6 +1472,7 @@
@@ -1118,6 +1485,7 @@
@Override
public void closeContainer() {
@@ -803,7 +804,7 @@
this.connection.send(new PacketPlayOutCloseWindow(this.containerMenu.containerId));
this.doCloseContainer();
}
@@ -1128,6 +1495,16 @@
@@ -1140,6 +1508,16 @@
}
this.jumping = flag;
@@ -820,34 +821,65 @@
this.setShiftKeyDown(flag1);
}
@@ -1136,7 +1513,7 @@
@@ -1173,19 +1551,19 @@
i = Math.round((float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
if (i > 0) {
this.awardStat(StatisticList.SWIM_ONE_CM, i);
- this.causeFoodExhaustion(0.01F * (float) i * 0.01F);
+ this.causeFoodExhaustion(0.01F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.SWIM); // CraftBukkit - EntityExhaustionEvent
}
} else if (this.isEyeInFluid(TagsFluid.WATER)) {
i = Math.round((float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
if (i > 0) {
this.awardStat(StatisticList.WALK_UNDER_WATER_ONE_CM, i);
- this.causeFoodExhaustion(0.01F * (float) i * 0.01F);
+ this.causeFoodExhaustion(0.01F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK_UNDERWATER); // CraftBukkit - EntityExhaustionEvent
}
} else if (this.isInWater()) {
i = Math.round((float) Math.sqrt(d0 * d0 + d2 * d2) * 100.0F);
if (i > 0) {
this.awardStat(StatisticList.WALK_ON_WATER_ONE_CM, i);
- this.causeFoodExhaustion(0.01F * (float) i * 0.01F);
+ this.causeFoodExhaustion(0.01F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK_ON_WATER); // CraftBukkit - EntityExhaustionEvent
}
} else if (this.onClimbable()) {
if (d1 > 0.0D) {
@@ -1196,13 +1574,13 @@
if (i > 0) {
if (this.isSprinting()) {
this.awardStat(StatisticList.SPRINT_ONE_CM, i);
- this.causeFoodExhaustion(0.1F * (float) i * 0.01F);
+ this.causeFoodExhaustion(0.1F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.SPRINT); // CraftBukkit - EntityExhaustionEvent
} else if (this.isCrouching()) {
this.awardStat(StatisticList.CROUCH_ONE_CM, i);
- this.causeFoodExhaustion(0.0F * (float) i * 0.01F);
+ this.causeFoodExhaustion(0.0F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.CROUCH); // CraftBukkit - EntityExhaustionEvent
} else {
this.awardStat(StatisticList.WALK_ONE_CM, i);
- this.causeFoodExhaustion(0.0F * (float) i * 0.01F);
+ this.causeFoodExhaustion(0.0F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK); // CraftBukkit - EntityExhaustionEvent
}
}
} else if (this.isFallFlying()) {
@@ -1245,7 +1623,7 @@
@Override
public void awardStat(Statistic<?> statistic, int i) {
this.stats.increment(this, statistic, i);
- this.getScoreboard().forAllObjectives(statistic, this.getScoreboardName(), (scoreboardscore) -> {
+ this.level().getCraftServer().getScoreboardManager().getScoreboardScores(statistic, this.getScoreboardName(), (scoreboardscore) -> { // CraftBukkit - Get our scores instead
scoreboardscore.add(i);
- this.getScoreboard().forAllObjectives(statistic, this, (scoreaccess) -> {
+ this.level().getCraftServer().getScoreboardManager().forAllObjectives(statistic, this, (scoreaccess) -> {
scoreaccess.add(i);
});
}
@@ -1144,7 +1521,7 @@
@@ -1253,7 +1631,7 @@
@Override
public void resetStat(Statistic<?> statistic) {
this.stats.setValue(this, statistic, 0);
- this.getScoreboard().forAllObjectives(statistic, this.getScoreboardName(), ScoreboardScore::reset);
+ this.level().getCraftServer().getScoreboardManager().getScoreboardScores(statistic, this.getScoreboardName(), ScoreboardScore::reset); // CraftBukkit - Get our scores instead
- this.getScoreboard().forAllObjectives(statistic, this, ScoreAccess::reset);
+ this.level().getCraftServer().getScoreboardManager().forAllObjectives(statistic, this, ScoreAccess::reset); // CraftBukkit - Get our scores instead
}
@Override
@@ -1165,7 +1542,7 @@
for (int j = 0; j < i; ++j) {
MinecraftKey minecraftkey = aminecraftkey1[j];
- Optional optional = this.server.getRecipeManager().byKey(minecraftkey);
+ Optional<? extends RecipeHolder<?>> optional = this.server.getRecipeManager().byKey(minecraftkey); // CraftBukkit - decompile error
Objects.requireNonNull(list);
optional.ifPresent(list::add);
@@ -1200,6 +1577,7 @@
@@ -1301,6 +1679,7 @@
public void resetSentInfo() {
this.lastSentHealth = -1.0E8F;
@@ -855,7 +887,7 @@
}
@Override
@@ -1257,7 +1635,7 @@
@@ -1358,7 +1737,7 @@
this.lastSentExp = -1;
this.lastSentHealth = -1.0F;
this.lastSentFood = -1;
@@ -864,7 +896,7 @@
this.seenCredits = entityplayer.seenCredits;
this.enteredNetherPosition = entityplayer.enteredNetherPosition;
this.chunkTrackingView = entityplayer.chunkTrackingView;
@@ -1308,6 +1686,12 @@
@@ -1409,6 +1788,12 @@
@Override
public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<RelativeMovement> set, float f, float f1) {
@@ -877,7 +909,7 @@
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(BlockPosition.containing(d0, d1, d2));
worldserver.getChunkSource().addRegionTicket(TicketType.POST_TELEPORT, chunkcoordintpair, 1, this.getId());
@@ -1317,9 +1701,9 @@
@@ -1418,9 +1803,9 @@
}
if (worldserver == this.level()) {
@@ -889,7 +921,7 @@
}
this.setYHeadRot(f);
@@ -1423,6 +1807,16 @@
@@ -1524,6 +1909,16 @@
}
public void updateOptions(ClientInformation clientinformation) {
@@ -906,7 +938,7 @@
this.language = clientinformation.language();
this.requestedViewDistance = clientinformation.viewDistance();
this.chatVisibility = clientinformation.chatVisibility();
@@ -1506,7 +1900,7 @@
@@ -1607,7 +2002,7 @@
if (world instanceof WorldServer) {
WorldServer worldserver = (WorldServer) world;
@@ -915,7 +947,7 @@
}
if (entity != null) {
@@ -1543,7 +1937,7 @@
@@ -1644,7 +2039,7 @@
@Nullable
public IChatBaseComponent getTabListDisplayName() {
@@ -924,7 +956,7 @@
}
@Override
@@ -1564,9 +1958,16 @@
@@ -1665,9 +2060,16 @@
return this.advancements;
}
@@ -941,7 +973,7 @@
if (worldserver == this.level()) {
this.connection.teleport(d0, d1, d2, f, f1);
} else {
@@ -1586,6 +1987,9 @@
@@ -1687,6 +2089,9 @@
this.server.getPlayerList().sendLevelInfo(this, worldserver);
this.server.getPlayerList().sendAllPlayerInfo(this);
}
@@ -951,7 +983,7 @@
}
@@ -1607,6 +2011,32 @@
@@ -1708,6 +2113,32 @@
}
public void setRespawnPosition(ResourceKey<World> resourcekey, @Nullable BlockPosition blockposition, float f, boolean flag, boolean flag1) {
@@ -984,7 +1016,7 @@
if (blockposition != null) {
boolean flag2 = blockposition.equals(this.respawnPosition) && resourcekey.equals(this.respawnDimension);
@@ -1812,4 +2242,146 @@
@@ -1913,4 +2344,146 @@
public CommonPlayerSpawnInfo createCommonSpawnInfo(WorldServer worldserver) {
return new CommonPlayerSpawnInfo(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), this.getLastDeathLocation(), this.getPortalCooldown());
}