Update to Minecraft 1.18.1

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2021-12-11 00:11:02 +11:00
parent aa726a99dc
commit 667cb32115
10 changed files with 125 additions and 127 deletions

View file

@ -12,7 +12,7 @@
+ +
public class Main { public class Main {
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER;
@@ -63,8 +69,9 @@ @@ -63,8 +69,9 @@
public Main() {} public Main() {}

View file

@ -40,7 +40,7 @@
public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, DefinedStructureManager definedstructuremanager, Executor executor, IAsyncTaskHandler<Runnable> iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, ChunkStatusUpdateListener chunkstatusupdatelistener, Supplier<WorldPersistentData> supplier, int i, boolean flag) { public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, DefinedStructureManager definedstructuremanager, 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); super(convertable_conversionsession.getDimensionPath(worldserver.dimension()).resolve("region"), datafixer, flag);
this.visibleChunkMap = this.updatingChunkMap.clone(); this.visibleChunkMap = this.updatingChunkMap.clone();
@@ -329,9 +355,12 @@ @@ -291,9 +317,12 @@
CompletableFuture<List<Either<IChunkAccess, PlayerChunk.Failure>>> completablefuture1 = SystemUtils.sequence(list); CompletableFuture<List<Either<IChunkAccess, PlayerChunk.Failure>>> completablefuture1 = SystemUtils.sequence(list);
CompletableFuture<Either<List<IChunkAccess>, PlayerChunk.Failure>> completablefuture2 = completablefuture1.thenApply((list2) -> { CompletableFuture<Either<List<IChunkAccess>, PlayerChunk.Failure>> completablefuture2 = completablefuture1.thenApply((list2) -> {
List<IChunkAccess> list3 = Lists.newArrayList(); List<IChunkAccess> list3 = Lists.newArrayList();
@ -55,7 +55,7 @@
final Either<IChunkAccess, PlayerChunk.Failure> either = (Either) iterator.next(); final Either<IChunkAccess, PlayerChunk.Failure> either = (Either) iterator.next();
Optional<IChunkAccess> optional = either.left(); Optional<IChunkAccess> optional = either.left();
@@ -501,7 +530,7 @@ @@ -463,7 +492,7 @@
private void scheduleUnload(long i, PlayerChunk playerchunk) { private void scheduleUnload(long i, PlayerChunk playerchunk) {
CompletableFuture<IChunkAccess> completablefuture = playerchunk.getChunkToSave(); CompletableFuture<IChunkAccess> completablefuture = playerchunk.getChunkToSave();
@ -64,7 +64,7 @@
CompletableFuture<IChunkAccess> completablefuture1 = playerchunk.getChunkToSave(); CompletableFuture<IChunkAccess> completablefuture1 = playerchunk.getChunkToSave();
if (completablefuture1 != completablefuture) { if (completablefuture1 != completablefuture) {
@@ -680,7 +709,21 @@ @@ -642,7 +671,21 @@
private static void postLoadProtoChunk(WorldServer worldserver, List<NBTTagCompound> list) { private static void postLoadProtoChunk(WorldServer worldserver, List<NBTTagCompound> list) {
if (!list.isEmpty()) { if (!list.isEmpty()) {
@ -87,7 +87,7 @@
} }
} }
@@ -778,7 +821,7 @@ @@ -740,7 +783,7 @@
if (!playerchunk.wasAccessibleSinceLastSave()) { if (!playerchunk.wasAccessibleSinceLastSave()) {
return false; return false;
} else { } else {
@ -96,7 +96,7 @@
if (!(ichunkaccess instanceof ProtoChunkExtension) && !(ichunkaccess instanceof Chunk)) { if (!(ichunkaccess instanceof ProtoChunkExtension) && !(ichunkaccess instanceof Chunk)) {
return false; return false;
@@ -927,7 +970,8 @@ @@ -890,7 +933,8 @@
return ichunkaccess instanceof Chunk ? Optional.of((Chunk) ichunkaccess) : Optional.empty(); return ichunkaccess instanceof Chunk ? Optional.of((Chunk) ichunkaccess) : Optional.empty();
}); });
@ -106,7 +106,7 @@
return chunk.getBlockEntities().size(); return chunk.getBlockEntities().size();
}).orElse(0), tickingtracker.getTicketDebugString(i), tickingtracker.getLevel(i), optional1.map((chunk) -> { }).orElse(0), tickingtracker.getTicketDebugString(i), tickingtracker.getLevel(i), optional1.map((chunk) -> {
return chunk.getBlockTicks().count(); return chunk.getBlockTicks().count();
@@ -940,7 +984,7 @@ @@ -903,7 +947,7 @@
private static String printFuture(CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture) { private static String printFuture(CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture) {
try { try {
@ -115,7 +115,7 @@
return either != null ? (String) either.map((chunk) -> { return either != null ? (String) either.map((chunk) -> {
return "done"; return "done";
@@ -958,7 +1002,7 @@ @@ -921,7 +965,7 @@
private NBTTagCompound readChunk(ChunkCoordIntPair chunkcoordintpair) throws IOException { private NBTTagCompound readChunk(ChunkCoordIntPair chunkcoordintpair) throws IOException {
NBTTagCompound nbttagcompound = this.read(chunkcoordintpair); NBTTagCompound nbttagcompound = this.read(chunkcoordintpair);
@ -124,7 +124,7 @@
} }
boolean anyPlayerCloseEnoughForSpawning(ChunkCoordIntPair chunkcoordintpair) { boolean anyPlayerCloseEnoughForSpawning(ChunkCoordIntPair chunkcoordintpair) {
@@ -1382,7 +1426,7 @@ @@ -1342,7 +1386,7 @@
public final Set<ServerPlayerConnection> seenBy = Sets.newIdentityHashSet(); public final Set<ServerPlayerConnection> seenBy = Sets.newIdentityHashSet();
public EntityTracker(Entity entity, int i, int j, boolean flag) { public EntityTracker(Entity entity, int i, int j, boolean flag) {
@ -133,7 +133,7 @@
this.entity = entity; this.entity = entity;
this.range = i; this.range = i;
this.lastSectionPos = SectionPosition.of(entity); this.lastSectionPos = SectionPosition.of(entity);
@@ -1435,12 +1479,17 @@ @@ -1395,12 +1439,17 @@
public void updatePlayer(EntityPlayer entityplayer) { public void updatePlayer(EntityPlayer entityplayer) {
if (entityplayer != this.entity) { if (entityplayer != this.entity) {

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/WorldServer.java --- a/net/minecraft/server/level/WorldServer.java
+++ b/net/minecraft/server/level/WorldServer.java +++ b/net/minecraft/server/level/WorldServer.java
@@ -147,6 +147,20 @@ @@ -149,6 +149,20 @@
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -21,7 +21,7 @@
public class WorldServer extends World implements GeneratorAccessSeed { public class WorldServer extends World implements GeneratorAccessSeed {
public static final BlockPosition END_SPAWN_POINT = new BlockPosition(100, 50, 0); public static final BlockPosition END_SPAWN_POINT = new BlockPosition(100, 50, 0);
@@ -164,7 +178,7 @@ @@ -166,7 +180,7 @@
final List<EntityPlayer> players; final List<EntityPlayer> players;
private final ChunkProviderServer chunkSource; private final ChunkProviderServer chunkSource;
private final MinecraftServer server; private final MinecraftServer server;
@ -30,7 +30,7 @@
final EntityTickList entityTickList; final EntityTickList entityTickList;
public final PersistentEntitySectionManager<Entity> entityManager; public final PersistentEntitySectionManager<Entity> entityManager;
public boolean noSave; public boolean noSave;
@@ -186,9 +200,29 @@ @@ -189,9 +203,29 @@
private final StructureCheck structureCheck; private final StructureCheck structureCheck;
private final boolean tickTime; private final boolean tickTime;
@ -63,7 +63,7 @@
this.players = Lists.newArrayList(); this.players = Lists.newArrayList();
this.entityTickList = new EntityTickList(); this.entityTickList = new EntityTickList();
this.blockTicks = new TickListServer<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier()); this.blockTicks = new TickListServer<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier());
@@ -200,7 +234,13 @@ @@ -203,7 +237,13 @@
this.tickTime = flag1; this.tickTime = flag1;
this.server = minecraftserver; this.server = minecraftserver;
this.customSpawners = list; this.customSpawners = list;
@ -78,7 +78,7 @@
boolean flag2 = minecraftserver.forceSynchronousWrites(); boolean flag2 = minecraftserver.forceSynchronousWrites();
DataFixer datafixer = minecraftserver.getFixerUpper(); DataFixer datafixer = minecraftserver.getFixerUpper();
EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver); EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver);
@@ -231,14 +271,15 @@ @@ -234,14 +274,15 @@
long l = minecraftserver.getWorldData().worldGenSettings().seed(); long l = minecraftserver.getWorldData().worldGenSettings().seed();
this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this, chunkgenerator.getBiomeSource(), l, datafixer); this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this, chunkgenerator.getBiomeSource(), l, datafixer);
@ -96,7 +96,7 @@
} }
public void setWeatherParameters(int i, int j, boolean flag, boolean flag1) { public void setWeatherParameters(int i, int j, boolean flag, boolean flag1) {
@@ -270,12 +311,20 @@ @@ -273,12 +314,20 @@
long j; long j;
if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) { if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) {
@ -120,7 +120,7 @@
if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) { if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) {
this.resetWeatherCycle(); this.resetWeatherCycle();
} }
@@ -301,7 +350,7 @@ @@ -304,7 +353,7 @@
this.runBlockEvents(); this.runBlockEvents();
this.handlingTick = false; this.handlingTick = false;
gameprofilerfiller.pop(); gameprofilerfiller.pop();
@ -129,7 +129,7 @@
if (flag) { if (flag) {
this.resetEmptyTime(); this.resetEmptyTime();
@@ -317,7 +366,7 @@ @@ -320,7 +369,7 @@
this.entityTickList.forEach((entity) -> { this.entityTickList.forEach((entity) -> {
if (!entity.isRemoved()) { if (!entity.isRemoved()) {
@ -138,7 +138,7 @@
entity.discard(); entity.discard();
} else { } else {
gameprofilerfiller.push("checkDespawn"); gameprofilerfiller.push("checkDespawn");
@@ -389,7 +438,7 @@ @@ -392,7 +441,7 @@
private void wakeUpAllPlayers() { private void wakeUpAllPlayers() {
this.sleepStatus.removeAllSleepers(); this.sleepStatus.removeAllSleepers();
@ -147,7 +147,7 @@
entityplayer.stopSleepInBed(false, false); entityplayer.stopSleepInBed(false, false);
}); });
} }
@@ -416,14 +465,14 @@ @@ -419,14 +468,14 @@
entityhorseskeleton.setTrap(true); entityhorseskeleton.setTrap(true);
entityhorseskeleton.setAge(0); entityhorseskeleton.setAge(0);
entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
@ -164,7 +164,7 @@
} }
} }
@@ -434,12 +483,12 @@ @@ -437,12 +486,12 @@
BiomeBase biomebase = this.getBiome(blockposition); BiomeBase biomebase = this.getBiome(blockposition);
if (biomebase.shouldFreeze(this, blockposition1)) { if (biomebase.shouldFreeze(this, blockposition1)) {
@ -179,7 +179,7 @@
} }
IBlockData iblockdata = this.getBlockState(blockposition1); IBlockData iblockdata = this.getBlockState(blockposition1);
@@ -635,6 +684,7 @@ @@ -638,6 +687,7 @@
this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F); this.rainLevel = MathHelper.clamp(this.rainLevel, 0.0F, 1.0F);
} }
@ -187,7 +187,7 @@
if (this.oRainLevel != this.rainLevel) { if (this.oRainLevel != this.rainLevel) {
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension()); this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel), this.dimension());
} }
@@ -653,14 +703,47 @@ @@ -656,14 +706,47 @@
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel)); this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel));
this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel)); this.server.getPlayerList().broadcastAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel));
} }
@ -237,7 +237,7 @@
} }
public void resetEmptyTime() { public void resetEmptyTime() {
@@ -695,6 +778,7 @@ @@ -698,6 +781,7 @@
}); });
gameprofilerfiller.incrementCounter("tickNonPassenger"); gameprofilerfiller.incrementCounter("tickNonPassenger");
entity.tick(); entity.tick();
@ -245,7 +245,7 @@
this.getProfiler().pop(); this.getProfiler().pop();
Iterator iterator = entity.getPassengers().iterator(); Iterator iterator = entity.getPassengers().iterator();
@@ -718,6 +802,7 @@ @@ -721,6 +805,7 @@
}); });
gameprofilerfiller.incrementCounter("tickPassenger"); gameprofilerfiller.incrementCounter("tickPassenger");
entity1.rideTick(); entity1.rideTick();
@ -253,7 +253,7 @@
gameprofilerfiller.pop(); gameprofilerfiller.pop();
Iterator iterator = entity1.getPassengers().iterator(); Iterator iterator = entity1.getPassengers().iterator();
@@ -742,6 +827,7 @@ @@ -745,6 +830,7 @@
ChunkProviderServer chunkproviderserver = this.getChunkSource(); ChunkProviderServer chunkproviderserver = this.getChunkSource();
if (!flag1) { if (!flag1) {
@ -261,7 +261,7 @@
if (iprogressupdate != null) { if (iprogressupdate != null) {
iprogressupdate.progressStartNoAbort(new ChatMessage("menu.savingLevel")); iprogressupdate.progressStartNoAbort(new ChatMessage("menu.savingLevel"));
} }
@@ -759,11 +845,19 @@ @@ -762,11 +848,19 @@
} }
} }
@ -282,7 +282,7 @@
} }
this.getChunkSource().getDataStorage().save(); this.getChunkSource().getDataStorage().save();
@@ -809,15 +903,34 @@ @@ -812,15 +906,34 @@
@Override @Override
public boolean addFreshEntity(Entity entity) { public boolean addFreshEntity(Entity entity) {
@ -320,7 +320,7 @@
} }
public void addDuringCommandTeleport(EntityPlayer entityplayer) { public void addDuringCommandTeleport(EntityPlayer entityplayer) {
@@ -848,24 +961,36 @@ @@ -851,24 +964,36 @@
this.entityManager.addNewEntity(entityplayer); this.entityManager.addNewEntity(entityplayer);
} }
@ -361,7 +361,7 @@
return true; return true;
} }
} }
@@ -879,10 +1004,32 @@ @@ -882,10 +1007,32 @@
entityplayer.remove(entity_removalreason); entityplayer.remove(entity_removalreason);
} }
@ -394,7 +394,7 @@
while (iterator.hasNext()) { while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next(); EntityPlayer entityplayer = (EntityPlayer) iterator.next();
@@ -891,6 +1038,12 @@ @@ -894,6 +1041,12 @@
double d1 = (double) blockposition.getY() - entityplayer.getY(); double d1 = (double) blockposition.getY() - entityplayer.getY();
double d2 = (double) blockposition.getZ() - entityplayer.getZ(); double d2 = (double) blockposition.getZ() - entityplayer.getZ();
@ -407,7 +407,7 @@
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) { if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j)); entityplayer.connection.send(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
} }
@@ -938,7 +1091,18 @@ @@ -948,7 +1101,18 @@
Iterator iterator = this.navigatingMobs.iterator(); Iterator iterator = this.navigatingMobs.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
@ -426,8 +426,8 @@
+ // CraftBukkit end + // CraftBukkit end
NavigationAbstract navigationabstract = entityinsentient.getNavigation(); NavigationAbstract navigationabstract = entityinsentient.getNavigation();
if (!navigationabstract.hasDelayedRecomputation()) { if (navigationabstract.shouldRecomputePath(blockposition)) {
@@ -961,10 +1125,20 @@ @@ -984,10 +1148,20 @@
@Override @Override
public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) { public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) {
@ -448,7 +448,7 @@
if (explosion_effect == Explosion.Effect.NONE) { if (explosion_effect == Explosion.Effect.NONE) {
explosion.clearToBlow(); explosion.clearToBlow();
} }
@@ -1045,13 +1219,20 @@ @@ -1068,13 +1242,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) { public <T extends ParticleParam> int sendParticles(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
@ -471,7 +471,7 @@
++j; ++j;
} }
} }
@@ -1102,7 +1283,7 @@ @@ -1125,7 +1306,7 @@
@Nullable @Nullable
public BlockPosition findNearestMapFeature(StructureGenerator<?> structuregenerator, BlockPosition blockposition, int i, boolean flag) { public BlockPosition findNearestMapFeature(StructureGenerator<?> structuregenerator, BlockPosition blockposition, int i, boolean flag) {
@ -480,7 +480,7 @@
} }
@Nullable @Nullable
@@ -1139,11 +1320,21 @@ @@ -1162,11 +1343,21 @@
@Nullable @Nullable
@Override @Override
public WorldMap getMapData(String s) { public WorldMap getMapData(String s) {
@ -503,7 +503,7 @@
this.getServer().overworld().getDataStorage().set(s, worldmap); this.getServer().overworld().getDataStorage().set(s, worldmap);
} }
@@ -1455,6 +1646,11 @@ @@ -1478,6 +1669,11 @@
@Override @Override
public void blockUpdated(BlockPosition blockposition, Block block) { public void blockUpdated(BlockPosition blockposition, Block block) {
if (!this.isDebug()) { if (!this.isDebug()) {
@ -515,7 +515,7 @@
this.updateNeighborsAt(blockposition, block); this.updateNeighborsAt(blockposition, block);
} }
@@ -1474,12 +1670,12 @@ @@ -1497,12 +1693,12 @@
} }
public boolean isFlat() { public boolean isFlat() {
@ -530,7 +530,7 @@
} }
@Nullable @Nullable
@@ -1507,7 +1703,7 @@ @@ -1530,7 +1726,7 @@
private static <T> String getTypeCount(Iterable<T> iterable, Function<T, String> function) { private static <T> String getTypeCount(Iterable<T> iterable, Function<T, String> function) {
try { try {
Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap(); Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap();
@ -539,7 +539,7 @@
while (iterator.hasNext()) { while (iterator.hasNext()) {
T t0 = iterator.next(); T t0 = iterator.next();
@@ -1516,7 +1712,7 @@ @@ -1539,7 +1735,7 @@
object2intopenhashmap.addTo(s, 1); object2intopenhashmap.addTo(s, 1);
} }
@ -548,7 +548,7 @@
String s1 = (String) entry.getKey(); String s1 = (String) entry.getKey();
return s1 + ":" + entry.getIntValue(); return s1 + ":" + entry.getIntValue();
@@ -1527,17 +1723,33 @@ @@ -1550,17 +1746,33 @@
} }
public static void makeObsidianPlatform(WorldServer worldserver) { public static void makeObsidianPlatform(WorldServer worldserver) {
@ -584,7 +584,7 @@
} }
@Override @Override
@@ -1632,6 +1844,7 @@ @@ -1666,6 +1878,7 @@
} }
} }
@ -592,7 +592,7 @@
} }
public void onTrackingEnd(Entity entity) { public void onTrackingEnd(Entity entity) {
@@ -1664,6 +1877,14 @@ @@ -1707,6 +1920,14 @@
gameeventlistenerregistrar.onListenerRemoved(entity.level); gameeventlistenerregistrar.onListenerRemoved(entity.level);
} }

