Only process BlockPhysicsEvent if a plugin has a listener

Saves on some object allocation and processing when no plugin listens to this
This commit is contained in:
Aikar 2016-03-28 19:55:45 -04:00
parent b2671f4dd1
commit 63fa3068c6
5 changed files with 54 additions and 51 deletions

View File

@ -933,7 +933,7 @@
} }
private ServerStatus.Players buildPlayerStatus() { private ServerStatus.Players buildPlayerStatus() {
@@ -1154,11 +1561,27 @@ @@ -1154,24 +1561,43 @@
this.getPlayerList().getPlayers().forEach((entityplayer) -> { this.getPlayerList().getPlayers().forEach((entityplayer) -> {
entityplayer.connection.suspendFlushing(); entityplayer.connection.suspendFlushing();
}); });
@ -960,8 +960,10 @@
+ +
while (iterator.hasNext()) { while (iterator.hasNext()) {
ServerLevel worldserver = (ServerLevel) iterator.next(); ServerLevel worldserver = (ServerLevel) iterator.next();
+ worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - BlockPhysicsEvent
@@ -1167,11 +1590,13 @@ gameprofilerfiller.push(() -> {
String s = String.valueOf(worldserver);
return s + " " + String.valueOf(worldserver.dimension().location()); return s + " " + String.valueOf(worldserver.dimension().location());
}); });
@ -975,7 +977,7 @@
gameprofilerfiller.push("tick"); gameprofilerfiller.push("tick");
@@ -1186,6 +1611,7 @@ @@ -1186,6 +1612,7 @@
gameprofilerfiller.pop(); gameprofilerfiller.pop();
gameprofilerfiller.pop(); gameprofilerfiller.pop();
@ -983,7 +985,7 @@
} }
gameprofilerfiller.popPush("connection"); gameprofilerfiller.popPush("connection");
@@ -1265,7 +1691,23 @@ @@ -1265,7 +1692,23 @@
@Nullable @Nullable
public ServerLevel getLevel(ResourceKey<Level> key) { public ServerLevel getLevel(ResourceKey<Level> key) {
return (ServerLevel) this.levels.get(key); return (ServerLevel) this.levels.get(key);
@ -1007,7 +1009,7 @@
public Set<ResourceKey<Level>> levelKeys() { public Set<ResourceKey<Level>> levelKeys() {
return this.levels.keySet(); return this.levels.keySet();
@@ -1296,7 +1738,7 @@ @@ -1296,7 +1739,7 @@
@DontObfuscate @DontObfuscate
public String getServerModName() { public String getServerModName() {
@ -1016,7 +1018,7 @@
} }
public SystemReport fillSystemReport(SystemReport details) { public SystemReport fillSystemReport(SystemReport details) {
@@ -1347,7 +1789,7 @@ @@ -1347,7 +1790,7 @@
@Override @Override
public void sendSystemMessage(Component message) { public void sendSystemMessage(Component message) {
@ -1025,7 +1027,7 @@
} }
public KeyPair getKeyPair() { public KeyPair getKeyPair() {
@@ -1481,10 +1923,20 @@ @@ -1481,10 +1924,20 @@
@Override @Override
public String getMotd() { public String getMotd() {
@ -1047,7 +1049,7 @@
this.motd = motd; this.motd = motd;
} }
@@ -1507,7 +1959,7 @@ @@ -1507,7 +1960,7 @@
} }
public ServerConnectionListener getConnection() { public ServerConnectionListener getConnection() {
@ -1056,7 +1058,7 @@
} }
public boolean isReady() { public boolean isReady() {
@@ -1634,11 +2086,11 @@ @@ -1634,11 +2087,11 @@
public CompletableFuture<Void> reloadResources(Collection<String> dataPacks) { public CompletableFuture<Void> reloadResources(Collection<String> dataPacks) {
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> { CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
@ -1070,7 +1072,7 @@
}, this).thenCompose((immutablelist) -> { }, this).thenCompose((immutablelist) -> {
MultiPackResourceManager resourcemanager = new MultiPackResourceManager(PackType.SERVER_DATA, immutablelist); MultiPackResourceManager resourcemanager = new MultiPackResourceManager(PackType.SERVER_DATA, immutablelist);
List<Registry.PendingTags<?>> list = TagLoader.loadTagsForExistingRegistries(resourcemanager, this.registries.compositeAccess()); List<Registry.PendingTags<?>> list = TagLoader.loadTagsForExistingRegistries(resourcemanager, this.registries.compositeAccess());
@@ -1654,6 +2106,7 @@ @@ -1654,6 +2107,7 @@
}).thenAcceptAsync((minecraftserver_reloadableresources) -> { }).thenAcceptAsync((minecraftserver_reloadableresources) -> {
this.resources.close(); this.resources.close();
this.resources = minecraftserver_reloadableresources; this.resources = minecraftserver_reloadableresources;
@ -1078,7 +1080,7 @@
this.packRepository.setSelected(dataPacks); this.packRepository.setSelected(dataPacks);
WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(MinecraftServer.getSelectedPacks(this.packRepository, true), this.worldData.enabledFeatures()); WorldDataConfiguration worlddataconfiguration = new WorldDataConfiguration(MinecraftServer.getSelectedPacks(this.packRepository, true), this.worldData.enabledFeatures());
@@ -1952,7 +2405,7 @@ @@ -1952,7 +2406,7 @@
final List<String> list = Lists.newArrayList(); final List<String> list = Lists.newArrayList();
final GameRules gamerules = this.getGameRules(); final GameRules gamerules = this.getGameRules();
@ -1087,7 +1089,7 @@
@Override @Override
public <T extends GameRules.Value<T>> void visit(GameRules.Key<T> key, GameRules.Type<T> type) { public <T extends GameRules.Value<T>> void visit(GameRules.Key<T> key, GameRules.Type<T> type) {
list.add(String.format(Locale.ROOT, "%s=%s\n", key.getId(), gamerules.getRule(key))); list.add(String.format(Locale.ROOT, "%s=%s\n", key.getId(), gamerules.getRule(key)));
@@ -2058,7 +2511,7 @@ @@ -2058,7 +2512,7 @@
try { try {
label51: label51:
{ {
@ -1096,7 +1098,7 @@
try { try {
arraylist = Lists.newArrayList(NativeModuleLister.listModules()); arraylist = Lists.newArrayList(NativeModuleLister.listModules());
@@ -2108,6 +2561,22 @@ @@ -2108,6 +2562,22 @@
} }
@ -1119,7 +1121,7 @@
private ProfilerFiller createProfiler() { private ProfilerFiller createProfiler() {
if (this.willStartRecordingMetrics) { if (this.willStartRecordingMetrics) {
this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(Util.timeSource, this.isDedicatedServer()), Util.timeSource, Util.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> { this.metricsRecorder = ActiveMetricsRecorder.createStarted(new ServerMetricsSamplersProvider(Util.timeSource, this.isDedicatedServer()), Util.timeSource, Util.ioPool(), new MetricsPersister("server"), this.onMetricsRecordingStopped, (path) -> {
@@ -2225,18 +2694,24 @@ @@ -2225,18 +2695,24 @@
} }
public void logChatMessage(Component message, ChatType.Bound params, @Nullable String prefix) { public void logChatMessage(Component message, ChatType.Bound params, @Nullable String prefix) {

View File

@ -61,7 +61,7 @@
private int lastSpawnChunkRadius; private int lastSpawnChunkRadius;
final EntityTickList entityTickList = new EntityTickList(); final EntityTickList entityTickList = new EntityTickList();
public final PersistentEntitySectionManager<Entity> entityManager; public final PersistentEntitySectionManager<Entity> entityManager;
@@ -214,52 +226,184 @@ @@ -214,52 +226,185 @@
private final boolean tickTime; private final boolean tickTime;
private final RandomSequences randomSequences; private final RandomSequences randomSequences;
@ -78,6 +78,7 @@
+ // CraftBukkit start + // CraftBukkit start
+ public final LevelStorageSource.LevelStorageAccess convertable; + public final LevelStorageSource.LevelStorageAccess convertable;
+ public final UUID uuid; + public final UUID uuid;
+ public boolean hasPhysicsEvent = true; // Paper - BlockPhysicsEvent
+ +
+ public LevelChunk getChunkIfLoaded(int x, int z) { + public LevelChunk getChunkIfLoaded(int x, int z) {
+ return this.chunkSource.getChunk(x, z, false); + return this.chunkSource.getChunk(x, z, false);
@ -270,7 +271,7 @@
} }
/** @deprecated */ /** @deprecated */
@@ -305,12 +449,20 @@ @@ -305,12 +450,20 @@
long j; long j;
if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) { if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) {
@ -294,7 +295,7 @@
if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) { if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) {
this.resetWeatherCycle(); this.resetWeatherCycle();
} }
@@ -345,7 +497,7 @@ @@ -345,7 +498,7 @@
this.handlingTick = false; this.handlingTick = false;
gameprofilerfiller.pop(); gameprofilerfiller.pop();
@ -303,7 +304,7 @@
if (flag1) { if (flag1) {
this.resetEmptyTime(); this.resetEmptyTime();
@@ -359,6 +511,7 @@ @@ -359,6 +512,7 @@
gameprofilerfiller.pop(); gameprofilerfiller.pop();
} }
@ -311,7 +312,7 @@
this.entityTickList.forEach((entity) -> { this.entityTickList.forEach((entity) -> {
if (!entity.isRemoved()) { if (!entity.isRemoved()) {
if (!tickratemanager.isEntityFrozen(entity)) { if (!tickratemanager.isEntityFrozen(entity)) {
@@ -429,7 +582,7 @@ @@ -429,7 +583,7 @@
private void wakeUpAllPlayers() { private void wakeUpAllPlayers() {
this.sleepStatus.removeAllSleepers(); this.sleepStatus.removeAllSleepers();
@ -320,7 +321,7 @@
entityplayer.stopSleepInBed(false, false); entityplayer.stopSleepInBed(false, false);
}); });
} }
@@ -442,12 +595,12 @@ @@ -442,12 +596,12 @@
ProfilerFiller gameprofilerfiller = Profiler.get(); ProfilerFiller gameprofilerfiller = Profiler.get();
gameprofilerfiller.push("thunder"); gameprofilerfiller.push("thunder");
@ -335,7 +336,7 @@
if (flag1) { if (flag1) {
SkeletonHorse entityhorseskeleton = (SkeletonHorse) EntityType.SKELETON_HORSE.create(this, EntitySpawnReason.EVENT); SkeletonHorse entityhorseskeleton = (SkeletonHorse) EntityType.SKELETON_HORSE.create(this, EntitySpawnReason.EVENT);
@@ -456,7 +609,7 @@ @@ -456,7 +610,7 @@
entityhorseskeleton.setTrap(true); entityhorseskeleton.setTrap(true);
entityhorseskeleton.setAge(0); entityhorseskeleton.setAge(0);
entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ()); entityhorseskeleton.setPos((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ());
@ -344,7 +345,7 @@
} }
} }
@@ -465,18 +618,20 @@ @@ -465,18 +619,20 @@
if (entitylightning != null) { if (entitylightning != null) {
entitylightning.moveTo(Vec3.atBottomCenterOf(blockposition)); entitylightning.moveTo(Vec3.atBottomCenterOf(blockposition));
entitylightning.setVisualOnly(flag1); entitylightning.setVisualOnly(flag1);
@ -366,7 +367,7 @@
gameprofilerfiller.popPush("tickBlocks"); gameprofilerfiller.popPush("tickBlocks");
if (randomTickSpeed > 0) { if (randomTickSpeed > 0) {
@@ -521,7 +676,7 @@ @@ -521,7 +677,7 @@
Biome biomebase = (Biome) this.getBiome(blockposition1).value(); Biome biomebase = (Biome) this.getBiome(blockposition1).value();
if (biomebase.shouldFreeze(this, blockposition2)) { if (biomebase.shouldFreeze(this, blockposition2)) {
@ -375,7 +376,7 @@
} }
if (this.isRaining()) { if (this.isRaining()) {
@@ -537,10 +692,10 @@ @@ -537,10 +693,10 @@
BlockState iblockdata1 = (BlockState) iblockdata.setValue(SnowLayerBlock.LAYERS, j + 1); BlockState iblockdata1 = (BlockState) iblockdata.setValue(SnowLayerBlock.LAYERS, j + 1);
Block.pushEntitiesUp(iblockdata, iblockdata1, this, blockposition1); Block.pushEntitiesUp(iblockdata, iblockdata1, this, blockposition1);
@ -388,7 +389,7 @@
} }
} }
@@ -701,33 +856,67 @@ @@ -701,33 +857,67 @@
this.rainLevel = Mth.clamp(this.rainLevel, 0.0F, 1.0F); this.rainLevel = Mth.clamp(this.rainLevel, 0.0F, 1.0F);
} }
@ -464,7 +465,7 @@
} }
public void resetEmptyTime() { public void resetEmptyTime() {
@@ -754,6 +943,13 @@ @@ -754,6 +944,13 @@
} }
public void tickNonPassenger(Entity entity) { public void tickNonPassenger(Entity entity) {
@ -478,7 +479,7 @@
entity.setOldPosAndRot(); entity.setOldPosAndRot();
ProfilerFiller gameprofilerfiller = Profiler.get(); ProfilerFiller gameprofilerfiller = Profiler.get();
@@ -763,6 +959,7 @@ @@ -763,6 +960,7 @@
}); });
gameprofilerfiller.incrementCounter("tickNonPassenger"); gameprofilerfiller.incrementCounter("tickNonPassenger");
entity.tick(); entity.tick();
@ -486,7 +487,7 @@
gameprofilerfiller.pop(); gameprofilerfiller.pop();
Iterator iterator = entity.getPassengers().iterator(); Iterator iterator = entity.getPassengers().iterator();
@@ -786,6 +983,7 @@ @@ -786,6 +984,7 @@
}); });
gameprofilerfiller.incrementCounter("tickPassenger"); gameprofilerfiller.incrementCounter("tickPassenger");
passenger.rideTick(); passenger.rideTick();
@ -494,7 +495,7 @@
gameprofilerfiller.pop(); gameprofilerfiller.pop();
Iterator iterator = passenger.getPassengers().iterator(); Iterator iterator = passenger.getPassengers().iterator();
@@ -810,6 +1008,7 @@ @@ -810,6 +1009,7 @@
ServerChunkCache chunkproviderserver = this.getChunkSource(); ServerChunkCache chunkproviderserver = this.getChunkSource();
if (!savingDisabled) { if (!savingDisabled) {
@ -502,7 +503,7 @@
if (progressListener != null) { if (progressListener != null) {
progressListener.progressStartNoAbort(Component.translatable("menu.savingLevel")); progressListener.progressStartNoAbort(Component.translatable("menu.savingLevel"));
} }
@@ -827,11 +1026,19 @@ @@ -827,11 +1027,19 @@
} }
} }
@ -523,7 +524,7 @@
} }
DimensionDataStorage worldpersistentdata = this.getChunkSource().getDataStorage(); DimensionDataStorage worldpersistentdata = this.getChunkSource().getDataStorage();
@@ -903,18 +1110,40 @@ @@ -903,18 +1111,40 @@
@Override @Override
public boolean addFreshEntity(Entity entity) { public boolean addFreshEntity(Entity entity) {
@ -567,7 +568,7 @@
} }
} }
@@ -939,41 +1168,86 @@ @@ -939,41 +1169,86 @@
this.entityManager.addNewEntity(player); this.entityManager.addNewEntity(player);
} }
@ -659,7 +660,7 @@
while (iterator.hasNext()) { while (iterator.hasNext()) {
ServerPlayer entityplayer = (ServerPlayer) iterator.next(); ServerPlayer entityplayer = (ServerPlayer) iterator.next();
@@ -982,6 +1256,12 @@ @@ -982,6 +1257,12 @@
double d1 = (double) pos.getY() - entityplayer.getY(); double d1 = (double) pos.getY() - entityplayer.getY();
double d2 = (double) pos.getZ() - entityplayer.getZ(); double d2 = (double) pos.getZ() - entityplayer.getZ();
@ -672,7 +673,7 @@
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) { if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D) {
entityplayer.connection.send(new ClientboundBlockDestructionPacket(entityId, pos, progress)); entityplayer.connection.send(new ClientboundBlockDestructionPacket(entityId, pos, progress));
} }
@@ -1060,7 +1340,18 @@ @@ -1060,7 +1341,18 @@
Iterator iterator = this.navigatingMobs.iterator(); Iterator iterator = this.navigatingMobs.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
@ -692,7 +693,7 @@
PathNavigation navigationabstract = entityinsentient.getNavigation(); PathNavigation navigationabstract = entityinsentient.getNavigation();
if (navigationabstract.shouldRecomputePath(pos)) { if (navigationabstract.shouldRecomputePath(pos)) {
@@ -1126,9 +1417,15 @@ @@ -1126,9 +1418,15 @@
@Override @Override
public void explode(@Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Level.ExplosionInteraction explosionSourceType, ParticleOptions smallParticle, ParticleOptions largeParticle, Holder<SoundEvent> soundEvent) { public void explode(@Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Level.ExplosionInteraction explosionSourceType, ParticleOptions smallParticle, ParticleOptions largeParticle, Holder<SoundEvent> soundEvent) {
@ -709,7 +710,7 @@
case NONE: case NONE:
explosion_effect = Explosion.BlockInteraction.KEEP; explosion_effect = Explosion.BlockInteraction.KEEP;
break; break;
@@ -1144,16 +1441,26 @@ @@ -1144,16 +1442,26 @@
case TRIGGER: case TRIGGER:
explosion_effect = Explosion.BlockInteraction.TRIGGER_BLOCK; explosion_effect = Explosion.BlockInteraction.TRIGGER_BLOCK;
break; break;
@ -739,7 +740,7 @@
Iterator iterator = this.players.iterator(); Iterator iterator = this.players.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
@@ -1162,10 +1469,11 @@ @@ -1162,10 +1470,11 @@
if (entityplayer.distanceToSqr(vec3d) < 4096.0D) { if (entityplayer.distanceToSqr(vec3d) < 4096.0D) {
Optional<Vec3> optional = Optional.ofNullable((Vec3) serverexplosion.getHitPlayers().get(entityplayer)); Optional<Vec3> optional = Optional.ofNullable((Vec3) serverexplosion.getHitPlayers().get(entityplayer));
@ -752,7 +753,7 @@
} }
private Explosion.BlockInteraction getDestroyType(GameRules.Key<GameRules.BooleanValue> decayRule) { private Explosion.BlockInteraction getDestroyType(GameRules.Key<GameRules.BooleanValue> decayRule) {
@@ -1226,17 +1534,24 @@ @@ -1226,17 +1535,24 @@
} }
public <T extends ParticleOptions> int sendParticles(T parameters, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double speed) { public <T extends ParticleOptions> int sendParticles(T parameters, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double speed) {
@ -780,7 +781,7 @@
++j; ++j;
} }
} }
@@ -1292,7 +1607,7 @@ @@ -1292,7 +1608,7 @@
@Nullable @Nullable
public BlockPos findNearestMapStructure(TagKey<Structure> structureTag, BlockPos pos, int radius, boolean skipReferencedStructures) { public BlockPos findNearestMapStructure(TagKey<Structure> structureTag, BlockPos pos, int radius, boolean skipReferencedStructures) {
@ -789,7 +790,7 @@
return null; return null;
} else { } else {
Optional<HolderSet.Named<Structure>> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(structureTag); Optional<HolderSet.Named<Structure>> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(structureTag);
@@ -1334,11 +1649,22 @@ @@ -1334,11 +1650,22 @@
@Nullable @Nullable
@Override @Override
public MapItemSavedData getMapData(MapId id) { public MapItemSavedData getMapData(MapId id) {
@ -813,7 +814,7 @@
this.getServer().overworld().getDataStorage().set(id.key(), state); this.getServer().overworld().getDataStorage().set(id.key(), state);
} }
@@ -1649,6 +1975,11 @@ @@ -1649,6 +1976,11 @@
@Override @Override
public void blockUpdated(BlockPos pos, Block block) { public void blockUpdated(BlockPos pos, Block block) {
if (!this.isDebug()) { if (!this.isDebug()) {
@ -825,7 +826,7 @@
this.updateNeighborsAt(pos, block); this.updateNeighborsAt(pos, block);
} }
@@ -1668,12 +1999,12 @@ @@ -1668,12 +2000,12 @@
} }
public boolean isFlat() { public boolean isFlat() {
@ -840,7 +841,7 @@
} }
@Nullable @Nullable
@@ -1696,7 +2027,7 @@ @@ -1696,7 +2028,7 @@
private static <T> String getTypeCount(Iterable<T> items, Function<T, String> classifier) { private static <T> String getTypeCount(Iterable<T> items, Function<T, String> classifier) {
try { try {
Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap(); Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap();
@ -849,7 +850,7 @@
while (iterator.hasNext()) { while (iterator.hasNext()) {
T t0 = iterator.next(); T t0 = iterator.next();
@@ -1705,7 +2036,7 @@ @@ -1705,7 +2037,7 @@
object2intopenhashmap.addTo(s, 1); object2intopenhashmap.addTo(s, 1);
} }
@ -858,7 +859,7 @@
String s1 = (String) entry.getKey(); String s1 = (String) entry.getKey();
return s1 + ":" + entry.getIntValue(); return s1 + ":" + entry.getIntValue();
@@ -1717,6 +2048,7 @@ @@ -1717,6 +2049,7 @@
@Override @Override
public LevelEntityGetter<Entity> getEntities() { public LevelEntityGetter<Entity> getEntities() {
@ -866,7 +867,7 @@
return this.entityManager.getEntityGetter(); return this.entityManager.getEntityGetter();
} }
@@ -1836,6 +2168,7 @@ @@ -1836,6 +2169,7 @@
} }
public void onTrackingStart(Entity entity) { public void onTrackingStart(Entity entity) {
@ -874,7 +875,7 @@
ServerLevel.this.getChunkSource().addEntity(entity); ServerLevel.this.getChunkSource().addEntity(entity);
if (entity instanceof ServerPlayer entityplayer) { if (entity instanceof ServerPlayer entityplayer) {
ServerLevel.this.players.add(entityplayer); ServerLevel.this.players.add(entityplayer);
@@ -1864,9 +2197,51 @@ @@ -1864,9 +2198,51 @@
} }
entity.updateDynamicGameEventListener(DynamicGameEventListener::add); entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
@ -926,7 +927,7 @@
ServerLevel.this.getChunkSource().removeEntity(entity); ServerLevel.this.getChunkSource().removeEntity(entity);
if (entity instanceof ServerPlayer entityplayer) { if (entity instanceof ServerPlayer entityplayer) {
ServerLevel.this.players.remove(entityplayer); ServerLevel.this.players.remove(entityplayer);
@@ -1895,6 +2270,14 @@ @@ -1895,6 +2271,14 @@
} }
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove); entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);

View File

@ -415,7 +415,7 @@
+ // CraftBukkit start + // CraftBukkit start
+ iblockdata1.updateIndirectNeighbourShapes(this, blockposition, k, j - 1); // Don't call an event for the old block to limit event spam + iblockdata1.updateIndirectNeighbourShapes(this, blockposition, k, j - 1); // Don't call an event for the old block to limit event spam
+ CraftWorld world = ((ServerLevel) this).getWorld(); + CraftWorld world = ((ServerLevel) this).getWorld();
+ if (world != null) { + if (world != null && ((ServerLevel)this).hasPhysicsEvent) { // Paper - BlockPhysicsEvent
+ BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftBlockData.fromData(iblockdata)); + BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftBlockData.fromData(iblockdata));
+ this.getCraftServer().getPluginManager().callEvent(event); + this.getCraftServer().getPluginManager().callEvent(event);
+ +

View File

@ -16,7 +16,7 @@
+ // CraftBukkit start + // CraftBukkit start
+ if (!state.canSurvive(world, pos)) { + if (!state.canSurvive(world, pos)) {
+ // Suppress during worldgen + // Suppress during worldgen
+ if (!(world instanceof Level world1) || !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world1, pos).isCancelled()) { + if (!(world instanceof net.minecraft.server.level.ServerLevel world1 && world1.hasPhysicsEvent) || !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world1, pos).isCancelled()) { // Paper
+ return Blocks.AIR.defaultBlockState(); + return Blocks.AIR.defaultBlockState();
+ } + }
+ } + }

View File

@ -5,7 +5,7 @@
protected static void preventDropFromBottomPart(Level world, BlockPos pos, BlockState state, Player player) { protected static void preventDropFromBottomPart(Level world, BlockPos pos, BlockState state, Player player) {
+ // CraftBukkit start + // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, pos).isCancelled()) { + if (((net.minecraft.server.level.ServerLevel)world).hasPhysicsEvent && org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, pos).isCancelled()) { // Paper
+ return; + return;
+ } + }
+ // CraftBukkit end + // CraftBukkit end