Fix Cancelling BlockPlaceEvent triggering physics

This commit is contained in:
Aikar 2016-04-03 17:48:50 -04:00
parent eb76e508f5
commit 55db966770

View file

@ -79,7 +79,7 @@
+ public final LevelStorageSource.LevelStorageAccess convertable;
+ public final UUID uuid;
+ public boolean hasPhysicsEvent = true; // Paper - BlockPhysicsEvent
+
+ public LevelChunk getChunkIfLoaded(int x, int z) {
+ return this.chunkSource.getChunk(x, z, false);
+ }
@ -200,7 +200,7 @@
+ ChunkGenerator chunkgenerator = worlddimension.generator();
+ // CraftBukkit start
+ this.serverLevelData.setWorld(this);
+
+ if (biomeProvider != null) {
+ BiomeSource worldChunkManager = new CustomWorldChunkManager(this.getWorld(), biomeProvider, this.server.registryAccess().lookupOrThrow(Registries.BIOME));
+ if (chunkgenerator instanceof NoiseBasedChunkGenerator cga) {
@ -445,9 +445,10 @@
@VisibleForTesting
public void resetWeatherCycle() {
- this.serverLevelData.setRainTime(0);
+ // CraftBukkit start
this.serverLevelData.setRaining(false);
- this.serverLevelData.setRaining(false);
- this.serverLevelData.setThunderTime(0);
+ // CraftBukkit start
+ this.serverLevelData.setRaining(false);
+ // 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.serverLevelData.isRaining()) {
@ -693,7 +694,21 @@
PathNavigation navigationabstract = entityinsentient.getNavigation();
if (navigationabstract.shouldRecomputePath(pos)) {
@@ -1126,9 +1418,15 @@
@@ -1086,11 +1378,13 @@
@Override
public void updateNeighborsAt(BlockPos pos, Block block) {
+ if (captureBlockStates) { return; } // Paper - Cancel all physics during placement
this.updateNeighborsAt(pos, block, ExperimentalRedstoneUtils.initialOrientation(this, (Direction) null, (Direction) null));
}
@Override
public void updateNeighborsAt(BlockPos pos, Block sourceBlock, @Nullable Orientation orientation) {
+ if (captureBlockStates) { return; } // Paper - Cancel all physics during placement
this.neighborUpdater.updateNeighborsAtExceptFromFacing(pos, sourceBlock, (Direction) null, orientation);
}
@@ -1126,9 +1420,15 @@
@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) {
@ -710,7 +725,7 @@
case NONE:
explosion_effect = Explosion.BlockInteraction.KEEP;
break;
@@ -1144,16 +1442,26 @@
@@ -1144,16 +1444,26 @@
case TRIGGER:
explosion_effect = Explosion.BlockInteraction.TRIGGER_BLOCK;
break;
@ -740,7 +755,7 @@
Iterator iterator = this.players.iterator();
while (iterator.hasNext()) {
@@ -1162,10 +1470,11 @@
@@ -1162,10 +1472,11 @@
if (entityplayer.distanceToSqr(vec3d) < 4096.0D) {
Optional<Vec3> optional = Optional.ofNullable((Vec3) serverexplosion.getHitPlayers().get(entityplayer));
@ -753,7 +768,7 @@
}
private Explosion.BlockInteraction getDestroyType(GameRules.Key<GameRules.BooleanValue> decayRule) {
@@ -1226,17 +1535,24 @@
@@ -1226,17 +1537,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) {
@ -781,7 +796,7 @@
++j;
}
}
@@ -1292,7 +1608,7 @@
@@ -1292,7 +1610,7 @@
@Nullable
public BlockPos findNearestMapStructure(TagKey<Structure> structureTag, BlockPos pos, int radius, boolean skipReferencedStructures) {
@ -790,7 +805,7 @@
return null;
} else {
Optional<HolderSet.Named<Structure>> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(structureTag);
@@ -1334,11 +1650,22 @@
@@ -1334,11 +1652,22 @@
@Nullable
@Override
public MapItemSavedData getMapData(MapId id) {
@ -814,7 +829,7 @@
this.getServer().overworld().getDataStorage().set(id.key(), state);
}
@@ -1649,6 +1976,11 @@
@@ -1649,6 +1978,11 @@
@Override
public void blockUpdated(BlockPos pos, Block block) {
if (!this.isDebug()) {
@ -826,7 +841,7 @@
this.updateNeighborsAt(pos, block);
}
@@ -1668,12 +2000,12 @@
@@ -1668,12 +2002,12 @@
}
public boolean isFlat() {
@ -841,7 +856,7 @@
}
@Nullable
@@ -1696,7 +2028,7 @@
@@ -1696,7 +2030,7 @@
private static <T> String getTypeCount(Iterable<T> items, Function<T, String> classifier) {
try {
Object2IntOpenHashMap<String> object2intopenhashmap = new Object2IntOpenHashMap();
@ -850,7 +865,7 @@
while (iterator.hasNext()) {
T t0 = iterator.next();
@@ -1705,7 +2037,7 @@
@@ -1705,7 +2039,7 @@
object2intopenhashmap.addTo(s, 1);
}
@ -859,7 +874,7 @@
String s1 = (String) entry.getKey();
return s1 + ":" + entry.getIntValue();
@@ -1717,6 +2049,7 @@
@@ -1717,6 +2051,7 @@
@Override
public LevelEntityGetter<Entity> getEntities() {
@ -867,7 +882,7 @@
return this.entityManager.getEntityGetter();
}
@@ -1836,6 +2169,7 @@
@@ -1836,6 +2171,7 @@
}
public void onTrackingStart(Entity entity) {
@ -875,7 +890,7 @@
ServerLevel.this.getChunkSource().addEntity(entity);
if (entity instanceof ServerPlayer entityplayer) {
ServerLevel.this.players.add(entityplayer);
@@ -1864,9 +2198,52 @@
@@ -1864,9 +2200,52 @@
}
entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
@ -928,7 +943,7 @@
ServerLevel.this.getChunkSource().removeEntity(entity);
if (entity instanceof ServerPlayer entityplayer) {
ServerLevel.this.players.remove(entityplayer);
@@ -1895,6 +2272,15 @@
@@ -1895,6 +2274,15 @@
}
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);