mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
Prevent GameEvents being fired from unloaded chunks
This commit is contained in:
parent
16b8d46c1c
commit
c060f3fae0
@ -97,7 +97,7 @@
|
||||
+ // be more strict too, add a block (dumb plugins in move events?)
|
||||
+ int minBlockX = Mth.floor(axisalignedbb.minX - 1.0E-7D) - 3;
|
||||
+ int maxBlockX = Mth.floor(axisalignedbb.maxX + 1.0E-7D) + 3;
|
||||
+
|
||||
|
||||
+ int minBlockZ = Mth.floor(axisalignedbb.minZ - 1.0E-7D) - 3;
|
||||
+ int maxBlockZ = Mth.floor(axisalignedbb.maxZ + 1.0E-7D) + 3;
|
||||
+
|
||||
@ -136,7 +136,7 @@
|
||||
+
|
||||
+ int minChunkX = minBlockX >> 4;
|
||||
+ int minChunkZ = minBlockZ >> 4;
|
||||
|
||||
+
|
||||
+ int maxChunkX = maxBlockX >> 4;
|
||||
+ int maxChunkZ = maxBlockZ >> 4;
|
||||
+
|
||||
@ -305,12 +305,13 @@
|
||||
long j;
|
||||
|
||||
if (this.sleepStatus.areEnoughSleeping(i) && this.sleepStatus.areEnoughDeepSleeping(i, this.players)) {
|
||||
- if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) {
|
||||
- j = this.levelData.getDayTime() + 24000L;
|
||||
- this.setDayTime(j - j % 24000L);
|
||||
+ // CraftBukkit start
|
||||
+ j = this.levelData.getDayTime() + 24000L;
|
||||
+ TimeSkipEvent event = new TimeSkipEvent(this.getWorld(), TimeSkipEvent.SkipReason.NIGHT_SKIP, (j - j % 24000L) - this.getDayTime());
|
||||
if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) {
|
||||
- j = this.levelData.getDayTime() + 24000L;
|
||||
- this.setDayTime(j - j % 24000L);
|
||||
+ if (this.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) {
|
||||
+ this.getCraftServer().getPluginManager().callEvent(event);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ this.setDayTime(this.getDayTime() + event.getSkipAmount());
|
||||
@ -770,7 +771,19 @@
|
||||
}
|
||||
|
||||
public int getLogicalHeight() {
|
||||
@@ -1052,6 +1374,7 @@
|
||||
@@ -1039,6 +1361,11 @@
|
||||
|
||||
@Override
|
||||
public void gameEvent(Holder<GameEvent> event, Vec3 emitterPos, GameEvent.Context emitter) {
|
||||
+ // Paper start - Prevent GameEvents being fired from unloaded chunks
|
||||
+ if (this.getChunkIfLoadedImmediately((Mth.floor(emitterPos.x) >> 4), (Mth.floor(emitterPos.z) >> 4)) == null) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end - Prevent GameEvents being fired from unloaded chunks
|
||||
this.gameEventDispatcher.post(event, emitterPos, emitter);
|
||||
}
|
||||
|
||||
@@ -1052,6 +1379,7 @@
|
||||
|
||||
this.getChunkSource().blockChanged(pos);
|
||||
this.pathTypesByPosCache.invalidate(pos);
|
||||
@ -778,7 +791,7 @@
|
||||
VoxelShape voxelshape = oldState.getCollisionShape(this, pos);
|
||||
VoxelShape voxelshape1 = newState.getCollisionShape(this, pos);
|
||||
|
||||
@@ -1060,7 +1383,18 @@
|
||||
@@ -1060,7 +1388,18 @@
|
||||
Iterator iterator = this.navigatingMobs.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@ -798,7 +811,7 @@
|
||||
PathNavigation navigationabstract = entityinsentient.getNavigation();
|
||||
|
||||
if (navigationabstract.shouldRecomputePath(pos)) {
|
||||
@@ -1082,15 +1416,18 @@
|
||||
@@ -1082,15 +1421,18 @@
|
||||
}
|
||||
|
||||
}
|
||||
@ -817,7 +830,7 @@
|
||||
this.neighborUpdater.updateNeighborsAtExceptFromFacing(pos, sourceBlock, (Direction) null, orientation);
|
||||
}
|
||||
|
||||
@@ -1126,9 +1463,20 @@
|
||||
@@ -1126,9 +1468,20 @@
|
||||
|
||||
@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) {
|
||||
@ -839,7 +852,7 @@
|
||||
case NONE:
|
||||
explosion_effect = Explosion.BlockInteraction.KEEP;
|
||||
break;
|
||||
@@ -1144,16 +1492,27 @@
|
||||
@@ -1144,16 +1497,27 @@
|
||||
case TRIGGER:
|
||||
explosion_effect = Explosion.BlockInteraction.TRIGGER_BLOCK;
|
||||
break;
|
||||
@ -870,7 +883,7 @@
|
||||
Iterator iterator = this.players.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -1162,10 +1521,11 @@
|
||||
@@ -1162,10 +1526,11 @@
|
||||
if (entityplayer.distanceToSqr(vec3d) < 4096.0D) {
|
||||
Optional<Vec3> optional = Optional.ofNullable((Vec3) serverexplosion.getHitPlayers().get(entityplayer));
|
||||
|
||||
@ -883,7 +896,7 @@
|
||||
}
|
||||
|
||||
private Explosion.BlockInteraction getDestroyType(GameRules.Key<GameRules.BooleanValue> decayRule) {
|
||||
@@ -1226,17 +1586,29 @@
|
||||
@@ -1226,17 +1591,29 @@
|
||||
}
|
||||
|
||||
public <T extends ParticleOptions> int sendParticles(T parameters, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double speed) {
|
||||
@ -918,7 +931,7 @@
|
||||
++j;
|
||||
}
|
||||
}
|
||||
@@ -1292,7 +1664,7 @@
|
||||
@@ -1292,7 +1669,7 @@
|
||||
|
||||
@Nullable
|
||||
public BlockPos findNearestMapStructure(TagKey<Structure> structureTag, BlockPos pos, int radius, boolean skipReferencedStructures) {
|
||||
@ -927,7 +940,7 @@
|
||||
return null;
|
||||
} else {
|
||||
Optional<HolderSet.Named<Structure>> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(structureTag);
|
||||
@@ -1334,11 +1706,22 @@
|
||||
@@ -1334,11 +1711,22 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public MapItemSavedData getMapData(MapId id) {
|
||||
@ -951,7 +964,7 @@
|
||||
this.getServer().overworld().getDataStorage().set(id.key(), state);
|
||||
}
|
||||
|
||||
@@ -1352,7 +1735,9 @@
|
||||
@@ -1352,7 +1740,9 @@
|
||||
float f1 = this.levelData.getSpawnAngle();
|
||||
|
||||
if (!blockposition1.equals(pos) || f1 != angle) {
|
||||
@ -961,7 +974,7 @@
|
||||
this.getServer().getPlayerList().broadcastAll(new ClientboundSetDefaultSpawnPositionPacket(pos, angle));
|
||||
}
|
||||
|
||||
@@ -1419,6 +1804,11 @@
|
||||
@@ -1419,6 +1809,11 @@
|
||||
});
|
||||
optional1.ifPresent((holder) -> {
|
||||
this.getServer().execute(() -> {
|
||||
@ -973,7 +986,7 @@
|
||||
this.getPoiManager().add(blockposition1, holder);
|
||||
DebugPackets.sendPoiAddedPacket(this, blockposition1);
|
||||
});
|
||||
@@ -1649,6 +2039,11 @@
|
||||
@@ -1649,6 +2044,11 @@
|
||||
@Override
|
||||
public void blockUpdated(BlockPos pos, Block block) {
|
||||
if (!this.isDebug()) {
|
||||
@ -985,7 +998,7 @@
|
||||
this.updateNeighborsAt(pos, block);
|
||||
}
|
||||
|
||||
@@ -1668,12 +2063,12 @@
|
||||
@@ -1668,12 +2068,12 @@
|
||||
}
|
||||
|
||||
public boolean isFlat() {
|
||||
@ -1000,7 +1013,7 @@
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1696,7 +2091,7 @@
|
||||
@@ -1696,7 +2096,7 @@
|
||||
private static <T> String getTypeCount(Iterable<T> items, Function<T, String> classifier) {
|
||||
try {
|
||||
Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap();
|
||||
@ -1009,7 +1022,7 @@
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
T t0 = iterator.next();
|
||||
@@ -1705,7 +2100,7 @@
|
||||
@@ -1705,7 +2105,7 @@
|
||||
object2intopenhashmap.addTo(s, 1);
|
||||
}
|
||||
|
||||
@ -1018,7 +1031,7 @@
|
||||
String s1 = (String) entry.getKey();
|
||||
|
||||
return s1 + ":" + entry.getIntValue();
|
||||
@@ -1717,6 +2112,7 @@
|
||||
@@ -1717,6 +2117,7 @@
|
||||
|
||||
@Override
|
||||
public LevelEntityGetter<Entity> getEntities() {
|
||||
@ -1026,7 +1039,7 @@
|
||||
return this.entityManager.getEntityGetter();
|
||||
}
|
||||
|
||||
@@ -1802,6 +2198,17 @@
|
||||
@@ -1802,6 +2203,17 @@
|
||||
return this.serverLevelData.getGameRules();
|
||||
}
|
||||
|
||||
@ -1044,7 +1057,7 @@
|
||||
@Override
|
||||
public CrashReportCategory fillReportDetails(CrashReport report) {
|
||||
CrashReportCategory crashreportsystemdetails = super.fillReportDetails(report);
|
||||
@@ -1828,6 +2235,7 @@
|
||||
@@ -1828,6 +2240,7 @@
|
||||
}
|
||||
|
||||
public void onTickingStart(Entity entity) {
|
||||
@ -1052,7 +1065,7 @@
|
||||
ServerLevel.this.entityTickList.add(entity);
|
||||
}
|
||||
|
||||
@@ -1836,14 +2244,15 @@
|
||||
@@ -1836,14 +2249,15 @@
|
||||
}
|
||||
|
||||
public void onTrackingStart(Entity entity) {
|
||||
@ -1070,7 +1083,7 @@
|
||||
String s = "onTrackingStart called during navigation iteration";
|
||||
|
||||
Util.logAndPauseIfInIde("onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration"));
|
||||
@@ -1864,9 +2273,58 @@
|
||||
@@ -1864,9 +2278,58 @@
|
||||
}
|
||||
|
||||
entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
|
||||
@ -1129,7 +1142,7 @@
|
||||
ServerLevel.this.getChunkSource().removeEntity(entity);
|
||||
if (entity instanceof ServerPlayer entityplayer) {
|
||||
ServerLevel.this.players.remove(entityplayer);
|
||||
@@ -1874,7 +2332,7 @@
|
||||
@@ -1874,7 +2337,7 @@
|
||||
}
|
||||
|
||||
if (entity instanceof Mob entityinsentient) {
|
||||
@ -1138,7 +1151,7 @@
|
||||
String s = "onTrackingStart called during navigation iteration";
|
||||
|
||||
Util.logAndPauseIfInIde("onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration"));
|
||||
@@ -1895,10 +2353,27 @@
|
||||
@@ -1895,10 +2358,27 @@
|
||||
}
|
||||
|
||||
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);
|
||||
|
Loading…
Reference in New Issue
Block a user