@@ -1,64 +1,64 @@
|
||||
--- a/net/minecraft/server/level/ChunkMapDistance.java
|
||||
+++ b/net/minecraft/server/level/ChunkMapDistance.java
|
||||
@@ -65,7 +65,7 @@
|
||||
@@ -73,7 +73,7 @@
|
||||
while (objectiterator.hasNext()) {
|
||||
Entry<ArraySetSorted<Ticket<?>>> entry = (Entry) objectiterator.next();
|
||||
|
||||
- if (((ArraySetSorted) entry.getValue()).removeIf((ticket) -> {
|
||||
+ if ((entry.getValue()).removeIf((ticket) -> { // CraftBukkit - decompile error
|
||||
return ticket.b(this.currentTick);
|
||||
return ticket.b(this.ticketTickCounter);
|
||||
})) {
|
||||
this.ticketLevelTracker.update(entry.getLongKey(), getLowestTicketLevel((ArraySetSorted) entry.getValue()), false);
|
||||
@@ -101,10 +101,25 @@
|
||||
this.ticketTracker.update(entry.getLongKey(), getLowestTicketLevel((ArraySetSorted) entry.getValue()), false);
|
||||
@@ -109,10 +109,25 @@
|
||||
}
|
||||
|
||||
if (!this.pendingChunkUpdates.isEmpty()) {
|
||||
- this.pendingChunkUpdates.forEach((playerchunk) -> {
|
||||
if (!this.chunksToUpdateFutures.isEmpty()) {
|
||||
- this.chunksToUpdateFutures.forEach((playerchunk) -> {
|
||||
+ // CraftBukkit start
|
||||
+ // Iterate pending chunk updates with protection against concurrent modification exceptions
|
||||
+ java.util.Iterator<PlayerChunk> iter = this.pendingChunkUpdates.iterator();
|
||||
+ int expectedSize = this.pendingChunkUpdates.size();
|
||||
+ java.util.Iterator<PlayerChunk> iter = this.chunksToUpdateFutures.iterator();
|
||||
+ int expectedSize = this.chunksToUpdateFutures.size();
|
||||
+ do {
|
||||
+ PlayerChunk playerchunk = iter.next();
|
||||
+ iter.remove();
|
||||
+ expectedSize--;
|
||||
+
|
||||
playerchunk.a(playerchunkmap);
|
||||
playerchunk.a(playerchunkmap, this.mainThreadExecutor);
|
||||
- });
|
||||
- this.pendingChunkUpdates.clear();
|
||||
- this.chunksToUpdateFutures.clear();
|
||||
+
|
||||
+ // Reset iterator if set was modified using add()
|
||||
+ if (this.pendingChunkUpdates.size() != expectedSize) {
|
||||
+ expectedSize = this.pendingChunkUpdates.size();
|
||||
+ iter = this.pendingChunkUpdates.iterator();
|
||||
+ if (this.chunksToUpdateFutures.size() != expectedSize) {
|
||||
+ expectedSize = this.chunksToUpdateFutures.size();
|
||||
+ iter = this.chunksToUpdateFutures.iterator();
|
||||
+ }
|
||||
+ } while (iter.hasNext());
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
return true;
|
||||
} else {
|
||||
if (!this.l.isEmpty()) {
|
||||
@@ -140,23 +155,25 @@
|
||||
if (!this.ticketsToRelease.isEmpty()) {
|
||||
@@ -148,23 +163,25 @@
|
||||
}
|
||||
}
|
||||
|
||||
- private void addTicket(long i, Ticket<?> ticket) {
|
||||
+ private boolean addTicket(long i, Ticket<?> ticket) { // CraftBukkit - void -> boolean
|
||||
- void addTicket(long i, Ticket<?> ticket) {
|
||||
+ boolean addTicket(long i, Ticket<?> ticket) { // CraftBukkit - void -> boolean
|
||||
ArraySetSorted<Ticket<?>> arraysetsorted = this.e(i);
|
||||
int j = getLowestTicketLevel(arraysetsorted);
|
||||
- Ticket<?> ticket1 = (Ticket) arraysetsorted.a((Object) ticket);
|
||||
+ Ticket<?> ticket1 = (Ticket) arraysetsorted.a(ticket); // CraftBukkit - decompile error
|
||||
|
||||
ticket1.a(this.currentTick);
|
||||
ticket1.a(this.ticketTickCounter);
|
||||
if (ticket.b() < j) {
|
||||
this.ticketLevelTracker.update(i, ticket.b(), true);
|
||||
this.ticketTracker.update(i, ticket.b(), true);
|
||||
}
|
||||
|
||||
+ return ticket == ticket1; // CraftBukkit
|
||||
}
|
||||
|
||||
- private void removeTicket(long i, Ticket<?> ticket) {
|
||||
+ private boolean removeTicket(long i, Ticket<?> ticket) { // CraftBukkit - void -> boolean
|
||||
- void removeTicket(long i, Ticket<?> ticket) {
|
||||
+ boolean removeTicket(long i, Ticket<?> ticket) { // CraftBukkit - void -> boolean
|
||||
ArraySetSorted<Ticket<?>> arraysetsorted = this.e(i);
|
||||
|
||||
+ boolean removed = false; // CraftBukkit
|
||||
@@ -68,10 +68,10 @@
|
||||
}
|
||||
|
||||
if (arraysetsorted.isEmpty()) {
|
||||
@@ -164,16 +181,29 @@
|
||||
@@ -172,16 +189,29 @@
|
||||
}
|
||||
|
||||
this.ticketLevelTracker.update(i, getLowestTicketLevel(arraysetsorted), false);
|
||||
this.ticketTracker.update(i, getLowestTicketLevel(arraysetsorted), false);
|
||||
+ return removed; // CraftBukkit
|
||||
}
|
||||
|
||||
@@ -101,16 +101,16 @@
|
||||
}
|
||||
|
||||
public <T> void addTicket(TicketType<T> tickettype, ChunkCoordIntPair chunkcoordintpair, int i, T t0) {
|
||||
@@ -216,6 +246,7 @@
|
||||
@@ -224,6 +254,7 @@
|
||||
public void b(SectionPosition sectionposition, EntityPlayer entityplayer) {
|
||||
long i = sectionposition.r().pair();
|
||||
ObjectSet<EntityPlayer> objectset = (ObjectSet) this.c.get(i);
|
||||
ObjectSet<EntityPlayer> objectset = (ObjectSet) this.playersPerChunk.get(i);
|
||||
+ if (objectset == null) return; // CraftBukkit - SPIGOT-6208
|
||||
|
||||
objectset.remove(entityplayer);
|
||||
if (objectset.isEmpty()) {
|
||||
@@ -257,6 +288,26 @@
|
||||
return this.i.a();
|
||||
@@ -300,6 +331,26 @@
|
||||
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
@@ -122,7 +122,7 @@
|
||||
+ ArraySetSorted<Ticket<?>> tickets = entry.getValue();
|
||||
+ if (tickets.remove(target)) {
|
||||
+ // copied from removeTicket
|
||||
+ this.ticketLevelTracker.update(entry.getLongKey(), getLowestTicketLevel(tickets), false);
|
||||
+ this.ticketTracker.update(entry.getLongKey(), getLowestTicketLevel(tickets), false);
|
||||
+
|
||||
+ // can't use entry after it's removed
|
||||
+ if (tickets.isEmpty()) {
|
||||
@@ -133,6 +133,6 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
class a extends ChunkMap {
|
||||
private class a extends ChunkMap {
|
||||
|
||||
public a() {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
--- a/net/minecraft/server/level/ChunkProviderServer.java
|
||||
+++ b/net/minecraft/server/level/ChunkProviderServer.java
|
||||
@@ -79,6 +79,24 @@
|
||||
@@ -83,6 +83,24 @@
|
||||
this.clearCache();
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - properly implement isChunkLoaded
|
||||
+ public boolean isChunkLoaded(int chunkX, int chunkZ) {
|
||||
+ PlayerChunk chunk = this.playerChunkMap.getUpdatingChunk(ChunkCoordIntPair.pair(chunkX, chunkZ));
|
||||
+ PlayerChunk chunk = this.chunkMap.getUpdatingChunk(ChunkCoordIntPair.pair(chunkX, chunkZ));
|
||||
+ if (chunk == null) {
|
||||
+ return false;
|
||||
+ }
|
||||
@@ -14,7 +14,7 @@
|
||||
+ }
|
||||
+
|
||||
+ public Chunk getChunkUnchecked(int chunkX, int chunkZ) {
|
||||
+ PlayerChunk chunk = this.playerChunkMap.getUpdatingChunk(ChunkCoordIntPair.pair(chunkX, chunkZ));
|
||||
+ PlayerChunk chunk = this.chunkMap.getUpdatingChunk(ChunkCoordIntPair.pair(chunkX, chunkZ));
|
||||
+ if (chunk == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
@@ -25,16 +25,16 @@
|
||||
@Override
|
||||
public LightEngineThreaded getLightEngine() {
|
||||
return this.lightEngine;
|
||||
@@ -123,7 +141,7 @@
|
||||
@@ -127,7 +145,7 @@
|
||||
for (int l = 0; l < 4; ++l) {
|
||||
if (k == this.cachePos[l] && chunkstatus == this.cacheStatus[l]) {
|
||||
ichunkaccess = this.cacheChunk[l];
|
||||
if (k == this.lastChunkPos[l] && chunkstatus == this.lastChunkStatus[l]) {
|
||||
ichunkaccess = this.lastChunk[l];
|
||||
- if (ichunkaccess != null || !flag) {
|
||||
+ if (ichunkaccess != null) { // CraftBukkit - the chunk can become accessible in the meantime TODO for non-null chunks it might also make sense to check that the chunk's state hasn't changed in the meantime
|
||||
return ichunkaccess;
|
||||
}
|
||||
}
|
||||
@@ -169,12 +187,12 @@
|
||||
@@ -175,12 +193,12 @@
|
||||
if (playerchunk == null) {
|
||||
return null;
|
||||
} else {
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
if (ichunkaccess1 != null) {
|
||||
this.a(k, ichunkaccess1, ChunkStatus.FULL);
|
||||
@@ -201,7 +219,15 @@
|
||||
@@ -228,7 +246,15 @@
|
||||
int l = 33 + ChunkStatus.a(chunkstatus);
|
||||
PlayerChunk playerchunk = this.getChunk(k);
|
||||
|
||||
@@ -63,10 +63,10 @@
|
||||
+ }
|
||||
+ if (flag && !currentlyUnloading) {
|
||||
+ // CraftBukkit end
|
||||
this.chunkMapDistance.a(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair);
|
||||
this.distanceManager.a(TicketType.UNKNOWN, chunkcoordintpair, l, chunkcoordintpair);
|
||||
if (this.a(playerchunk, l)) {
|
||||
GameProfilerFiller gameprofilerfiller = this.world.getMethodProfiler();
|
||||
@@ -220,7 +246,7 @@
|
||||
GameProfilerFiller gameprofilerfiller = this.level.getMethodProfiler();
|
||||
@@ -247,7 +273,7 @@
|
||||
}
|
||||
|
||||
private boolean a(@Nullable PlayerChunk playerchunk, int i) {
|
||||
@@ -74,31 +74,17 @@
|
||||
+ return playerchunk == null || playerchunk.oldTicketLevel > i; // CraftBukkit using oldTicketLevel for isLoaded checks
|
||||
}
|
||||
|
||||
public boolean isLoaded(int i, int j) {
|
||||
@@ -282,19 +308,19 @@
|
||||
public boolean a(Entity entity) {
|
||||
long i = ChunkCoordIntPair.pair(MathHelper.floor(entity.locX()) >> 4, MathHelper.floor(entity.locZ()) >> 4);
|
||||
|
||||
- return this.a(i, PlayerChunk::b);
|
||||
+ return this.a(i, (Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>>) PlayerChunk::b); // CraftBukkit - decompile error
|
||||
@Override
|
||||
@@ -307,7 +333,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(ChunkCoordIntPair chunkcoordintpair) {
|
||||
- return this.a(chunkcoordintpair.pair(), PlayerChunk::b);
|
||||
+ return this.a(chunkcoordintpair.pair(), (Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>>) PlayerChunk::b); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(BlockPosition blockposition) {
|
||||
long i = ChunkCoordIntPair.pair(blockposition.getX() >> 4, blockposition.getZ() >> 4);
|
||||
|
||||
public boolean a(long i) {
|
||||
- return this.a(i, PlayerChunk::a);
|
||||
+ return this.a(i, (Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>>) PlayerChunk::a); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
private boolean a(long i, Function<PlayerChunk, CompletableFuture<Either<Chunk, PlayerChunk.Failure>>> function) {
|
||||
@@ -316,11 +342,31 @@
|
||||
@@ -329,11 +355,31 @@
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
@@ -113,44 +99,46 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.lightEngine.close();
|
||||
this.playerChunkMap.close();
|
||||
this.chunkMap.close();
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - modelled on below
|
||||
+ public void purgeUnload() {
|
||||
+ this.world.getMethodProfiler().enter("purge");
|
||||
+ this.chunkMapDistance.purgeTickets();
|
||||
+ this.level.getMethodProfiler().enter("purge");
|
||||
+ this.distanceManager.purgeTickets();
|
||||
+ this.tickDistanceManager();
|
||||
+ this.world.getMethodProfiler().exitEnter("unload");
|
||||
+ this.playerChunkMap.unloadChunks(() -> true);
|
||||
+ this.world.getMethodProfiler().exit();
|
||||
+ this.level.getMethodProfiler().exitEnter("unload");
|
||||
+ this.chunkMap.unloadChunks(() -> true);
|
||||
+ this.level.getMethodProfiler().exit();
|
||||
+ this.clearCache();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public void tick(BooleanSupplier booleansupplier) {
|
||||
this.world.getMethodProfiler().enter("purge");
|
||||
this.chunkMapDistance.purgeTickets();
|
||||
@@ -340,12 +386,12 @@
|
||||
this.lastTickTime = i;
|
||||
WorldData worlddata = this.world.getWorldData();
|
||||
boolean flag = this.world.isDebugWorld();
|
||||
- boolean flag1 = this.world.getGameRules().getBoolean(GameRules.DO_MOB_SPAWNING);
|
||||
+ boolean flag1 = this.world.getGameRules().getBoolean(GameRules.DO_MOB_SPAWNING) && !world.getPlayers().isEmpty(); // CraftBukkit
|
||||
this.level.getMethodProfiler().enter("purge");
|
||||
@@ -354,12 +400,12 @@
|
||||
this.lastInhabitedUpdate = i;
|
||||
WorldData worlddata = this.level.getWorldData();
|
||||
boolean flag = this.level.isDebugWorld();
|
||||
- boolean flag1 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING);
|
||||
+ boolean flag1 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !level.getPlayers().isEmpty(); // CraftBukkit
|
||||
|
||||
if (!flag) {
|
||||
this.world.getMethodProfiler().enter("pollingChunks");
|
||||
int k = this.world.getGameRules().getInt(GameRules.RANDOM_TICK_SPEED);
|
||||
this.level.getMethodProfiler().enter("pollingChunks");
|
||||
int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING);
|
||||
- boolean flag2 = worlddata.getTime() % 400L == 0L;
|
||||
+ boolean flag2 = world.ticksPerAnimalSpawns != 0L && worlddata.getTime() % world.ticksPerAnimalSpawns == 0L; // CraftBukkit
|
||||
+ boolean flag2 = level.ticksPerAnimalSpawns != 0L && worlddata.getTime() % level.ticksPerAnimalSpawns == 0L; // CraftBukkit
|
||||
|
||||
this.world.getMethodProfiler().enter("naturalSpawnCount");
|
||||
int l = this.chunkMapDistance.b();
|
||||
@@ -532,12 +578,18 @@
|
||||
this.level.getMethodProfiler().enter("naturalSpawnCount");
|
||||
int l = this.distanceManager.b();
|
||||
@@ -548,13 +594,19 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean executeNext() {
|
||||
- protected boolean executeNext() {
|
||||
+ // CraftBukkit start - process pending Chunk loadCallback() and unloadCallback() after each run task
|
||||
+ public boolean executeNext() {
|
||||
+ try {
|
||||
if (ChunkProviderServer.this.tickDistanceManager()) {
|
||||
return true;
|
||||
@@ -159,7 +147,7 @@
|
||||
return super.executeNext();
|
||||
}
|
||||
+ } finally {
|
||||
+ playerChunkMap.callbackExecutor.run();
|
||||
+ chunkMap.callbackExecutor.run();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,10 +1,11 @@
|
||||
--- a/net/minecraft/server/level/EntityTrackerEntry.java
|
||||
+++ b/net/minecraft/server/level/EntityTrackerEntry.java
|
||||
@@ -40,6 +40,11 @@
|
||||
@@ -42,6 +42,12 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.server.network.ServerPlayerConnection;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.player.PlayerVelocityEvent;
|
||||
+// CraftBukkit end
|
||||
@@ -12,44 +13,51 @@
|
||||
public class EntityTrackerEntry {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -60,8 +65,12 @@
|
||||
private List<Entity> p;
|
||||
private boolean q;
|
||||
private boolean r;
|
||||
@@ -63,8 +69,12 @@
|
||||
private List<Entity> lastPassengers;
|
||||
private boolean wasRiding;
|
||||
private boolean wasOnGround;
|
||||
+ // CraftBukkit start
|
||||
+ private final Set<EntityPlayer> trackedPlayers;
|
||||
+ private final Set<ServerPlayerConnection> trackedPlayers;
|
||||
|
||||
- public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer<Packet<?>> consumer) {
|
||||
+ public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer<Packet<?>> consumer, Set<EntityPlayer> trackedPlayers) {
|
||||
+ public EntityTrackerEntry(WorldServer worldserver, Entity entity, int i, boolean flag, Consumer<Packet<?>> consumer, Set<ServerPlayerConnection> trackedPlayers) {
|
||||
+ this.trackedPlayers = trackedPlayers;
|
||||
+ // CraftBukkit end
|
||||
this.m = Vec3D.ORIGIN;
|
||||
this.p = Collections.emptyList();
|
||||
this.b = worldserver;
|
||||
@@ -81,16 +90,16 @@
|
||||
this.ap = Vec3D.ZERO;
|
||||
this.lastPassengers = Collections.emptyList();
|
||||
this.level = worldserver;
|
||||
@@ -84,22 +94,22 @@
|
||||
|
||||
if (!list.equals(this.p)) {
|
||||
this.p = list;
|
||||
- this.f.accept(new PacketPlayOutMount(this.tracker));
|
||||
+ this.broadcastIncludingSelf(new PacketPlayOutMount(this.tracker)); // CraftBukkit
|
||||
if (!list.equals(this.lastPassengers)) {
|
||||
this.lastPassengers = list;
|
||||
- this.broadcast.accept(new PacketPlayOutMount(this.entity));
|
||||
+ this.broadcastIncludingSelf(new PacketPlayOutMount(this.entity)); // CraftBukkit
|
||||
}
|
||||
|
||||
- if (this.tracker instanceof EntityItemFrame && this.tickCounter % 10 == 0) {
|
||||
+ if (this.tracker instanceof EntityItemFrame /*&& this.tickCounter % 10 == 0*/) { // CraftBukkit - Moved below, should always enter this block
|
||||
EntityItemFrame entityitemframe = (EntityItemFrame) this.tracker;
|
||||
- if (this.entity instanceof EntityItemFrame && this.tickCount % 10 == 0) {
|
||||
+ if (this.entity instanceof EntityItemFrame /*&& this.tickCounter % 10 == 0*/) { // CraftBukkit - Moved below, should always enter this block
|
||||
EntityItemFrame entityitemframe = (EntityItemFrame) this.entity;
|
||||
ItemStack itemstack = entityitemframe.getItem();
|
||||
|
||||
- if (itemstack.getItem() instanceof ItemWorldMap) {
|
||||
+ if (this.tickCounter % 10 == 0 && itemstack.getItem() instanceof ItemWorldMap) { // CraftBukkit - Moved this.tickCounter % 10 logic here so item frames do not enter the other blocks
|
||||
WorldMap worldmap = ItemWorldMap.getSavedMap(itemstack, this.b);
|
||||
- Iterator iterator = this.b.getPlayers().iterator();
|
||||
+ Iterator iterator = this.trackedPlayers.iterator(); // CraftBukkit
|
||||
+ if (this.tickCount % 10 == 0 && itemstack.getItem() instanceof ItemWorldMap) { // CraftBukkit - Moved this.tickCounter % 10 logic here so item frames do not enter the other blocks
|
||||
Integer integer = ItemWorldMap.d(itemstack);
|
||||
WorldMap worldmap = ItemWorldMap.a(integer, (World) this.level);
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||
@@ -135,6 +144,17 @@
|
||||
boolean flag2 = flag1 || this.tickCounter % 60 == 0;
|
||||
boolean flag3 = Math.abs(i - this.yRot) >= 1 || Math.abs(j - this.xRot) >= 1;
|
||||
if (worldmap != null) {
|
||||
- Iterator iterator = this.level.getPlayers().iterator();
|
||||
+ Iterator<ServerPlayerConnection> iterator = this.trackedPlayers.iterator(); // CraftBukkit
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
- EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||
+ EntityPlayer entityplayer = iterator.next().d(); // CraftBukkit
|
||||
|
||||
worldmap.a((EntityHuman) entityplayer, itemstack);
|
||||
Packet<?> packet = worldmap.a(integer, entityplayer);
|
||||
@@ -142,6 +152,17 @@
|
||||
boolean flag2 = flag1 || this.tickCount % 60 == 0;
|
||||
boolean flag3 = Math.abs(i - this.yRotp) >= 1 || Math.abs(j - this.xRotp) >= 1;
|
||||
|
||||
+ // CraftBukkit start - Code moved from below
|
||||
+ if (flag2) {
|
||||
@@ -57,15 +65,15 @@
|
||||
+ }
|
||||
+
|
||||
+ if (flag3) {
|
||||
+ this.yRot = i;
|
||||
+ this.xRot = j;
|
||||
+ this.yRotp = i;
|
||||
+ this.xRotp = j;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (this.tickCounter > 0 || this.tracker instanceof EntityArrow) {
|
||||
if (this.tickCount > 0 || this.entity instanceof EntityArrow) {
|
||||
long k = PacketPlayOutEntity.a(vec3d.x);
|
||||
long l = PacketPlayOutEntity.a(vec3d.y);
|
||||
@@ -173,6 +193,7 @@
|
||||
@@ -180,6 +201,7 @@
|
||||
}
|
||||
|
||||
this.c();
|
||||
@@ -73,28 +81,28 @@
|
||||
if (flag2) {
|
||||
this.d();
|
||||
}
|
||||
@@ -181,6 +202,7 @@
|
||||
this.yRot = i;
|
||||
this.xRot = j;
|
||||
@@ -188,6 +210,7 @@
|
||||
this.yRotp = i;
|
||||
this.xRotp = j;
|
||||
}
|
||||
+ // CraftBukkit end */
|
||||
|
||||
this.q = false;
|
||||
this.wasRiding = false;
|
||||
}
|
||||
@@ -196,7 +218,27 @@
|
||||
@@ -203,7 +226,27 @@
|
||||
|
||||
++this.tickCounter;
|
||||
if (this.tracker.velocityChanged) {
|
||||
- this.broadcastIncludingSelf(new PacketPlayOutEntityVelocity(this.tracker));
|
||||
++this.tickCount;
|
||||
if (this.entity.hurtMarked) {
|
||||
- this.broadcastIncludingSelf(new PacketPlayOutEntityVelocity(this.entity));
|
||||
+ // CraftBukkit start - Create PlayerVelocity event
|
||||
+ boolean cancelled = false;
|
||||
+
|
||||
+ if (this.tracker instanceof EntityPlayer) {
|
||||
+ Player player = (Player) this.tracker.getBukkitEntity();
|
||||
+ if (this.entity instanceof EntityPlayer) {
|
||||
+ Player player = (Player) this.entity.getBukkitEntity();
|
||||
+ org.bukkit.util.Vector velocity = player.getVelocity();
|
||||
+
|
||||
+ PlayerVelocityEvent event = new PlayerVelocityEvent(player, velocity.clone());
|
||||
+ this.tracker.world.getServer().getPluginManager().callEvent(event);
|
||||
+ this.entity.level.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ cancelled = true;
|
||||
@@ -104,70 +112,69 @@
|
||||
+ }
|
||||
+
|
||||
+ if (!cancelled) {
|
||||
+ this.broadcastIncludingSelf(new PacketPlayOutEntityVelocity(this.tracker));
|
||||
+ this.broadcastIncludingSelf(new PacketPlayOutEntityVelocity(this.entity));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.tracker.velocityChanged = false;
|
||||
this.entity.hurtMarked = false;
|
||||
}
|
||||
|
||||
@@ -211,14 +253,17 @@
|
||||
PlayerConnection playerconnection = entityplayer.playerConnection;
|
||||
@@ -218,13 +261,16 @@
|
||||
PlayerConnection playerconnection = entityplayer.connection;
|
||||
|
||||
entityplayer.playerConnection.getClass();
|
||||
Objects.requireNonNull(entityplayer.connection);
|
||||
- this.a(playerconnection::sendPacket);
|
||||
+ this.a(playerconnection::sendPacket, entityplayer); // CraftBukkit - add player
|
||||
this.tracker.b(entityplayer);
|
||||
entityplayer.d(this.tracker);
|
||||
this.entity.c(entityplayer);
|
||||
}
|
||||
|
||||
- public void a(Consumer<Packet<?>> consumer) {
|
||||
+ public void a(Consumer<Packet<?>> consumer, EntityPlayer entityplayer) { // CraftBukkit - add player
|
||||
if (this.tracker.dead) {
|
||||
- EntityTrackerEntry.LOGGER.warn("Fetching packet for removed entity " + this.tracker);
|
||||
if (this.entity.isRemoved()) {
|
||||
- EntityTrackerEntry.LOGGER.warn("Fetching packet for removed entity {}", this.entity);
|
||||
+ // CraftBukkit start - Remove useless error spam, just return
|
||||
+ // EntityTrackerEntry.LOGGER.warn("Fetching packet for removed entity " + this.tracker);
|
||||
+ // EntityTrackerEntry.LOGGER.warn("Fetching packet for removed entity {}", this.entity);
|
||||
+ return;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
Packet<?> packet = this.tracker.P();
|
||||
@@ -234,6 +279,12 @@
|
||||
if (this.tracker instanceof EntityLiving) {
|
||||
Collection<AttributeModifiable> collection = ((EntityLiving) this.tracker).getAttributeMap().b();
|
||||
Packet<?> packet = this.entity.getPacket();
|
||||
@@ -240,6 +286,12 @@
|
||||
if (this.entity instanceof EntityLiving) {
|
||||
Collection<AttributeModifiable> collection = ((EntityLiving) this.entity).getAttributeMap().b();
|
||||
|
||||
+ // CraftBukkit start - If sending own attributes send scaled health instead of current maximum health
|
||||
+ if (this.tracker.getId() == entityplayer.getId()) {
|
||||
+ ((EntityPlayer) this.tracker).getBukkitEntity().injectScaledMaxHealth(collection, false);
|
||||
+ if (this.entity.getId() == entityplayer.getId()) {
|
||||
+ ((EntityPlayer) this.entity).getBukkitEntity().injectScaledMaxHealth(collection, false);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (!collection.isEmpty()) {
|
||||
consumer.accept(new PacketPlayOutUpdateAttributes(this.tracker.getId(), collection));
|
||||
consumer.accept(new PacketPlayOutUpdateAttributes(this.entity.getId(), collection));
|
||||
}
|
||||
@@ -265,8 +316,14 @@
|
||||
@@ -271,8 +323,14 @@
|
||||
if (!list.isEmpty()) {
|
||||
consumer.accept(new PacketPlayOutEntityEquipment(this.tracker.getId(), list));
|
||||
consumer.accept(new PacketPlayOutEntityEquipment(this.entity.getId(), list));
|
||||
}
|
||||
+ ((EntityLiving) this.tracker).updateEquipment(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending
|
||||
+ ((EntityLiving) this.entity).updateEquipment(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Fix for nonsensical head yaw
|
||||
+ this.headYaw = MathHelper.d(this.tracker.getHeadRotation() * 256.0F / 360.0F);
|
||||
+ consumer.accept(new PacketPlayOutEntityHeadRotation(this.tracker, (byte) headYaw));
|
||||
+ this.yHeadRotp = MathHelper.d(this.entity.getHeadRotation() * 256.0F / 360.0F);
|
||||
+ consumer.accept(new PacketPlayOutEntityHeadRotation(this.entity, (byte) yHeadRotp));
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (this.tracker instanceof EntityLiving) {
|
||||
EntityLiving entityliving = (EntityLiving) this.tracker;
|
||||
if (this.entity instanceof EntityLiving) {
|
||||
EntityLiving entityliving = (EntityLiving) this.entity;
|
||||
Iterator iterator = entityliving.getEffects().iterator();
|
||||
@@ -307,6 +364,11 @@
|
||||
Set<AttributeModifiable> set = ((EntityLiving) this.tracker).getAttributeMap().getAttributes();
|
||||
@@ -313,6 +371,11 @@
|
||||
Set<AttributeModifiable> set = ((EntityLiving) this.entity).getAttributeMap().getAttributes();
|
||||
|
||||
if (!set.isEmpty()) {
|
||||
+ // CraftBukkit start - Send scaled max health
|
||||
+ if (this.tracker instanceof EntityPlayer) {
|
||||
+ ((EntityPlayer) this.tracker).getBukkitEntity().injectScaledMaxHealth(set, false);
|
||||
+ if (this.entity instanceof EntityPlayer) {
|
||||
+ ((EntityPlayer) this.entity).getBukkitEntity().injectScaledMaxHealth(set, false);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.broadcastIncludingSelf(new PacketPlayOutUpdateAttributes(this.tracker.getId(), set));
|
||||
this.broadcastIncludingSelf(new PacketPlayOutUpdateAttributes(this.entity.getId(), set));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/PlayerChunk.java
|
||||
+++ b/net/minecraft/server/level/PlayerChunk.java
|
||||
@@ -33,6 +33,10 @@
|
||||
@@ -38,6 +38,10 @@
|
||||
import net.minecraft.world.level.chunk.ProtoChunkExtension;
|
||||
import net.minecraft.world.level.lighting.LightEngine;
|
||||
|
||||
@@ -10,18 +10,23 @@
|
||||
+
|
||||
public class PlayerChunk {
|
||||
|
||||
public static final Either<IChunkAccess, PlayerChunk.Failure> UNLOADED_CHUNK_ACCESS = Either.right(PlayerChunk.Failure.b);
|
||||
@@ -65,7 +69,7 @@
|
||||
this.fullChunkFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE;
|
||||
this.tickingFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE;
|
||||
this.entityTickingFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE;
|
||||
- this.chunkSave = CompletableFuture.completedFuture((Object) null);
|
||||
+ this.chunkSave = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error
|
||||
this.dirtyBlocks = new ShortSet[16];
|
||||
this.location = chunkcoordintpair;
|
||||
public static final Either<IChunkAccess, PlayerChunk.Failure> UNLOADED_CHUNK = Either.right(PlayerChunk.Failure.UNLOADED);
|
||||
@@ -75,11 +79,11 @@
|
||||
this.fullChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE;
|
||||
this.tickingChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE;
|
||||
this.entityTickingChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE;
|
||||
- this.chunkToSave = CompletableFuture.completedFuture((Object) null);
|
||||
+ this.chunkToSave = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error
|
||||
this.chunkToSaveHistory = null;
|
||||
this.blockChangedLightSectionFilter = new BitSet();
|
||||
this.skyChangedLightSectionFilter = new BitSet();
|
||||
- this.pendingFullStateConfirmation = CompletableFuture.completedFuture((Object) null);
|
||||
+ this.pendingFullStateConfirmation = CompletableFuture.completedFuture(null); // CraftBukkit - decompile error
|
||||
this.pos = chunkcoordintpair;
|
||||
this.levelHeightAccessor = levelheightaccessor;
|
||||
this.lightEngine = lightengine;
|
||||
@@ -77,6 +81,19 @@
|
||||
this.a(i);
|
||||
@@ -92,6 +96,19 @@
|
||||
this.changedBlocksPerSection = new ShortSet[levelheightaccessor.getSectionsCount()];
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
@@ -38,9 +43,9 @@
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> getStatusFutureUnchecked(ChunkStatus chunkstatus) {
|
||||
CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = (CompletableFuture) this.statusFutures.get(chunkstatus.c());
|
||||
CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = (CompletableFuture) this.futures.get(chunkstatus.c());
|
||||
|
||||
@@ -102,9 +119,9 @@
|
||||
@@ -117,9 +134,9 @@
|
||||
@Nullable
|
||||
public Chunk getChunk() {
|
||||
CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture = this.a();
|
||||
@@ -52,25 +57,34 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -135,6 +152,7 @@
|
||||
@@ -164,6 +181,7 @@
|
||||
if (chunk != null) {
|
||||
byte b0 = (byte) SectionPosition.a(blockposition.getY());
|
||||
int i = this.levelHeightAccessor.getSectionIndex(blockposition.getY());
|
||||
|
||||
+ if (b0 < 0 || b0 >= this.dirtyBlocks.length) return; // CraftBukkit - SPIGOT-6086, SPIGOT-6296
|
||||
if (this.dirtyBlocks[b0] == null) {
|
||||
this.p = true;
|
||||
this.dirtyBlocks[b0] = new ShortArraySet();
|
||||
@@ -237,7 +255,7 @@
|
||||
CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = (CompletableFuture) this.statusFutures.get(i);
|
||||
+ if (i < 0 || i >= this.changedBlocksPerSection.length) return; // CraftBukkit - SPIGOT-6086, SPIGOT-6296
|
||||
if (this.changedBlocksPerSection[i] == null) {
|
||||
this.hasChangedSections = true;
|
||||
this.changedBlocksPerSection[i] = new ShortArraySet();
|
||||
@@ -274,7 +292,7 @@
|
||||
CompletableFuture<Either<IChunkAccess, PlayerChunk.Failure>> completablefuture = (CompletableFuture) this.futures.get(i);
|
||||
|
||||
if (completablefuture != null) {
|
||||
- Either<IChunkAccess, PlayerChunk.Failure> either = (Either) completablefuture.getNow((Object) null);
|
||||
+ Either<IChunkAccess, PlayerChunk.Failure> either = (Either) completablefuture.getNow(null); // CraftBukkit - decompile error
|
||||
boolean flag = either != null && either.right().isPresent();
|
||||
|
||||
if (either == null || either.left().isPresent()) {
|
||||
return completablefuture;
|
||||
@@ -292,6 +310,30 @@
|
||||
boolean flag1 = this.ticketLevel <= PlayerChunkMap.GOLDEN_TICKET;
|
||||
if (!flag) {
|
||||
@@ -341,7 +359,7 @@
|
||||
this.pendingFullStateConfirmation = completablefuture1;
|
||||
completablefuture.thenAccept((either) -> {
|
||||
either.ifLeft((chunk) -> {
|
||||
- completablefuture1.complete((Object) null);
|
||||
+ completablefuture1.complete(null); // CraftBukkit - decompile error
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -358,6 +376,30 @@
|
||||
boolean flag1 = this.ticketLevel <= PlayerChunkMap.MAX_CHUNK_DISTANCE;
|
||||
PlayerChunk.State playerchunk_state = getChunkState(this.oldTicketLevel);
|
||||
PlayerChunk.State playerchunk_state1 = getChunkState(this.ticketLevel);
|
||||
+ // CraftBukkit start
|
||||
@@ -89,7 +103,7 @@
|
||||
+ }
|
||||
+ }).exceptionally((throwable) -> {
|
||||
+ // ensure exceptions are printed, by default this is not the case
|
||||
+ MinecraftServer.LOGGER.fatal("Failed to schedule unload callback for chunk " + PlayerChunk.this.location, throwable);
|
||||
+ MinecraftServer.LOGGER.fatal("Failed to schedule unload callback for chunk " + PlayerChunk.this.pos, throwable);
|
||||
+ return null;
|
||||
+ });
|
||||
+
|
||||
@@ -100,18 +114,18 @@
|
||||
CompletableFuture completablefuture;
|
||||
|
||||
if (flag) {
|
||||
@@ -323,7 +365,7 @@
|
||||
@@ -388,7 +430,7 @@
|
||||
if (flag2 && !flag3) {
|
||||
completablefuture = this.fullChunkFuture;
|
||||
this.fullChunkFuture = PlayerChunk.UNLOADED_CHUNK_FUTURE;
|
||||
this.fullChunkFuture = PlayerChunk.UNLOADED_LEVEL_CHUNK_FUTURE;
|
||||
- this.a(completablefuture.thenApply((either1) -> {
|
||||
+ this.a(((CompletableFuture<Either<Chunk, PlayerChunk.Failure>>) completablefuture).thenApply((either1) -> { // CraftBukkit - decompile error
|
||||
playerchunkmap.getClass();
|
||||
Objects.requireNonNull(playerchunkmap);
|
||||
return either1.ifLeft(playerchunkmap::a);
|
||||
}));
|
||||
@@ -361,6 +403,26 @@
|
||||
}), "unfull");
|
||||
@@ -432,6 +474,26 @@
|
||||
|
||||
this.u.a(this.location, this::k, this.ticketLevel, this::d);
|
||||
this.onLevelChange.a(this.pos, this::k, this.ticketLevel, this::d);
|
||||
this.oldTicketLevel = this.ticketLevel;
|
||||
+ // CraftBukkit start
|
||||
+ // ChunkLoadEvent: Called after the chunk is loaded: isChunkLoaded returns true and chunk is ready to be modified by plugins.
|
||||
@@ -125,7 +139,7 @@
|
||||
+ }
|
||||
+ }).exceptionally((throwable) -> {
|
||||
+ // ensure exceptions are printed, by default this is not the case
|
||||
+ MinecraftServer.LOGGER.fatal("Failed to schedule load callback for chunk " + PlayerChunk.this.location, throwable);
|
||||
+ MinecraftServer.LOGGER.fatal("Failed to schedule load callback for chunk " + PlayerChunk.this.pos, throwable);
|
||||
+ return null;
|
||||
+ });
|
||||
+
|
||||
|
||||
@@ -1,47 +1,43 @@
|
||||
--- a/net/minecraft/server/level/PlayerChunkMap.java
|
||||
+++ b/net/minecraft/server/level/PlayerChunkMap.java
|
||||
@@ -89,6 +89,8 @@
|
||||
@@ -91,6 +91,8 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+import org.bukkit.entity.Player; // CraftBukkit
|
||||
+
|
||||
public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.d {
|
||||
public class PlayerChunkMap extends IChunkLoader implements PlayerChunk.e {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -119,6 +121,31 @@
|
||||
private final Queue<Runnable> A;
|
||||
private int viewDistance;
|
||||
private static final byte CHUNK_TYPE_REPLACEABLE = -1;
|
||||
@@ -129,6 +131,27 @@
|
||||
private final Queue<Runnable> unloadQueue;
|
||||
int viewDistance;
|
||||
|
||||
+ // CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback()
|
||||
+ public final CallbackExecutor callbackExecutor = new CallbackExecutor();
|
||||
+ public static final class CallbackExecutor implements java.util.concurrent.Executor, Runnable {
|
||||
+
|
||||
+ private Runnable queued;
|
||||
+ private final java.util.Queue<Runnable> queue = new java.util.ArrayDeque<>();
|
||||
+
|
||||
+ @Override
|
||||
+ public void execute(Runnable runnable) {
|
||||
+ if (queued != null) {
|
||||
+ throw new IllegalStateException("Already queued");
|
||||
+ }
|
||||
+ queued = runnable;
|
||||
+ queue.add(runnable);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void run() {
|
||||
+ Runnable task = queued;
|
||||
+ queued = null;
|
||||
+ if (task != null) {
|
||||
+ Runnable task;
|
||||
+ while ((task = queue.poll()) != null) {
|
||||
+ task.run();
|
||||
+ }
|
||||
+ }
|
||||
+ };
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public PlayerChunkMap(WorldServer worldserver, Convertable.ConversionSession convertable_conversionsession, DataFixer datafixer, DefinedStructureManager definedstructuremanager, Executor executor, IAsyncTaskHandler<Runnable> iasynctaskhandler, ILightAccess ilightaccess, ChunkGenerator chunkgenerator, WorldLoadListener worldloadlistener, 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(new File(convertable_conversionsession.a(worldserver.getDimensionKey()), "region"), datafixer, flag);
|
||||
this.visibleChunks = this.updatingChunks.clone();
|
||||
@@ -239,9 +266,12 @@
|
||||
this.visibleChunkMap = this.updatingChunkMap.clone();
|
||||
@@ -279,9 +302,12 @@
|
||||
|
||||
return completablefuture1.thenApply((list1) -> {
|
||||
List<IChunkAccess> list2 = Lists.newArrayList();
|
||||
@@ -56,24 +52,24 @@
|
||||
final Either<IChunkAccess, PlayerChunk.Failure> either = (Either) iterator.next();
|
||||
Optional<IChunkAccess> optional = either.left();
|
||||
|
||||
@@ -344,7 +374,7 @@
|
||||
PlayerChunkMap.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.w.getName());
|
||||
@@ -389,7 +415,7 @@
|
||||
PlayerChunkMap.LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", this.storageFolder.getName());
|
||||
} else {
|
||||
this.visibleChunks.values().stream().filter(PlayerChunk::hasBeenLoaded).forEach((playerchunk) -> {
|
||||
this.visibleChunkMap.values().stream().filter(PlayerChunk::hasBeenLoaded).forEach((playerchunk) -> {
|
||||
- IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkSave().getNow((Object) null);
|
||||
+ IChunkAccess ichunkaccess = (IChunkAccess) playerchunk.getChunkSave().getNow(null); // CraftBukkit - decompile error
|
||||
|
||||
if (ichunkaccess instanceof ProtoChunkExtension || ichunkaccess instanceof Chunk) {
|
||||
this.saveChunk(ichunkaccess);
|
||||
@@ -355,7 +385,6 @@
|
||||
@@ -400,7 +426,6 @@
|
||||
}
|
||||
|
||||
}
|
||||
-
|
||||
protected void unloadChunks(BooleanSupplier booleansupplier) {
|
||||
GameProfilerFiller gameprofilerfiller = this.world.getMethodProfiler();
|
||||
GameProfilerFiller gameprofilerfiller = this.level.getMethodProfiler();
|
||||
|
||||
@@ -394,7 +423,7 @@
|
||||
@@ -439,7 +464,7 @@
|
||||
|
||||
private void a(long i, PlayerChunk playerchunk) {
|
||||
CompletableFuture<IChunkAccess> completablefuture = playerchunk.getChunkSave();
|
||||
@@ -82,42 +78,40 @@
|
||||
CompletableFuture<IChunkAccess> completablefuture1 = playerchunk.getChunkSave();
|
||||
|
||||
if (completablefuture1 != completablefuture) {
|
||||
@@ -616,8 +645,23 @@
|
||||
@@ -615,7 +640,21 @@
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = (Entity) iterator.next();
|
||||
+ // CraftBukkit start - these are spawned serialized (DefinedStructure) and we don't call an add event below at the moment due to ordering complexities
|
||||
+ boolean needsRemoval = false;
|
||||
+ if (chunk.needsDecoration) {
|
||||
+ net.minecraft.server.dedicated.DedicatedServer server = this.world.getServer().getServer();
|
||||
+ if (!server.getSpawnNPCs() && entity instanceof net.minecraft.world.entity.npc.NPC) {
|
||||
+ entity.die();
|
||||
+ needsRemoval = true;
|
||||
+ }
|
||||
+
|
||||
+ if (!server.getSpawnAnimals() && (entity instanceof net.minecraft.world.entity.animal.EntityAnimal || entity instanceof net.minecraft.world.entity.animal.EntityWaterAnimal)) {
|
||||
+ entity.die();
|
||||
+ needsRemoval = true;
|
||||
+ }
|
||||
+ }
|
||||
private static void a(WorldServer worldserver, List<NBTTagCompound> list) {
|
||||
if (!list.isEmpty()) {
|
||||
- worldserver.b(EntityTypes.a(list, (World) worldserver));
|
||||
+ // CraftBukkit start - these are spawned serialized (DefinedStructure) and we don't call an add event below at the moment due to ordering complexities
|
||||
+ worldserver.b(EntityTypes.a(list, (World) worldserver).filter((entity) -> {
|
||||
+ boolean needsRemoval = false;
|
||||
+ net.minecraft.server.dedicated.DedicatedServer server = worldserver.getServer().getServer();
|
||||
+ if (!server.getSpawnNPCs() && entity instanceof net.minecraft.world.entity.npc.NPC) {
|
||||
+ entity.die();
|
||||
+ needsRemoval = true;
|
||||
+ }
|
||||
+ if (!server.getSpawnAnimals() && (entity instanceof net.minecraft.world.entity.animal.EntityAnimal || entity instanceof net.minecraft.world.entity.animal.EntityWaterAnimal)) {
|
||||
+ entity.die();
|
||||
+ needsRemoval = true;
|
||||
+ }
|
||||
+ return !needsRemoval;
|
||||
+ }));
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
- if (!(entity instanceof EntityHuman) && !this.world.addEntityChunk(entity)) {
|
||||
+ if (!(entity instanceof EntityHuman) && (needsRemoval || !this.world.addEntityChunk(entity))) {
|
||||
+ // CraftBukkit end
|
||||
if (list == null) {
|
||||
list = Lists.newArrayList(new Entity[]{entity});
|
||||
} else {
|
||||
@@ -828,7 +872,8 @@
|
||||
}
|
||||
@@ -843,7 +882,8 @@
|
||||
return ichunkaccess instanceof Chunk ? Optional.of((Chunk) ichunkaccess) : Optional.empty();
|
||||
});
|
||||
|
||||
- csvwriter.a(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getChunkStatus).orElse((Object) null), optional1.map(Chunk::getState).orElse((Object) null), a(playerchunk.c()), a(playerchunk.a()), a(playerchunk.b()), this.chunkDistanceManager.c(entry.getLongKey()), !this.isOutsideOfRange(chunkcoordintpair), optional1.map((chunk) -> {
|
||||
- csvwriter.a(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getChunkStatus).orElse((Object) null), optional1.map(Chunk::getState).orElse((Object) null), a(playerchunk.c()), a(playerchunk.a()), a(playerchunk.b()), this.distanceManager.c(entry.getLongKey()), !this.isOutsideOfRange(chunkcoordintpair), optional1.map((chunk) -> {
|
||||
+ // CraftBukkit - decompile error
|
||||
+ csvwriter.a(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getChunkStatus).orElse(null), optional1.map(Chunk::getState).orElse(null), a(playerchunk.c()), a(playerchunk.a()), a(playerchunk.b()), this.chunkDistanceManager.c(entry.getLongKey()), !this.isOutsideOfRange(chunkcoordintpair), optional1.map((chunk) -> {
|
||||
return Stream.of(chunk.getEntitySlices()).mapToInt(EntitySlice::size).sum();
|
||||
}).orElse(0), optional1.map((chunk) -> {
|
||||
+ csvwriter.a(chunkcoordintpair.x, chunkcoordintpair.z, playerchunk.getTicketLevel(), optional.isPresent(), optional.map(IChunkAccess::getChunkStatus).orElse(null), optional1.map(Chunk::getState).orElse(null), a(playerchunk.c()), a(playerchunk.a()), a(playerchunk.b()), this.distanceManager.c(entry.getLongKey()), !this.isOutsideOfRange(chunkcoordintpair), optional1.map((chunk) -> {
|
||||
return chunk.getTileEntities().size();
|
||||
@@ -839,7 +884,7 @@
|
||||
}).orElse(0));
|
||||
}
|
||||
@@ -852,7 +892,7 @@
|
||||
|
||||
private static String a(CompletableFuture<Either<Chunk, PlayerChunk.Failure>> completablefuture) {
|
||||
try {
|
||||
@@ -126,48 +120,41 @@
|
||||
|
||||
return either != null ? (String) either.map((chunk) -> {
|
||||
return "done";
|
||||
@@ -857,7 +902,7 @@
|
||||
@@ -870,7 +910,7 @@
|
||||
private NBTTagCompound readChunkData(ChunkCoordIntPair chunkcoordintpair) throws IOException {
|
||||
NBTTagCompound nbttagcompound = this.read(chunkcoordintpair);
|
||||
|
||||
- return nbttagcompound == null ? null : this.getChunkData(this.world.getDimensionKey(), this.l, nbttagcompound);
|
||||
+ return nbttagcompound == null ? null : this.getChunkData(this.world.getTypeKey(), this.l, nbttagcompound, chunkcoordintpair, world); // CraftBukkit
|
||||
- return nbttagcompound == null ? null : this.getChunkData(this.level.getDimensionKey(), this.overworldDataStorage, nbttagcompound);
|
||||
+ return nbttagcompound == null ? null : this.getChunkData(this.level.getTypeKey(), this.overworldDataStorage, nbttagcompound, chunkcoordintpair, level); // CraftBukkit
|
||||
}
|
||||
|
||||
boolean isOutsideOfRange(ChunkCoordIntPair chunkcoordintpair) {
|
||||
@@ -1189,7 +1234,7 @@
|
||||
public final Set<EntityPlayer> trackedPlayers = Sets.newHashSet();
|
||||
@@ -1233,7 +1273,7 @@
|
||||
public final Set<ServerPlayerConnection> seenBy = Sets.newIdentityHashSet();
|
||||
|
||||
public EntityTracker(Entity entity, int i, int j, boolean flag) {
|
||||
- this.trackerEntry = new EntityTrackerEntry(PlayerChunkMap.this.world, entity, j, flag, this::broadcast);
|
||||
+ this.trackerEntry = new EntityTrackerEntry(PlayerChunkMap.this.world, entity, j, flag, this::broadcast, trackedPlayers); // CraftBukkit
|
||||
this.tracker = entity;
|
||||
this.trackingDistance = i;
|
||||
this.e = SectionPosition.a(entity);
|
||||
@@ -1242,7 +1287,7 @@
|
||||
- this.serverEntity = new EntityTrackerEntry(PlayerChunkMap.this.level, entity, j, flag, this::broadcast);
|
||||
+ this.serverEntity = new EntityTrackerEntry(PlayerChunkMap.this.level, entity, j, flag, this::broadcast, seenBy); // CraftBukkit
|
||||
this.entity = entity;
|
||||
this.range = i;
|
||||
this.lastSectionPos = SectionPosition.a(entity);
|
||||
@@ -1286,10 +1326,18 @@
|
||||
|
||||
public void updatePlayer(EntityPlayer entityplayer) {
|
||||
if (entityplayer != this.tracker) {
|
||||
- Vec3D vec3d = entityplayer.getPositionVector().d(this.trackerEntry.b());
|
||||
+ Vec3D vec3d = entityplayer.getPositionVector().d(this.tracker.getPositionVector()); // MC-155077, SPIGOT-5113
|
||||
if (entityplayer != this.entity) {
|
||||
- Vec3D vec3d = entityplayer.getPositionVector().d(this.serverEntity.b());
|
||||
+ Vec3D vec3d = entityplayer.getPositionVector().d(this.entity.getPositionVector()); // MC-155077, SPIGOT-5113
|
||||
int i = Math.min(this.b(), (PlayerChunkMap.this.viewDistance - 1) * 16);
|
||||
boolean flag = vec3d.x >= (double) (-i) && vec3d.x <= (double) i && vec3d.z >= (double) (-i) && vec3d.z <= (double) i && this.tracker.a(entityplayer);
|
||||
boolean flag = vec3d.x >= (double) (-i) && vec3d.x <= (double) i && vec3d.z >= (double) (-i) && vec3d.z <= (double) i && this.entity.a(entityplayer);
|
||||
|
||||
@@ -1258,6 +1303,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - respect vanish API
|
||||
+ if (this.tracker instanceof EntityPlayer) {
|
||||
+ Player player = ((EntityPlayer) this.tracker).getBukkitEntity();
|
||||
+ if (!entityplayer.getBukkitEntity().canSee(player)) {
|
||||
+ flag1 = false;
|
||||
+ }
|
||||
+ // CraftBukkit start - respect vanish API
|
||||
+ if (this.entity instanceof EntityPlayer) {
|
||||
+ Player player = ((EntityPlayer) this.entity).getBukkitEntity();
|
||||
+ if (!entityplayer.getBukkitEntity().canSee(player)) {
|
||||
+ flag = false;
|
||||
+ }
|
||||
+
|
||||
+ entityplayer.removeQueue.remove(Integer.valueOf(this.tracker.getId()));
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (flag1 && this.trackedPlayers.add(entityplayer)) {
|
||||
this.trackerEntry.b(entityplayer);
|
||||
}
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (flag) {
|
||||
if (this.seenBy.add(entityplayer.connection)) {
|
||||
this.serverEntity.b(entityplayer);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/PlayerInteractManager.java
|
||||
+++ b/net/minecraft/server/level/PlayerInteractManager.java
|
||||
@@ -26,6 +26,25 @@
|
||||
@@ -25,6 +25,25 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -26,49 +26,49 @@
|
||||
public class PlayerInteractManager {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -60,7 +79,7 @@
|
||||
this.gamemode = enumgamemode;
|
||||
enumgamemode.a(this.player.abilities);
|
||||
@@ -65,7 +84,7 @@
|
||||
this.gameModeForPlayer = enumgamemode;
|
||||
enumgamemode.a(this.player.getAbilities());
|
||||
this.player.updateAbilities();
|
||||
- this.player.server.getPlayerList().sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_GAME_MODE, new EntityPlayer[]{this.player}));
|
||||
+ this.player.server.getPlayerList().sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_GAME_MODE, new EntityPlayer[]{this.player}), this.player); // CraftBukkit
|
||||
this.world.everyoneSleeping();
|
||||
this.level.everyoneSleeping();
|
||||
}
|
||||
|
||||
@@ -89,7 +108,7 @@
|
||||
@@ -87,7 +106,7 @@
|
||||
}
|
||||
|
||||
public void a() {
|
||||
- ++this.currentTick;
|
||||
+ this.currentTick = MinecraftServer.currentTick; // CraftBukkit;
|
||||
- ++this.gameTicks;
|
||||
+ this.gameTicks = MinecraftServer.currentTick; // CraftBukkit;
|
||||
IBlockData iblockdata;
|
||||
|
||||
if (this.j) {
|
||||
@@ -145,9 +164,31 @@
|
||||
if (this.hasDelayedDestroy) {
|
||||
@@ -143,9 +162,31 @@
|
||||
|
||||
if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.START_DESTROY_BLOCK) {
|
||||
if (!this.world.a((EntityHuman) this.player, blockposition)) {
|
||||
if (!this.level.a((EntityHuman) this.player, blockposition)) {
|
||||
+ // CraftBukkit start - fire PlayerInteractEvent
|
||||
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.inventory.getItemInHand(), EnumHand.MAIN_HAND);
|
||||
this.player.playerConnection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.world.getType(blockposition), packetplayinblockdig_enumplayerdigtype, false, "may not interact"));
|
||||
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getItemInHand(), EnumHand.MAIN_HAND);
|
||||
this.player.connection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.level.getType(blockposition), packetplayinblockdig_enumplayerdigtype, false, "may not interact"));
|
||||
+ // Update any tile entity data for this block
|
||||
+ TileEntity tileentity = world.getTileEntity(blockposition);
|
||||
+ TileEntity tileentity = level.getTileEntity(blockposition);
|
||||
+ if (tileentity != null) {
|
||||
+ this.player.playerConnection.sendPacket(tileentity.getUpdatePacket());
|
||||
+ this.player.connection.sendPacket(tileentity.getUpdatePacket());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.inventory.getItemInHand(), EnumHand.MAIN_HAND);
|
||||
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, blockposition, enumdirection, this.player.getInventory().getItemInHand(), EnumHand.MAIN_HAND);
|
||||
+ if (event.isCancelled()) {
|
||||
+ // Let the client know the block still exists
|
||||
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition));
|
||||
+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition));
|
||||
+ // Update any tile entity data for this block
|
||||
+ TileEntity tileentity = this.world.getTileEntity(blockposition);
|
||||
+ TileEntity tileentity = this.level.getTileEntity(blockposition);
|
||||
+ if (tileentity != null) {
|
||||
+ this.player.playerConnection.sendPacket(tileentity.getUpdatePacket());
|
||||
+ this.player.connection.sendPacket(tileentity.getUpdatePacket());
|
||||
+ }
|
||||
return;
|
||||
}
|
||||
@@ -76,40 +76,40 @@
|
||||
|
||||
if (this.isCreative()) {
|
||||
this.a(blockposition, packetplayinblockdig_enumplayerdigtype, "creative destroy");
|
||||
@@ -163,11 +204,43 @@
|
||||
@@ -161,11 +202,43 @@
|
||||
float f = 1.0F;
|
||||
|
||||
iblockdata = this.world.getType(blockposition);
|
||||
iblockdata = this.level.getType(blockposition);
|
||||
- if (!iblockdata.isAir()) {
|
||||
+ // CraftBukkit start - Swings at air do *NOT* exist.
|
||||
+ if (event.useInteractedBlock() == Event.Result.DENY) {
|
||||
+ // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
|
||||
+ IBlockData data = this.world.getType(blockposition);
|
||||
+ IBlockData data = this.level.getType(blockposition);
|
||||
+ if (data.getBlock() instanceof BlockDoor) {
|
||||
+ // For some reason *BOTH* the bottom/top part have to be marked updated.
|
||||
+ boolean bottom = data.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER;
|
||||
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition));
|
||||
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, bottom ? blockposition.up() : blockposition.down()));
|
||||
+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition));
|
||||
+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, bottom ? blockposition.up() : blockposition.down()));
|
||||
+ } else if (data.getBlock() instanceof BlockTrapdoor) {
|
||||
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition));
|
||||
+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition));
|
||||
+ }
|
||||
+ } else if (!iblockdata.isAir()) {
|
||||
iblockdata.attack(this.world, blockposition, this.player);
|
||||
f = iblockdata.getDamage(this.player, this.player.world, blockposition);
|
||||
iblockdata.attack(this.level, blockposition, this.player);
|
||||
f = iblockdata.getDamage(this.player, this.player.level, blockposition);
|
||||
}
|
||||
|
||||
+ if (event.useItemInHand() == Event.Result.DENY) {
|
||||
+ // If we 'insta destroyed' then the client needs to be informed.
|
||||
+ if (f > 1.0f) {
|
||||
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition));
|
||||
+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition));
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+ org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this.player.inventory.getItemInHand(), f >= 1.0f);
|
||||
+ org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, blockposition.getX(), blockposition.getY(), blockposition.getZ(), this.player.getInventory().getItemInHand(), f >= 1.0f);
|
||||
+
|
||||
+ if (blockEvent.isCancelled()) {
|
||||
+ // Let the client know the block still exists
|
||||
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition));
|
||||
+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition));
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
@@ -121,41 +121,40 @@
|
||||
if (!iblockdata.isAir() && f >= 1.0F) {
|
||||
this.a(blockposition, packetplayinblockdig_enumplayerdigtype, "insta mine");
|
||||
} else {
|
||||
@@ -211,7 +284,7 @@
|
||||
@@ -209,7 +282,7 @@
|
||||
} else if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) {
|
||||
this.f = false;
|
||||
if (!Objects.equals(this.h, blockposition)) {
|
||||
- PlayerInteractManager.LOGGER.warn("Mismatch in destroy block pos: " + this.h + " " + blockposition);
|
||||
+ PlayerInteractManager.LOGGER.debug("Mismatch in destroy block pos: " + this.h + " " + blockposition); // CraftBukkit - SPIGOT-5457 sent by client when interact event cancelled
|
||||
this.world.a(this.player.getId(), this.h, -1);
|
||||
this.player.playerConnection.sendPacket(new PacketPlayOutBlockBreak(this.h, this.world.getType(this.h), packetplayinblockdig_enumplayerdigtype, true, "aborted mismatched destroying"));
|
||||
this.isDestroyingBlock = false;
|
||||
if (!Objects.equals(this.destroyPos, blockposition)) {
|
||||
- PlayerInteractManager.LOGGER.warn("Mismatch in destroy block pos: {} {}", this.destroyPos, blockposition);
|
||||
+ PlayerInteractManager.LOGGER.debug("Mismatch in destroy block pos: {} {}", this.destroyPos, blockposition); // CraftBukkit - SPIGOT-5457 sent by client when interact event cancelled
|
||||
this.level.a(this.player.getId(), this.destroyPos, -1);
|
||||
this.player.connection.sendPacket(new PacketPlayOutBlockBreak(this.destroyPos, this.level.getType(this.destroyPos), packetplayinblockdig_enumplayerdigtype, true, "aborted mismatched destroying"));
|
||||
}
|
||||
@@ -227,17 +300,73 @@
|
||||
@@ -225,17 +298,72 @@
|
||||
if (this.breakBlock(blockposition)) {
|
||||
this.player.playerConnection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.world.getType(blockposition), packetplayinblockdig_enumplayerdigtype, true, s));
|
||||
this.player.connection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.level.getType(blockposition), packetplayinblockdig_enumplayerdigtype, true, s));
|
||||
} else {
|
||||
- this.player.playerConnection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.world.getType(blockposition), packetplayinblockdig_enumplayerdigtype, false, s));
|
||||
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); // CraftBukkit - SPIGOT-5196
|
||||
- this.player.connection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.level.getType(blockposition), packetplayinblockdig_enumplayerdigtype, false, s));
|
||||
+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition)); // CraftBukkit - SPIGOT-5196
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean breakBlock(BlockPosition blockposition) {
|
||||
IBlockData iblockdata = this.world.getType(blockposition);
|
||||
IBlockData iblockdata = this.level.getType(blockposition);
|
||||
+ // CraftBukkit start - fire BlockBreakEvent
|
||||
+ org.bukkit.block.Block bblock = CraftBlock.at(world, blockposition);
|
||||
+ org.bukkit.block.Block bblock = CraftBlock.at(level, blockposition);
|
||||
+ BlockBreakEvent event = null;
|
||||
+
|
||||
+ if (this.player instanceof EntityPlayer) {
|
||||
+ // Sword + Creative mode pre-cancel
|
||||
+ boolean isSwordNoBreak = !this.player.getItemInMainHand().getItem().a(iblockdata, this.world, blockposition, (EntityHuman) this.player);
|
||||
+ boolean isSwordNoBreak = !this.player.getItemInMainHand().getItem().a(iblockdata, this.level, blockposition, (EntityHuman) this.player);
|
||||
+
|
||||
+ // Tell client the block is gone immediately then process events
|
||||
+ // Don't tell the client if its a creative sword break because its not broken!
|
||||
+ if (world.getTileEntity(blockposition) == null && !isSwordNoBreak) {
|
||||
+ PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(this.world, blockposition);
|
||||
+ packet.block = Blocks.AIR.getBlockData();
|
||||
+ this.player.playerConnection.sendPacket(packet);
|
||||
+ if (level.getTileEntity(blockposition) == null && !isSwordNoBreak) {
|
||||
+ PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(blockposition, Blocks.AIR.getBlockData());
|
||||
+ this.player.connection.sendPacket(packet);
|
||||
+ }
|
||||
+
|
||||
+ event = new BlockBreakEvent(bblock, this.player.getBukkitEntity());
|
||||
@@ -164,60 +163,60 @@
|
||||
+ event.setCancelled(isSwordNoBreak);
|
||||
+
|
||||
+ // Calculate default block experience
|
||||
+ IBlockData nmsData = this.world.getType(blockposition);
|
||||
+ IBlockData nmsData = this.level.getType(blockposition);
|
||||
+ Block nmsBlock = nmsData.getBlock();
|
||||
+
|
||||
+ ItemStack itemstack = this.player.getEquipment(EnumItemSlot.MAINHAND);
|
||||
+
|
||||
+ if (nmsBlock != null && !event.isCancelled() && !this.isCreative() && this.player.hasBlock(nmsBlock.getBlockData())) {
|
||||
+ event.setExpToDrop(nmsBlock.getExpDrop(nmsData, this.world, blockposition, itemstack));
|
||||
+ event.setExpToDrop(nmsBlock.getExpDrop(nmsData, this.level, blockposition, itemstack));
|
||||
+ }
|
||||
|
||||
- if (!this.player.getItemInMainHand().getItem().a(iblockdata, (World) this.world, blockposition, (EntityHuman) this.player)) {
|
||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||
- if (!this.player.getItemInMainHand().getItem().a(iblockdata, (World) this.level, blockposition, (EntityHuman) this.player)) {
|
||||
+ this.level.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ if (isSwordNoBreak) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Let the client know the block still exists
|
||||
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition));
|
||||
+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(this.level, blockposition));
|
||||
+
|
||||
+ // Brute force all possible updates
|
||||
+ for (EnumDirection dir : EnumDirection.values()) {
|
||||
+ this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.shift(dir)));
|
||||
+ this.player.connection.sendPacket(new PacketPlayOutBlockChange(level, blockposition.shift(dir)));
|
||||
+ }
|
||||
+
|
||||
+ // Update any tile entity data for this block
|
||||
+ TileEntity tileentity = this.world.getTileEntity(blockposition);
|
||||
+ TileEntity tileentity = this.level.getTileEntity(blockposition);
|
||||
+ if (tileentity != null) {
|
||||
+ this.player.playerConnection.sendPacket(tileentity.getUpdatePacket());
|
||||
+ this.player.connection.sendPacket(tileentity.getUpdatePacket());
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ if (false && !this.player.getItemInMainHand().getItem().a(iblockdata, (World) this.world, blockposition, (EntityHuman) this.player)) { // CraftBukkit - false
|
||||
+ if (false && !this.player.getItemInMainHand().getItem().a(iblockdata, (World) this.level, blockposition, (EntityHuman) this.player)) { // CraftBukkit - false
|
||||
return false;
|
||||
} else {
|
||||
+ iblockdata = this.world.getType(blockposition); // CraftBukkit - update state from plugins
|
||||
+ iblockdata = this.level.getType(blockposition); // CraftBukkit - update state from plugins
|
||||
+ if (iblockdata.isAir()) return false; // CraftBukkit - A plugin set block to air without cancelling
|
||||
TileEntity tileentity = this.world.getTileEntity(blockposition);
|
||||
TileEntity tileentity = this.level.getTileEntity(blockposition);
|
||||
Block block = iblockdata.getBlock();
|
||||
|
||||
@@ -247,6 +376,10 @@
|
||||
} else if (this.player.a((World) this.world, blockposition, this.gamemode)) {
|
||||
@@ -245,6 +373,10 @@
|
||||
} else if (this.player.a((World) this.level, blockposition, this.gameModeForPlayer)) {
|
||||
return false;
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.block.BlockState state = bblock.getState();
|
||||
+ world.captureDrops = new ArrayList<>();
|
||||
+ level.captureDrops = new ArrayList<>();
|
||||
+ // CraftBukkit end
|
||||
block.a((World) this.world, blockposition, iblockdata, (EntityHuman) this.player);
|
||||
boolean flag = this.world.a(blockposition, false);
|
||||
block.a((World) this.level, blockposition, iblockdata, (EntityHuman) this.player);
|
||||
boolean flag = this.level.a(blockposition, false);
|
||||
|
||||
@@ -255,19 +388,32 @@
|
||||
@@ -253,19 +385,32 @@
|
||||
}
|
||||
|
||||
if (this.isCreative()) {
|
||||
@@ -228,10 +227,10 @@
|
||||
ItemStack itemstack1 = itemstack.cloneItemStack();
|
||||
boolean flag1 = this.player.hasBlock(iblockdata);
|
||||
|
||||
itemstack.a(this.world, iblockdata, blockposition, this.player);
|
||||
itemstack.a(this.level, iblockdata, blockposition, this.player);
|
||||
- if (flag && flag1) {
|
||||
+ if (flag && flag1 && event.isDropItems()) { // CraftBukkit - Check if block should drop items
|
||||
block.a(this.world, this.player, blockposition, iblockdata, tileentity, itemstack1);
|
||||
block.a(this.level, this.player, blockposition, iblockdata, tileentity, itemstack1);
|
||||
}
|
||||
|
||||
- return true;
|
||||
@@ -239,13 +238,13 @@
|
||||
+ }
|
||||
+ // CraftBukkit start
|
||||
+ if (event.isDropItems()) {
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, world.captureDrops);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, level.captureDrops);
|
||||
}
|
||||
+ world.captureDrops = null;
|
||||
+ level.captureDrops = null;
|
||||
+
|
||||
+ // Drop event experience
|
||||
+ if (flag && event != null) {
|
||||
+ iblockdata.getBlock().dropExperience(this.world, blockposition, event.getExpToDrop());
|
||||
+ iblockdata.getBlock().dropExperience(this.level, blockposition, event.getExpToDrop());
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
@@ -253,7 +252,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -309,12 +455,52 @@
|
||||
@@ -307,12 +452,52 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,7 +268,7 @@
|
||||
+ EnumInteractionResult enuminteractionresult = EnumInteractionResult.PASS;
|
||||
+ boolean cancelledBlock = false;
|
||||
|
||||
if (this.gamemode == EnumGamemode.SPECTATOR) {
|
||||
if (this.gameModeForPlayer == EnumGamemode.SPECTATOR) {
|
||||
ITileInventory itileinventory = iblockdata.b(world, blockposition);
|
||||
+ cancelledBlock = !(itileinventory instanceof ITileInventory);
|
||||
+ }
|
||||
@@ -289,24 +288,24 @@
|
||||
+ // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
|
||||
+ if (iblockdata.getBlock() instanceof BlockDoor) {
|
||||
+ boolean bottom = iblockdata.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER;
|
||||
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockChange(world, bottom ? blockposition.up() : blockposition.down()));
|
||||
+ entityplayer.connection.sendPacket(new PacketPlayOutBlockChange(world, bottom ? blockposition.up() : blockposition.down()));
|
||||
+ } else if (iblockdata.getBlock() instanceof BlockCake) {
|
||||
+ entityplayer.getBukkitEntity().sendHealthUpdate(); // SPIGOT-1341 - reset health for cake
|
||||
+ } else if (interactItemStack.getItem() instanceof ItemBisected) {
|
||||
+ // send a correcting update to the client, as it already placed the upper half of the bisected item
|
||||
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.shift(movingobjectpositionblock.getDirection()).up()));
|
||||
+ entityplayer.connection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.shift(movingobjectpositionblock.getDirection()).up()));
|
||||
+
|
||||
+ // send a correcting update to the client for the block above as well, this because of replaceable blocks (such as grass, sea grass etc)
|
||||
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.up()));
|
||||
+ entityplayer.connection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.up()));
|
||||
+ }
|
||||
+ entityplayer.getBukkitEntity().updateInventory(); // SPIGOT-2867
|
||||
+ enuminteractionresult = (event.useItemInHand() != Event.Result.ALLOW) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS;
|
||||
+ } else if (this.gamemode == EnumGamemode.SPECTATOR) {
|
||||
+ } else if (this.gameModeForPlayer == EnumGamemode.SPECTATOR) {
|
||||
+ ITileInventory itileinventory = iblockdata.b(world, blockposition);
|
||||
|
||||
if (itileinventory != null) {
|
||||
entityplayer.openContainer(itileinventory);
|
||||
@@ -328,7 +514,7 @@
|
||||
@@ -326,7 +511,7 @@
|
||||
ItemStack itemstack1 = itemstack.cloneItemStack();
|
||||
|
||||
if (!flag1) {
|
||||
@@ -314,8 +313,8 @@
|
||||
+ enuminteractionresult = iblockdata.interact(world, entityplayer, enumhand, movingobjectpositionblock);
|
||||
|
||||
if (enuminteractionresult.a()) {
|
||||
CriterionTriggers.M.a(entityplayer, blockposition, itemstack1);
|
||||
@@ -336,17 +522,17 @@
|
||||
CriterionTriggers.ITEM_USED_ON_BLOCK.a(entityplayer, blockposition, itemstack1);
|
||||
@@ -334,17 +519,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,7 +335,7 @@
|
||||
}
|
||||
|
||||
if (enuminteractionresult1.a()) {
|
||||
@@ -354,10 +540,10 @@
|
||||
@@ -352,10 +537,10 @@
|
||||
}
|
||||
|
||||
return enuminteractionresult1;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/RegionLimitedWorldAccess.java
|
||||
+++ b/net/minecraft/server/level/RegionLimitedWorldAccess.java
|
||||
@@ -273,6 +273,13 @@
|
||||
@@ -308,6 +308,13 @@
|
||||
|
||||
@Override
|
||||
public boolean addEntity(Entity entity) {
|
||||
@@ -11,6 +11,6 @@
|
||||
+ @Override
|
||||
+ public boolean addEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
|
||||
+ // CraftBukkit end
|
||||
int i = MathHelper.floor(entity.locX() / 16.0D);
|
||||
int j = MathHelper.floor(entity.locZ() / 16.0D);
|
||||
int i = SectionPosition.a(entity.cW());
|
||||
int j = SectionPosition.a(entity.dc());
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/level/WorldServer.java
|
||||
+++ b/net/minecraft/server/level/WorldServer.java
|
||||
@@ -145,6 +145,21 @@
|
||||
@@ -152,6 +152,22 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
+import java.util.logging.Level;
|
||||
+import net.minecraft.world.entity.monster.EntityDrowned;
|
||||
+import net.minecraft.world.level.block.ITileEntity;
|
||||
+import net.minecraft.world.level.block.entity.TileEntity;
|
||||
+import net.minecraft.world.level.storage.WorldDataServer;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.WeatherType;
|
||||
@@ -21,21 +22,22 @@
|
||||
+
|
||||
public class WorldServer extends World implements GeneratorAccessSeed {
|
||||
|
||||
public static final BlockPosition a = new BlockPosition(100, 50, 0);
|
||||
@@ -156,7 +171,7 @@
|
||||
private final ChunkProviderServer chunkProvider;
|
||||
boolean tickingEntities;
|
||||
public static final BlockPosition END_SPAWN_POINT = new BlockPosition(100, 50, 0);
|
||||
@@ -160,7 +176,7 @@
|
||||
final List<EntityPlayer> players;
|
||||
private final ChunkProviderServer chunkSource;
|
||||
private final MinecraftServer server;
|
||||
- public final IWorldDataServer worldDataServer;
|
||||
+ public final WorldDataServer worldDataServer; // CraftBukkit - type
|
||||
public boolean savingDisabled;
|
||||
private boolean everyoneSleeping;
|
||||
private int emptyTime;
|
||||
@@ -173,8 +188,23 @@
|
||||
private final StructureManager structureManager;
|
||||
private final boolean Q;
|
||||
- public final IWorldDataServer serverLevelData;
|
||||
+ public final WorldDataServer serverLevelData; // CraftBukkit - type
|
||||
final EntityTickList entityTickList;
|
||||
private final PersistentEntitySectionManager<Entity> entityManager;
|
||||
public boolean noSave;
|
||||
@@ -180,31 +196,52 @@
|
||||
private final StructureManager structureFeatureManager;
|
||||
private final boolean tickTime;
|
||||
|
||||
- public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey<World> resourcekey, DimensionManager dimensionmanager, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List<MobSpawner> list, boolean flag1) {
|
||||
- Objects.requireNonNull(minecraftserver);
|
||||
- super(iworlddataserver, resourcekey, dimensionmanager, minecraftserver::getMethodProfiler, false, flag, i);
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
@@ -44,50 +46,67 @@
|
||||
+ public final UUID uuid;
|
||||
+
|
||||
+ public Chunk getChunkIfLoaded(int x, int z) {
|
||||
+ return this.chunkProvider.getChunkAt(x, z, false);
|
||||
+ return this.chunkSource.getChunkAt(x, z, false);
|
||||
+ }
|
||||
+
|
||||
+ // Add env and gen to constructor, WorldData -> WorldDataServer
|
||||
+ public WorldServer(MinecraftServer minecraftserver, Executor executor, Convertable.ConversionSession convertable_conversionsession, IWorldDataServer iworlddataserver, ResourceKey<World> resourcekey, DimensionManager dimensionmanager, WorldLoadListener worldloadlistener, ChunkGenerator chunkgenerator, boolean flag, long i, List<MobSpawner> list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) {
|
||||
+ // Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error
|
||||
+ super(iworlddataserver, resourcekey, dimensionmanager, minecraftserver::getMethodProfiler, false, flag, i, gen, env);
|
||||
+ this.pvpMode = minecraftserver.getPVP();
|
||||
+ convertable = convertable_conversionsession;
|
||||
+ uuid = WorldUUID.getUUID(convertable_conversionsession.folder.toFile());
|
||||
+ uuid = WorldUUID.getUUID(convertable_conversionsession.levelPath.toFile());
|
||||
+ // CraftBukkit end
|
||||
this.nextTickListBlock = new TickListServer<>(this, (block) -> {
|
||||
this.players = Lists.newArrayList();
|
||||
this.entityTickList = new EntityTickList();
|
||||
- Predicate predicate = (block) -> {
|
||||
+ Predicate<Block> predicate = (block) -> { // CraftBukkit - decompile eror
|
||||
return block == null || block.getBlockData().isAir();
|
||||
}, IRegistry.BLOCK::getKey, this::b);
|
||||
@@ -186,10 +216,17 @@
|
||||
this.Q = flag1;
|
||||
};
|
||||
RegistryBlocks registryblocks = IRegistry.BLOCK;
|
||||
|
||||
Objects.requireNonNull(registryblocks);
|
||||
- this.blockTicks = new TickListServer<>(this, predicate, registryblocks::getKey, this::b);
|
||||
- predicate = (fluidtype) -> {
|
||||
+ this.blockTicks = new TickListServer<>(this, predicate, IRegistry.BLOCK::getKey, this::b); // CraftBukkit - decompile error
|
||||
+ Predicate<FluidType> predicate2 = (fluidtype) -> { // CraftBukkit - decompile error
|
||||
return fluidtype == null || fluidtype == FluidTypes.EMPTY;
|
||||
};
|
||||
registryblocks = IRegistry.FLUID;
|
||||
Objects.requireNonNull(registryblocks);
|
||||
- this.liquidTicks = new TickListServer<>(this, predicate, registryblocks::getKey, this::a);
|
||||
+ this.liquidTicks = new TickListServer<>(this, predicate2, IRegistry.FLUID::getKey, this::a); // CraftBukkit - decompile error
|
||||
this.navigatingMobs = new ObjectOpenHashSet();
|
||||
this.blockEvents = new ObjectLinkedOpenHashSet();
|
||||
this.dragonParts = new Int2ObjectOpenHashMap();
|
||||
this.tickTime = flag1;
|
||||
this.server = minecraftserver;
|
||||
this.mobSpawners = list;
|
||||
- this.worldDataServer = iworlddataserver;
|
||||
this.customSpawners = list;
|
||||
- this.serverLevelData = iworlddataserver;
|
||||
+ // CraftBukkit start
|
||||
+ this.worldDataServer = (WorldDataServer) iworlddataserver;
|
||||
+ worldDataServer.world = this;
|
||||
+ this.serverLevelData = (WorldDataServer) iworlddataserver;
|
||||
+ serverLevelData.world = this;
|
||||
+ if (gen != null) {
|
||||
+ chunkgenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, chunkgenerator, gen);
|
||||
+ }
|
||||
+
|
||||
this.chunkProvider = new ChunkProviderServer(this, convertable_conversionsession, minecraftserver.getDataFixer(), minecraftserver.getDefinedStructureManager(), executor, chunkgenerator, minecraftserver.getPlayerList().getViewDistance(), minecraftserver.isSyncChunkWrites(), worldloadlistener, () -> {
|
||||
return minecraftserver.E().getWorldPersistentData();
|
||||
});
|
||||
+ // CraftBukkit end
|
||||
this.portalTravelAgent = new PortalTravelAgent(this);
|
||||
this.Q();
|
||||
this.R();
|
||||
@@ -201,14 +238,50 @@
|
||||
boolean flag2 = minecraftserver.isSyncChunkWrites();
|
||||
DataFixer datafixer = minecraftserver.getDataFixer();
|
||||
EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, new File(convertable_conversionsession.a(resourcekey), "entities"), datafixer, flag2, minecraftserver);
|
||||
@@ -231,15 +268,51 @@
|
||||
iworlddataserver.setGameType(minecraftserver.getGamemode());
|
||||
}
|
||||
|
||||
- this.structureManager = new StructureManager(this, minecraftserver.getSaveData().getGeneratorSettings());
|
||||
+ this.structureManager = new StructureManager(this, this.worldDataServer.getGeneratorSettings()); // CraftBukkit
|
||||
- this.structureFeatureManager = new StructureManager(this, minecraftserver.getSaveData().getGeneratorSettings());
|
||||
+ this.structureFeatureManager = new StructureManager(this, this.serverLevelData.getGeneratorSettings()); // CraftBukkit
|
||||
if (this.getDimensionManager().isCreateDragonBattle()) {
|
||||
- this.dragonBattle = new EnderDragonBattle(this, minecraftserver.getSaveData().getGeneratorSettings().getSeed(), minecraftserver.getSaveData().C());
|
||||
+ this.dragonBattle = new EnderDragonBattle(this, this.worldDataServer.getGeneratorSettings().getSeed(), this.worldDataServer.C()); // CraftBukkit
|
||||
- this.dragonFight = new EnderDragonBattle(this, minecraftserver.getSaveData().getGeneratorSettings().getSeed(), minecraftserver.getSaveData().C());
|
||||
+ this.dragonFight = new EnderDragonBattle(this, this.serverLevelData.getGeneratorSettings().getSeed(), this.serverLevelData.C()); // CraftBukkit
|
||||
} else {
|
||||
this.dragonBattle = null;
|
||||
this.dragonFight = null;
|
||||
}
|
||||
|
||||
this.sleepStatus = new SleepStatus();
|
||||
+ this.getServer().addWorld(this.getWorld()); // CraftBukkit
|
||||
+ }
|
||||
+
|
||||
@@ -95,13 +114,13 @@
|
||||
+ @Override
|
||||
+ public TileEntity getTileEntity(BlockPosition pos, boolean validate) {
|
||||
+ TileEntity result = super.getTileEntity(pos, validate);
|
||||
+ if (!validate || Thread.currentThread() != this.serverThread) {
|
||||
+ if (!validate || Thread.currentThread() != this.thread) {
|
||||
+ // SPIGOT-5378: avoid deadlock, this can be called in loading logic (i.e lighting) but getType() will block on chunk load
|
||||
+ return result;
|
||||
+ }
|
||||
+ Block type = getType(pos).getBlock();
|
||||
|
||||
+ if (result != null && type != Blocks.AIR) {
|
||||
+ IBlockData type = getType(pos);
|
||||
+
|
||||
+ if (result != null && !type.a(Blocks.AIR)) {
|
||||
+ if (!result.getTileType().isValidBlock(type)) {
|
||||
+ result = fixTileEntity(pos, type, result);
|
||||
+ }
|
||||
@@ -110,15 +129,14 @@
|
||||
+ return result;
|
||||
+ }
|
||||
+
|
||||
+ private TileEntity fixTileEntity(BlockPosition pos, Block type, TileEntity found) {
|
||||
+ private TileEntity fixTileEntity(BlockPosition pos, IBlockData type, TileEntity found) {
|
||||
+ this.getServer().getLogger().log(Level.SEVERE, "Block at {0}, {1}, {2} is {3} but has {4}" + ". "
|
||||
+ + "Bukkit will attempt to fix this, but there may be additional damage that we cannot recover.", new Object[]{pos.getX(), pos.getY(), pos.getZ(), type, found});
|
||||
+
|
||||
+ if (type instanceof ITileEntity) {
|
||||
+ TileEntity replacement = ((ITileEntity) type).createTile(this);
|
||||
+ TileEntity replacement = ((ITileEntity) type).createTile(pos, type);
|
||||
+ if (replacement != null) {
|
||||
+ replacement.setLocation(this, pos);
|
||||
+ this.setTileEntity(pos, replacement);
|
||||
+ this.setTileEntity(replacement);
|
||||
+ }
|
||||
+ return replacement;
|
||||
+ } else {
|
||||
@@ -128,22 +146,22 @@
|
||||
+ // CraftBukkit end
|
||||
|
||||
public void a(int i, int j, boolean flag, boolean flag1) {
|
||||
this.worldDataServer.setClearWeatherTime(i);
|
||||
@@ -299,6 +372,7 @@
|
||||
this.serverLevelData.setClearWeatherTime(i);
|
||||
@@ -331,6 +404,7 @@
|
||||
this.rainLevel = MathHelper.a(this.rainLevel, 0.0F, 1.0F);
|
||||
}
|
||||
|
||||
+ /* CraftBukkit start
|
||||
if (this.lastRainLevel != this.rainLevel) {
|
||||
this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.h, this.rainLevel)), this.getDimensionKey());
|
||||
if (this.oRainLevel != this.rainLevel) {
|
||||
this.server.getPlayerList().a((Packet) (new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel)), this.getDimensionKey());
|
||||
}
|
||||
@@ -317,18 +391,47 @@
|
||||
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.h, this.rainLevel));
|
||||
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.i, this.thunderLevel));
|
||||
@@ -349,16 +423,45 @@
|
||||
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.RAIN_LEVEL_CHANGE, this.rainLevel));
|
||||
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.THUNDER_LEVEL_CHANGE, this.thunderLevel));
|
||||
}
|
||||
+ // */
|
||||
+ for (int idx = 0; idx < this.players.size(); ++idx) {
|
||||
+ if (((EntityPlayer) this.players.get(idx)).world == this) {
|
||||
+ if (((EntityPlayer) this.players.get(idx)).level == this) {
|
||||
+ ((EntityPlayer) this.players.get(idx)).tickWeather();
|
||||
+ }
|
||||
+ }
|
||||
@@ -151,28 +169,25 @@
|
||||
+ if (flag != this.isRaining()) {
|
||||
+ // Only send weather packets to those affected
|
||||
+ for (int idx = 0; idx < this.players.size(); ++idx) {
|
||||
+ if (((EntityPlayer) this.players.get(idx)).world == this) {
|
||||
+ if (((EntityPlayer) this.players.get(idx)).level == this) {
|
||||
+ ((EntityPlayer) this.players.get(idx)).setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ for (int idx = 0; idx < this.players.size(); ++idx) {
|
||||
+ if (((EntityPlayer) this.players.get(idx)).world == this) {
|
||||
+ ((EntityPlayer) this.players.get(idx)).updateWeather(this.lastRainLevel, this.rainLevel, this.lastThunderLevel, this.thunderLevel);
|
||||
+ if (((EntityPlayer) this.players.get(idx)).level == this) {
|
||||
+ ((EntityPlayer) this.players.get(idx)).updateWeather(this.oRainLevel, this.rainLevel, this.oThunderLevel, this.thunderLevel);
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (this.everyoneSleeping && this.players.stream().noneMatch((entityplayer) -> {
|
||||
- return !entityplayer.isSpectator() && !entityplayer.isDeeplySleeping();
|
||||
+ return !entityplayer.isSpectator() && !entityplayer.isDeeplySleeping() && !entityplayer.fauxSleeping; // CraftBukkit
|
||||
})) {
|
||||
- this.everyoneSleeping = false;
|
||||
i = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE);
|
||||
if (this.sleepStatus.a(i) && this.sleepStatus.a(i, this.players)) {
|
||||
+ // CraftBukkit start
|
||||
+ long l = this.worldData.getDayTime() + 24000L;
|
||||
+ long l = this.levelData.getDayTime() + 24000L;
|
||||
+ TimeSkipEvent event = new TimeSkipEvent(this.getWorld(), TimeSkipEvent.SkipReason.NIGHT_SKIP, (l - l % 24000L) - this.getDayTime());
|
||||
if (this.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE)) {
|
||||
- long l = this.worldData.getDayTime() + 24000L;
|
||||
if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) {
|
||||
- long l = this.levelData.getDayTime() + 24000L;
|
||||
+ getServer().getPluginManager().callEvent(event);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ this.setDayTime(this.getDayTime() + event.getSkipAmount());
|
||||
@@ -183,49 +198,41 @@
|
||||
|
||||
- this.wakeupPlayers();
|
||||
+ if (!event.isCancelled()) {
|
||||
+ this.everyoneSleeping = false;
|
||||
+ this.wakeupPlayers();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (this.getGameRules().getBoolean(GameRules.DO_WEATHER_CYCLE)) {
|
||||
if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE)) {
|
||||
this.clearWeather();
|
||||
}
|
||||
@@ -350,7 +453,7 @@
|
||||
this.ak();
|
||||
this.ticking = false;
|
||||
gameprofilerfiller.exitEnter("entities");
|
||||
@@ -380,7 +483,7 @@
|
||||
this.aq();
|
||||
this.handlingTick = false;
|
||||
gameprofilerfiller.exit();
|
||||
- boolean flag3 = !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty();
|
||||
+ boolean flag3 = true || !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players
|
||||
|
||||
if (flag3) {
|
||||
this.resetEmptyTime();
|
||||
@@ -369,6 +472,7 @@
|
||||
Entity entity = (Entity) entry.getValue();
|
||||
Entity entity1 = entity.getVehicle();
|
||||
@@ -396,7 +499,7 @@
|
||||
|
||||
+ /* CraftBukkit start - We prevent spawning in general, so this butchering is not needed
|
||||
if (!this.server.getSpawnAnimals() && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) {
|
||||
entity.die();
|
||||
}
|
||||
@@ -376,6 +480,7 @@
|
||||
if (!this.server.getSpawnNPCs() && entity instanceof NPC) {
|
||||
entity.die();
|
||||
}
|
||||
+ // CraftBukkit end */
|
||||
|
||||
gameprofilerfiller.enter("checkDespawn");
|
||||
if (!entity.dead) {
|
||||
@@ -450,7 +555,7 @@
|
||||
}
|
||||
this.entityTickList.a((entity) -> {
|
||||
if (!entity.isRemoved()) {
|
||||
- if (this.i(entity)) {
|
||||
+ if (false && this.i(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed
|
||||
entity.die();
|
||||
} else {
|
||||
gameprofilerfiller.enter("checkDespawn");
|
||||
@@ -461,7 +564,7 @@
|
||||
|
||||
private void wakeupPlayers() {
|
||||
this.sleepStatus.a();
|
||||
- ((List) this.players.stream().filter(EntityLiving::isSleeping).collect(Collectors.toList())).forEach((entityplayer) -> {
|
||||
+ (this.players.stream().filter(EntityLiving::isSleeping).collect(Collectors.toList())).forEach((entityplayer) -> { // CraftBukkit - decompile error
|
||||
entityplayer.wakeup(false, false);
|
||||
});
|
||||
}
|
||||
@@ -477,14 +582,14 @@
|
||||
entityhorseskeleton.t(true);
|
||||
@@ -488,14 +591,14 @@
|
||||
entityhorseskeleton.v(true);
|
||||
entityhorseskeleton.setAgeRaw(0);
|
||||
entityhorseskeleton.setPosition((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
|
||||
- this.addEntity(entityhorseskeleton);
|
||||
@@ -241,80 +248,63 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -495,11 +600,11 @@
|
||||
@@ -506,12 +609,12 @@
|
||||
BiomeBase biomebase = this.getBiome(blockposition);
|
||||
|
||||
if (biomebase.a(this, blockposition1)) {
|
||||
if (biomebase.a((IWorldReader) this, blockposition1)) {
|
||||
- this.setTypeUpdate(blockposition1, Blocks.ICE.getBlockData());
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition1, Blocks.ICE.getBlockData(), null); // CraftBukkit
|
||||
}
|
||||
|
||||
if (flag && biomebase.b(this, blockposition)) {
|
||||
- this.setTypeUpdate(blockposition, Blocks.SNOW.getBlockData());
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, Blocks.SNOW.getBlockData(), null); // CraftBukkit
|
||||
}
|
||||
if (flag) {
|
||||
if (biomebase.b(this, blockposition)) {
|
||||
- this.setTypeUpdate(blockposition, Blocks.SNOW.getBlockData());
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockposition, Blocks.SNOW.getBlockData(), null); // CraftBukkit
|
||||
}
|
||||
|
||||
if (flag && this.getBiome(blockposition1).c() == BiomeBase.Precipitation.RAIN) {
|
||||
@@ -546,7 +651,7 @@
|
||||
protected BlockPosition a(BlockPosition blockposition) {
|
||||
BlockPosition blockposition1 = this.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING, blockposition);
|
||||
AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockposition1, new BlockPosition(blockposition1.getX(), this.getBuildHeight(), blockposition1.getZ()))).g(3.0D);
|
||||
- List<EntityLiving> list = this.a(EntityLiving.class, axisalignedbb, (entityliving) -> {
|
||||
+ List<EntityLiving> list = this.a(EntityLiving.class, axisalignedbb, (java.util.function.Predicate<EntityLiving>) (entityliving) -> { // CraftBukkit - decompile error
|
||||
return entityliving != null && entityliving.isAlive() && this.e(entityliving.getChunkCoordinates());
|
||||
});
|
||||
|
||||
@@ -575,7 +680,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||
|
||||
- if (entityplayer.isSpectator()) {
|
||||
+ if (entityplayer.isSpectator() || (entityplayer.fauxSleeping && !entityplayer.isSleeping())) { // CraftBukkit
|
||||
++i;
|
||||
} else if (entityplayer.isSleeping()) {
|
||||
++j;
|
||||
@@ -593,10 +698,22 @@
|
||||
IBlockData iblockdata = this.getType(blockposition1);
|
||||
@@ -642,10 +745,22 @@
|
||||
}
|
||||
|
||||
private void clearWeather() {
|
||||
- this.worldDataServer.setWeatherDuration(0);
|
||||
- this.serverLevelData.setWeatherDuration(0);
|
||||
+ // CraftBukkit start
|
||||
this.worldDataServer.setStorm(false);
|
||||
- this.worldDataServer.setThunderDuration(0);
|
||||
this.serverLevelData.setStorm(false);
|
||||
- this.serverLevelData.setThunderDuration(0);
|
||||
+ // If we stop due to everyone sleeping we should reset the weather duration to some other random value.
|
||||
+ // Not that everyone ever manages to get the whole server to sleep at the same time....
|
||||
+ if (!this.worldDataServer.hasStorm()) {
|
||||
+ this.worldDataServer.setWeatherDuration(0);
|
||||
+ if (!this.serverLevelData.hasStorm()) {
|
||||
+ this.serverLevelData.setWeatherDuration(0);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.worldDataServer.setThundering(false);
|
||||
this.serverLevelData.setThundering(false);
|
||||
+ // CraftBukkit start
|
||||
+ // If we stop due to everyone sleeping we should reset the weather duration to some other random value.
|
||||
+ // Not that everyone ever manages to get the whole server to sleep at the same time....
|
||||
+ if (!this.worldDataServer.isThundering()) {
|
||||
+ this.worldDataServer.setThunderDuration(0);
|
||||
+ if (!this.serverLevelData.isThundering()) {
|
||||
+ this.serverLevelData.setThunderDuration(0);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public void resetEmptyTime() {
|
||||
@@ -637,6 +754,7 @@
|
||||
@@ -680,6 +795,7 @@
|
||||
});
|
||||
gameprofilerfiller.c("tickNonPassenger");
|
||||
entity.tick();
|
||||
+ entity.postTick(); // CraftBukkit
|
||||
this.getMethodProfiler().exit();
|
||||
Iterator iterator = entity.getPassengers().iterator();
|
||||
|
||||
@@ -703,6 +819,7 @@
|
||||
});
|
||||
gameprofilerfiller.c("tickNonPassenger");
|
||||
entity.tick();
|
||||
+ entity.postTick(); // CraftBukkit
|
||||
gameprofilerfiller.c("tickPassenger");
|
||||
entity1.passengerTick();
|
||||
+ entity1.postTick(); // CraftBukkit
|
||||
gameprofilerfiller.exit();
|
||||
}
|
||||
Iterator iterator = entity1.getPassengers().iterator();
|
||||
|
||||
@@ -669,6 +787,7 @@
|
||||
});
|
||||
gameprofilerfiller.c("tickPassenger");
|
||||
entity1.passengerTick();
|
||||
+ entity1.postTick(); // CraftBukkit
|
||||
gameprofilerfiller.exit();
|
||||
}
|
||||
|
||||
@@ -725,6 +844,7 @@
|
||||
@@ -727,6 +844,7 @@
|
||||
ChunkProviderServer chunkproviderserver = this.getChunkProvider();
|
||||
|
||||
if (!flag1) {
|
||||
@@ -322,28 +312,28 @@
|
||||
if (iprogressupdate != null) {
|
||||
iprogressupdate.a(new ChatMessage("menu.savingLevel"));
|
||||
}
|
||||
@@ -736,11 +856,19 @@
|
||||
@@ -744,11 +862,19 @@
|
||||
}
|
||||
|
||||
chunkproviderserver.save(flag);
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start - moved from MinecraftServer.saveChunks
|
||||
+ WorldServer worldserver1 = this;
|
||||
+
|
||||
+ worldDataServer.a(worldserver1.getWorldBorder().t());
|
||||
+ worldDataServer.setCustomBossEvents(this.server.getBossBattleCustomData().save());
|
||||
+ convertable.a(this.server.customRegistry, this.worldDataServer, this.server.getPlayerList().save());
|
||||
+ serverLevelData.a(worldserver1.getWorldBorder().t());
|
||||
+ serverLevelData.setCustomBossEvents(this.server.getBossBattleCustomData().save());
|
||||
+ convertable.a(this.server.registryHolder, this.serverLevelData, this.server.getPlayerList().save());
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
private void aj() {
|
||||
if (this.dragonBattle != null) {
|
||||
- this.server.getSaveData().a(this.dragonBattle.a());
|
||||
+ this.worldDataServer.a(this.dragonBattle.a()); // CraftBukkit
|
||||
private void ap() {
|
||||
if (this.dragonFight != null) {
|
||||
- this.server.getSaveData().a(this.dragonFight.a());
|
||||
+ this.serverLevelData.a(this.dragonFight.a()); // CraftBukkit
|
||||
}
|
||||
|
||||
this.getChunkProvider().getWorldPersistentData().a();
|
||||
@@ -801,11 +929,24 @@
|
||||
@@ -794,15 +920,34 @@
|
||||
|
||||
@Override
|
||||
public boolean addEntity(Entity entity) {
|
||||
@@ -370,47 +360,56 @@
|
||||
}
|
||||
|
||||
public void addEntityTeleport(Entity entity) {
|
||||
@@ -855,13 +996,18 @@
|
||||
this.registerEntity(entityplayer);
|
||||
- this.addEntity0(entity);
|
||||
+ // CraftBukkit start
|
||||
+ this.addEntity0(entity, CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ }
|
||||
+
|
||||
+ public void addEntityTeleport(Entity entity, CreatureSpawnEvent.SpawnReason reason) {
|
||||
+ this.addEntity0(entity, reason);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public void addPlayerCommand(EntityPlayer entityplayer) {
|
||||
@@ -830,27 +975,39 @@
|
||||
this.a((EntityPlayer) entity, Entity.RemovalReason.DISCARDED);
|
||||
}
|
||||
|
||||
- this.entityManager.a((EntityAccess) entityplayer);
|
||||
+ this.entityManager.a(entityplayer); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
- private boolean addEntity0(Entity entity) {
|
||||
+ // CraftBukkit start
|
||||
+ private boolean addEntity0(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
if (entity.dead) {
|
||||
if (entity.isRemoved()) {
|
||||
- WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.getEntityType()));
|
||||
+ // WorldServer.LOGGER.warn("Tried to add entity {} but it was marked as removed already", EntityTypes.getName(entity.getEntityType())); // CraftBukkit
|
||||
return false;
|
||||
} else if (this.isUUIDTaken(entity)) {
|
||||
return false;
|
||||
} else {
|
||||
- return this.entityManager.a((EntityAccess) entity);
|
||||
+ if (!CraftEventFactory.doEntityAddEventCalling(this, entity, spawnReason)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
IChunkAccess ichunkaccess = this.getChunkAt(MathHelper.floor(entity.locX() / 16.0D), MathHelper.floor(entity.locZ() / 16.0D), ChunkStatus.FULL, entity.attachedToPlayer);
|
||||
|
||||
if (!(ichunkaccess instanceof Chunk)) {
|
||||
@@ -890,7 +1036,7 @@
|
||||
if (entity1 == null) {
|
||||
return false;
|
||||
} else {
|
||||
- WorldServer.LOGGER.warn("Trying to add entity with duplicated UUID {}. Existing {}#{}, new: {}#{}", uuid, EntityTypes.getName(entity1.getEntityType()), entity1.getId(), EntityTypes.getName(entity.getEntityType()), entity.getId());
|
||||
+ // WorldServer.LOGGER.warn("Trying to add entity with duplicated UUID {}. Existing {}#{}, new: {}#{}", uuid, EntityTypes.getName(entity1.getEntityType()), entity1.getId(), EntityTypes.getName(entity.getEntityType()), entity.getId()); // CraftBukkit
|
||||
return true;
|
||||
+
|
||||
+ return this.entityManager.a(entity); // CraftBukkit - decompile error
|
||||
}
|
||||
}
|
||||
@@ -919,10 +1065,16 @@
|
||||
}
|
||||
|
||||
public boolean addAllEntitiesSafely(Entity entity) {
|
||||
- Stream stream = entity.recursiveStream().map(Entity::getUniqueID);
|
||||
+ // CraftBukkit start
|
||||
+ return this.addAllEntitiesSafely(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ }
|
||||
+
|
||||
+ public boolean addAllEntitiesSafely(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) {
|
||||
+ // CraftBukkit end
|
||||
if (entity.recursiveStream().anyMatch(this::isUUIDTaken)) {
|
||||
+ Stream<UUID> stream = entity.recursiveStream().map(Entity::getUniqueID); // CraftBukkit - decompile error
|
||||
PersistentEntitySectionManager persistententitysectionmanager = this.entityManager;
|
||||
|
||||
Objects.requireNonNull(this.entityManager);
|
||||
if (stream.anyMatch(persistententitysectionmanager::a)) {
|
||||
return false;
|
||||
} else {
|
||||
- this.addAllEntities(entity);
|
||||
@@ -418,52 +417,8 @@
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -973,10 +1125,17 @@
|
||||
}
|
||||
|
||||
this.getScoreboard().a(entity);
|
||||
+ // CraftBukkit start - SPIGOT-5278
|
||||
+ if (entity instanceof EntityDrowned) {
|
||||
+ this.navigators.remove(((EntityDrowned) entity).navigationWater);
|
||||
+ this.navigators.remove(((EntityDrowned) entity).navigationLand);
|
||||
+ } else
|
||||
+ // CraftBukkit end
|
||||
if (entity instanceof EntityInsentient) {
|
||||
this.navigators.remove(((EntityInsentient) entity).getNavigation());
|
||||
}
|
||||
|
||||
+ entity.valid = false; // CraftBukkit
|
||||
}
|
||||
|
||||
private void registerEntity(Entity entity) {
|
||||
@@ -997,9 +1156,16 @@
|
||||
|
||||
this.entitiesByUUID.put(entity.getUniqueID(), entity);
|
||||
this.getChunkProvider().addEntity(entity);
|
||||
+ // CraftBukkit start - SPIGOT-5278
|
||||
+ if (entity instanceof EntityDrowned) {
|
||||
+ this.navigators.add(((EntityDrowned) entity).navigationWater);
|
||||
+ this.navigators.add(((EntityDrowned) entity).navigationLand);
|
||||
+ } else
|
||||
+ // CraftBukkit end
|
||||
if (entity instanceof EntityInsentient) {
|
||||
this.navigators.add(((EntityInsentient) entity).getNavigation());
|
||||
}
|
||||
+ entity.valid = true; // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1015,7 +1181,7 @@
|
||||
}
|
||||
|
||||
private void removeEntityFromChunk(Entity entity) {
|
||||
- IChunkAccess ichunkaccess = this.getChunkAt(entity.chunkX, entity.chunkZ, ChunkStatus.FULL, false);
|
||||
+ IChunkAccess ichunkaccess = chunkProvider.getChunkUnchecked(entity.chunkX, entity.chunkZ); // CraftBukkit - SPIGOT-5228: getChunkAt won't find the entity's chunk if it has already been unloaded (i.e. if it switched to state INACCESSIBLE).
|
||||
|
||||
if (ichunkaccess instanceof Chunk) {
|
||||
((Chunk) ichunkaccess).b(entity);
|
||||
@@ -1029,10 +1195,32 @@
|
||||
this.everyoneSleeping();
|
||||
@@ -863,10 +1020,32 @@
|
||||
entityplayer.a(entity_removalreason);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
@@ -495,7 +450,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||
|
||||
@@ -1041,6 +1229,12 @@
|
||||
@@ -875,6 +1054,12 @@
|
||||
double d1 = (double) blockposition.getY() - entityplayer.locY();
|
||||
double d2 = (double) blockposition.getZ() - entityplayer.locZ();
|
||||
|
||||
@@ -506,17 +461,17 @@
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
|
||||
entityplayer.playerConnection.sendPacket(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
|
||||
entityplayer.connection.sendPacket(new PacketPlayOutBlockBreakAnimation(i, blockposition, j));
|
||||
}
|
||||
@@ -1079,7 +1273,18 @@
|
||||
Iterator iterator = this.navigators.iterator();
|
||||
@@ -923,7 +1108,18 @@
|
||||
Iterator iterator = this.navigatingMobs.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
- NavigationAbstract navigationabstract = (NavigationAbstract) iterator.next();
|
||||
- EntityInsentient entityinsentient = (EntityInsentient) iterator.next();
|
||||
+ // CraftBukkit start - fix SPIGOT-6362
|
||||
+ NavigationAbstract navigationabstract;
|
||||
+ EntityInsentient entityinsentient;
|
||||
+ try {
|
||||
+ navigationabstract = (NavigationAbstract) iterator.next();
|
||||
+ entityinsentient = (EntityInsentient) iterator.next();
|
||||
+ } catch (java.util.ConcurrentModificationException ex) {
|
||||
+ // This can happen because the pathfinder update below may trigger a chunk load, which in turn may cause more navigators to register
|
||||
+ // In this case we just run the update again across all the iterators as the chunk will then be loaded
|
||||
@@ -525,10 +480,10 @@
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
NavigationAbstract navigationabstract = entityinsentient.getNavigation();
|
||||
|
||||
if (!navigationabstract.i()) {
|
||||
navigationabstract.b(blockposition);
|
||||
@@ -1101,10 +1306,20 @@
|
||||
@@ -946,10 +1142,20 @@
|
||||
|
||||
@Override
|
||||
public Explosion createExplosion(@Nullable Entity entity, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator explosiondamagecalculator, double d0, double d1, double d2, float f, boolean flag, Explosion.Effect explosion_effect) {
|
||||
@@ -549,7 +504,7 @@
|
||||
if (explosion_effect == Explosion.Effect.NONE) {
|
||||
explosion.clearBlocks();
|
||||
}
|
||||
@@ -1169,13 +1384,20 @@
|
||||
@@ -1023,13 +1229,20 @@
|
||||
}
|
||||
|
||||
public <T extends ParticleParam> int a(T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
|
||||
@@ -572,85 +527,39 @@
|
||||
++j;
|
||||
}
|
||||
}
|
||||
@@ -1217,7 +1439,7 @@
|
||||
@@ -1079,7 +1292,7 @@
|
||||
|
||||
@Nullable
|
||||
public BlockPosition a(StructureGenerator<?> structuregenerator, BlockPosition blockposition, int i, boolean flag) {
|
||||
- return !this.server.getSaveData().getGeneratorSettings().shouldGenerateMapFeatures() ? null : this.getChunkProvider().getChunkGenerator().findNearestMapFeature(this, structuregenerator, blockposition, i, flag);
|
||||
+ return !this.worldDataServer.getGeneratorSettings().shouldGenerateMapFeatures() ? null : this.getChunkProvider().getChunkGenerator().findNearestMapFeature(this, structuregenerator, blockposition, i, flag); // CraftBukkit
|
||||
+ return !this.serverLevelData.getGeneratorSettings().shouldGenerateMapFeatures() ? null : this.getChunkProvider().getChunkGenerator().findNearestMapFeature(this, structuregenerator, blockposition, i, flag); // CraftBukkit
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1255,7 +1477,13 @@
|
||||
@@ -1116,11 +1329,21 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public WorldMap a(String s) {
|
||||
return (WorldMap) this.getMinecraftServer().E().getWorldPersistentData().b(() -> {
|
||||
- return new WorldMap(s);
|
||||
- return (WorldMap) this.getMinecraftServer().F().getWorldPersistentData().a(WorldMap::b, s);
|
||||
+ return (WorldMap) this.getMinecraftServer().F().getWorldPersistentData().a((nbttagcompound) -> {
|
||||
+ // CraftBukkit start
|
||||
+ // We only get here when the data file exists, but is not a valid map
|
||||
+ WorldMap newMap = new WorldMap(s);
|
||||
+ WorldMap newMap = WorldMap.b(nbttagcompound);
|
||||
+ newMap.id = s;
|
||||
+ MapInitializeEvent event = new MapInitializeEvent(newMap.mapView);
|
||||
+ Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
+ return newMap;
|
||||
+ // CraftBukkit end
|
||||
}, s);
|
||||
+ }, s);
|
||||
}
|
||||
|
||||
@@ -1386,9 +1614,9 @@
|
||||
reputationhandler.a(reputationevent, entity);
|
||||
@Override
|
||||
public void a(String s, WorldMap worldmap) {
|
||||
+ worldmap.id = s; // CraftBukkit
|
||||
this.getMinecraftServer().F().getWorldPersistentData().a(s, (PersistentBase) worldmap);
|
||||
}
|
||||
|
||||
- public void a(Path path) throws IOException {
|
||||
+ public void a(java.nio.file.Path java_nio_file_path) throws IOException {
|
||||
PlayerChunkMap playerchunkmap = this.getChunkProvider().playerChunkMap;
|
||||
- BufferedWriter bufferedwriter = Files.newBufferedWriter(path.resolve("stats.txt"));
|
||||
+ BufferedWriter bufferedwriter = Files.newBufferedWriter(java_nio_file_path.resolve("stats.txt"));
|
||||
Throwable throwable = null;
|
||||
|
||||
try {
|
||||
@@ -1432,7 +1660,7 @@
|
||||
CrashReport crashreport = new CrashReport("Level dump", new Exception("dummy"));
|
||||
|
||||
this.a(crashreport);
|
||||
- BufferedWriter bufferedwriter1 = Files.newBufferedWriter(path.resolve("example_crash.txt"));
|
||||
+ BufferedWriter bufferedwriter1 = Files.newBufferedWriter(java_nio_file_path.resolve("example_crash.txt"));
|
||||
Throwable throwable3 = null;
|
||||
|
||||
try {
|
||||
@@ -1455,8 +1683,8 @@
|
||||
|
||||
}
|
||||
|
||||
- Path path1 = path.resolve("chunks.csv");
|
||||
- BufferedWriter bufferedwriter2 = Files.newBufferedWriter(path1);
|
||||
+ java.nio.file.Path java_nio_file_path1 = java_nio_file_path.resolve("chunks.csv");
|
||||
+ BufferedWriter bufferedwriter2 = Files.newBufferedWriter(java_nio_file_path1);
|
||||
Throwable throwable6 = null;
|
||||
|
||||
try {
|
||||
@@ -1479,8 +1707,8 @@
|
||||
|
||||
}
|
||||
|
||||
- Path path2 = path.resolve("entities.csv");
|
||||
- BufferedWriter bufferedwriter3 = Files.newBufferedWriter(path2);
|
||||
+ java.nio.file.Path java_nio_file_path2 = java_nio_file_path.resolve("entities.csv");
|
||||
+ BufferedWriter bufferedwriter3 = Files.newBufferedWriter(java_nio_file_path2);
|
||||
Throwable throwable9 = null;
|
||||
|
||||
try {
|
||||
@@ -1503,8 +1731,8 @@
|
||||
|
||||
}
|
||||
|
||||
- Path path3 = path.resolve("block_entities.csv");
|
||||
- BufferedWriter bufferedwriter4 = Files.newBufferedWriter(path3);
|
||||
+ java.nio.file.Path java_nio_file_path3 = java_nio_file_path.resolve("block_entities.csv");
|
||||
+ BufferedWriter bufferedwriter4 = Files.newBufferedWriter(java_nio_file_path3);
|
||||
Throwable throwable12 = null;
|
||||
|
||||
try {
|
||||
@@ -1566,6 +1794,11 @@
|
||||
@@ -1432,6 +1655,11 @@
|
||||
@Override
|
||||
public void update(BlockPosition blockposition, Block block) {
|
||||
if (!this.isDebugWorld()) {
|
||||
@@ -662,53 +571,40 @@
|
||||
this.applyPhysics(blockposition, block);
|
||||
}
|
||||
|
||||
@@ -1580,12 +1813,12 @@
|
||||
@@ -1451,12 +1679,12 @@
|
||||
}
|
||||
|
||||
public boolean isFlatWorld() {
|
||||
- return this.server.getSaveData().getGeneratorSettings().isFlatWorld();
|
||||
+ return this.worldDataServer.getGeneratorSettings().isFlatWorld(); // CraftBukkit
|
||||
+ return this.serverLevelData.getGeneratorSettings().isFlatWorld(); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSeed() {
|
||||
- return this.server.getSaveData().getGeneratorSettings().getSeed();
|
||||
+ return this.worldDataServer.getGeneratorSettings().getSeed(); // CraftBukkit
|
||||
+ return this.serverLevelData.getGeneratorSettings().getSeed(); // CraftBukkit
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1605,9 +1838,9 @@
|
||||
|
||||
@VisibleForTesting
|
||||
public String F() {
|
||||
- return String.format("players: %s, entities: %d [%s], block_entities: %d [%s], block_ticks: %d, fluid_ticks: %d, chunk_source: %s", this.players.size(), this.entitiesById.size(), a((Collection) this.entitiesById.values(), (entity) -> {
|
||||
+ return String.format("players: %s, entities: %d [%s], block_entities: %d [%s], block_ticks: %d, fluid_ticks: %d, chunk_source: %s", this.players.size(), this.entitiesById.size(), a(this.entitiesById.values(), (entity) -> { // CraftBukkit - decompile error
|
||||
return IRegistry.ENTITY_TYPE.getKey(entity.getEntityType());
|
||||
- }), this.tileEntityListTick.size(), a((Collection) this.tileEntityListTick, (tileentity) -> {
|
||||
+ }), this.tileEntityListTick.size(), a(this.tileEntityListTick, (tileentity) -> { // CraftBukkit - decompile error
|
||||
return IRegistry.BLOCK_ENTITY_TYPE.getKey(tileentity.getTileType());
|
||||
}), this.getBlockTickList().a(), this.getFluidTickList().a(), this.P());
|
||||
}
|
||||
@@ -1615,7 +1848,7 @@
|
||||
private static <T> String a(Collection<T> collection, Function<T, MinecraftKey> function) {
|
||||
@@ -1484,7 +1712,7 @@
|
||||
private static <T> String a(Iterable<T> iterable, Function<T, String> function) {
|
||||
try {
|
||||
Object2IntOpenHashMap<MinecraftKey> object2intopenhashmap = new Object2IntOpenHashMap();
|
||||
- Iterator iterator = collection.iterator();
|
||||
+ Iterator<T> iterator = collection.iterator(); // CraftBukkit - decompile error
|
||||
Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap();
|
||||
- Iterator iterator = iterable.iterator();
|
||||
+ Iterator<T> iterator = iterable.iterator(); // CraftBukkit - decompile error
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
T t0 = iterator.next();
|
||||
@@ -1624,7 +1857,8 @@
|
||||
object2intopenhashmap.addTo(minecraftkey, 1);
|
||||
@@ -1493,7 +1721,7 @@
|
||||
object2intopenhashmap.addTo(s, 1);
|
||||
}
|
||||
|
||||
- return (String) object2intopenhashmap.object2IntEntrySet().stream().sorted(Comparator.comparing(it.unimi.dsi.fastutil.objects.Object2IntMap.Entry::getIntValue).reversed()).limit(5L).map((it_unimi_dsi_fastutil_objects_object2intmap_entry) -> {
|
||||
+ // CraftBukkit - decompile error
|
||||
+ return (String) object2intopenhashmap.object2IntEntrySet().stream().sorted(Comparator.comparing(it.unimi.dsi.fastutil.objects.Object2IntMap.Entry<MinecraftKey>::getIntValue).reversed()).limit(5L).map((it_unimi_dsi_fastutil_objects_object2intmap_entry) -> {
|
||||
return it_unimi_dsi_fastutil_objects_object2intmap_entry.getKey() + ":" + it_unimi_dsi_fastutil_objects_object2intmap_entry.getIntValue();
|
||||
}).collect(Collectors.joining(","));
|
||||
} catch (Exception exception) {
|
||||
@@ -1633,16 +1867,32 @@
|
||||
- return (String) object2intopenhashmap.object2IntEntrySet().stream().sorted(Comparator.comparing(Entry::getIntValue).reversed()).limit(5L).map((entry) -> {
|
||||
+ return (String) object2intopenhashmap.object2IntEntrySet().stream().sorted(Comparator.comparing(Entry<String>::getIntValue).reversed()).limit(5L).map((entry) -> { // CraftBukkit - decompile error
|
||||
String s1 = (String) entry.getKey();
|
||||
|
||||
return s1 + ":" + entry.getIntValue();
|
||||
@@ -1504,17 +1732,33 @@
|
||||
}
|
||||
|
||||
public static void a(WorldServer worldserver) {
|
||||
@@ -718,7 +614,7 @@
|
||||
+
|
||||
+ public static void a(WorldServer worldserver, Entity entity) {
|
||||
+ // CraftBukkit end
|
||||
BlockPosition blockposition = WorldServer.a;
|
||||
BlockPosition blockposition = WorldServer.END_SPAWN_POINT;
|
||||
int i = blockposition.getX();
|
||||
int j = blockposition.getY() - 2;
|
||||
int k = blockposition.getZ();
|
||||
@@ -742,4 +638,21 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1601,6 +1845,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ entity.valid = true; // CraftBukkit
|
||||
}
|
||||
|
||||
public void a(Entity entity) {
|
||||
@@ -1633,6 +1878,7 @@
|
||||
gameeventlistenerregistrar.a(entity.level);
|
||||
}
|
||||
|
||||
+ entity.valid = false; // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user