Update to Minecraft 1.20

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2023-06-08 01:30:00 +10:00
parent bac55e67d6
commit 9d740b84b0
269 changed files with 2605 additions and 2568 deletions

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/ChunkMapDistance.java
+++ b/net/minecraft/server/level/ChunkMapDistance.java
@@ -126,10 +126,25 @@
@@ -122,10 +122,25 @@
}
if (!this.chunksToUpdateFutures.isEmpty()) {
@@ -29,7 +29,7 @@
return true;
} else {
if (!this.ticketsToRelease.isEmpty()) {
@@ -165,7 +180,7 @@
@@ -161,7 +176,7 @@
}
}
@@ -38,7 +38,7 @@
ArraySetSorted<Ticket<?>> arraysetsorted = this.getTickets(i);
int j = getTicketLevelAt(arraysetsorted);
Ticket<?> ticket1 = (Ticket) arraysetsorted.addOrGet(ticket);
@@ -175,13 +190,15 @@
@@ -171,13 +186,15 @@
this.ticketTracker.update(i, ticket.getTicketLevel(), true);
}
@@ -56,7 +56,7 @@
}
if (arraysetsorted.isEmpty()) {
@@ -189,6 +206,7 @@
@@ -185,6 +202,7 @@
}
this.ticketTracker.update(i, getTicketLevelAt(arraysetsorted), false);
@@ -64,7 +64,7 @@
}
public <T> void addTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
@@ -202,19 +220,33 @@
@@ -198,19 +216,33 @@
}
public <T> void addRegionTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
@@ -74,7 +74,7 @@
+
+ public <T> boolean addRegionTicketAtDistance(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
+ // CraftBukkit end
Ticket<T> ticket = new Ticket<>(tickettype, 33 - i, t0);
Ticket<T> ticket = new Ticket<>(tickettype, ChunkLevel.byStatus(FullChunkStatus.FULL) - i, t0);
long j = chunkcoordintpair.toLong();
- this.addTicket(j, ticket);
@@ -90,7 +90,7 @@
+
+ public <T> boolean removeRegionTicketAtDistance(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
+ // CraftBukkit end
Ticket<T> ticket = new Ticket<>(tickettype, 33 - i, t0);
Ticket<T> ticket = new Ticket<>(tickettype, ChunkLevel.byStatus(FullChunkStatus.FULL) - i, t0);
long j = chunkcoordintpair.toLong();
- this.removeTicket(j, ticket);
@@ -100,7 +100,7 @@
}
private ArraySetSorted<Ticket<?>> getTickets(long i) {
@@ -253,6 +285,7 @@
@@ -249,6 +281,7 @@
ChunkCoordIntPair chunkcoordintpair = sectionposition.chunk();
long i = chunkcoordintpair.toLong();
ObjectSet<EntityPlayer> objectset = (ObjectSet) this.playersPerChunk.get(i);
@@ -108,7 +108,7 @@
objectset.remove(entityplayer);
if (objectset.isEmpty()) {
@@ -382,6 +415,26 @@
@@ -378,6 +411,26 @@
return !this.tickets.isEmpty();
}
@@ -134,4 +134,4 @@
+
private class a extends ChunkMap {
public a() {
private static final int MAX_LEVEL = ChunkLevel.MAX_LEVEL + 1;

View File

@@ -42,16 +42,16 @@
if (ichunkaccess1 != null) {
this.storeInCache(k, ichunkaccess1, ChunkStatus.FULL);
@@ -230,7 +240,15 @@
int l = 33 + ChunkStatus.getDistance(chunkstatus);
int l = ChunkLevel.byStatus(chunkstatus);
PlayerChunk playerchunk = this.getVisibleChunkIfPresent(k);
- if (flag) {
+ // CraftBukkit start - don't add new ticket for currently unloading chunk
+ boolean currentlyUnloading = false;
+ if (playerchunk != null) {
+ PlayerChunk.State oldChunkState = PlayerChunk.getFullChunkStatus(playerchunk.oldTicketLevel);
+ PlayerChunk.State currentChunkState = PlayerChunk.getFullChunkStatus(playerchunk.getTicketLevel());
+ currentlyUnloading = (oldChunkState.isOrAfter(PlayerChunk.State.BORDER) && !currentChunkState.isOrAfter(PlayerChunk.State.BORDER));
+ FullChunkStatus oldChunkState = ChunkLevel.fullStatus(playerchunk.oldTicketLevel);
+ FullChunkStatus currentChunkState = ChunkLevel.fullStatus(playerchunk.getTicketLevel());
+ currentlyUnloading = (oldChunkState.isOrAfter(FullChunkStatus.FULL) && !currentChunkState.isOrAfter(FullChunkStatus.FULL));
+ }
+ if (flag && !currentlyUnloading) {
+ // CraftBukkit end
@@ -67,7 +67,7 @@
}
@Override
@@ -316,7 +334,7 @@
@@ -317,7 +335,7 @@
} else if (!this.level.shouldTickBlocksAt(i)) {
return false;
} else {
@@ -76,7 +76,7 @@
return either != null && either.left().isPresent();
}
@@ -329,11 +347,31 @@
@@ -330,11 +348,31 @@
@Override
public void close() throws IOException {
@@ -109,7 +109,7 @@
@Override
public void tick(BooleanSupplier booleansupplier, boolean flag) {
this.level.getProfiler().push("purge");
@@ -365,7 +403,7 @@
@@ -366,7 +404,7 @@
gameprofilerfiller.push("pollingChunks");
int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING);
@@ -118,7 +118,7 @@
gameprofilerfiller.push("naturalSpawnCount");
int l = this.distanceManager.getNaturalSpawnChunkCount();
@@ -386,7 +424,7 @@
@@ -387,7 +425,7 @@
}
gameprofilerfiller.popPush("spawnAndTick");
@@ -127,7 +127,7 @@
Collections.shuffle(list);
Iterator iterator1 = list.iterator();
@@ -591,13 +629,19 @@
@@ -592,13 +630,19 @@
}
@Override

View File

@@ -61,7 +61,7 @@
public EntityPlayer(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile) {
super(worldserver, worldserver.getSharedSpawnPos(), worldserver.getSharedSpawnAngle(), gameprofile);
this.chatVisibility = EnumChatVisibility.FULL;
@@ -275,12 +322,56 @@
@@ -274,12 +321,56 @@
this.advancements = minecraftserver.getPlayerList().getPlayerAdvancements(this);
this.setMaxUpStep(1.0F);
this.fudgeSpawnLocation(worldserver);
@@ -119,7 +119,7 @@
int i = Math.max(0, this.server.getSpawnRadius(worldserver));
int j = MathHelper.floor(worldserver.getWorldBorder().getDistanceToBorder((double) blockposition.getX(), (double) blockposition.getZ()));
@@ -329,7 +420,7 @@
@@ -328,7 +419,7 @@
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.readAdditionalSaveData(nbttagcompound);
if (nbttagcompound.contains("warden_spawn_tracker", 10)) {
@@ -128,7 +128,7 @@
Logger logger = EntityPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -348,17 +439,26 @@
@@ -347,17 +438,26 @@
if (nbttagcompound.contains("recipeBook", 10)) {
this.recipeBook.fromNbt(nbttagcompound.getCompound("recipeBook"), this.server.getRecipeManager());
}
@@ -156,7 +156,7 @@
Logger logger1 = EntityPlayer.LOGGER;
Objects.requireNonNull(logger1);
@@ -371,7 +471,7 @@
@@ -370,7 +470,7 @@
@Override
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.addAdditionalSaveData(nbttagcompound);
@@ -165,7 +165,7 @@
Logger logger = EntityPlayer.LOGGER;
Objects.requireNonNull(logger);
@@ -392,7 +492,20 @@
@@ -391,7 +491,20 @@
Entity entity = this.getRootVehicle();
Entity entity1 = this.getVehicle();
@@ -187,7 +187,7 @@
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
NBTTagCompound nbttagcompound3 = new NBTTagCompound();
@@ -417,8 +530,32 @@
@@ -416,8 +529,32 @@
nbttagcompound.put("SpawnDimension", nbtbase);
});
}
@@ -197,7 +197,7 @@
+ // CraftBukkit start - World fallback code, either respawn location or global spawn
+ public void spawnIn(World world) {
+ this.level = world;
+ this.setLevel(world);
+ if (world == null) {
+ this.unsetRemoved();
+ Vec3D position = null;
@@ -211,7 +211,7 @@
+ world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle();
+ position = Vec3D.atCenterOf(world.getSharedSpawnPos());
+ }
+ this.level = world;
+ this.setLevel(world);
+ this.setPos(position);
+ }
+ this.gameMode.setLevel((WorldServer) world);
@@ -220,7 +220,7 @@
public void setExperiencePoints(int i) {
float f = (float) this.getXpNeededForNextLevel();
@@ -478,6 +615,11 @@
@@ -477,6 +614,11 @@
@Override
public void tick() {
@@ -232,7 +232,7 @@
this.gameMode.tick();
this.wardenSpawnTracker.tick();
--this.spawnInvulnerableTime;
@@ -534,7 +676,7 @@
@@ -533,7 +675,7 @@
}
if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) {
@@ -241,7 +241,7 @@
this.lastSentHealth = this.getHealth();
this.lastSentFood = this.foodData.getFoodLevel();
this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F;
@@ -565,6 +707,12 @@
@@ -564,6 +706,12 @@
this.updateScoreForCriteria(IScoreboardCriteria.EXPERIENCE, MathHelper.ceil((float) this.lastRecordedExperience));
}
@@ -254,7 +254,7 @@
if (this.experienceLevel != this.lastRecordedLevel) {
this.lastRecordedLevel = this.experienceLevel;
this.updateScoreForCriteria(IScoreboardCriteria.LEVEL, MathHelper.ceil((float) this.lastRecordedLevel));
@@ -579,6 +727,20 @@
@@ -578,6 +726,20 @@
CriterionTriggers.LOCATION.trigger(this);
}
@@ -275,26 +275,26 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking player");
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Player being ticked");
@@ -621,7 +783,8 @@
@@ -620,7 +782,8 @@
}
private void updateScoreForCriteria(IScoreboardCriteria iscoreboardcriteria, int i) {
- this.getScoreboard().forAllObjectives(iscoreboardcriteria, this.getScoreboardName(), (scoreboardscore) -> {
+ // CraftBukkit - Use our scores instead
+ this.level.getCraftServer().getScoreboardManager().getScoreboardScores(iscoreboardcriteria, this.getScoreboardName(), (scoreboardscore) -> {
+ this.level().getCraftServer().getScoreboardManager().getScoreboardScores(iscoreboardcriteria, this.getScoreboardName(), (scoreboardscore) -> {
scoreboardscore.setScore(i);
});
}
@@ -630,9 +793,47 @@
@@ -629,9 +792,47 @@
public void die(DamageSource damagesource) {
this.gameEvent(GameEvent.ENTITY_DIE);
boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
+ // CraftBukkit start - fire PlayerDeathEvent
+ if (this.isRemoved()) {
+ return;
+ }
+ java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>(this.getInventory().getContainerSize());
+ boolean keepInventory = this.level.getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || this.isSpectator();
+ boolean keepInventory = this.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || this.isSpectator();
+
+ if (!keepInventory) {
+ for (ItemStack item : this.getInventory().getContents()) {
@@ -333,10 +333,10 @@
+ ichatbasecomponent = org.bukkit.craftbukkit.util.CraftChatMessage.fromStringOrNull(deathMessage);
+ }
this.connection.send(new ClientboundPlayerCombatKillPacket(this.getCombatTracker(), ichatbasecomponent), PacketSendListener.exceptionallySend(() -> {
this.connection.send(new ClientboundPlayerCombatKillPacket(this.getId(), ichatbasecomponent), PacketSendListener.exceptionallySend(() -> {
boolean flag1 = true;
@@ -663,12 +864,18 @@
if (this.level.getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) {
@@ -662,12 +863,18 @@
if (this.level().getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) {
this.tellNeutralMobsThatIDied();
}
-
@@ -354,42 +354,42 @@
+ // CraftBukkit end
+
+ // CraftBukkit - Get our scores instead
+ this.level.getCraftServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.DEATH_COUNT, this.getScoreboardName(), ScoreboardScore::increment);
+ this.level().getCraftServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.DEATH_COUNT, this.getScoreboardName(), ScoreboardScore::increment);
EntityLiving entityliving = this.getKillCredit();
if (entityliving != null) {
@@ -706,10 +913,12 @@
@@ -705,10 +912,12 @@
String s = this.getScoreboardName();
String s1 = entity.getScoreboardName();
- this.getScoreboard().forAllObjectives(IScoreboardCriteria.KILL_COUNT_ALL, s, ScoreboardScore::increment);
+ // CraftBukkit - Get our scores instead
+ this.level.getCraftServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.KILL_COUNT_ALL, s, ScoreboardScore::increment);
+ this.level().getCraftServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.KILL_COUNT_ALL, s, ScoreboardScore::increment);
if (entity instanceof EntityHuman) {
this.awardStat(StatisticList.PLAYER_KILLS);
- this.getScoreboard().forAllObjectives(IScoreboardCriteria.KILL_COUNT_PLAYERS, s, ScoreboardScore::increment);
+ // CraftBukkit - Get our scores instead
+ this.level.getCraftServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.KILL_COUNT_PLAYERS, s, ScoreboardScore::increment);
+ this.level().getCraftServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.KILL_COUNT_PLAYERS, s, ScoreboardScore::increment);
} else {
this.awardStat(StatisticList.MOB_KILLS);
}
@@ -727,7 +936,8 @@
@@ -726,7 +935,8 @@
int i = scoreboardteam.getColor().getId();
if (i >= 0 && i < aiscoreboardcriteria.length) {
- this.getScoreboard().forAllObjectives(aiscoreboardcriteria[i], s, ScoreboardScore::increment);
+ // CraftBukkit - Get our scores instead
+ this.level.getCraftServer().getScoreboardManager().getScoreboardScores(aiscoreboardcriteria[i], s, ScoreboardScore::increment);
+ this.level().getCraftServer().getScoreboardManager().getScoreboardScores(aiscoreboardcriteria[i], s, ScoreboardScore::increment);
}
}
@@ -777,18 +987,20 @@
@@ -776,18 +986,20 @@
}
private boolean isPvpAllowed() {
- return this.server.isPvpAllowed();
+ // CraftBukkit - this.server.isPvpAllowed() -> this.world.pvpMode
+ return this.level.pvpMode;
+ return this.level().pvpMode;
}
@Nullable
@@ -398,8 +398,8 @@
ShapeDetectorShape shapedetectorshape = super.findDimensionEntryPoint(worldserver);
+ worldserver = (shapedetectorshape == null) ? worldserver : shapedetectorshape.world; // CraftBukkit
- if (shapedetectorshape != null && this.level.dimension() == World.OVERWORLD && worldserver.dimension() == World.END) {
+ if (shapedetectorshape != null && this.level.getTypeKey() == WorldDimension.OVERWORLD && worldserver != null && worldserver.getTypeKey() == WorldDimension.END) { // CraftBukkit
- if (shapedetectorshape != null && this.level().dimension() == World.OVERWORLD && worldserver.dimension() == World.END) {
+ if (shapedetectorshape != null && this.level().getTypeKey() == WorldDimension.OVERWORLD && worldserver != null && worldserver.getTypeKey() == WorldDimension.END) { // CraftBukkit
Vec3D vec3d = shapedetectorshape.pos.add(0.0D, -1.0D, 0.0D);
- return new ShapeDetectorShape(vec3d, Vec3D.ZERO, 90.0F, 0.0F);
@@ -407,7 +407,7 @@
} else {
return shapedetectorshape;
}
@@ -797,11 +1009,20 @@
@@ -796,11 +1008,20 @@
@Nullable
@Override
public Entity changeDimension(WorldServer worldserver) {
@@ -421,7 +421,7 @@
+ // CraftBukkit end
+ if (this.isSleeping()) return this; // CraftBukkit - SPIGOT-3154
+ // this.isChangingDimension = true; // CraftBukkit - Moved down and into PlayerList#changeDimension
WorldServer worldserver1 = this.getLevel();
WorldServer worldserver1 = this.serverLevel();
- ResourceKey<World> resourcekey = worldserver1.dimension();
+ ResourceKey<WorldDimension> resourcekey = worldserver1.getTypeKey(); // CraftBukkit
@@ -429,9 +429,9 @@
+ if (resourcekey == WorldDimension.END && worldserver != null && worldserver.getTypeKey() == WorldDimension.OVERWORLD) { // CraftBukkit
+ this.isChangingDimension = true; // CraftBukkit - Moved down from above
this.unRide();
this.getLevel().removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
this.serverLevel().removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
if (!this.wonGame) {
@@ -812,6 +1033,8 @@
@@ -811,6 +1032,8 @@
return this;
} else {
@@ -439,8 +439,8 @@
+ /*
WorldData worlddata = worldserver.getLevelData();
this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), (byte) 3, this.getLastDeathLocation()));
@@ -821,20 +1044,50 @@
this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), (byte) 3, this.getLastDeathLocation(), this.getPortalCooldown()));
@@ -820,20 +1043,50 @@
playerlist.sendPlayerPermissionLevel(this);
worldserver1.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
this.unsetRemoved();
@@ -479,8 +479,8 @@
+ if (true) { // CraftBukkit
+ this.isChangingDimension = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds
+
+ this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), (byte) 3, this.getLastDeathLocation()));
+ this.connection.send(new PacketPlayOutServerDifficulty(this.level.getDifficulty(), this.level.getLevelData().isDifficultyLocked()));
+ this.connection.send(new PacketPlayOutRespawn(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), this.gameMode.getGameModeForPlayer(), this.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), (byte) 3, this.getLastDeathLocation(), this.getPortalCooldown()));
+ this.connection.send(new PacketPlayOutServerDifficulty(this.level().getDifficulty(), this.level().getLevelData().isDifficultyLocked()));
+ PlayerList playerlist = this.server.getPlayerList();
+
+ playerlist.sendPlayerPermissionLevel(this);
@@ -490,20 +490,20 @@
- worldserver1.getProfiler().pop();
- worldserver1.getProfiler().push("placing");
+ // CraftBukkit end
this.setLevel(worldserver);
this.setServerLevel(worldserver);
- this.connection.teleport(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, shapedetectorshape.xRot);
+ this.connection.teleport(exit); // CraftBukkit - use internal teleport without event
this.connection.resetPosition();
worldserver.addDuringPortalTeleport(this);
worldserver1.getProfiler().pop();
@@ -854,39 +1107,66 @@
@@ -853,39 +1106,66 @@
this.lastSentExp = -1;
this.lastSentHealth = -1.0F;
this.lastSentFood = -1;
+
+ // CraftBukkit start
+ PlayerChangedWorldEvent changeEvent = new PlayerChangedWorldEvent(this.getBukkitEntity(), worldserver1.getWorld());
+ this.level.getCraftServer().getPluginManager().callEvent(changeEvent);
+ this.level().getCraftServer().getPluginManager().callEvent(changeEvent);
+ // CraftBukkit end
}
@@ -559,7 +559,7 @@
+ if (optional.isPresent() || !canCreatePortal) { // CraftBukkit
return optional;
} else {
EnumDirection.EnumAxis enumdirection_enumaxis = (EnumDirection.EnumAxis) this.level.getBlockState(this.portalEntrancePos).getOptionalValue(BlockPortal.AXIS).orElse(EnumDirection.EnumAxis.X);
EnumDirection.EnumAxis enumdirection_enumaxis = (EnumDirection.EnumAxis) this.level().getBlockState(this.portalEntrancePos).getOptionalValue(BlockPortal.AXIS).orElse(EnumDirection.EnumAxis.X);
- Optional<BlockUtil.Rectangle> optional1 = worldserver.getPortalForcer().createPortal(blockposition, enumdirection_enumaxis);
+ Optional<BlockUtil.Rectangle> optional1 = worldserver.getPortalForcer().createPortal(blockposition, enumdirection_enumaxis, this, createRadius); // CraftBukkit
@@ -569,13 +569,13 @@
}
return optional1;
@@ -896,13 +1176,21 @@
@@ -895,13 +1175,21 @@
public void triggerDimensionChangeTriggers(WorldServer worldserver) {
ResourceKey<World> resourcekey = worldserver.dimension();
ResourceKey<World> resourcekey1 = this.level.dimension();
ResourceKey<World> resourcekey1 = this.level().dimension();
+ // CraftBukkit start
+ ResourceKey<World> maindimensionkey = CraftDimensionUtil.getMainDimensionKey(worldserver);
+ ResourceKey<World> maindimensionkey1 = CraftDimensionUtil.getMainDimensionKey(this.level);
+ ResourceKey<World> maindimensionkey1 = CraftDimensionUtil.getMainDimensionKey(this.level());
+
+ CriterionTriggers.CHANGED_DIMENSION.trigger(this, maindimensionkey, maindimensionkey1);
+ if (maindimensionkey != resourcekey || maindimensionkey1 != resourcekey1) {
@@ -594,31 +594,31 @@
this.enteredNetherPosition = null;
}
@@ -919,19 +1207,17 @@
@@ -918,19 +1206,17 @@
this.containerMenu.broadcastChanges();
}
- @Override
- public Either<EntityHuman.EnumBedResult, Unit> startSleepInBed(BlockPosition blockposition) {
- EnumDirection enumdirection = (EnumDirection) this.level.getBlockState(blockposition).getValue(BlockFacingHorizontal.FACING);
- EnumDirection enumdirection = (EnumDirection) this.level().getBlockState(blockposition).getValue(BlockFacingHorizontal.FACING);
-
+ // CraftBukkit start - moved bed result checks from below into separate method
+ private Either<EntityHuman.EnumBedResult, Unit> getBedResult(BlockPosition blockposition, EnumDirection enumdirection) {
if (!this.isSleeping() && this.isAlive()) {
- if (!this.level.dimensionType().natural()) {
+ if (!this.level.dimensionType().natural() || !this.level.dimensionType().bedWorks()) {
- if (!this.level().dimensionType().natural()) {
+ if (!this.level().dimensionType().natural() || !this.level().dimensionType().bedWorks()) {
return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE);
} else if (!this.bedInRange(blockposition, enumdirection)) {
return Either.left(EntityHuman.EnumBedResult.TOO_FAR_AWAY);
} else if (this.bedBlocked(blockposition, enumdirection)) {
return Either.left(EntityHuman.EnumBedResult.OBSTRUCTED);
} else {
- this.setRespawnPosition(this.level.dimension(), blockposition, this.getYRot(), false, true);
+ this.setRespawnPosition(this.level.dimension(), blockposition, this.getYRot(), false, true, PlayerSpawnChangeEvent.Cause.BED); // CraftBukkit
if (this.level.isDay()) {
- this.setRespawnPosition(this.level().dimension(), blockposition, this.getYRot(), false, true);
+ this.setRespawnPosition(this.level().dimension(), blockposition, this.getYRot(), false, true, PlayerSpawnChangeEvent.Cause.BED); // CraftBukkit
if (this.level().isDay()) {
return Either.left(EntityHuman.EnumBedResult.NOT_POSSIBLE_NOW);
} else {
@@ -948,7 +1234,36 @@
@@ -947,7 +1233,36 @@
}
}
@@ -633,7 +633,7 @@
+
+ @Override
+ public Either<EntityHuman.EnumBedResult, Unit> startSleepInBed(BlockPosition blockposition, boolean force) {
+ EnumDirection enumdirection = (EnumDirection) this.level.getBlockState(blockposition).getValue(BlockFacingHorizontal.FACING);
+ EnumDirection enumdirection = (EnumDirection) this.level().getBlockState(blockposition).getValue(BlockFacingHorizontal.FACING);
+ Either<EntityHuman.EnumBedResult, Unit> bedResult = this.getBedResult(blockposition, enumdirection);
+
+ if (bedResult.left().orElse(null) == EntityHuman.EnumBedResult.OTHER_PROBLEM) {
@@ -656,7 +656,7 @@
this.awardStat(StatisticList.SLEEP_IN_BED);
CriterionTriggers.SLEPT_IN_BED.trigger(this);
});
@@ -961,9 +1276,8 @@
@@ -960,9 +1275,8 @@
return either;
}
}
@@ -667,7 +667,7 @@
}
@Override
@@ -990,6 +1304,24 @@
@@ -989,6 +1303,24 @@
@Override
public void stopSleepInBed(boolean flag, boolean flag1) {
@@ -678,22 +678,22 @@
+
+ org.bukkit.block.Block bed;
+ if (bedPosition != null) {
+ bed = this.level.getWorld().getBlockAt(bedPosition.getX(), bedPosition.getY(), bedPosition.getZ());
+ bed = this.level().getWorld().getBlockAt(bedPosition.getX(), bedPosition.getY(), bedPosition.getZ());
+ } else {
+ bed = this.level.getWorld().getBlockAt(player.getLocation());
+ bed = this.level().getWorld().getBlockAt(player.getLocation());
+ }
+
+ PlayerBedLeaveEvent event = new PlayerBedLeaveEvent(player, bed, true);
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
if (this.isSleeping()) {
this.getLevel().getChunkSource().broadcastAndSend(this, new PacketPlayOutAnimation(this, 2));
this.serverLevel().getChunkSource().broadcastAndSend(this, new PacketPlayOutAnimation(this, 2));
}
@@ -1038,8 +1370,9 @@
this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos()));
@@ -1037,8 +1369,9 @@
this.connection.send(new PacketPlayOutOpenSignEditor(tileentitysign.getBlockPos(), flag));
}
- public void nextContainerCounter() {
@@ -703,7 +703,7 @@
}
@Override
@@ -1047,13 +1380,35 @@
@@ -1046,13 +1379,35 @@
if (itileinventory == null) {
return OptionalInt.empty();
} else {
@@ -739,7 +739,7 @@
if (container == null) {
if (this.isSpectator()) {
this.displayClientMessage(IChatBaseComponent.translatable("container.spectatorCantOpen").withStyle(EnumChatFormat.RED), true);
@@ -1061,9 +1416,11 @@
@@ -1060,9 +1415,11 @@
return OptionalInt.empty();
} else {
@@ -753,7 +753,7 @@
return OptionalInt.of(this.containerCounter);
}
}
@@ -1076,13 +1433,24 @@
@@ -1075,13 +1432,24 @@
@Override
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
@@ -780,7 +780,7 @@
this.initMenu(this.containerMenu);
}
@@ -1105,6 +1473,7 @@
@@ -1104,6 +1472,7 @@
@Override
public void closeContainer() {
@@ -788,7 +788,7 @@
this.connection.send(new PacketPlayOutCloseWindow(this.containerMenu.containerId));
this.doCloseContainer();
}
@@ -1127,6 +1496,16 @@
@@ -1126,6 +1495,16 @@
}
this.jumping = flag;
@@ -805,25 +805,25 @@
this.setShiftKeyDown(flag1);
}
@@ -1135,7 +1514,7 @@
@@ -1134,7 +1513,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
+ this.level().getCraftServer().getScoreboardManager().getScoreboardScores(statistic, this.getScoreboardName(), (scoreboardscore) -> { // CraftBukkit - Get our scores instead
scoreboardscore.add(i);
});
}
@@ -1143,7 +1522,7 @@
@@ -1142,7 +1521,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.level().getCraftServer().getScoreboardManager().getScoreboardScores(statistic, this.getScoreboardName(), ScoreboardScore::reset); // CraftBukkit - Get our scores instead
}
@Override
@@ -1159,7 +1538,7 @@
@@ -1163,7 +1542,7 @@
for (int j = 0; j < i; ++j) {
MinecraftKey minecraftkey = aminecraftkey1[j];
@@ -832,7 +832,7 @@
Objects.requireNonNull(list);
optional.ifPresent(list::add);
@@ -1194,6 +1573,7 @@
@@ -1198,6 +1577,7 @@
public void resetSentInfo() {
this.lastSentHealth = -1.0E8F;
@@ -840,7 +840,7 @@
}
@Override
@@ -1252,7 +1632,7 @@
@@ -1256,7 +1636,7 @@
this.lastSentExp = -1;
this.lastSentHealth = -1.0F;
this.lastSentFood = -1;
@@ -849,7 +849,7 @@
this.seenCredits = entityplayer.seenCredits;
this.enteredNetherPosition = entityplayer.enteredNetherPosition;
this.setShoulderEntityLeft(entityplayer.getShoulderEntityLeft());
@@ -1302,6 +1682,12 @@
@@ -1306,6 +1686,12 @@
@Override
public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<RelativeMovement> set, float f, float f1) {
@@ -862,10 +862,10 @@
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(BlockPosition.containing(d0, d1, d2));
worldserver.getChunkSource().addRegionTicket(TicketType.POST_TELEPORT, chunkcoordintpair, 1, this.getId());
@@ -1311,9 +1697,9 @@
@@ -1315,9 +1701,9 @@
}
if (worldserver == this.level) {
if (worldserver == this.level()) {
- this.connection.teleport(d0, d1, d2, f, f1, set);
+ this.connection.teleport(d0, d1, d2, f, f1, set, cause); // CraftBukkit
} else {
@@ -874,7 +874,7 @@
}
this.setYHeadRot(f);
@@ -1417,7 +1803,20 @@
@@ -1420,7 +1806,20 @@
}
}
@@ -895,7 +895,7 @@
this.chatVisibility = packetplayinsettings.chatVisibility();
this.canChatColor = packetplayinsettings.chatColors();
this.textFilteringEnabled = packetplayinsettings.textFilteringEnabled();
@@ -1492,7 +1891,7 @@
@@ -1495,7 +1894,7 @@
if (world instanceof WorldServer) {
WorldServer worldserver = (WorldServer) world;
@@ -904,7 +904,7 @@
}
if (entity != null) {
@@ -1529,7 +1928,7 @@
@@ -1532,7 +1931,7 @@
@Nullable
public IChatBaseComponent getTabListDisplayName() {
@@ -913,7 +913,7 @@
}
@Override
@@ -1550,9 +1949,16 @@
@@ -1553,9 +1952,16 @@
return this.advancements;
}
@@ -927,10 +927,10 @@
this.setCamera(this);
this.stopRiding();
+ /* CraftBukkit start - replace with bukkit handling for multi-world
if (worldserver == this.level) {
if (worldserver == this.level()) {
this.connection.teleport(d0, d1, d2, f, f1);
} else {
@@ -1572,6 +1978,9 @@
@@ -1575,6 +1981,9 @@
this.server.getPlayerList().sendLevelInfo(this, worldserver);
this.server.getPlayerList().sendAllPlayerInfo(this);
}
@@ -940,7 +940,7 @@
}
@@ -1593,6 +2002,32 @@
@@ -1596,6 +2005,32 @@
}
public void setRespawnPosition(ResourceKey<World> resourcekey, @Nullable BlockPosition blockposition, float f, boolean flag, boolean flag1) {
@@ -973,9 +973,9 @@
if (blockposition != null) {
boolean flag2 = blockposition.equals(this.respawnPosition) && resourcekey.equals(this.respawnDimension);
@@ -1762,4 +2197,146 @@
this.hurtDir = (float) (MathHelper.atan2(d1, d0) * 57.2957763671875D - (double) this.getYRot());
this.connection.send(new ClientboundHurtAnimationPacket(this));
@@ -1805,4 +2240,146 @@
}
}
+
+ // CraftBukkit start - Add per-player time and weather.
@@ -985,10 +985,10 @@
+ public long getPlayerTime() {
+ if (this.relativeTime) {
+ // Adds timeOffset to the current server time.
+ return this.level.getDayTime() + this.timeOffset;
+ return this.level().getDayTime() + this.timeOffset;
+ } else {
+ // Adds timeOffset to the beginning of this day.
+ return this.level.getDayTime() - (this.level.getDayTime() % 24000) + this.timeOffset;
+ return this.level().getDayTime() - (this.level().getDayTime() % 24000) + this.timeOffset;
+ }
+ }
+
@@ -1054,7 +1054,7 @@
+
+ public void resetPlayerWeather() {
+ this.weather = null;
+ this.setPlayerWeather(this.level.getLevelData().isRaining() ? WeatherType.DOWNFALL : WeatherType.CLEAR, false);
+ this.setPlayerWeather(this.level().getLevelData().isRaining() ? WeatherType.DOWNFALL : WeatherType.CLEAR, false);
+ }
+
+ @Override
@@ -1080,7 +1080,7 @@
+
+ public void reset() {
+ float exp = 0;
+ boolean keepInventory = this.level.getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY);
+ boolean keepInventory = this.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY);
+
+ if (this.keepLevel) { // CraftBukkit - SPIGOT-6687: Only use keepLevel (was pre-set with RULE_KEEPINVENTORY value in PlayerDeathEvent)
+ exp = this.experienceProgress;

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/EntityTrackerEntry.java
+++ b/net/minecraft/server/level/EntityTrackerEntry.java
@@ -44,6 +44,12 @@
@@ -42,6 +42,12 @@
import net.minecraft.world.phys.Vec3D;
import org.slf4j.Logger;
@@ -13,7 +13,7 @@
public class EntityTrackerEntry {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -65,8 +71,12 @@
@@ -63,8 +69,12 @@
private boolean wasOnGround;
@Nullable
private List<DataWatcher.b<?>> trackedDataValues;
@@ -27,16 +27,16 @@
this.ap = Vec3D.ZERO;
this.lastPassengers = Collections.emptyList();
this.level = worldserver;
@@ -86,7 +96,7 @@
@@ -84,7 +94,7 @@
List<Entity> list = this.entity.getPassengers();
if (!list.equals(this.lastPassengers)) {
- this.broadcast.accept(new PacketPlayOutMount(this.entity));
+ this.broadcastAndSend(new PacketPlayOutMount(this.entity)); // CraftBukkit
this.changedPassengers(list, this.lastPassengers).forEach((entity) -> {
removedPassengers(list, this.lastPassengers).forEach((entity) -> {
if (entity instanceof EntityPlayer) {
EntityPlayer entityplayer = (EntityPlayer) entity;
@@ -105,18 +115,18 @@
@@ -101,18 +111,18 @@
if (entity instanceof EntityItemFrame) {
EntityItemFrame entityitemframe = (EntityItemFrame) entity;
@@ -59,7 +59,7 @@
worldmap.tickCarriedBy(entityplayer, itemstack);
Packet<?> packet = worldmap.getUpdatePacket(integer, entityplayer);
@@ -229,7 +239,27 @@
@@ -225,7 +235,27 @@
++this.tickCount;
if (this.entity.hurtMarked) {
@@ -72,7 +72,7 @@
+ org.bukkit.util.Vector velocity = player.getVelocity();
+
+ PlayerVelocityEvent event = new PlayerVelocityEvent(player, velocity.clone());
+ this.entity.level.getCraftServer().getPluginManager().callEvent(event);
+ this.entity.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ cancelled = true;
@@ -88,18 +88,9 @@
this.entity.hurtMarked = false;
}
@@ -252,14 +282,17 @@
List<Packet<PacketListenerPlayOut>> list = new ArrayList();
@@ -253,7 +283,10 @@
Objects.requireNonNull(list);
- this.sendPairingData(list::add);
+ this.sendPairingData(list::add, entityplayer); // CraftBukkit - add player
entityplayer.connection.send(new ClientboundBundlePacket(list));
this.entity.startSeenByPlayer(entityplayer);
}
- public void sendPairingData(Consumer<Packet<PacketListenerPlayOut>> consumer) {
+ public void sendPairingData(Consumer<Packet<PacketListenerPlayOut>> consumer, EntityPlayer entityplayer) { // CraftBukkit - add player
public void sendPairingData(EntityPlayer entityplayer, Consumer<Packet<PacketListenerPlayOut>> consumer) {
if (this.entity.isRemoved()) {
- EntityTrackerEntry.LOGGER.warn("Fetching packet for removed entity {}", this.entity);
+ // CraftBukkit start - Remove useless error spam, just return
@@ -109,7 +100,7 @@
}
Packet<PacketListenerPlayOut> packet = this.entity.getAddEntityPacket();
@@ -275,6 +308,12 @@
@@ -269,6 +302,12 @@
if (this.entity instanceof EntityLiving) {
Collection<AttributeModifiable> collection = ((EntityLiving) this.entity).getAttributes().getSyncableAttributes();
@@ -122,7 +113,7 @@
if (!collection.isEmpty()) {
consumer.accept(new PacketPlayOutUpdateAttributes(this.entity.getId(), collection));
}
@@ -306,8 +345,14 @@
@@ -300,8 +339,14 @@
if (!list.isEmpty()) {
consumer.accept(new PacketPlayOutEntityEquipment(this.entity.getId(), list));
}
@@ -134,10 +125,10 @@
+ consumer.accept(new PacketPlayOutEntityHeadRotation(this.entity, (byte) yHeadRotp));
+ // CraftBukkit end
+
if (this.entity instanceof EntityLiving) {
EntityLiving entityliving = (EntityLiving) this.entity;
Iterator iterator = entityliving.getActiveEffects().iterator();
@@ -350,6 +395,11 @@
if (!this.entity.getPassengers().isEmpty()) {
consumer.accept(new PacketPlayOutMount(this.entity));
}
@@ -333,6 +378,11 @@
Set<AttributeModifiable> set = ((EntityLiving) this.entity).getAttributes().getDirtyAttributes();
if (!set.isEmpty()) {

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/server/level/PlayerChunk.java
+++ b/net/minecraft/server/level/PlayerChunk.java
@@ -37,6 +37,10 @@
@@ -36,6 +36,10 @@
import net.minecraft.world.level.chunk.ProtoChunkExtension;
import net.minecraft.world.level.lighting.LightEngine;
import net.minecraft.world.level.lighting.LevelLightEngine;
+// CraftBukkit start
+import net.minecraft.server.MinecraftServer;
@@ -11,7 +11,7 @@
public class PlayerChunk {
public static final Either<IChunkAccess, PlayerChunk.Failure> UNLOADED_CHUNK = Either.right(PlayerChunk.Failure.UNLOADED);
@@ -75,11 +79,11 @@
@@ -71,11 +75,11 @@
this.fullChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE;
this.tickingChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE;
this.entityTickingChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE;
@@ -24,15 +24,15 @@
+ this.pendingFullStateConfirmation = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error
this.pos = chunkcoordintpair;
this.levelHeightAccessor = levelheightaccessor;
this.lightEngine = lightengine;
@@ -92,6 +96,20 @@
this.lightEngine = levellightengine;
@@ -88,6 +92,20 @@
this.changedBlocksPerSection = new ShortSet[levelheightaccessor.getSectionsCount()];
}
+ // CraftBukkit start
+ public Chunk getFullChunkNow() {
+ // Note: We use the oldTicketLevel for isLoaded checks.
+ if (!getFullChunkStatus(this.oldTicketLevel).isOrAfter(PlayerChunk.State.BORDER)) return null;
+ if (!ChunkLevel.fullStatus(this.oldTicketLevel).isOrAfter(FullChunkStatus.FULL)) return null;
+ return this.getFullChunkNowUnchecked();
+ }
+
@@ -46,7 +46,7 @@
public CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> getFutureIfPresentUnchecked(ChunkStatus chunkstatus) {
CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = (CompletableFuture) this.futures.get(chunkstatus.getIndex());
@@ -117,17 +135,17 @@
@@ -113,17 +131,17 @@
@Nullable
public Chunk getTickingChunk() {
CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture = this.getTickingChunkFuture();
@@ -68,7 +68,7 @@
}
@Nullable
@@ -172,6 +190,7 @@
@@ -168,6 +186,7 @@
if (chunk != null) {
int i = this.levelHeightAccessor.getSectionIndex(blockposition.getY());
@@ -76,12 +76,12 @@
if (this.changedBlocksPerSection[i] == null) {
this.hasChangedSections = true;
this.changedBlocksPerSection[i] = new ShortOpenHashSet();
@@ -182,10 +201,10 @@
@@ -178,10 +197,10 @@
}
public void sectionLightChanged(EnumSkyBlock enumskyblock, int i) {
- Either<IChunkAccess, PlayerChunk.Failure> either = (Either) this.getFutureIfPresent(ChunkStatus.FEATURES).getNow((Object) null);
+ Either<IChunkAccess, PlayerChunk.Failure> either = (Either) this.getFutureIfPresent(ChunkStatus.FEATURES).getNow(null); // CraftBukkit - decompile error
- Either<IChunkAccess, PlayerChunk.Failure> either = (Either) this.getFutureIfPresent(ChunkStatus.INITIALIZE_LIGHT).getNow((Object) null);
+ Either<IChunkAccess, PlayerChunk.Failure> either = (Either) this.getFutureIfPresent(ChunkStatus.INITIALIZE_LIGHT).getNow(null); // CraftBukkit - decompile error
if (either != null) {
- IChunkAccess ichunkaccess = (IChunkAccess) either.left().orElse((Object) null);
@@ -89,7 +89,20 @@
if (ichunkaccess != null) {
ichunkaccess.setUnsaved(true);
@@ -372,7 +391,7 @@
@@ -246,8 +265,11 @@
PacketPlayOutMultiBlockChange packetplayoutmultiblockchange = new PacketPlayOutMultiBlockChange(sectionposition, shortset, chunksection);
this.broadcast(list, packetplayoutmultiblockchange);
+ // CraftBukkit start
+ List finalList = list;
packetplayoutmultiblockchange.runUpdates((blockposition1, iblockdata1) -> {
- this.broadcastBlockEntityIfNeeded(list, world, blockposition1, iblockdata1);
+ this.broadcastBlockEntityIfNeeded(finalList, world, blockposition1, iblockdata1);
+ // CraftBukkit end
});
}
}
@@ -372,7 +394,7 @@
this.pendingFullStateConfirmation = completablefuture1;
completablefuture.thenAccept((either) -> {
either.ifLeft((chunk) -> {
@@ -98,13 +111,13 @@
});
});
}
@@ -389,6 +408,30 @@
boolean flag1 = this.ticketLevel <= PlayerChunkMap.MAX_CHUNK_DISTANCE;
PlayerChunk.State playerchunk_state = getFullChunkStatus(this.oldTicketLevel);
PlayerChunk.State playerchunk_state1 = getFullChunkStatus(this.ticketLevel);
@@ -389,6 +411,30 @@
boolean flag1 = ChunkLevel.isLoaded(this.ticketLevel);
FullChunkStatus fullchunkstatus = ChunkLevel.fullStatus(this.oldTicketLevel);
FullChunkStatus fullchunkstatus1 = ChunkLevel.fullStatus(this.ticketLevel);
+ // CraftBukkit start
+ // ChunkUnloadEvent: Called before the chunk is unloaded: isChunkLoaded is still true and chunk can still be modified by plugins.
+ if (playerchunk_state.isOrAfter(PlayerChunk.State.BORDER) && !playerchunk_state1.isOrAfter(PlayerChunk.State.BORDER)) {
+ if (fullchunkstatus.isOrAfter(FullChunkStatus.FULL) && !fullchunkstatus1.isOrAfter(FullChunkStatus.FULL)) {
+ this.getFutureIfPresentUnchecked(ChunkStatus.FULL).thenAccept((either) -> {
+ Chunk chunk = (Chunk)either.left().orElse(null);
+ if (chunk != null) {
@@ -129,13 +142,13 @@
if (flag) {
Either<IChunkAccess, PlayerChunk.Failure> either = Either.right(new PlayerChunk.Failure() {
@@ -459,6 +502,26 @@
@@ -459,6 +505,26 @@
this.onLevelChange.onLevelChange(this.pos, this::getQueueLevel, this.ticketLevel, this::setQueueLevel);
this.oldTicketLevel = this.ticketLevel;
+ // CraftBukkit start
+ // ChunkLoadEvent: Called after the chunk is loaded: isChunkLoaded returns true and chunk is ready to be modified by plugins.
+ if (!playerchunk_state.isOrAfter(PlayerChunk.State.BORDER) && playerchunk_state1.isOrAfter(PlayerChunk.State.BORDER)) {
+ if (!fullchunkstatus.isOrAfter(FullChunkStatus.FULL) && fullchunkstatus1.isOrAfter(FullChunkStatus.FULL)) {
+ this.getFutureIfPresentUnchecked(ChunkStatus.FULL).thenAccept((either) -> {
+ Chunk chunk = (Chunk)either.left().orElse(null);
+ if (chunk != null) {
@@ -155,4 +168,4 @@
+ // CraftBukkit end
}
public static ChunkStatus getStatus(int i) {
public boolean wasAccessibleSinceLastSave() {

View File

@@ -10,10 +10,10 @@
+import org.bukkit.entity.Player;
+// CraftBukkit end
+
public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.e {
public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
private static final byte CHUNK_TYPE_REPLACEABLE = -1;
@@ -152,6 +158,27 @@
@@ -151,6 +157,27 @@
private final Queue<Runnable> unloadQueue;
int viewDistance;
@@ -41,7 +41,7 @@
public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, StructureTemplateManager structuretemplatemanager, Executor executor, IAsyncTaskHandler<Runnable> iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, ChunkStatusUpdateListener chunkstatusupdatelistener, Supplier<WorldPersistentData> supplier, int i, boolean flag) {
super(convertable_conversionsession.getDimensionPath(worldserver.dimension()).resolve("region"), datafixer, flag);
this.visibleChunkMap = this.updatingChunkMap.clone();
@@ -170,6 +197,11 @@
@@ -169,6 +196,11 @@
this.storageName = path.getFileName().toString();
this.level = worldserver;
this.generator = chunkgenerator;
@@ -53,22 +53,22 @@
IRegistryCustom iregistrycustom = worldserver.registryAccess();
long j = worldserver.getSeed();
@@ -329,9 +361,12 @@
CompletableFuture<List<Either<IChunkAccess, PlayerChunk.Failure>>> completablefuture1 = SystemUtils.sequence(list);
CompletableFuture<Either<List<IChunkAccess>, PlayerChunk.Failure>> completablefuture2 = completablefuture1.thenApply((list2) -> {
List<IChunkAccess> list3 = Lists.newArrayList();
- final int l1 = 0;
+ // CraftBukkit start - decompile error
+ int cnt = 0;
@@ -335,9 +367,12 @@
CompletableFuture<List<Either<IChunkAccess, PlayerChunk.Failure>>> completablefuture1 = SystemUtils.sequence(list);
CompletableFuture<Either<List<IChunkAccess>, PlayerChunk.Failure>> completablefuture2 = completablefuture1.thenApply((list2) -> {
List<IChunkAccess> list3 = Lists.newArrayList();
- final int l1 = 0;
+ // CraftBukkit start - decompile error
+ int cnt = 0;
- for (Iterator iterator = list2.iterator(); iterator.hasNext(); ++l1) {
+ for (Iterator iterator = list2.iterator(); iterator.hasNext(); ++cnt) {
+ final int l1 = cnt;
+ // CraftBukkit end
final Either<IChunkAccess, PlayerChunk.Failure> either = (Either) iterator.next();
- for (Iterator iterator = list2.iterator(); iterator.hasNext(); ++l1) {
+ for (Iterator iterator = list2.iterator(); iterator.hasNext(); ++cnt) {
+ final int l1 = cnt;
+ // CraftBukkit end
final Either<IChunkAccess, PlayerChunk.Failure> either = (Either) iterator.next();
if (either == null) {
@@ -536,7 +571,7 @@
if (either == null) {
@@ -543,7 +578,7 @@
private void scheduleUnload(long i, PlayerChunk playerchunk) {
CompletableFuture<IChunkAccess> completablefuture = playerchunk.getChunkToSave();
@@ -77,7 +77,7 @@
CompletableFuture<IChunkAccess> completablefuture1 = playerchunk.getChunkToSave();
if (completablefuture1 != completablefuture) {
@@ -625,9 +660,9 @@
@@ -634,9 +669,9 @@
ProtoChunk protochunk = ChunkRegionLoader.read(this.level, this.poiManager, chunkcoordintpair, (NBTTagCompound) optional.get());
this.markPosition(chunkcoordintpair, protochunk.getStatus().getChunkType());
@@ -89,7 +89,7 @@
}
}, this.mainThreadExecutor).exceptionallyAsync((throwable) -> {
return this.handleChunkLoadFailure(throwable, chunkcoordintpair);
@@ -733,7 +768,21 @@
@@ -751,7 +786,21 @@
private static void postLoadProtoChunk(WorldServer worldserver, List<NBTTagCompound> list) {
if (!list.isEmpty()) {
@@ -112,7 +112,7 @@
}
}
@@ -832,7 +881,7 @@
@@ -852,7 +901,7 @@
if (!playerchunk.wasAccessibleSinceLastSave()) {
return false;
} else {
@@ -121,7 +121,7 @@
if (!(ichunkaccess instanceof ProtoChunkExtension) && !(ichunkaccess instanceof Chunk)) {
return false;
@@ -994,7 +1043,8 @@
@@ -1014,7 +1063,8 @@
return ichunkaccess instanceof Chunk ? Optional.of((Chunk) ichunkaccess) : Optional.empty();
});
@@ -131,7 +131,7 @@
return chunk.getBlockEntities().size();
}).orElse(0), tickingtracker.getTicketDebugString(i), tickingtracker.getLevel(i), optional1.map((chunk) -> {
return chunk.getBlockTicks().count();
@@ -1007,7 +1057,7 @@
@@ -1027,7 +1077,7 @@
private static String printFuture(CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture) {
try {
@@ -140,7 +140,7 @@
return either != null ? (String) either.map((chunk) -> {
return "done";
@@ -1023,12 +1073,14 @@
@@ -1043,12 +1093,14 @@
private CompletableFuture<Optional<NBTTagCompound>> readChunk(ChunkCoordIntPair chunkcoordintpair) {
return this.read(chunkcoordintpair).thenApplyAsync((optional) -> {
@@ -158,7 +158,7 @@
}
boolean anyPlayerCloseEnoughForSpawning(ChunkCoordIntPair chunkcoordintpair) {
@@ -1482,7 +1534,7 @@
@@ -1503,7 +1555,7 @@
public final Set<ServerPlayerConnection> seenBy = Sets.newIdentityHashSet();
public EntityTracker(Entity entity, int i, int j, boolean flag) {
@@ -167,7 +167,7 @@
this.entity = entity;
this.range = i;
this.lastSectionPos = SectionPosition.of((EntityAccess) entity);
@@ -1541,6 +1593,11 @@
@@ -1562,6 +1614,11 @@
double d2 = d0 * d0;
boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(entityplayer);

View File

@@ -108,7 +108,7 @@
+ }
+ } else if (!iblockdata.isAir()) {
iblockdata.attack(this.level, blockposition, this.player);
f = iblockdata.getDestroyProgress(this.player, this.player.level, blockposition);
f = iblockdata.getDestroyProgress(this.player, this.player.level(), blockposition);
}
+ if (event.useItemInHand() == Event.Result.DENY) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/WorldServer.java
+++ b/net/minecraft/server/level/WorldServer.java
@@ -159,6 +159,26 @@
@@ -162,6 +162,26 @@
import net.minecraft.world.ticks.TickListServer;
import org.slf4j.Logger;
@@ -27,7 +27,7 @@
public class WorldServer extends World implements GeneratorAccessSeed {
public static final BlockPosition END_SPAWN_POINT = new BlockPosition(100, 50, 0);
@@ -172,7 +192,7 @@
@@ -175,7 +195,7 @@
final List<EntityPlayer> players;
private final ChunkProviderServer chunkSource;
private final MinecraftServer server;
@@ -36,11 +36,11 @@
final EntityTickList entityTickList;
public final PersistentEntitySectionManager<Entity> entityManager;
private final GameEventDispatcher gameEventDispatcher;
@@ -196,12 +216,30 @@
private final StructureCheck structureCheck;
@@ -200,12 +220,30 @@
private final boolean tickTime;
private final RandomSequences randomSequences;
- public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey<World> resourcekey, WorldDimension worlddimension, WorldLoadListener worldloadlistener, boolean flag, long i, List<MobSpawner> list, boolean flag1) {
- public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey<World> resourcekey, WorldDimension worlddimension, WorldLoadListener worldloadlistener, boolean flag, long i, List<MobSpawner> list, boolean flag1, @Nullable RandomSequences randomsequences) {
- IRegistryCustom.Dimension iregistrycustom_dimension = minecraftserver.registryAccess();
- Holder holder = worlddimension.type();
+ // CraftBukkit start
@@ -59,7 +59,7 @@
- Objects.requireNonNull(minecraftserver);
- super(iworlddataserver, resourcekey, iregistrycustom_dimension, holder, minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates());
+ // Add env and gen to constructor, IWorldDataServer -> WorldDataServer
+ public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, WorldDataServer iworlddataserver, ResourceKey<World> resourcekey, WorldDimension worlddimension, WorldLoadListener worldloadlistener, boolean flag, long i, List<MobSpawner> list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
+ public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, WorldDataServer iworlddataserver, ResourceKey<World> resourcekey, WorldDimension worlddimension, WorldLoadListener worldloadlistener, boolean flag, long i, List<MobSpawner> list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
+ // IRegistryCustom.Dimension iregistrycustom_dimension = minecraftserver.registryAccess(); // CraftBukkit - decompile error
+ // Holder holder = worlddimension.type(); // CraftBukkit - decompile error
+
@@ -72,7 +72,7 @@
this.players = Lists.newArrayList();
this.entityTickList = new EntityTickList();
this.blockTicks = new TickListServer<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier());
@@ -215,6 +253,22 @@
@@ -219,6 +257,22 @@
this.customSpawners = list;
this.serverLevelData = iworlddataserver;
ChunkGenerator chunkgenerator = worlddimension.generator();
@@ -95,7 +95,7 @@
boolean flag2 = minecraftserver.forceSynchronousWrites();
DataFixer datafixer = minecraftserver.getFixerUpper();
EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver);
@@ -246,15 +300,16 @@
@@ -250,9 +304,9 @@
long l = minecraftserver.getWorldData().worldGenOptions().seed();
this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this.chunkSource.randomState(), this, chunkgenerator.getBiomeSource(), l, datafixer);
@@ -108,14 +108,15 @@
} else {
this.dragonFight = null;
}
this.sleepStatus = new SleepStatus();
this.gameEventDispatcher = new GameEventDispatcher(this);
@@ -266,6 +320,7 @@
return new RandomSequences(l);
}, "random_sequences");
});
+ this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit
}
public void setWeatherParameters(int i, int j, boolean flag, boolean flag1) {
@@ -286,12 +341,20 @@
/** @deprecated */
@@ -304,12 +359,20 @@
long j;
if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) {
@@ -139,7 +140,7 @@
if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) {
this.resetWeatherCycle();
}
@@ -317,7 +380,7 @@
@@ -335,7 +398,7 @@
this.runBlockEvents();
this.handlingTick = false;
gameprofilerfiller.pop();
@@ -148,7 +149,7 @@
if (flag) {
this.resetEmptyTime();
@@ -333,7 +396,7 @@
@@ -351,7 +414,7 @@
this.entityTickList.forEach((entity) -> {
if (!entity.isRemoved()) {
@@ -157,7 +158,7 @@
entity.discard();
} else {
gameprofilerfiller.push("checkDespawn");
@@ -405,7 +468,7 @@
@@ -423,7 +486,7 @@
private void wakeUpAllPlayers() {
this.sleepStatus.removeAllSleepers();
@@ -166,7 +167,7 @@
entityplayer.stopSleepInBed(false, false);
});
}
@@ -433,7 +496,7 @@
@@ -451,7 +514,7 @@
entityhorseskeleton.setTrap(true);
entityhorseskeleton.setAge(0);
entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
@@ -175,7 +176,7 @@
}
}
@@ -442,7 +505,7 @@
@@ -460,7 +523,7 @@
if (entitylightning != null) {
entitylightning.moveTo(Vec3D.atBottomCenterOf(blockposition));
entitylightning.setVisualOnly(flag1);
@@ -184,7 +185,7 @@
}
}
}
@@ -456,7 +519,7 @@
@@ -475,7 +538,7 @@
BiomeBase biomebase = (BiomeBase) this.getBiome(blockposition).value();
if (biomebase.shouldFreeze(this, blockposition1)) {
@@ -193,8 +194,8 @@
}
if (flag) {
@@ -471,10 +534,10 @@
IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSnow.LAYERS, l + 1);
@@ -489,10 +552,10 @@
IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSnow.LAYERS, i1 + 1);
Block.pushEntitiesUp(iblockdata, iblockdata1, this, blockposition);
- this.setBlockAndUpdate(blockposition, iblockdata1);
@@ -206,7 +207,7 @@
}
}
@@ -670,6 +733,7 @@
@@ -688,6 +751,7 @@
this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F);
}
@@ -214,13 +215,13 @@
if (this.oRainLevel != this.rainLevel) {
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension());
}
@@ -688,14 +752,47 @@
@@ -706,14 +770,47 @@
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel));
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel));
}
+ // */
+ for (int idx = 0; idx < this.players.size(); ++idx) {
+ if (((EntityPlayer) this.players.get(idx)).level == this) {
+ if (((EntityPlayer) this.players.get(idx)).level() == this) {
+ ((EntityPlayer) this.players.get(idx)).tickWeather();
+ }
+ }
@@ -228,13 +229,13 @@
+ if (flag != this.isRaining()) {
+ // Only send weather packets to those affected
+ for (int idx = 0; idx < this.players.size(); ++idx) {
+ if (((EntityPlayer) this.players.get(idx)).level == this) {
+ if (((EntityPlayer) this.players.get(idx)).level() == this) {
+ ((EntityPlayer) this.players.get(idx)).setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false);
+ }
+ }
+ }
+ for (int idx = 0; idx < this.players.size(); ++idx) {
+ if (((EntityPlayer) this.players.get(idx)).level == this) {
+ if (((EntityPlayer) this.players.get(idx)).level() == this) {
+ ((EntityPlayer) this.players.get(idx)).updateWeather(this.oRainLevel, this.rainLevel, this.oThunderLevel, this.thunderLevel);
+ }
+ }
@@ -264,7 +265,7 @@
}
public void resetEmptyTime() {
@@ -730,6 +827,7 @@
@@ -748,6 +845,7 @@
});
gameprofilerfiller.incrementCounter("tickNonPassenger");
entity.tick();
@@ -272,7 +273,7 @@
this.getProfiler().pop();
Iterator iterator = entity.getPassengers().iterator();
@@ -753,6 +851,7 @@
@@ -771,6 +869,7 @@
});
gameprofilerfiller.incrementCounter("tickPassenger");
entity1.rideTick();
@@ -280,7 +281,7 @@
gameprofilerfiller.pop();
Iterator iterator = entity1.getPassengers().iterator();
@@ -777,6 +876,7 @@
@@ -795,6 +894,7 @@
ChunkProviderServer chunkproviderserver = this.getChunkSource();
if (!flag1) {
@@ -288,7 +289,7 @@
if (iprogressupdate != null) {
iprogressupdate.progressStartNoAbort(IChatBaseComponent.translatable("menu.savingLevel"));
}
@@ -794,11 +894,19 @@
@@ -812,11 +912,19 @@
}
}
@@ -309,7 +310,7 @@
}
this.getChunkSource().getDataStorage().save();
@@ -863,15 +971,37 @@
@@ -881,15 +989,37 @@
@Override
public boolean addFreshEntity(Entity entity) {
@@ -350,7 +351,7 @@
}
public void addDuringCommandTeleport(EntityPlayer entityplayer) {
@@ -902,24 +1032,37 @@
@@ -920,24 +1050,37 @@
this.entityManager.addNewEntity(entityplayer);
}
@@ -392,7 +393,7 @@
return true;
}
}
@@ -933,10 +1076,32 @@
@@ -951,10 +1094,32 @@
entityplayer.remove(entity_removalreason);
}
@@ -425,7 +426,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
@@ -945,6 +1110,12 @@
@@ -963,6 +1128,12 @@
double d1 = (double) blockposition.getY() - entityplayer.getY();
double d2 = (double) blockposition.getZ() - entityplayer.getZ();
@@ -438,7 +439,7 @@
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
}
@@ -1004,7 +1175,18 @@
@@ -1022,7 +1193,18 @@
Iterator iterator = this.navigatingMobs.iterator();
while (iterator.hasNext()) {
@@ -458,7 +459,7 @@
NavigationAbstract navigationabstract = entityinsentient.getNavigation();
if (navigationabstract.shouldRecomputePath(blockposition)) {
@@ -1066,6 +1248,11 @@
@@ -1084,6 +1266,11 @@
@Override
public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, World.a world_a) {
Explosion explosion = this.explode(entity, damagesource, explosiondamagecalculator, d0, d1, d2, f, flag, world_a, false);
@@ -470,7 +471,7 @@
if (!explosion.interactsWithBlocks()) {
explosion.clearToBlow();
@@ -1138,13 +1325,20 @@
@@ -1156,13 +1343,20 @@
}
public <T extends ParticleParam> int sendParticles(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
@@ -493,7 +494,7 @@
++j;
}
}
@@ -1195,7 +1389,7 @@
@@ -1213,7 +1407,7 @@
@Nullable
public BlockPosition findNearestMapStructure(TagKey<Structure> tagkey, BlockPosition blockposition, int i, boolean flag) {
@@ -502,7 +503,7 @@
return null;
} else {
Optional<HolderSet.Named<Structure>> optional = this.registryAccess().registryOrThrow(Registries.STRUCTURE).getTag(tagkey);
@@ -1232,11 +1426,21 @@
@@ -1250,11 +1444,21 @@
@Nullable
@Override
public WorldMap getMapData(String s) {
@@ -525,7 +526,7 @@
this.getServer().overworld().getDataStorage().set(s, worldmap);
}
@@ -1534,6 +1738,11 @@
@@ -1552,6 +1756,11 @@
@Override
public void blockUpdated(BlockPosition blockposition, Block block) {
if (!this.isDebug()) {
@@ -537,7 +538,7 @@
this.updateNeighborsAt(blockposition, block);
}
@@ -1553,12 +1762,12 @@
@@ -1571,12 +1780,12 @@
}
public boolean isFlat() {
@@ -552,7 +553,7 @@
}
@Nullable
@@ -1581,7 +1790,7 @@
@@ -1599,7 +1808,7 @@
private static <T> String getTypeCount(Iterable<T> iterable, Function<T, String> function) {
try {
Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap();
@@ -561,7 +562,7 @@
while (iterator.hasNext()) {
T t0 = iterator.next();
@@ -1590,7 +1799,7 @@
@@ -1608,7 +1817,7 @@
object2intopenhashmap.addTo(s, 1);
}
@@ -570,7 +571,7 @@
String s1 = (String) entry.getKey();
return s1 + ":" + entry.getIntValue();
@@ -1601,17 +1810,33 @@
@@ -1619,17 +1828,33 @@
}
public static void makeObsidianPlatform(WorldServer worldserver) {
@@ -606,7 +607,7 @@
}
@Override
@@ -1727,6 +1952,7 @@
@@ -1753,6 +1978,7 @@
}
entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
@@ -614,7 +615,7 @@
}
public void onTrackingEnd(Entity entity) {
@@ -1763,6 +1989,14 @@
@@ -1789,6 +2015,14 @@
}
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);