View file

@ -74,9 +74,9 @@
private int dropSpamTickCount; private int dropSpamTickCount;
private double firstGoodX; private double firstGoodX;
private double firstGoodY; private double firstGoodY;
@@ -201,7 +259,33 @@ @@ -202,7 +260,33 @@
this.player = entityplayer;
entityplayer.connection = this; entityplayer.connection = this;
this.keepAliveTime = SystemUtils.getMillis();
entityplayer.getTextFilter().join(); entityplayer.getTextFilter().join();
+ +
+ // CraftBukkit start - add fields and methods + // CraftBukkit start - add fields and methods
@ -108,7 +108,7 @@
public void tick() { public void tick() {
this.resetPosition(); this.resetPosition();
@@ -250,7 +334,7 @@ @@ -251,7 +335,7 @@
this.server.getProfiler().push("keepAlive"); this.server.getProfiler().push("keepAlive");
long i = SystemUtils.getMillis(); long i = SystemUtils.getMillis();
@ -117,7 +117,7 @@
if (this.keepAlivePending) { if (this.keepAlivePending) {
this.disconnect(new ChatMessage("disconnect.timeout")); this.disconnect(new ChatMessage("disconnect.timeout"));
} else { } else {
@@ -262,15 +346,21 @@ @@ -263,15 +347,21 @@
} }
this.server.getProfiler().pop(); this.server.getProfiler().pop();
@ -139,7 +139,7 @@
this.disconnect(new ChatMessage("multiplayer.disconnect.idling")); this.disconnect(new ChatMessage("multiplayer.disconnect.idling"));
} }
@@ -294,16 +384,46 @@ @@ -295,16 +385,46 @@
return this.server.isSingleplayerOwner(this.player.getGameProfile()); return this.server.isSingleplayerOwner(this.player.getGameProfile());
} }
@ -187,7 +187,7 @@
} }
private <T, R> void filterTextPacket(T t0, Consumer<R> consumer, BiFunction<ITextFilter, T, CompletableFuture<R>> bifunction) { private <T, R> void filterTextPacket(T t0, Consumer<R> consumer, BiFunction<ITextFilter, T, CompletableFuture<R>> bifunction) {
@@ -370,7 +490,34 @@ @@ -371,7 +491,34 @@
double d9 = entity.getDeltaMovement().lengthSqr(); double d9 = entity.getDeltaMovement().lengthSqr();
double d10 = d6 * d6 + d7 * d7 + d8 * d8; double d10 = d6 * d6 + d7 * d7 + d8 * d8;
@ -223,7 +223,7 @@
PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getName().getString(), this.player.getName().getString(), d6, d7, d8); PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getName().getString(), this.player.getName().getString(), d6, d7, d8);
this.connection.send(new PacketPlayOutVehicleMove(entity)); this.connection.send(new PacketPlayOutVehicleMove(entity));
return; return;
@@ -400,14 +547,72 @@ @@ -401,14 +548,72 @@
} }
entity.absMoveTo(d3, d4, d5, f, f1); entity.absMoveTo(d3, d4, d5, f, f1);
@ -296,7 +296,7 @@
this.player.getLevel().getChunkSource().move(this.player); this.player.getLevel().getChunkSource().move(this.player);
this.player.checkMovementStatistics(this.player.getX() - d0, this.player.getY() - d1, this.player.getZ() - d2); this.player.checkMovementStatistics(this.player.getX() - d0, this.player.getY() - d1, this.player.getZ() - d2);
this.clientVehicleIsFloating = d11 >= -0.03125D && !this.server.isFlightAllowed() && this.noBlocksAround(entity); this.clientVehicleIsFloating = d11 >= -0.03125D && !this.server.isFlightAllowed() && this.noBlocksAround(entity);
@@ -426,7 +631,7 @@ @@ -427,7 +632,7 @@
@Override @Override
public void handleAcceptTeleportPacket(PacketPlayInTeleportAccept packetplayinteleportaccept) { public void handleAcceptTeleportPacket(PacketPlayInTeleportAccept packetplayinteleportaccept) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinteleportaccept, this, this.player.getLevel()); PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinteleportaccept, this, this.player.getLevel());
@ -305,7 +305,7 @@
this.player.absMoveTo(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot()); this.player.absMoveTo(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
this.lastGoodX = this.awaitingPositionFromClient.x; this.lastGoodX = this.awaitingPositionFromClient.x;
this.lastGoodY = this.awaitingPositionFromClient.y; this.lastGoodY = this.awaitingPositionFromClient.y;
@@ -436,6 +641,7 @@ @@ -437,6 +642,7 @@
} }
this.awaitingPositionFromClient = null; this.awaitingPositionFromClient = null;
@ -313,7 +313,7 @@
} }
} }
@@ -443,7 +649,7 @@ @@ -444,7 +650,7 @@
@Override @Override
public void handleRecipeBookSeenRecipePacket(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) { public void handleRecipeBookSeenRecipePacket(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipedisplayed, this, this.player.getLevel()); PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipedisplayed, this, this.player.getLevel());
@ -322,7 +322,7 @@
RecipeBookServer recipebookserver = this.player.getRecipeBook(); RecipeBookServer recipebookserver = this.player.getRecipeBook();
Objects.requireNonNull(recipebookserver); Objects.requireNonNull(recipebookserver);
@@ -473,6 +679,12 @@ @@ -474,6 +680,12 @@
@Override @Override
public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) { public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.getLevel()); PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.getLevel());
@ -335,7 +335,7 @@
StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand()); StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand());
if (stringreader.canRead() && stringreader.peek() == '/') { if (stringreader.canRead() && stringreader.peek() == '/') {
@@ -482,6 +694,7 @@ @@ -483,6 +695,7 @@
ParseResults<CommandListenerWrapper> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack()); ParseResults<CommandListenerWrapper> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack());
this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> { this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
@ -343,7 +343,7 @@
this.connection.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions)); this.connection.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions));
}); });
} }
@@ -714,6 +927,7 @@ @@ -715,6 +928,7 @@
if (container instanceof ContainerMerchant) { if (container instanceof ContainerMerchant) {
ContainerMerchant containermerchant = (ContainerMerchant) container; ContainerMerchant containermerchant = (ContainerMerchant) container;
@ -351,7 +351,7 @@
containermerchant.setSelectionHint(i); containermerchant.setSelectionHint(i);
containermerchant.tryMoveItems(i); containermerchant.tryMoveItems(i);
@@ -723,6 +937,13 @@ @@ -724,6 +938,13 @@
@Override @Override
public void handleEditBook(PacketPlayInBEdit packetplayinbedit) { public void handleEditBook(PacketPlayInBEdit packetplayinbedit) {
@ -365,7 +365,7 @@
int i = packetplayinbedit.getSlot(); int i = packetplayinbedit.getSlot();
if (PlayerInventory.isHotbarSlot(i) || i == 40) { if (PlayerInventory.isHotbarSlot(i) || i == 40) {
@@ -731,7 +952,7 @@ @@ -732,7 +953,7 @@
Objects.requireNonNull(list); Objects.requireNonNull(list);
optional.ifPresent(list::add); optional.ifPresent(list::add);
@ -374,7 +374,7 @@
Objects.requireNonNull(list); Objects.requireNonNull(list);
stream.forEach(list::add); stream.forEach(list::add);
@@ -747,7 +968,7 @@ @@ -748,7 +969,7 @@
ItemStack itemstack = this.player.getInventory().getItem(i); ItemStack itemstack = this.player.getInventory().getItem(i);
if (itemstack.is(Items.WRITABLE_BOOK)) { if (itemstack.is(Items.WRITABLE_BOOK)) {
@ -383,7 +383,7 @@
} }
} }
@@ -772,16 +993,16 @@ @@ -773,16 +994,16 @@
this.updateBookPages(list, (s) -> { this.updateBookPages(list, (s) -> {
return IChatBaseComponent.ChatSerializer.toJson(new ChatComponentText(s)); return IChatBaseComponent.ChatSerializer.toJson(new ChatComponentText(s));
@ -404,7 +404,7 @@
return NBTTagString.valueOf((String) unaryoperator.apply(itextfilter_a.getFiltered())); return NBTTagString.valueOf((String) unaryoperator.apply(itextfilter_a.getFiltered()));
}); });
@@ -809,6 +1030,7 @@ @@ -810,6 +1031,7 @@
} }
itemstack.addTagElement("pages", nbttaglist); itemstack.addTagElement("pages", nbttaglist);
@ -412,7 +412,7 @@
} }
@Override @Override
@@ -845,7 +1067,7 @@ @@ -846,7 +1068,7 @@
} else { } else {
WorldServer worldserver = this.player.getLevel(); WorldServer worldserver = this.player.getLevel();
@ -421,7 +421,7 @@
if (this.tickCount == 0) { if (this.tickCount == 0) {
this.resetPosition(); this.resetPosition();
} }
@@ -855,7 +1077,7 @@ @@ -856,7 +1078,7 @@
this.awaitingTeleportTime = this.tickCount; this.awaitingTeleportTime = this.tickCount;
this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot()); this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
} }
@ -430,7 +430,7 @@
} else { } else {
this.awaitingTeleportTime = this.tickCount; this.awaitingTeleportTime = this.tickCount;
double d0 = clampHorizontal(packetplayinflying.getX(this.player.getX())); double d0 = clampHorizontal(packetplayinflying.getX(this.player.getX()));
@@ -867,7 +1089,15 @@ @@ -868,7 +1090,15 @@
if (this.player.isPassenger()) { if (this.player.isPassenger()) {
this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1); this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1);
this.player.getLevel().getChunkSource().move(this.player); this.player.getLevel().getChunkSource().move(this.player);
@ -446,7 +446,7 @@
double d3 = this.player.getX(); double d3 = this.player.getX();
double d4 = this.player.getY(); double d4 = this.player.getY();
double d5 = this.player.getZ(); double d5 = this.player.getZ();
@@ -887,15 +1117,33 @@ @@ -888,15 +1118,33 @@
++this.receivedMovePacketCount; ++this.receivedMovePacketCount;
int i = this.receivedMovePacketCount - this.knownMovePacketCount; int i = this.receivedMovePacketCount - this.knownMovePacketCount;
@ -482,7 +482,7 @@
PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getName().getString(), d7, d8, d9); PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getName().getString(), d7, d8, d9);
this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot()); this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot());
return; return;
@@ -914,6 +1162,7 @@ @@ -915,6 +1163,7 @@
} }
this.player.move(EnumMoveType.PLAYER, new Vec3D(d7, d8, d9)); this.player.move(EnumMoveType.PLAYER, new Vec3D(d7, d8, d9));
@ -490,7 +490,7 @@
double d12 = d8; double d12 = d8;
d7 = d0 - this.player.getX(); d7 = d0 - this.player.getX();
@@ -935,7 +1184,71 @@ @@ -936,7 +1185,71 @@
if (!this.player.noPhysics && !this.player.isSleeping() && (flag1 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb))) { if (!this.player.noPhysics && !this.player.isSleeping() && (flag1 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb))) {
this.teleport(d3, d4, d5, f, f1); this.teleport(d3, d4, d5, f, f1);
} else { } else {
@ -563,7 +563,7 @@
this.player.getLevel().getChunkSource().move(this.player); this.player.getLevel().getChunkSource().move(this.player);
this.player.doCheckFallDamage(this.player.getY() - d6, packetplayinflying.isOnGround()); this.player.doCheckFallDamage(this.player.getY() - d6, packetplayinflying.isOnGround());
this.player.setOnGround(packetplayinflying.isOnGround()); this.player.setOnGround(packetplayinflying.isOnGround());
@@ -973,19 +1286,80 @@ @@ -974,19 +1287,80 @@
return true; return true;
} }
@ -648,7 +648,7 @@
double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.getX() : 0.0D; double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.getX() : 0.0D;
double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.getY() : 0.0D; double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.getY() : 0.0D;
double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.getZ() : 0.0D; double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.getZ() : 0.0D;
@@ -997,6 +1371,14 @@ @@ -998,6 +1372,14 @@
this.awaitingTeleport = 0; this.awaitingTeleport = 0;
} }
@ -663,7 +663,7 @@
this.awaitingTeleportTime = this.tickCount; this.awaitingTeleportTime = this.tickCount;
this.player.absMoveTo(d0, d1, d2, f, f1); this.player.absMoveTo(d0, d1, d2, f, f1);
this.player.connection.send(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport, flag)); this.player.connection.send(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport, flag));
@@ -1005,6 +1387,7 @@ @@ -1006,6 +1388,7 @@
@Override @Override
public void handlePlayerAction(PacketPlayInBlockDig packetplayinblockdig) { public void handlePlayerAction(PacketPlayInBlockDig packetplayinblockdig) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockdig, this, this.player.getLevel()); PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockdig, this, this.player.getLevel());
@ -671,7 +671,7 @@
BlockPosition blockposition = packetplayinblockdig.getPos(); BlockPosition blockposition = packetplayinblockdig.getPos();
this.player.resetLastActionTime(); this.player.resetLastActionTime();
@@ -1015,14 +1398,46 @@ @@ -1016,14 +1399,46 @@
if (!this.player.isSpectator()) { if (!this.player.isSpectator()) {
ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND); ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND);
@ -720,7 +720,7 @@
this.player.drop(false); this.player.drop(false);
} }
@@ -1059,6 +1474,7 @@ @@ -1060,6 +1475,7 @@
@Override @Override
public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) { public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.getLevel()); PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.getLevel());
@ -728,7 +728,7 @@
WorldServer worldserver = this.player.getLevel(); WorldServer worldserver = this.player.getLevel();
EnumHand enumhand = packetplayinuseitem.getHand(); EnumHand enumhand = packetplayinuseitem.getHand();
ItemStack itemstack = this.player.getItemInHand(enumhand); ItemStack itemstack = this.player.getItemInHand(enumhand);
@@ -1071,6 +1487,14 @@ @@ -1072,6 +1488,14 @@
if (blockposition.getY() < i) { if (blockposition.getY() < i) {
if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.mayInteract(this.player, blockposition)) { if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.mayInteract(this.player, blockposition)) {
@ -743,7 +743,7 @@
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock); EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
if (enumdirection == EnumDirection.UP && !enuminteractionresult.consumesAction() && blockposition.getY() >= i - 1 && wasBlockPlacementAttempt(this.player, itemstack)) { if (enumdirection == EnumDirection.UP && !enuminteractionresult.consumesAction() && blockposition.getY() >= i - 1 && wasBlockPlacementAttempt(this.player, itemstack)) {
@@ -1094,12 +1518,51 @@ @@ -1095,12 +1519,51 @@
@Override @Override
public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) { public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.getLevel()); PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.getLevel());
@ -795,7 +795,7 @@
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand); EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
if (enuminteractionresult.shouldSwing()) { if (enuminteractionresult.shouldSwing()) {
@@ -1120,7 +1583,7 @@ @@ -1121,7 +1584,7 @@
Entity entity = packetplayinspectate.getEntity(worldserver); Entity entity = packetplayinspectate.getEntity(worldserver);
if (entity != null) { if (entity != null) {
@ -804,7 +804,7 @@
return; return;
} }
} }
@@ -1135,6 +1598,7 @@ @@ -1136,6 +1599,7 @@
PlayerConnection.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getName()); PlayerConnection.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getName());
this.disconnect(new ChatMessage("multiplayer.requiredTexturePrompt.disconnect")); this.disconnect(new ChatMessage("multiplayer.requiredTexturePrompt.disconnect"));
} }
@ -812,7 +812,7 @@
} }
@@ -1154,11 +1618,26 @@ @@ -1155,11 +1619,26 @@
@Override @Override
public void onDisconnect(IChatBaseComponent ichatbasecomponent) { public void onDisconnect(IChatBaseComponent ichatbasecomponent) {
@ -840,7 +840,7 @@
this.player.getTextFilter().leave(); this.player.getTextFilter().leave();
if (this.isSingleplayerOwner()) { if (this.isSingleplayerOwner()) {
PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out"); PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out");
@@ -1173,6 +1652,15 @@ @@ -1174,6 +1653,15 @@
} }
public void send(Packet<?> packet, @Nullable GenericFutureListener<? extends Future<? super Void>> genericfuturelistener) { public void send(Packet<?> packet, @Nullable GenericFutureListener<? extends Future<? super Void>> genericfuturelistener) {
@ -856,7 +856,7 @@
try { try {
this.connection.send(packet, genericfuturelistener); this.connection.send(packet, genericfuturelistener);
} catch (Throwable throwable) { } catch (Throwable throwable) {
@@ -1189,7 +1677,16 @@ @@ -1190,7 +1678,16 @@
@Override @Override
public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) { public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.getLevel()); PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.getLevel());
@ -873,7 +873,7 @@
if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) { if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) {
this.player.stopUsingItem(); this.player.stopUsingItem();
} }
@@ -1198,11 +1695,18 @@ @@ -1199,11 +1696,18 @@
this.player.resetLastActionTime(); this.player.resetLastActionTime();
} else { } else {
PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString()); PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
@ -892,7 +892,7 @@
String s = StringUtils.normalizeSpace(packetplayinchat.getMessage()); String s = StringUtils.normalizeSpace(packetplayinchat.getMessage());
for (int i = 0; i < s.length(); ++i) { for (int i = 0; i < s.length(); ++i) {
@@ -1216,20 +1720,42 @@ @@ -1217,20 +1721,42 @@
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinchat, this, this.player.getLevel()); PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinchat, this, this.player.getLevel());
this.handleChat(ITextFilter.a.passThrough(s)); this.handleChat(ITextFilter.a.passThrough(s));
} else { } else {
@ -939,7 +939,7 @@
} else { } else {
String s1 = itextfilter_a.getFiltered(); String s1 = itextfilter_a.getFiltered();
ChatMessage chatmessage = s1.isEmpty() ? null : new ChatMessage("chat.type.text", new Object[]{this.player.getDisplayName(), s1}); ChatMessage chatmessage = s1.isEmpty() ? null : new ChatMessage("chat.type.text", new Object[]{this.player.getDisplayName(), s1});
@@ -1240,28 +1766,198 @@ @@ -1241,28 +1767,198 @@
}, ChatMessageType.CHAT, this.player.getUUID()); }, ChatMessageType.CHAT, this.player.getUUID());
} }
@ -1142,7 +1142,7 @@
this.player.resetLastActionTime(); this.player.resetLastActionTime();
IJumpable ijumpable; IJumpable ijumpable;
@@ -1319,6 +2015,7 @@ @@ -1320,6 +2016,7 @@
@Override @Override
public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) { public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.getLevel()); PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.getLevel());
@ -1150,7 +1150,7 @@
WorldServer worldserver = this.player.getLevel(); WorldServer worldserver = this.player.getLevel();
final Entity entity = packetplayinuseentity.getTarget(worldserver); final Entity entity = packetplayinuseentity.getTarget(worldserver);
@@ -1333,10 +2030,44 @@ @@ -1334,10 +2031,44 @@
if (this.player.distanceToSqr(entity) < 36.0D) { if (this.player.distanceToSqr(entity) < 36.0D) {
packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() { packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() {
@ -1196,7 +1196,7 @@
if (enuminteractionresult.consumesAction()) { if (enuminteractionresult.consumesAction()) {
CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(PlayerConnection.this.player, itemstack, entity); CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(PlayerConnection.this.player, itemstack, entity);
if (enuminteractionresult.shouldSwing()) { if (enuminteractionresult.shouldSwing()) {
@@ -1348,20 +2079,27 @@ @@ -1349,20 +2080,27 @@
@Override @Override
public void onInteraction(EnumHand enumhand) { public void onInteraction(EnumHand enumhand) {
@ -1227,7 +1227,7 @@
} else { } else {
PlayerConnection.this.disconnect(new ChatMessage("multiplayer.disconnect.invalid_entity_attacked")); PlayerConnection.this.disconnect(new ChatMessage("multiplayer.disconnect.invalid_entity_attacked"));
PlayerConnection.LOGGER.warn("Player {} tried to attack an invalid entity", PlayerConnection.this.player.getName().getString()); PlayerConnection.LOGGER.warn("Player {} tried to attack an invalid entity", PlayerConnection.this.player.getName().getString());
@@ -1406,21 +2144,304 @@ @@ -1407,21 +2145,304 @@
@Override @Override
public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) { public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.getLevel()); PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.getLevel());
@ -1535,7 +1535,7 @@
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator(); ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator();
while (objectiterator.hasNext()) { while (objectiterator.hasNext()) {
@@ -1455,6 +2476,7 @@ @@ -1456,6 +2477,7 @@
@Override @Override
public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) { public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.getLevel()); PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.getLevel());
@ -1543,7 +1543,7 @@
this.player.resetLastActionTime(); this.player.resetLastActionTime();
if (this.player.containerMenu.containerId == packetplayinenchantitem.getContainerId() && !this.player.isSpectator()) { if (this.player.containerMenu.containerId == packetplayinenchantitem.getContainerId() && !this.player.isSpectator()) {
this.player.containerMenu.clickMenuButton(this.player, packetplayinenchantitem.getButtonId()); this.player.containerMenu.clickMenuButton(this.player, packetplayinenchantitem.getButtonId());
@@ -1482,6 +2504,43 @@ @@ -1483,6 +2505,43 @@
boolean flag1 = packetplayinsetcreativeslot.getSlotNum() >= 1 && packetplayinsetcreativeslot.getSlotNum() <= 45; boolean flag1 = packetplayinsetcreativeslot.getSlotNum() >= 1 && packetplayinsetcreativeslot.getSlotNum() <= 45;
boolean flag2 = itemstack.isEmpty() || itemstack.getDamageValue() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty(); boolean flag2 = itemstack.isEmpty() || itemstack.getDamageValue() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty();
@ -1587,7 +1587,7 @@
if (flag1 && flag2) { if (flag1 && flag2) {
this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.getSlotNum()).set(itemstack); this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.getSlotNum()).set(itemstack);
@@ -1504,6 +2563,7 @@ @@ -1505,6 +2564,7 @@
} }
private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List<ITextFilter.a> list) { private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List<ITextFilter.a> list) {
@ -1595,7 +1595,7 @@
this.player.resetLastActionTime(); this.player.resetLastActionTime();
WorldServer worldserver = this.player.getLevel(); WorldServer worldserver = this.player.getLevel();
BlockPosition blockposition = packetplayinupdatesign.getPos(); BlockPosition blockposition = packetplayinupdatesign.getPos();
@@ -1520,18 +2580,37 @@ @@ -1521,18 +2581,37 @@
if (!tileentitysign.isEditable() || !this.player.getUUID().equals(tileentitysign.getPlayerWhoMayEdit())) { if (!tileentitysign.isEditable() || !this.player.getUUID().equals(tileentitysign.getPlayerWhoMayEdit())) {
PlayerConnection.LOGGER.warn("Player {} just tried to change non-editable sign", this.player.getName().getString()); PlayerConnection.LOGGER.warn("Player {} just tried to change non-editable sign", this.player.getName().getString());
@ -1635,7 +1635,7 @@
tileentitysign.setChanged(); tileentitysign.setChanged();
worldserver.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3); worldserver.sendBlockUpdated(blockposition, iblockdata, iblockdata, 3);
@@ -1541,6 +2620,7 @@ @@ -1542,6 +2621,7 @@
@Override @Override
public void handleKeepAlive(PacketPlayInKeepAlive packetplayinkeepalive) { public void handleKeepAlive(PacketPlayInKeepAlive packetplayinkeepalive) {
@ -1643,7 +1643,7 @@
if (this.keepAlivePending && packetplayinkeepalive.getId() == this.keepAliveChallenge) { if (this.keepAlivePending && packetplayinkeepalive.getId() == this.keepAliveChallenge) {
int i = (int) (SystemUtils.getMillis() - this.keepAliveTime); int i = (int) (SystemUtils.getMillis() - this.keepAliveTime);
@@ -1555,7 +2635,17 @@ @@ -1556,7 +2636,17 @@
@Override @Override
public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) { public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) {
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.getLevel()); PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.getLevel());
@ -1662,7 +1662,7 @@
} }
@Override @Override
@@ -1564,8 +2654,50 @@ @@ -1565,8 +2655,50 @@
this.player.updateOptions(packetplayinsettings); this.player.updateOptions(packetplayinsettings);
} }

View file

@ -1,7 +1,7 @@
--- a/net/minecraft/world/inventory/ContainerBeacon.java --- a/net/minecraft/world/inventory/ContainerBeacon.java
+++ b/net/minecraft/world/inventory/ContainerBeacon.java +++ b/net/minecraft/world/inventory/ContainerBeacon.java
@@ -10,6 +10,11 @@ @@ -11,6 +11,11 @@
import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.World;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
+// CraftBukkit start +// CraftBukkit start
@ -12,7 +12,7 @@
public class ContainerBeacon extends Container { public class ContainerBeacon extends Container {
private static final int PAYMENT_SLOT = 0; private static final int PAYMENT_SLOT = 0;
@@ -23,6 +28,10 @@ @@ -24,6 +29,10 @@
private final ContainerBeacon.SlotBeacon paymentSlot; private final ContainerBeacon.SlotBeacon paymentSlot;
private final ContainerAccess access; private final ContainerAccess access;
private final IContainerProperties beaconData; private final IContainerProperties beaconData;
@ -23,7 +23,7 @@
public ContainerBeacon(int i, IInventory iinventory) { public ContainerBeacon(int i, IInventory iinventory) {
this(i, iinventory, new ContainerProperties(3), ContainerAccess.NULL); this(i, iinventory, new ContainerProperties(3), ContainerAccess.NULL);
@@ -30,6 +39,7 @@ @@ -31,6 +40,7 @@
public ContainerBeacon(int i, IInventory iinventory, IContainerProperties icontainerproperties, ContainerAccess containeraccess) { public ContainerBeacon(int i, IInventory iinventory, IContainerProperties icontainerproperties, ContainerAccess containeraccess) {
super(Containers.BEACON, i); super(Containers.BEACON, i);
@ -31,7 +31,7 @@
this.beacon = new InventorySubcontainer(1) { this.beacon = new InventorySubcontainer(1) {
@Override @Override
public boolean canPlaceItem(int j, ItemStack itemstack) { public boolean canPlaceItem(int j, ItemStack itemstack) {
@@ -79,6 +89,7 @@ @@ -80,6 +90,7 @@
@Override @Override
public boolean stillValid(EntityHuman entityhuman) { public boolean stillValid(EntityHuman entityhuman) {
@ -39,7 +39,7 @@
return stillValid(this.access, entityhuman, Blocks.BEACON); return stillValid(this.access, entityhuman, Blocks.BEACON);
} }
@@ -178,4 +189,17 @@ @@ -180,4 +191,17 @@
return 1; return 1;
} }
} }

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/ItemStack.java --- a/net/minecraft/world/item/ItemStack.java
+++ b/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java
@@ -73,6 +73,40 @@ @@ -72,6 +72,40 @@
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -41,7 +41,7 @@
public final class ItemStack { public final class ItemStack {
public static final Codec<ItemStack> CODEC = RecordCodecBuilder.create((instance) -> { public static final Codec<ItemStack> CODEC = RecordCodecBuilder.create((instance) -> {
@@ -140,16 +174,30 @@ @@ -139,16 +173,30 @@
this.updateEmptyCacheFlag(); this.updateEmptyCacheFlag();
} }
@ -74,7 +74,7 @@
this.getItem().verifyTagAfterLoad(this.tag); this.getItem().verifyTagAfterLoad(this.tag);
} }
@@ -157,6 +205,11 @@ @@ -156,6 +204,11 @@
this.setDamageValue(this.getDamageValue()); this.setDamageValue(this.getDamageValue());
} }
@ -86,7 +86,7 @@
this.updateEmptyCacheFlag(); this.updateEmptyCacheFlag();
} }
@@ -194,7 +247,7 @@ @@ -193,7 +246,7 @@
return this.getItem() == item; return this.getItem() == item;
} }
@ -95,7 +95,7 @@
EntityHuman entityhuman = itemactioncontext.getPlayer(); EntityHuman entityhuman = itemactioncontext.getPlayer();
BlockPosition blockposition = itemactioncontext.getClickedPos(); BlockPosition blockposition = itemactioncontext.getClickedPos();
ShapeDetectorBlock shapedetectorblock = new ShapeDetectorBlock(itemactioncontext.getLevel(), blockposition, false); ShapeDetectorBlock shapedetectorblock = new ShapeDetectorBlock(itemactioncontext.getLevel(), blockposition, false);
@@ -202,12 +255,157 @@ @@ -201,12 +254,157 @@
if (entityhuman != null && !entityhuman.getAbilities().mayBuild && !this.hasAdventureModePlaceTagForBlock(itemactioncontext.getLevel().getTagManager(), shapedetectorblock)) { if (entityhuman != null && !entityhuman.getAbilities().mayBuild && !this.hasAdventureModePlaceTagForBlock(itemactioncontext.getLevel().getTagManager(), shapedetectorblock)) {
return EnumInteractionResult.PASS; return EnumInteractionResult.PASS;
} else { } else {
@ -254,7 +254,7 @@
return enuminteractionresult; return enuminteractionresult;
} }
@@ -288,6 +486,21 @@ @@ -287,6 +485,21 @@
} }
i -= k; i -= k;
@ -276,7 +276,7 @@
if (i <= 0) { if (i <= 0) {
return false; return false;
} }
@@ -309,6 +522,11 @@ @@ -308,6 +521,11 @@
if (this.hurt(i, t0.getRandom(), t0 instanceof EntityPlayer ? (EntityPlayer) t0 : null)) { if (this.hurt(i, t0.getRandom(), t0 instanceof EntityPlayer ? (EntityPlayer) t0 : null)) {
consumer.accept(t0); consumer.accept(t0);
Item item = this.getItem(); Item item = this.getItem();
@ -288,7 +288,7 @@
this.shrink(1); this.shrink(1);
if (t0 instanceof EntityHuman) { if (t0 instanceof EntityHuman) {
@@ -464,6 +682,17 @@ @@ -463,6 +681,17 @@
return this.tag; return this.tag;
} }
@ -306,7 +306,7 @@
public NBTTagCompound getOrCreateTag() { public NBTTagCompound getOrCreateTag() {
if (this.tag == null) { if (this.tag == null) {
this.setTag(new NBTTagCompound()); this.setTag(new NBTTagCompound());
@@ -844,6 +1073,12 @@ @@ -843,6 +1072,12 @@
} }
public void setRepairCost(int i) { public void setRepairCost(int i) {
@ -319,7 +319,7 @@
this.getOrCreateTag().putInt("RepairCost", i); this.getOrCreateTag().putInt("RepairCost", i);
} }
@@ -893,6 +1128,13 @@ @@ -892,6 +1127,13 @@
nbttaglist.add(nbttagcompound); nbttaglist.add(nbttagcompound);
} }

View file

@ -42,9 +42,9 @@
+ return releaseBee(this.level, this.worldPosition, iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, this.savedFlowerPos, force); + return releaseBee(this.level, this.worldPosition, iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, this.savedFlowerPos, force);
+ // CraftBukkit end + // CraftBukkit end
}); });
return list; if (!list.isEmpty()) {
} super.setChanged();
@@ -138,7 +145,19 @@ @@ -142,7 +149,19 @@
} }
public void addOccupantWithPresetTicks(Entity entity, boolean flag, int i) { public void addOccupantWithPresetTicks(Entity entity, boolean flag, int i) {
@ -65,7 +65,7 @@
entity.stopRiding(); entity.stopRiding();
entity.ejectPassengers(); entity.ejectPassengers();
NBTTagCompound nbttagcompound = new NBTTagCompound(); NBTTagCompound nbttagcompound = new NBTTagCompound();
@@ -168,7 +187,13 @@ @@ -173,7 +192,13 @@
} }
private static boolean releaseOccupant(World world, BlockPosition blockposition, IBlockData iblockdata, TileEntityBeehive.HiveBee tileentitybeehive_hivebee, @Nullable List<Entity> list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, @Nullable BlockPosition blockposition1) { private static boolean releaseOccupant(World world, BlockPosition blockposition, IBlockData iblockdata, TileEntityBeehive.HiveBee tileentitybeehive_hivebee, @Nullable List<Entity> list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, @Nullable BlockPosition blockposition1) {
@ -79,8 +79,8 @@
+ // CraftBukkit end + // CraftBukkit end
return false; return false;
} else { } else {
NBTTagCompound nbttagcompound = tileentitybeehive_hivebee.entityData; NBTTagCompound nbttagcompound = tileentitybeehive_hivebee.entityData.copy();
@@ -191,6 +216,18 @@ @@ -196,6 +221,18 @@
if (!entity.getType().is(TagsEntity.BEEHIVE_INHABITORS)) { if (!entity.getType().is(TagsEntity.BEEHIVE_INHABITORS)) {
return false; return false;
} else { } else {
@ -99,7 +99,7 @@
if (entity instanceof EntityBee) { if (entity instanceof EntityBee) {
EntityBee entitybee = (EntityBee) entity; EntityBee entitybee = (EntityBee) entity;
@@ -220,6 +257,7 @@ @@ -225,6 +262,7 @@
list.add(entitybee); list.add(entitybee);
} }
@ -107,7 +107,7 @@
float f = entity.getBbWidth(); float f = entity.getBbWidth();
double d0 = flag ? 0.0D : 0.55D + (double) (f / 2.0F); double d0 = flag ? 0.0D : 0.55D + (double) (f / 2.0F);
double d1 = (double) blockposition.getX() + 0.5D + d0 * (double) enumdirection.getStepX(); double d1 = (double) blockposition.getX() + 0.5D + d0 * (double) enumdirection.getStepX();
@@ -227,10 +265,11 @@ @@ -232,10 +270,11 @@
double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getStepZ(); double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getStepZ();
entity.moveTo(d1, d2, d3, entity.getYRot(), entity.getXRot()); entity.moveTo(d1, d2, d3, entity.getYRot(), entity.getXRot());
@ -120,9 +120,9 @@
} }
} else { } else {
return false; return false;
@@ -276,6 +315,10 @@ @@ -284,6 +323,10 @@
if (releaseOccupant(world, blockposition, iblockdata, tileentitybeehive_hivebee, (List) null, tileentitybeehive_releasestatus, blockposition1)) { if (releaseOccupant(world, blockposition, iblockdata, tileentitybeehive_hivebee, (List) null, tileentitybeehive_releasestatus, blockposition1)) {
flag = true;
iterator.remove(); iterator.remove();
+ // CraftBukkit start + // CraftBukkit start
+ } else { + } else {
@ -131,7 +131,7 @@
} }
} }
} }
@@ -313,6 +356,11 @@ @@ -325,6 +368,11 @@
this.savedFlowerPos = GameProfileSerializer.readBlockPos(nbttagcompound.getCompound("FlowerPos")); this.savedFlowerPos = GameProfileSerializer.readBlockPos(nbttagcompound.getCompound("FlowerPos"));
} }
@ -143,7 +143,7 @@
} }
@Override @Override
@@ -322,6 +370,7 @@ @@ -334,6 +382,7 @@
if (this.hasSavedFlowerPos()) { if (this.hasSavedFlowerPos()) {
nbttagcompound.put("FlowerPos", GameProfileSerializer.writeBlockPos(this.savedFlowerPos)); nbttagcompound.put("FlowerPos", GameProfileSerializer.writeBlockPos(this.savedFlowerPos));
} }

