1.21.6 dev
Co-authored-by: Bjarne Koll <git@lynxplay.dev> Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Co-authored-by: Noah van der Aa <ndvdaa@gmail.com> Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
This commit is contained in:
committed by
Nassim Jahnke
parent
39203a65e0
commit
a24f9b204c
@@ -5,7 +5,7 @@
|
||||
@VisibleForDebug
|
||||
private NaturalSpawner.SpawnState lastSpawnState;
|
||||
+ // Paper start
|
||||
+ private final ca.spottedleaf.concurrentutil.map.ConcurrentLong2ReferenceChainedHashTable<net.minecraft.world.level.chunk.LevelChunk> fullChunks = new ca.spottedleaf.concurrentutil.map.ConcurrentLong2ReferenceChainedHashTable<>();
|
||||
+ public final ca.spottedleaf.concurrentutil.map.ConcurrentLong2ReferenceChainedHashTable<net.minecraft.world.level.chunk.LevelChunk> fullChunks = new ca.spottedleaf.concurrentutil.map.ConcurrentLong2ReferenceChainedHashTable<>();
|
||||
+ public int getFullChunksCount() {
|
||||
+ return this.fullChunks.size();
|
||||
+ }
|
||||
@@ -146,7 +146,7 @@
|
||||
+ ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
+
|
||||
+ gameprofilerfiller.push("purge");
|
||||
+ this.ticketStorage.purgeStaleTickets();
|
||||
+ this.ticketStorage.purgeStaleTickets(this.chunkMap);
|
||||
+ this.runDistanceManagerUpdates();
|
||||
+ gameprofilerfiller.popPush("unload");
|
||||
+ this.chunkMap.tick(() -> true);
|
||||
@@ -161,7 +161,7 @@
|
||||
profilerFiller.push("purge");
|
||||
- if (this.level.tickRateManager().runsNormally() || !tickChunks) {
|
||||
+ if (this.level.tickRateManager().runsNormally() || !tickChunks || this.level.spigotConfig.unloadFrozenChunks) { // Spigot
|
||||
this.ticketStorage.purgeStaleTickets();
|
||||
this.ticketStorage.purgeStaleTickets(this.chunkMap);
|
||||
}
|
||||
|
||||
@@ -388,12 +_,20 @@
|
||||
@@ -188,7 +188,7 @@
|
||||
} else {
|
||||
filteredSpawningCategories = List.of();
|
||||
}
|
||||
@@ -544,8 +_,13 @@
|
||||
@@ -547,8 +_,13 @@
|
||||
|
||||
@Override
|
||||
public void setSpawnSettings(boolean spawnSettings) {
|
||||
@@ -203,7 +203,7 @@
|
||||
}
|
||||
|
||||
public String getChunkDebugData(ChunkPos chunkPos) {
|
||||
@@ -618,12 +_,18 @@
|
||||
@@ -621,12 +_,18 @@
|
||||
|
||||
@Override
|
||||
public boolean pollTask() {
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
Packet<?> packet = null;
|
||||
boolean flag2 = flag1 || this.tickCount % 60 == 0;
|
||||
boolean flag3 = false;
|
||||
@@ -223,6 +_,25 @@
|
||||
@@ -227,6 +_,25 @@
|
||||
|
||||
this.tickCount++;
|
||||
if (this.entity.hurtMarked) {
|
||||
@@ -96,7 +96,7 @@
|
||||
this.entity.hurtMarked = false;
|
||||
this.broadcastAndSend(new ClientboundSetEntityMotionPacket(this.entity));
|
||||
}
|
||||
@@ -280,7 +_,10 @@
|
||||
@@ -284,7 +_,10 @@
|
||||
|
||||
public void sendPairingData(ServerPlayer player, Consumer<Packet<ClientGamePacketListener>> consumer) {
|
||||
if (this.entity.isRemoved()) {
|
||||
@@ -108,11 +108,10 @@
|
||||
}
|
||||
|
||||
Packet<ClientGamePacketListener> addEntityPacket = this.entity.getAddEntityPacket(this);
|
||||
@@ -292,6 +_,12 @@
|
||||
boolean flag = this.trackDelta;
|
||||
if (this.entity instanceof LivingEntity) {
|
||||
Collection<AttributeInstance> syncableAttributes = ((LivingEntity)this.entity).getAttributes().getSyncableAttributes();
|
||||
+
|
||||
@@ -295,6 +_,11 @@
|
||||
|
||||
if (this.entity instanceof LivingEntity livingEntity) {
|
||||
Collection<AttributeInstance> syncableAttributes = livingEntity.getAttributes().getSyncableAttributes();
|
||||
+ // CraftBukkit start - If sending own attributes send scaled health instead of current maximum health
|
||||
+ if (this.entity.getId() == player.getId()) {
|
||||
+ ((ServerPlayer) this.entity).getBukkitEntity().injectScaledMaxHealth(syncableAttributes, false);
|
||||
@@ -121,7 +120,7 @@
|
||||
if (!syncableAttributes.isEmpty()) {
|
||||
consumer.accept(new ClientboundUpdateAttributesPacket(this.entity.getId(), syncableAttributes));
|
||||
}
|
||||
@@ -316,8 +_,9 @@
|
||||
@@ -311,8 +_,9 @@
|
||||
}
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
@@ -132,7 +131,7 @@
|
||||
}
|
||||
|
||||
if (!this.entity.getPassengers().isEmpty()) {
|
||||
@@ -364,6 +_,11 @@
|
||||
@@ -359,6 +_,11 @@
|
||||
if (this.entity instanceof LivingEntity) {
|
||||
Set<AttributeInstance> attributesToSync = ((LivingEntity)this.entity).getAttributes().getAttributesToSync();
|
||||
if (!attributesToSync.isEmpty()) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -178,7 +_,7 @@
|
||||
@@ -180,7 +_,7 @@
|
||||
final List<ServerPlayer> players = Lists.newArrayList();
|
||||
public final ServerChunkCache chunkSource;
|
||||
private final MinecraftServer server;
|
||||
@@ -8,8 +8,8 @@
|
||||
+ public final net.minecraft.world.level.storage.PrimaryLevelData serverLevelData; // CraftBukkit - type
|
||||
private int lastSpawnChunkRadius;
|
||||
final EntityTickList entityTickList = new EntityTickList();
|
||||
public final PersistentEntitySectionManager<Entity> entityManager;
|
||||
@@ -205,11 +_,131 @@
|
||||
private final ServerWaypointManager waypointManager;
|
||||
@@ -208,11 +_,131 @@
|
||||
private final boolean tickTime;
|
||||
private final RandomSequences randomSequences;
|
||||
|
||||
@@ -142,7 +142,7 @@
|
||||
ResourceKey<Level> dimension,
|
||||
LevelStem levelStem,
|
||||
ChunkProgressListener progressListener,
|
||||
@@ -217,14 +_,38 @@
|
||||
@@ -220,14 +_,38 @@
|
||||
long biomeZoomSeed,
|
||||
List<CustomSpawner> customSpawners,
|
||||
boolean tickTime,
|
||||
@@ -183,7 +183,7 @@
|
||||
boolean flag = server.forceSynchronousWrites();
|
||||
DataFixer fixerUpper = server.getFixerUpper();
|
||||
EntityPersistentStorage<Entity> entityPersistentStorage = new EntityStorage(
|
||||
@@ -246,8 +_,8 @@
|
||||
@@ -249,8 +_,8 @@
|
||||
server.getStructureManager(),
|
||||
dispatcher,
|
||||
chunkGenerator,
|
||||
@@ -194,7 +194,7 @@
|
||||
flag,
|
||||
progressListener,
|
||||
this.entityManager::updateChunkStatus,
|
||||
@@ -268,7 +_,7 @@
|
||||
@@ -271,7 +_,7 @@
|
||||
this.chunkSource.chunkScanner(),
|
||||
this.registryAccess(),
|
||||
server.getStructureManager(),
|
||||
@@ -203,7 +203,7 @@
|
||||
chunkGenerator,
|
||||
this.chunkSource.randomState(),
|
||||
this,
|
||||
@@ -276,9 +_,9 @@
|
||||
@@ -279,9 +_,9 @@
|
||||
seed,
|
||||
fixerUpper
|
||||
);
|
||||
@@ -216,10 +216,10 @@
|
||||
} else {
|
||||
this.dragonFight = null;
|
||||
}
|
||||
@@ -286,7 +_,15 @@
|
||||
this.sleepStatus = new SleepStatus();
|
||||
@@ -290,7 +_,15 @@
|
||||
this.gameEventDispatcher = new GameEventDispatcher(this);
|
||||
this.randomSequences = Objects.requireNonNullElseGet(randomSequences, () -> this.getDataStorage().computeIfAbsent(RandomSequences.TYPE));
|
||||
this.waypointManager = new ServerWaypointManager();
|
||||
- }
|
||||
+ this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit
|
||||
+ }
|
||||
@@ -233,7 +233,7 @@
|
||||
|
||||
@Deprecated
|
||||
@VisibleForTesting
|
||||
@@ -298,8 +_,8 @@
|
||||
@@ -302,8 +_,8 @@
|
||||
this.serverLevelData.setClearWeatherTime(clearTime);
|
||||
this.serverLevelData.setRainTime(weatherTime);
|
||||
this.serverLevelData.setThunderTime(weatherTime);
|
||||
@@ -244,7 +244,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -326,12 +_,25 @@
|
||||
@@ -330,12 +_,25 @@
|
||||
|
||||
int _int = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE);
|
||||
if (this.sleepStatus.areEnoughSleeping(_int) && this.sleepStatus.areEnoughDeepSleeping(_int, this.players)) {
|
||||
@@ -273,7 +273,7 @@
|
||||
if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) {
|
||||
this.resetWeatherCycle();
|
||||
}
|
||||
@@ -346,9 +_,9 @@
|
||||
@@ -350,9 +_,9 @@
|
||||
if (!this.isDebug() && runsNormally) {
|
||||
long l = this.getGameTime();
|
||||
profilerFiller.push("blockTicks");
|
||||
@@ -285,7 +285,7 @@
|
||||
profilerFiller.pop();
|
||||
}
|
||||
|
||||
@@ -366,7 +_,7 @@
|
||||
@@ -370,7 +_,7 @@
|
||||
|
||||
this.handlingTick = false;
|
||||
profilerFiller.pop();
|
||||
@@ -294,7 +294,7 @@
|
||||
if (flag) {
|
||||
this.resetEmptyTime();
|
||||
}
|
||||
@@ -455,11 +_,13 @@
|
||||
@@ -459,11 +_,13 @@
|
||||
ProfilerFiller profilerFiller = Profiler.get();
|
||||
profilerFiller.push("iceandsnow");
|
||||
|
||||
@@ -308,7 +308,7 @@
|
||||
|
||||
profilerFiller.popPush("tickBlocks");
|
||||
if (randomTickSpeed > 0) {
|
||||
@@ -502,12 +_,12 @@
|
||||
@@ -506,12 +_,12 @@
|
||||
int minBlockZ = pos.getMinBlockZ();
|
||||
ProfilerFiller profilerFiller = Profiler.get();
|
||||
profilerFiller.push("thunder");
|
||||
@@ -323,7 +323,7 @@
|
||||
&& !this.getBlockState(blockPos.below()).is(Blocks.LIGHTNING_ROD);
|
||||
if (flag) {
|
||||
SkeletonHorse skeletonHorse = EntityType.SKELETON_HORSE.create(this, EntitySpawnReason.EVENT);
|
||||
@@ -515,7 +_,7 @@
|
||||
@@ -519,7 +_,7 @@
|
||||
skeletonHorse.setTrap(true);
|
||||
skeletonHorse.setAge(0);
|
||||
skeletonHorse.setPos(blockPos.getX(), blockPos.getY(), blockPos.getZ());
|
||||
@@ -332,7 +332,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -523,7 +_,7 @@
|
||||
@@ -527,7 +_,7 @@
|
||||
if (lightningBolt != null) {
|
||||
lightningBolt.snapTo(Vec3.atBottomCenterOf(blockPos));
|
||||
lightningBolt.setVisualOnly(flag);
|
||||
@@ -341,7 +341,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -537,7 +_,7 @@
|
||||
@@ -541,7 +_,7 @@
|
||||
BlockPos blockPos1 = heightmapPos.below();
|
||||
Biome biome = this.getBiome(heightmapPos).value();
|
||||
if (biome.shouldFreeze(this, blockPos1)) {
|
||||
@@ -350,7 +350,7 @@
|
||||
}
|
||||
|
||||
if (this.isRaining()) {
|
||||
@@ -549,10 +_,10 @@
|
||||
@@ -553,10 +_,10 @@
|
||||
if (layersValue < Math.min(_int, 8)) {
|
||||
BlockState blockState1 = blockState.setValue(SnowLayerBlock.LAYERS, layersValue + 1);
|
||||
Block.pushEntitiesUp(blockState, blockState1, this, heightmapPos);
|
||||
@@ -363,7 +363,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -577,6 +_,12 @@
|
||||
@@ -581,6 +_,12 @@
|
||||
}
|
||||
|
||||
protected BlockPos findLightningTargetAround(BlockPos pos) {
|
||||
@@ -376,7 +376,7 @@
|
||||
BlockPos heightmapPos = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos);
|
||||
Optional<BlockPos> optional = this.findLightningRod(heightmapPos);
|
||||
if (optional.isPresent()) {
|
||||
@@ -584,11 +_,12 @@
|
||||
@@ -588,11 +_,12 @@
|
||||
} else {
|
||||
AABB aabb = AABB.encapsulatingFullBlocks(heightmapPos, heightmapPos.atY(this.getMaxY() + 1)).inflate(3.0);
|
||||
List<LivingEntity> entitiesOfClass = this.getEntitiesOfClass(
|
||||
@@ -390,7 +390,7 @@
|
||||
if (heightmapPos.getY() == this.getMinY() - 1) {
|
||||
heightmapPos = heightmapPos.above(2);
|
||||
}
|
||||
@@ -675,8 +_,8 @@
|
||||
@@ -683,8 +_,8 @@
|
||||
this.serverLevelData.setThunderTime(thunderTime);
|
||||
this.serverLevelData.setRainTime(rainTime);
|
||||
this.serverLevelData.setClearWeatherTime(clearWeatherTime);
|
||||
@@ -401,7 +401,7 @@
|
||||
}
|
||||
|
||||
this.oThunderLevel = this.thunderLevel;
|
||||
@@ -697,6 +_,7 @@
|
||||
@@ -705,6 +_,7 @@
|
||||
this.rainLevel = Mth.clamp(this.rainLevel, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
@@ -409,7 +409,7 @@
|
||||
if (this.oRainLevel != this.rainLevel) {
|
||||
this.server
|
||||
.getPlayerList()
|
||||
@@ -719,14 +_,47 @@
|
||||
@@ -727,14 +_,47 @@
|
||||
this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.RAIN_LEVEL_CHANGE, this.rainLevel));
|
||||
this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, this.thunderLevel));
|
||||
}
|
||||
@@ -461,7 +461,7 @@
|
||||
}
|
||||
|
||||
public void resetEmptyTime() {
|
||||
@@ -748,18 +_,46 @@
|
||||
@@ -756,18 +_,46 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,7 +508,7 @@
|
||||
}
|
||||
|
||||
private void tickPassenger(Entity ridingEntity, Entity passengerEntity) {
|
||||
@@ -768,10 +_,12 @@
|
||||
@@ -776,10 +_,12 @@
|
||||
} else if (passengerEntity instanceof Player || this.entityTickList.contains(passengerEntity)) {
|
||||
passengerEntity.setOldPosAndRot();
|
||||
passengerEntity.tickCount++;
|
||||
@@ -521,7 +521,7 @@
|
||||
profilerFiller.pop();
|
||||
|
||||
for (Entity entity : passengerEntity.getPassengers()) {
|
||||
@@ -788,6 +_,7 @@
|
||||
@@ -810,6 +_,7 @@
|
||||
public void save(@Nullable ProgressListener progress, boolean flush, boolean skipSave) {
|
||||
ServerChunkCache chunkSource = this.getChunkSource();
|
||||
if (!skipSave) {
|
||||
@@ -529,7 +529,7 @@
|
||||
if (progress != null) {
|
||||
progress.progressStartNoAbort(Component.translatable("menu.savingLevel"));
|
||||
}
|
||||
@@ -804,11 +_,19 @@
|
||||
@@ -826,11 +_,19 @@
|
||||
this.entityManager.autoSave();
|
||||
}
|
||||
}
|
||||
@@ -550,7 +550,7 @@
|
||||
}
|
||||
|
||||
DimensionDataStorage dataStorage = this.getChunkSource().getDataStorage();
|
||||
@@ -873,18 +_,40 @@
|
||||
@@ -895,18 +_,40 @@
|
||||
|
||||
@Override
|
||||
public boolean addFreshEntity(Entity entity) {
|
||||
@@ -594,7 +594,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -907,40 +_,119 @@
|
||||
@@ -929,40 +_,119 @@
|
||||
this.entityManager.addNewEntity(player);
|
||||
}
|
||||
|
||||
@@ -719,7 +719,7 @@
|
||||
if (d * d + d1 * d1 + d2 * d2 < 1024.0) {
|
||||
serverPlayer.connection.send(new ClientboundBlockDestructionPacket(breakerId, pos, progress));
|
||||
}
|
||||
@@ -1015,7 +_,7 @@
|
||||
@@ -1037,7 +_,7 @@
|
||||
pos.getX(),
|
||||
pos.getY(),
|
||||
pos.getZ(),
|
||||
@@ -728,7 +728,7 @@
|
||||
this.dimension(),
|
||||
new ClientboundLevelEventPacket(type, pos, data, false)
|
||||
);
|
||||
@@ -1027,6 +_,11 @@
|
||||
@@ -1049,6 +_,11 @@
|
||||
|
||||
@Override
|
||||
public void gameEvent(Holder<GameEvent> gameEvent, Vec3 pos, GameEvent.Context context) {
|
||||
@@ -740,7 +740,7 @@
|
||||
this.gameEventDispatcher.post(gameEvent, pos, context);
|
||||
}
|
||||
|
||||
@@ -1039,17 +_,28 @@
|
||||
@@ -1061,17 +_,28 @@
|
||||
|
||||
this.getChunkSource().blockChanged(pos);
|
||||
this.pathTypesByPosCache.invalidate(pos);
|
||||
@@ -769,7 +769,7 @@
|
||||
|
||||
try {
|
||||
this.isUpdatingNavigations = true;
|
||||
@@ -1061,15 +_,23 @@
|
||||
@@ -1083,15 +_,23 @@
|
||||
this.isUpdatingNavigations = false;
|
||||
}
|
||||
}
|
||||
@@ -793,7 +793,7 @@
|
||||
this.neighborUpdater.updateNeighborsAtExceptFromFacing(pos, block, null, orientation);
|
||||
}
|
||||
|
||||
@@ -1118,6 +_,42 @@
|
||||
@@ -1140,6 +_,42 @@
|
||||
ParticleOptions largeExplosionParticles,
|
||||
Holder<SoundEvent> explosionSound
|
||||
) {
|
||||
@@ -836,7 +836,7 @@
|
||||
Explosion.BlockInteraction blockInteraction = switch (explosionInteraction) {
|
||||
case NONE -> Explosion.BlockInteraction.KEEP;
|
||||
case BLOCK -> this.getDestroyType(GameRules.RULE_BLOCK_EXPLOSION_DROP_DECAY);
|
||||
@@ -1126,10 +_,17 @@
|
||||
@@ -1148,10 +_,17 @@
|
||||
: Explosion.BlockInteraction.KEEP;
|
||||
case TNT -> this.getDestroyType(GameRules.RULE_TNT_EXPLOSION_DROP_DECAY);
|
||||
case TRIGGER -> Explosion.BlockInteraction.TRIGGER_BLOCK;
|
||||
@@ -854,7 +854,7 @@
|
||||
ParticleOptions particleOptions = serverExplosion.isSmall() ? smallExplosionParticles : largeExplosionParticles;
|
||||
|
||||
for (ServerPlayer serverPlayer : this.players) {
|
||||
@@ -1138,6 +_,8 @@
|
||||
@@ -1160,6 +_,8 @@
|
||||
serverPlayer.connection.send(new ClientboundExplodePacket(vec3, optional, particleOptions, explosionSound));
|
||||
}
|
||||
}
|
||||
@@ -863,7 +863,7 @@
|
||||
}
|
||||
|
||||
private Explosion.BlockInteraction getDestroyType(GameRules.Key<GameRules.BooleanValue> decayGameRule) {
|
||||
@@ -1208,7 +_,7 @@
|
||||
@@ -1230,7 +_,7 @@
|
||||
public <T extends ParticleOptions> int sendParticles(
|
||||
T type, double posX, double posY, double posZ, int particleCount, double xOffset, double yOffset, double zOffset, double speed
|
||||
) {
|
||||
@@ -872,7 +872,7 @@
|
||||
}
|
||||
|
||||
public <T extends ParticleOptions> int sendParticles(
|
||||
@@ -1224,13 +_,49 @@
|
||||
@@ -1246,13 +_,49 @@
|
||||
double zOffset,
|
||||
double speed
|
||||
) {
|
||||
@@ -924,7 +924,7 @@
|
||||
if (this.sendParticles(serverPlayer, overrideLimiter, posX, posY, posZ, clientboundLevelParticlesPacket)) {
|
||||
i++;
|
||||
}
|
||||
@@ -1293,7 +_,7 @@
|
||||
@@ -1315,7 +_,7 @@
|
||||
|
||||
@Nullable
|
||||
public BlockPos findNearestMapStructure(TagKey<Structure> structureTag, BlockPos pos, int radius, boolean skipExistingChunks) {
|
||||
@@ -933,7 +933,7 @@
|
||||
return null;
|
||||
} else {
|
||||
Optional<HolderSet.Named<Structure>> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(structureTag);
|
||||
@@ -1340,10 +_,36 @@
|
||||
@@ -1362,10 +_,36 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public MapItemSavedData getMapData(MapId mapId) {
|
||||
@@ -971,7 +971,7 @@
|
||||
this.getServer().overworld().getDataStorage().set(MapItemSavedData.type(mapId), data);
|
||||
}
|
||||
|
||||
@@ -1355,17 +_,27 @@
|
||||
@@ -1377,17 +_,27 @@
|
||||
BlockPos spawnPos = this.levelData.getSpawnPos();
|
||||
float spawnAngle = this.levelData.getSpawnAngle();
|
||||
if (!spawnPos.equals(pos) || spawnAngle != angle) {
|
||||
@@ -1001,7 +1001,7 @@
|
||||
}
|
||||
|
||||
this.lastSpawnChunkRadius = i;
|
||||
@@ -1400,6 +_,11 @@
|
||||
@@ -1422,6 +_,11 @@
|
||||
DebugPackets.sendPoiRemovedPacket(this, blockPos);
|
||||
}));
|
||||
optional1.ifPresent(holder -> this.getServer().execute(() -> {
|
||||
@@ -1013,7 +1013,7 @@
|
||||
this.getPoiManager().add(blockPos, (Holder<PoiType>)holder);
|
||||
DebugPackets.sendPoiAddedPacket(this, blockPos);
|
||||
}));
|
||||
@@ -1552,12 +_,12 @@
|
||||
@@ -1574,12 +_,12 @@
|
||||
}
|
||||
|
||||
public boolean isFlat() {
|
||||
@@ -1028,7 +1028,7 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1608,6 +_,7 @@
|
||||
@@ -1630,6 +_,7 @@
|
||||
|
||||
@Override
|
||||
public LevelEntityGetter<Entity> getEntities() {
|
||||
@@ -1036,7 +1036,7 @@
|
||||
return this.entityManager.getEntityGetter();
|
||||
}
|
||||
|
||||
@@ -1697,6 +_,28 @@
|
||||
@@ -1736,6 +_,28 @@
|
||||
return this.serverLevelData.getGameRules();
|
||||
}
|
||||
|
||||
@@ -1065,15 +1065,15 @@
|
||||
@Override
|
||||
public CrashReportCategory fillReportDetails(CrashReport report) {
|
||||
CrashReportCategory crashReportCategory = super.fillReportDetails(report);
|
||||
@@ -1712,6 +_,7 @@
|
||||
final class EntityCallbacks implements LevelCallback<Entity> {
|
||||
@Override
|
||||
public void onCreated(Entity entity) {
|
||||
@@ -1754,6 +_,7 @@
|
||||
if (entity instanceof WaypointTransmitter waypointTransmitter && waypointTransmitter.isTransmittingWaypoint()) {
|
||||
ServerLevel.this.getWaypointManager().trackWaypoint(waypointTransmitter);
|
||||
}
|
||||
+ entity.setOldPosAndRot(); // Paper - update old pos / rot for new entities as it will default to Vec3.ZERO
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1721,24 +_,32 @@
|
||||
@@ -1767,17 +_,24 @@
|
||||
|
||||
@Override
|
||||
public void onTickingStart(Entity entity) {
|
||||
@@ -1086,8 +1086,7 @@
|
||||
ServerLevel.this.entityTickList.remove(entity);
|
||||
+ // Paper start - Reset pearls when they stop being ticked
|
||||
+ if (ServerLevel.this.paperConfig().fixes.disableUnloadedChunkEnderpearlExploit && ServerLevel.this.paperConfig().misc.legacyEnderPearlBehavior && entity instanceof net.minecraft.world.entity.projectile.ThrownEnderpearl pearl) {
|
||||
+ pearl.cachedOwner = null;
|
||||
+ pearl.ownerUUID = null;
|
||||
+ pearl.setOwner(null);
|
||||
+ }
|
||||
+ // Paper end - Reset pearls when they stop being ticked
|
||||
}
|
||||
@@ -1099,7 +1098,8 @@
|
||||
+ // ServerLevel.this.getChunkSource().addEntity(entity); // Paper - ignore and warn about illegal addEntity calls instead of crashing server; moved down below valid=true
|
||||
if (entity instanceof ServerPlayer serverPlayer) {
|
||||
ServerLevel.this.players.add(serverPlayer);
|
||||
ServerLevel.this.updateSleepingPlayerList();
|
||||
if (serverPlayer.isReceivingWaypoints()) {
|
||||
@@ -1792,7 +_,7 @@
|
||||
}
|
||||
|
||||
if (entity instanceof Mob mob) {
|
||||
@@ -1108,7 +1108,7 @@
|
||||
String string = "onTrackingStart called during navigation iteration";
|
||||
Util.logAndPauseIfInIde(
|
||||
"onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration")
|
||||
@@ -1755,10 +_,52 @@
|
||||
@@ -1809,10 +_,52 @@
|
||||
}
|
||||
|
||||
entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
|
||||
@@ -1161,7 +1161,7 @@
|
||||
ServerLevel.this.getChunkSource().removeEntity(entity);
|
||||
if (entity instanceof ServerPlayer serverPlayer) {
|
||||
ServerLevel.this.players.remove(serverPlayer);
|
||||
@@ -1766,7 +_,7 @@
|
||||
@@ -1821,7 +_,7 @@
|
||||
}
|
||||
|
||||
if (entity instanceof Mob mob) {
|
||||
@@ -1170,7 +1170,7 @@
|
||||
String string = "onTrackingStart called during navigation iteration";
|
||||
Util.logAndPauseIfInIde(
|
||||
"onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration")
|
||||
@@ -1783,6 +_,15 @@
|
||||
@@ -1838,6 +_,15 @@
|
||||
}
|
||||
|
||||
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);
|
||||
@@ -1186,7 +1186,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1790,4 +_,24 @@
|
||||
@@ -1845,4 +_,24 @@
|
||||
entity.updateDynamicGameEventListener(DynamicGameEventListener::move);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -65,7 +_,6 @@
|
||||
import net.minecraft.network.protocol.game.ClientboundHurtAnimationPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundMerchantOffersPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundOpenBookPacket;
|
||||
-import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundOpenSignEditorPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerCombatEndPacket;
|
||||
@@ -235,7 +_,8 @@
|
||||
@@ -245,7 +_,8 @@
|
||||
private int levitationStartTime;
|
||||
private boolean disconnected;
|
||||
private int requestedViewDistance = 2;
|
||||
@@ -18,7 +10,7 @@
|
||||
@Nullable
|
||||
private Vec3 startingToFallPosition;
|
||||
@Nullable
|
||||
@@ -281,6 +_,13 @@
|
||||
@@ -291,6 +_,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +24,7 @@
|
||||
@Override
|
||||
public void sendSlotChange(AbstractContainerMenu container, int slot, ItemStack itemStack) {
|
||||
ServerPlayer.this.connection.send(new ClientboundContainerSetSlotPacket(container.containerId, container.incrementStateId(), slot, itemStack));
|
||||
@@ -316,6 +_,32 @@
|
||||
@@ -326,6 +_,32 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +57,7 @@
|
||||
@Override
|
||||
public void dataChanged(AbstractContainerMenu containerMenu, int dataSlotIndex, int value) {
|
||||
}
|
||||
@@ -344,9 +_,43 @@
|
||||
@@ -354,9 +_,43 @@
|
||||
public void sendSystemMessage(Component component) {
|
||||
ServerPlayer.this.sendSystemMessage(component);
|
||||
}
|
||||
@@ -108,22 +100,20 @@
|
||||
+ public @Nullable org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event
|
||||
|
||||
public ServerPlayer(MinecraftServer server, ServerLevel level, GameProfile gameProfile, ClientInformation clientInformation) {
|
||||
super(level, level.getSharedSpawnPos(), level.getSharedSpawnAngle(), gameProfile);
|
||||
@@ -356,16 +_,22 @@
|
||||
super(level, gameProfile);
|
||||
@@ -366,15 +_,21 @@
|
||||
this.server = server;
|
||||
this.stats = server.getPlayerList().getPlayerStats(this);
|
||||
this.advancements = server.getPlayerList().getPlayerAdvancements(this);
|
||||
- this.snapTo(this.adjustSpawnLocation(level, level.getSharedSpawnPos()).getBottomCenter(), 0.0F, 0.0F);
|
||||
- this.updateOptions(clientInformation);
|
||||
+ // this.snapTo(this.adjustSpawnLocation(level, level.getSharedSpawnPos()).getBottomCenter(), 0.0F, 0.0F); // Paper - Don't move existing players to world spawn
|
||||
+ this.updateOptionsNoEvents(clientInformation); // Paper - don't call options events on login
|
||||
this.object = null;
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ this.displayName = this.getScoreboardName();
|
||||
+ this.adventure$displayName = net.kyori.adventure.text.Component.text(this.getScoreboardName()); // Paper
|
||||
+ this.bukkitPickUpLoot = true;
|
||||
+ this.maxHealthCache = this.getMaxHealth();
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,22 +125,22 @@
|
||||
int max = Math.max(0, this.server.getSpawnRadius(level));
|
||||
int floor = Mth.floor(level.getWorldBorder().getDistanceToBorder(pos.getX(), pos.getZ()));
|
||||
if (floor < max) {
|
||||
@@ -436,6 +_,7 @@
|
||||
this.enteredNetherPosition = compound.read("entered_nether_pos", Vec3.CODEC).orElse(null);
|
||||
this.seenCredits = compound.getBooleanOr("seenCredits", false);
|
||||
this.recipeBook.fromNbt(compound.getCompoundOrEmpty("recipeBook"), key -> this.server.getRecipeManager().byKey(key).isPresent());
|
||||
+ this.getBukkitEntity().readExtraData(compound); // CraftBukkit
|
||||
@@ -446,6 +_,7 @@
|
||||
this.seenCredits = input.getBooleanOr("seenCredits", false);
|
||||
input.read("recipeBook", ServerRecipeBook.Packed.CODEC)
|
||||
.ifPresent(packed -> this.recipeBook.loadUntrusted(packed, key -> this.server.getRecipeManager().byKey(key).isPresent()));
|
||||
+ this.getBukkitEntity().readExtraData(input); // CraftBukkit
|
||||
if (this.isSleeping()) {
|
||||
this.stopSleeping();
|
||||
}
|
||||
@@ -459,12 +_,24 @@
|
||||
compound.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall);
|
||||
compound.storeNullable("raid_omen_position", BlockPos.CODEC, this.raidOmenPosition);
|
||||
this.saveEnderPearls(compound);
|
||||
+ this.getBukkitEntity().setExtraData(compound); // CraftBukkit
|
||||
@@ -469,12 +_,24 @@
|
||||
output.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall);
|
||||
output.storeNullable("raid_omen_position", BlockPos.CODEC, this.raidOmenPosition);
|
||||
this.saveEnderPearls(output);
|
||||
+ this.getBukkitEntity().setExtraData(output); // CraftBukkit
|
||||
}
|
||||
|
||||
private void saveParentVehicle(CompoundTag tag) {
|
||||
private void saveParentVehicle(ValueOutput output) {
|
||||
Entity rootVehicle = this.getRootVehicle();
|
||||
Entity vehicle = this.getVehicle();
|
||||
- if (vehicle != null && rootVehicle != this && rootVehicle.hasExactlyOnePlayerPassenger()) {
|
||||
@@ -166,19 +156,19 @@
|
||||
+ }
|
||||
+ if (persistVehicle && vehicle != null && rootVehicle != this && rootVehicle.hasExactlyOnePlayerPassenger() && !rootVehicle.isRemoved()) { // Paper - Ensure valid vehicle status
|
||||
+ // CraftBukkit end
|
||||
CompoundTag compoundTag = new CompoundTag();
|
||||
CompoundTag compoundTag1 = new CompoundTag();
|
||||
rootVehicle.save(compoundTag1);
|
||||
@@ -479,7 +_,7 @@
|
||||
if (!compound.isEmpty()) {
|
||||
ServerLevel serverLevel = this.serverLevel();
|
||||
ValueOutput valueOutput = output.child("RootVehicle");
|
||||
valueOutput.store("Attach", UUIDUtil.CODEC, vehicle.getUUID());
|
||||
rootVehicle.save(valueOutput.child("Entity"));
|
||||
@@ -486,7 +_,7 @@
|
||||
if (!optional.isEmpty()) {
|
||||
ServerLevel serverLevel = this.level();
|
||||
Entity entity = EntityType.loadEntityRecursive(
|
||||
- compound.get().getCompoundOrEmpty("Entity"), serverLevel, EntitySpawnReason.LOAD, entity2 -> !serverLevel.addWithUUID(entity2) ? null : entity2
|
||||
+ compound.get().getCompoundOrEmpty("Entity"), serverLevel, EntitySpawnReason.LOAD, entity2 -> !serverLevel.addWithUUID(entity2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.MOUNT) ? null : entity2 // Paper - Entity#getEntitySpawnReason
|
||||
- optional.get().childOrEmpty("Entity"), serverLevel, EntitySpawnReason.LOAD, entity2 -> !serverLevel.addWithUUID(entity2) ? null : entity2
|
||||
+ optional.get().childOrEmpty("Entity"), serverLevel, EntitySpawnReason.LOAD, entity2 -> !serverLevel.addWithUUID(entity2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.MOUNT) ? null : entity2 // Paper - Entity#getEntitySpawnReason
|
||||
);
|
||||
if (entity != null) {
|
||||
UUID uuid = compound.get().read("Attach", UUIDUtil.CODEC).orElse(null);
|
||||
@@ -496,10 +_,10 @@
|
||||
UUID uuid = optional.get().read("Attach", UUIDUtil.CODEC).orElse(null);
|
||||
@@ -503,10 +_,10 @@
|
||||
|
||||
if (!this.isPassenger()) {
|
||||
LOGGER.warn("Couldn't reattach entity to player");
|
||||
@@ -191,15 +181,15 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -511,6 +_,7 @@
|
||||
ListTag listTag = new ListTag();
|
||||
@@ -518,6 +_,7 @@
|
||||
ValueOutput.ValueOutputList valueOutputList = output.childrenList("ender_pearls");
|
||||
|
||||
for (ThrownEnderpearl thrownEnderpearl : this.enderPearls) {
|
||||
+ if (thrownEnderpearl.level().paperConfig().misc.legacyEnderPearlBehavior) continue; // Paper - Allow using old ender pearl behavior
|
||||
if (thrownEnderpearl.isRemoved()) {
|
||||
LOGGER.warn("Trying to save removed ender pearl, skipping");
|
||||
} else {
|
||||
@@ -546,6 +_,16 @@
|
||||
@@ -550,6 +_,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +206,7 @@
|
||||
public void setExperiencePoints(int experiencePoints) {
|
||||
float f = this.getXpNeededForNextLevel();
|
||||
float f1 = (f - 1.0F) / f;
|
||||
@@ -603,6 +_,11 @@
|
||||
@@ -607,6 +_,11 @@
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
@@ -228,7 +218,7 @@
|
||||
this.tickClientLoadTimeout();
|
||||
this.gameMode.tick();
|
||||
this.wardenSpawnTracker.tick();
|
||||
@@ -610,9 +_,14 @@
|
||||
@@ -614,9 +_,14 @@
|
||||
this.invulnerableTime--;
|
||||
}
|
||||
|
||||
@@ -246,7 +236,7 @@
|
||||
this.containerMenu = this.inventoryMenu;
|
||||
}
|
||||
|
||||
@@ -662,7 +_,7 @@
|
||||
@@ -675,7 +_,7 @@
|
||||
|
||||
public void doTick() {
|
||||
try {
|
||||
@@ -255,7 +245,7 @@
|
||||
super.tick();
|
||||
}
|
||||
|
||||
@@ -676,7 +_,7 @@
|
||||
@@ -689,7 +_,7 @@
|
||||
if (this.getHealth() != this.lastSentHealth
|
||||
|| this.lastSentFood != this.foodData.getFoodLevel()
|
||||
|| this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) {
|
||||
@@ -264,7 +254,7 @@
|
||||
this.lastSentHealth = this.getHealth();
|
||||
this.lastSentFood = this.foodData.getFoodLevel();
|
||||
this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F;
|
||||
@@ -707,6 +_,12 @@
|
||||
@@ -720,6 +_,12 @@
|
||||
this.updateScoreForCriteria(ObjectiveCriteria.EXPERIENCE, Mth.ceil((float)this.lastRecordedExperience));
|
||||
}
|
||||
|
||||
@@ -277,7 +267,7 @@
|
||||
if (this.experienceLevel != this.lastRecordedLevel) {
|
||||
this.lastRecordedLevel = this.experienceLevel;
|
||||
this.updateScoreForCriteria(ObjectiveCriteria.LEVEL, Mth.ceil((float)this.lastRecordedLevel));
|
||||
@@ -720,6 +_,21 @@
|
||||
@@ -733,6 +_,21 @@
|
||||
if (this.tickCount % 20 == 0) {
|
||||
CriteriaTriggers.LOCATION.trigger(this);
|
||||
}
|
||||
@@ -299,8 +289,8 @@
|
||||
} catch (Throwable var4) {
|
||||
CrashReport crashReport = CrashReport.forThrowable(var4, "Ticking player");
|
||||
CrashReportCategory crashReportCategory = crashReport.addCategory("Player being ticked");
|
||||
@@ -744,7 +_,7 @@
|
||||
if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.serverLevel().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
|
||||
@@ -757,7 +_,7 @@
|
||||
if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.level().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
|
||||
if (this.tickCount % 20 == 0) {
|
||||
if (this.getHealth() < this.getMaxHealth()) {
|
||||
- this.heal(1.0F);
|
||||
@@ -308,7 +298,7 @@
|
||||
}
|
||||
|
||||
float saturationLevel = this.foodData.getSaturationLevel();
|
||||
@@ -793,15 +_,36 @@
|
||||
@@ -806,15 +_,36 @@
|
||||
}
|
||||
|
||||
private void updateScoreForCriteria(ObjectiveCriteria criteria, int points) {
|
||||
@@ -318,7 +308,7 @@
|
||||
- @Override
|
||||
- public void die(DamageSource cause) {
|
||||
- this.gameEvent(GameEvent.ENTITY_DIE);
|
||||
- boolean _boolean = this.serverLevel().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
|
||||
- boolean _boolean = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
|
||||
- if (_boolean) {
|
||||
- Component deathMessage = this.getCombatTracker().getDeathMessage();
|
||||
+ this.level().getCraftServer().getScoreboardManager().forAllObjectives(criteria, this, score -> score.set(points)); // CraftBukkit - Use our scores instead
|
||||
@@ -354,7 +344,7 @@
|
||||
this.connection
|
||||
.send(
|
||||
new ClientboundPlayerCombatKillPacket(this.getId(), deathMessage),
|
||||
@@ -818,6 +_,65 @@
|
||||
@@ -831,6 +_,65 @@
|
||||
}
|
||||
)
|
||||
);
|
||||
@@ -366,13 +356,13 @@
|
||||
+ @Override
|
||||
+ public void die(DamageSource cause) {
|
||||
+ // this.gameEvent(GameEvent.ENTITY_DIE); // Paper - move below event cancellation check
|
||||
+ boolean _boolean = this.serverLevel().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); final boolean showDeathMessage = _boolean; // Paper - OBFHELPER
|
||||
+ boolean _boolean = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); final boolean showDeathMessage = _boolean; // Paper - OBFHELPER
|
||||
+ // CraftBukkit start - fire PlayerDeathEvent
|
||||
+ if (this.isRemoved()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ List<DefaultDrop> loot = new java.util.ArrayList<>(this.getInventory().getContainerSize()); // Paper - Restore vanilla drops behavior
|
||||
+ boolean keepInventory = this.serverLevel().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()) {
|
||||
+ if (!item.isEmpty() && !EnchantmentHelper.has(item, net.minecraft.world.item.enchantment.EnchantmentEffectComponents.PREVENT_EQUIPMENT_DROP)) {
|
||||
@@ -380,9 +370,9 @@
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ if (this.shouldDropLoot() && this.serverLevel().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Paper - fix player loottables running when mob loot gamerule is false
|
||||
+ if (this.shouldDropLoot() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Paper - fix player loottables running when mob loot gamerule is false
|
||||
+ // SPIGOT-5071: manually add player loot tables (SPIGOT-5195 - ignores keepInventory rule)
|
||||
+ this.dropFromLootTable(this.serverLevel(), cause, this.lastHurtByPlayerMemoryTime > 0);
|
||||
+ this.dropFromLootTable(this.level(), cause, this.lastHurtByPlayerMemoryTime > 0);
|
||||
+ // Paper - Restore vanilla drops behaviour; custom death loot is a noop on server player, remove.
|
||||
+ loot.addAll(this.drops);
|
||||
+ this.drops.clear(); // SPIGOT-5188: make sure to clear
|
||||
@@ -420,7 +410,7 @@
|
||||
Team team = this.getTeam();
|
||||
if (team == null || team.getDeathMessageVisibility() == Team.Visibility.ALWAYS) {
|
||||
this.server.getPlayerList().broadcastSystemMessage(deathMessage, false);
|
||||
@@ -827,7 +_,7 @@
|
||||
@@ -840,7 +_,7 @@
|
||||
this.server.getPlayerList().broadcastSystemToAllExceptTeam(this, deathMessage);
|
||||
}
|
||||
} else {
|
||||
@@ -429,14 +419,14 @@
|
||||
}
|
||||
|
||||
this.removeEntitiesOnShoulder();
|
||||
@@ -835,11 +_,35 @@
|
||||
@@ -848,11 +_,35 @@
|
||||
this.tellNeutralMobsThatIDied();
|
||||
}
|
||||
|
||||
- if (!this.isSpectator()) {
|
||||
- this.dropAllDeathLoot(this.serverLevel(), cause);
|
||||
- this.dropAllDeathLoot(this.level(), cause);
|
||||
+ // SPIGOT-5478 must be called manually now
|
||||
+ if (event.shouldDropExperience()) this.dropExperience(this.serverLevel(), cause.getEntity()); // Paper - tie to event
|
||||
+ if (event.shouldDropExperience()) this.dropExperience(this.level(), cause.getEntity()); // Paper - tie to event
|
||||
+ // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory.
|
||||
+ if (!event.getKeepInventory()) {
|
||||
+ // Paper start - PlayerDeathEvent#getItemsToKeep
|
||||
@@ -468,7 +458,7 @@
|
||||
LivingEntity killCredit = this.getKillCredit();
|
||||
if (killCredit != null) {
|
||||
this.awardStat(Stats.ENTITY_KILLED_BY.get(killCredit.getType()));
|
||||
@@ -872,10 +_,10 @@
|
||||
@@ -885,10 +_,10 @@
|
||||
public void awardKillScore(Entity entity, DamageSource damageSource) {
|
||||
if (entity != this) {
|
||||
super.awardKillScore(entity, damageSource);
|
||||
@@ -481,7 +471,7 @@
|
||||
} else {
|
||||
this.awardStat(Stats.MOB_KILLS);
|
||||
}
|
||||
@@ -891,7 +_,7 @@
|
||||
@@ -904,7 +_,7 @@
|
||||
if (playersTeam != null) {
|
||||
int id = playersTeam.getColor().getId();
|
||||
if (id >= 0 && id < crtieria.length) {
|
||||
@@ -490,7 +480,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -902,9 +_,20 @@
|
||||
@@ -915,9 +_,20 @@
|
||||
return false;
|
||||
} else {
|
||||
Entity entity = damageSource.getEntity();
|
||||
@@ -513,7 +503,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -914,23 +_,77 @@
|
||||
@@ -927,23 +_,77 @@
|
||||
}
|
||||
|
||||
private boolean isPvpAllowed() {
|
||||
@@ -596,8 +586,8 @@
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public static Optional<ServerPlayer.RespawnPosAngle> findRespawnAndUseSpawnBlock(
|
||||
@@ -947,10 +_,10 @@
|
||||
public boolean isReceivingWaypoints() {
|
||||
@@ -978,10 +_,10 @@
|
||||
level.setBlock(blockPos, blockState.setValue(RespawnAnchorBlock.CHARGE, blockState.getValue(RespawnAnchorBlock.CHARGE) - 1), 3);
|
||||
}
|
||||
|
||||
@@ -610,7 +600,7 @@
|
||||
} else if (!flag) {
|
||||
return Optional.empty();
|
||||
} else {
|
||||
@@ -958,7 +_,7 @@
|
||||
@@ -989,7 +_,7 @@
|
||||
BlockState blockState1 = level.getBlockState(blockPos.above());
|
||||
boolean isPossibleToRespawnInThis1 = blockState1.getBlock().isPossibleToRespawnInThis(blockState1);
|
||||
return isPossibleToRespawnInThis && isPossibleToRespawnInThis1
|
||||
@@ -619,7 +609,7 @@
|
||||
: Optional.empty();
|
||||
}
|
||||
}
|
||||
@@ -976,6 +_,7 @@
|
||||
@@ -1007,6 +_,7 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public ServerPlayer teleport(TeleportTransition teleportTransition) {
|
||||
@@ -627,10 +617,10 @@
|
||||
if (this.isRemoved()) {
|
||||
return null;
|
||||
} else {
|
||||
@@ -985,17 +_,52 @@
|
||||
@@ -1016,17 +_,52 @@
|
||||
|
||||
ServerLevel level = teleportTransition.newLevel();
|
||||
ServerLevel serverLevel = this.serverLevel();
|
||||
ServerLevel serverLevel = this.level();
|
||||
- ResourceKey<Level> resourceKey = serverLevel.dimension();
|
||||
+ // CraftBukkit start
|
||||
+ ResourceKey<net.minecraft.world.level.dimension.LevelStem> resourceKey = serverLevel.getTypeKey();
|
||||
@@ -640,8 +630,8 @@
|
||||
+ org.bukkit.Location exit = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(absolutePosition.position(), level.getWorld(), absolutePosition.yRot(), absolutePosition.xRot());
|
||||
+ org.bukkit.event.player.PlayerTeleportEvent tpEvent = new org.bukkit.event.player.PlayerTeleportEvent(this.getBukkitEntity(), enter, exit.clone(), teleportTransition.cause());
|
||||
+ // Paper start - gateway-specific teleport event
|
||||
+ if (this.portalProcess != null && this.portalProcess.isSamePortal(((net.minecraft.world.level.block.EndGatewayBlock) net.minecraft.world.level.block.Blocks.END_GATEWAY)) && this.serverLevel().getBlockEntity(this.portalProcess.getEntryPosition()) instanceof net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity theEndGatewayBlockEntity) {
|
||||
+ tpEvent = new com.destroystokyo.paper.event.player.PlayerTeleportEndGatewayEvent(this.getBukkitEntity(), enter, exit.clone(), new org.bukkit.craftbukkit.block.CraftEndGateway(this.serverLevel().getWorld(), theEndGatewayBlockEntity));
|
||||
+ if (this.portalProcess != null && this.portalProcess.isSamePortal(((net.minecraft.world.level.block.EndGatewayBlock) net.minecraft.world.level.block.Blocks.END_GATEWAY)) && this.level().getBlockEntity(this.portalProcess.getEntryPosition()) instanceof net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity theEndGatewayBlockEntity) {
|
||||
+ tpEvent = new com.destroystokyo.paper.event.player.PlayerTeleportEndGatewayEvent(this.getBukkitEntity(), enter, exit.clone(), new org.bukkit.craftbukkit.block.CraftEndGateway(this.level().getWorld(), theEndGatewayBlockEntity));
|
||||
+ }
|
||||
+ // Paper end - gateway-specific teleport event
|
||||
+ org.bukkit.Bukkit.getServer().getPluginManager().callEvent(tpEvent);
|
||||
@@ -683,7 +673,7 @@
|
||||
this.isChangingDimension = true;
|
||||
LevelData levelData = level.getLevelData();
|
||||
this.connection.send(new ClientboundRespawnPacket(this.createCommonSpawnInfo(level), (byte)3));
|
||||
@@ -1004,16 +_,30 @@
|
||||
@@ -1035,16 +_,30 @@
|
||||
playerList.sendPlayerPermissionLevel(this);
|
||||
serverLevel.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
|
||||
this.unsetRemoved();
|
||||
@@ -716,12 +706,10 @@
|
||||
this.connection.resetPosition();
|
||||
level.addDuringTeleport(this);
|
||||
profilerFiller.pop();
|
||||
@@ -1027,10 +_,39 @@
|
||||
this.lastSentExp = -1;
|
||||
@@ -1059,10 +_,37 @@
|
||||
this.lastSentHealth = -1.0F;
|
||||
this.lastSentFood = -1;
|
||||
+
|
||||
+
|
||||
this.teleportSpectators(teleportTransition, serverLevel);
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.event.player.PlayerChangedWorldEvent changeEvent = new org.bukkit.event.player.PlayerChangedWorldEvent(this.getBukkitEntity(), serverLevel.getWorld());
|
||||
+ this.level().getCraftServer().getPluginManager().callEvent(changeEvent);
|
||||
@@ -756,7 +744,7 @@
|
||||
|
||||
@Override
|
||||
public void forceSetRotation(float yRot, float xRot) {
|
||||
@@ -1040,12 +_,26 @@
|
||||
@@ -1072,12 +_,26 @@
|
||||
public void triggerDimensionChangeTriggers(ServerLevel level) {
|
||||
ResourceKey<Level> resourceKey = level.dimension();
|
||||
ResourceKey<Level> resourceKey1 = this.level().dimension();
|
||||
@@ -786,7 +774,7 @@
|
||||
this.enteredNetherPosition = null;
|
||||
}
|
||||
}
|
||||
@@ -1061,19 +_,18 @@
|
||||
@@ -1093,19 +_,18 @@
|
||||
this.containerMenu.broadcastChanges();
|
||||
}
|
||||
|
||||
@@ -810,7 +798,7 @@
|
||||
if (this.level().isBrightOutside()) {
|
||||
return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_NOW);
|
||||
} else {
|
||||
@@ -1092,7 +_,34 @@
|
||||
@@ -1124,7 +_,34 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -846,7 +834,7 @@
|
||||
this.awardStat(Stats.SLEEP_IN_BED);
|
||||
CriteriaTriggers.SLEPT_IN_BED.trigger(this);
|
||||
});
|
||||
@@ -1128,21 +_,29 @@
|
||||
@@ -1160,21 +_,29 @@
|
||||
|
||||
@Override
|
||||
public void stopSleepInBed(boolean wakeImmediately, boolean updateLevelForSleepingPlayers) {
|
||||
@@ -859,7 +847,7 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (this.isSleeping()) {
|
||||
this.serverLevel().getChunkSource().broadcastAndSend(this, new ClientboundAnimatePacket(this, 2));
|
||||
this.level().getChunkSource().broadcastAndSend(this, new ClientboundAnimatePacket(this, 2));
|
||||
}
|
||||
|
||||
super.stopSleepInBed(wakeImmediately, updateLevelForSleepingPlayers);
|
||||
@@ -879,8 +867,8 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1185,8 +_,9 @@
|
||||
this.connection.send(new ClientboundOpenSignEditorPacket(signEntity.getBlockPos(), isFrontText));
|
||||
@@ -1222,8 +_,9 @@
|
||||
this.connection.send(new ClientboundShowDialogPacket(dialog));
|
||||
}
|
||||
|
||||
- public void nextContainerCounter() {
|
||||
@@ -890,7 +878,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1194,12 +_,39 @@
|
||||
@@ -1231,12 +_,39 @@
|
||||
if (menu == null) {
|
||||
return OptionalInt.empty();
|
||||
} else {
|
||||
@@ -931,7 +919,7 @@
|
||||
if (abstractContainerMenu == null) {
|
||||
if (this.isSpectator()) {
|
||||
this.displayClientMessage(Component.translatable("container.spectatorCantOpen").withStyle(ChatFormatting.RED), true);
|
||||
@@ -1207,10 +_,14 @@
|
||||
@@ -1244,10 +_,14 @@
|
||||
|
||||
return OptionalInt.empty();
|
||||
} else {
|
||||
@@ -948,7 +936,7 @@
|
||||
return OptionalInt.of(this.containerCounter);
|
||||
}
|
||||
}
|
||||
@@ -1223,14 +_,25 @@
|
||||
@@ -1260,14 +_,25 @@
|
||||
|
||||
@Override
|
||||
public void openHorseInventory(AbstractHorse horse, Container inventory) {
|
||||
@@ -977,7 +965,7 @@
|
||||
this.initMenu(this.containerMenu);
|
||||
}
|
||||
|
||||
@@ -1252,10 +_,30 @@
|
||||
@@ -1289,10 +_,30 @@
|
||||
|
||||
@Override
|
||||
public void closeContainer() {
|
||||
@@ -1008,7 +996,7 @@
|
||||
@Override
|
||||
public void doCloseContainer() {
|
||||
this.containerMenu.removed(this);
|
||||
@@ -1278,19 +_,19 @@
|
||||
@@ -1315,19 +_,19 @@
|
||||
int rounded = Math.round((float)Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F);
|
||||
if (rounded > 0) {
|
||||
this.awardStat(Stats.SWIM_ONE_CM, rounded);
|
||||
@@ -1031,7 +1019,7 @@
|
||||
}
|
||||
} else if (this.onClimbable()) {
|
||||
if (dy > 0.0) {
|
||||
@@ -1301,13 +_,13 @@
|
||||
@@ -1338,13 +_,13 @@
|
||||
if (rounded > 0) {
|
||||
if (this.isSprinting()) {
|
||||
this.awardStat(Stats.SPRINT_ONE_CM, rounded);
|
||||
@@ -1048,7 +1036,7 @@
|
||||
}
|
||||
}
|
||||
} else if (this.isFallFlying()) {
|
||||
@@ -1347,13 +_,13 @@
|
||||
@@ -1386,13 +_,13 @@
|
||||
@Override
|
||||
public void awardStat(Stat<?> stat, int amount) {
|
||||
this.stats.increment(this, stat, amount);
|
||||
@@ -1064,7 +1052,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1384,9 +_,9 @@
|
||||
@@ -1423,9 +_,9 @@
|
||||
super.jumpFromGround();
|
||||
this.awardStat(Stats.JUMP);
|
||||
if (this.isSprinting()) {
|
||||
@@ -1076,7 +1064,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1399,6 +_,13 @@
|
||||
@@ -1438,6 +_,13 @@
|
||||
public void disconnect() {
|
||||
this.disconnected = true;
|
||||
this.ejectPassengers();
|
||||
@@ -1090,7 +1078,7 @@
|
||||
if (this.isSleeping()) {
|
||||
this.stopSleepInBed(true, false);
|
||||
}
|
||||
@@ -1410,6 +_,7 @@
|
||||
@@ -1449,6 +_,7 @@
|
||||
|
||||
public void resetSentInfo() {
|
||||
this.lastSentHealth = -1.0E8F;
|
||||
@@ -1098,7 +1086,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1444,12 +_,12 @@
|
||||
@@ -1483,12 +_,12 @@
|
||||
this.onUpdateAbilities();
|
||||
if (keepEverything) {
|
||||
this.getAttributes().assignBaseValues(that.getAttributes());
|
||||
@@ -1113,16 +1101,16 @@
|
||||
}
|
||||
|
||||
this.getInventory().replaceWith(that.getInventory());
|
||||
@@ -1460,7 +_,7 @@
|
||||
@@ -1499,7 +_,7 @@
|
||||
this.portalProcess = that.portalProcess;
|
||||
} else {
|
||||
this.getAttributes().assignBaseValues(that.getAttributes());
|
||||
- this.setHealth(this.getMaxHealth());
|
||||
+ // this.setHealth(this.getMaxHealth()); // CraftBukkit
|
||||
if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || that.isSpectator()) {
|
||||
if (this.level().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || that.isSpectator()) {
|
||||
this.getInventory().replaceWith(that.getInventory());
|
||||
this.experienceLevel = that.experienceLevel;
|
||||
@@ -1476,7 +_,7 @@
|
||||
@@ -1515,7 +_,7 @@
|
||||
this.lastSentExp = -1;
|
||||
this.lastSentHealth = -1.0F;
|
||||
this.lastSentFood = -1;
|
||||
@@ -1131,7 +1119,7 @@
|
||||
this.seenCredits = that.seenCredits;
|
||||
this.enteredNetherPosition = that.enteredNetherPosition;
|
||||
this.chunkTrackingView = that.chunkTrackingView;
|
||||
@@ -1529,7 +_,7 @@
|
||||
@@ -1568,7 +_,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1140,7 +1128,7 @@
|
||||
if (this.isSleeping()) {
|
||||
this.stopSleepInBed(true, true);
|
||||
}
|
||||
@@ -1538,7 +_,7 @@
|
||||
@@ -1577,7 +_,7 @@
|
||||
this.setCamera(this);
|
||||
}
|
||||
|
||||
@@ -1149,7 +1137,7 @@
|
||||
if (flag) {
|
||||
this.setYHeadRot(relativeMovements.contains(Relative.Y_ROT) ? this.getYHeadRot() + yaw : yaw);
|
||||
}
|
||||
@@ -1575,9 +_,17 @@
|
||||
@@ -1615,9 +_,17 @@
|
||||
}
|
||||
|
||||
public boolean setGameMode(GameType gameMode) {
|
||||
@@ -1169,7 +1157,7 @@
|
||||
} else {
|
||||
this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, gameMode.getId()));
|
||||
if (gameMode == GameType.SPECTATOR) {
|
||||
@@ -1593,7 +_,7 @@
|
||||
@@ -1633,7 +_,7 @@
|
||||
|
||||
this.onUpdateAbilities();
|
||||
this.updateEffectVisibility();
|
||||
@@ -1178,7 +1166,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1649,8 +_,13 @@
|
||||
@@ -1689,8 +_,13 @@
|
||||
}
|
||||
|
||||
public void sendChatMessage(OutgoingChatMessage message, boolean filtered, ChatType.Bound boundType) {
|
||||
@@ -1193,7 +1181,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1661,7 +_,42 @@
|
||||
@@ -1701,7 +_,42 @@
|
||||
}
|
||||
|
||||
public void updateOptions(ClientInformation clientInformation) {
|
||||
@@ -1236,7 +1224,7 @@
|
||||
this.requestedViewDistance = clientInformation.viewDistance();
|
||||
this.chatVisibility = clientInformation.chatVisibility();
|
||||
this.canChatColor = clientInformation.chatColors();
|
||||
@@ -1747,8 +_,23 @@
|
||||
@@ -1787,8 +_,23 @@
|
||||
Entity camera = this.getCamera();
|
||||
this.camera = (Entity)(entityToSpectate == null ? this : entityToSpectate);
|
||||
if (camera != this.camera) {
|
||||
@@ -1261,7 +1249,7 @@
|
||||
}
|
||||
|
||||
if (entityToSpectate != null) {
|
||||
@@ -1782,11 +_,11 @@
|
||||
@@ -1822,11 +_,11 @@
|
||||
|
||||
@Nullable
|
||||
public Component getTabListDisplayName() {
|
||||
@@ -1275,7 +1263,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1817,11 +_,56 @@
|
||||
@@ -1857,11 +_,56 @@
|
||||
}
|
||||
|
||||
public void setRespawnPosition(@Nullable ServerPlayer.RespawnConfig respawnConfig, boolean displayInChat) {
|
||||
@@ -1334,7 +1322,7 @@
|
||||
}
|
||||
|
||||
public SectionPos getLastSectionPos() {
|
||||
@@ -1851,16 +_,23 @@
|
||||
@@ -1891,16 +_,23 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1362,24 +1350,24 @@
|
||||
return itemEntity;
|
||||
}
|
||||
|
||||
@@ -1888,6 +_,16 @@
|
||||
@@ -1928,6 +_,16 @@
|
||||
}
|
||||
|
||||
public void loadGameTypes(@Nullable CompoundTag tag) {
|
||||
public void loadGameTypes(@Nullable ValueInput input) {
|
||||
+ // Paper start - Expand PlayerGameModeChangeEvent
|
||||
+ if (this.server.getForcedGameType() != null && this.server.getForcedGameType() != readPlayerMode(tag, "playerGameType")) {
|
||||
+ if (this.server.getForcedGameType() != null && this.server.getForcedGameType() != readPlayerMode(input, "playerGameType")) {
|
||||
+ if (new org.bukkit.event.player.PlayerGameModeChangeEvent(this.getBukkitEntity(), org.bukkit.GameMode.getByValue(this.server.getDefaultGameType().getId()), org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.DEFAULT_GAMEMODE, null).callEvent()) {
|
||||
+ this.gameMode.setGameModeForPlayer(this.server.getForcedGameType(), GameType.DEFAULT_MODE);
|
||||
+ } else {
|
||||
+ this.gameMode.setGameModeForPlayer(readPlayerMode(tag,"playerGameType"), readPlayerMode(tag, "previousPlayerGameType"));
|
||||
+ this.gameMode.setGameModeForPlayer(readPlayerMode(input, "playerGameType"), readPlayerMode(input, "previousPlayerGameType"));
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - Expand PlayerGameModeChangeEvent
|
||||
this.gameMode
|
||||
.setGameModeForPlayer(this.calculateGameModeForNewPlayer(readPlayerMode(tag, "playerGameType")), readPlayerMode(tag, "previousPlayerGameType"));
|
||||
.setGameModeForPlayer(this.calculateGameModeForNewPlayer(readPlayerMode(input, "playerGameType")), readPlayerMode(input, "previousPlayerGameType"));
|
||||
}
|
||||
@@ -1989,8 +_,14 @@
|
||||
@@ -2029,8 +_,14 @@
|
||||
|
||||
@Override
|
||||
public void removeVehicle() {
|
||||
@@ -1395,7 +1383,7 @@
|
||||
if (vehicle instanceof LivingEntity livingEntity) {
|
||||
for (MobEffectInstance mobEffectInstance : livingEntity.getActiveEffects()) {
|
||||
this.connection.send(new ClientboundRemoveMobEffectPacket(vehicle.getId(), mobEffectInstance.getEffect()));
|
||||
@@ -2089,7 +_,7 @@
|
||||
@@ -2129,7 +_,7 @@
|
||||
}
|
||||
|
||||
public static long placeEnderPearlTicket(ServerLevel level, ChunkPos pos) {
|
||||
@@ -1404,7 +1392,7 @@
|
||||
return TicketType.ENDER_PEARL.timeout();
|
||||
}
|
||||
|
||||
@@ -2113,9 +_,11 @@
|
||||
@@ -2153,9 +_,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1419,7 +1407,7 @@
|
||||
}
|
||||
|
||||
private static float calculateLookAtYaw(Vec3 position, BlockPos towardsPos) {
|
||||
@@ -2123,4 +_,143 @@
|
||||
@@ -2163,4 +_,143 @@
|
||||
return (float)Mth.wrapDegrees(Mth.atan2(vec3.z, vec3.x) * 180.0F / (float)Math.PI - 90.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
public ServerPlayerGameMode(ServerPlayer player) {
|
||||
this.player = player;
|
||||
this.level = player.serverLevel();
|
||||
this.level = player.level();
|
||||
}
|
||||
|
||||
+ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper
|
||||
@@ -40,8 +40,8 @@
|
||||
+ // CraftBukkit end
|
||||
+ this.setGameModeForPlayer(gameModeForPlayer, this.gameModeForPlayer); // Paper - Fix MC-259571
|
||||
this.player.onUpdateAbilities();
|
||||
this.player
|
||||
.server
|
||||
this.level
|
||||
.getServer()
|
||||
.getPlayerList()
|
||||
- .broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_GAME_MODE, this.player));
|
||||
+ .broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_GAME_MODE, this.player), this.player); // CraftBukkit
|
||||
|
||||
Reference in New Issue
Block a user