View file

@ -4,7 +4,7 @@
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId> <artifactId>craftbukkit</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1.18-R0.1-SNAPSHOT</version> <version>1.18.1-R0.1-SNAPSHOT</version>
<name>CraftBukkit</name> <name>CraftBukkit</name>
<url>https://www.spigotmc.org/</url> <url>https://www.spigotmc.org/</url>

View file

@ -19,8 +19,6 @@ public class Main {
public static boolean useConsole = true; public static boolean useConsole = true;
public static void main(String[] args) { public static void main(String[] args) {
System.setProperty("log4j2.formatMsgNoLookups", "true");
// Todo: Installation script // Todo: Installation script
OptionParser parser = new OptionParser() { OptionParser parser = new OptionParser() {
{ {
@ -183,7 +181,7 @@ public class Main {
useConsole = false; useConsole = false;
} }
if (false && Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) { if (Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) {
Date buildDate = new Date(Integer.parseInt(Main.class.getPackage().getImplementationVendor()) * 1000L); Date buildDate = new Date(Integer.parseInt(Main.class.getPackage().getImplementationVendor()) * 1000L);
Calendar deadline = Calendar.getInstance(); Calendar deadline = Calendar.getInstance();

View file

@ -224,7 +224,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
* @return string * @return string
*/ */
public String getMappingsVersion() { public String getMappingsVersion() {
return "9e9fe6961a80f3e586c25601590b51ec"; return "20b026e774dbf715e40a0b2afe114792";
} }
@Override @Override