readd beacon effect cause

This commit is contained in:
Lulu13022002
2024-12-18 19:09:46 +01:00
parent dedc6b3394
commit 6126012369
102 changed files with 443 additions and 488 deletions

View File

@@ -73,11 +73,11 @@
}
nextSpawnData.getEquipment().ifPresent(mob::equip);
+ // Spigot Start
+ // Spigot start
+ if (mob.level().spigotConfig.nerfSpawnerMobs) {
+ mob.aware = false;
+ }
+ // Spigot End
+ // Spigot end
}
- if (!serverLevel.tryAddFreshEntityWithPassengers(entity)) {

View File

@@ -140,7 +140,7 @@
}
- public void set(boolean value, @Nullable MinecraftServer server) {
+ public void set(boolean value, @Nullable ServerLevel level) { // CraftBukkit - per-world
+ public void set(boolean value, @Nullable ServerLevel level) { // CraftBukkit - per-world
this.value = value;
- this.onChanged(server);
+ this.onChanged(level); // CraftBukkit - per-world
@@ -161,7 +161,7 @@
@Override
- public void setFrom(GameRules.BooleanValue value, @Nullable MinecraftServer server) {
+ public void setFrom(GameRules.BooleanValue value, @Nullable ServerLevel level) { // CraftBukkit - per-world
+ public void setFrom(GameRules.BooleanValue value, @Nullable ServerLevel level) { // CraftBukkit - per-world
this.value = value.value;
- this.onChanged(server);
+ this.onChanged(level); // CraftBukkit - per-world
@@ -208,7 +208,7 @@
+ public void set(int value, @Nullable ServerLevel level) { // CraftBukkit - per-world
this.value = value;
- this.onChanged(server);
+ this.onChanged(level) ;// CraftBukkit - per-world
+ this.onChanged(level); // CraftBukkit - per-world
}
@Override

View File

@@ -530,30 +530,25 @@
return chunk.getBlockState(pos);
}
}
@@ -454,32 +_,54 @@
@@ -454,32 +_,49 @@
this.pendingBlockEntityTickers.clear();
}
- Iterator<TickingBlockEntity> iterator = this.blockEntityTickers.iterator();
+ // Spigot start
+ // Iterator<TickingBlockEntity> iterator = this.blockEntityTickers.iterator();
boolean runsNormally = this.tickRateManager().runsNormally();
- while (iterator.hasNext()) {
- TickingBlockEntity tickingBlockEntity = iterator.next();
+ int tilesThisCycle = 0;
+ var toRemove = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<TickingBlockEntity>(); // Paper - Fix MC-117075; use removeAll
+ toRemove.add(null); // Paper - Fix MC-117075
+ for (tileTickPosition = 0; tileTickPosition < this.blockEntityTickers.size(); tileTickPosition++) { // Paper - Disable tick limiters
+ this.tileTickPosition = (this.tileTickPosition < this.blockEntityTickers.size()) ? this.tileTickPosition : 0;
+ TickingBlockEntity tickingBlockEntity = (TickingBlockEntity) this.blockEntityTickers.get(this.tileTickPosition);
+ TickingBlockEntity tickingBlockEntity = this.blockEntityTickers.get(this.tileTickPosition);
+ // Spigot end
if (tickingBlockEntity.isRemoved()) {
- iterator.remove();
+ // Spigot start
+ tilesThisCycle--;
+ toRemove.add(tickingBlockEntity); // Paper - Fix MC-117075; use removeAll
+ // Spigot end
+ toRemove.add(tickingBlockEntity); // Paper - Fix MC-117075; use removeAll
} else if (runsNormally && this.shouldTickBlocksAt(tickingBlockEntity.getPos())) {
tickingBlockEntity.tick();
}

View File

@@ -107,7 +107,7 @@
if (nearestPlayer != null) {
double d2 = nearestPlayer.distanceToSqr(d, y, d1);
- if (isRightDistanceToPlayerAndSpawnPoint(level, chunk, mutableBlockPos, d2)) {
+ if (level.isLoadedAndInBounds(mutableBlockPos) && isRightDistanceToPlayerAndSpawnPoint(level, chunk, mutableBlockPos, d2)) { // Paper - don't load chunks for mob spawn
+ if (level.isLoadedAndInBounds(mutableBlockPos) && isRightDistanceToPlayerAndSpawnPoint(level, chunk, mutableBlockPos, d2)) { // Paper - don't load chunks for mob spawn
if (spawnerData == null) {
Optional<MobSpawnSettings.SpawnerData> randomSpawnMobAt = getRandomSpawnMobAt(
level, structureManager, generator, category, level.random, mutableBlockPos

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java
@@ -33,6 +_,18 @@
@@ -33,6 +_,17 @@
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
@@ -8,7 +8,6 @@
+import net.minecraft.world.entity.boss.EnderDragonPart;
+import net.minecraft.world.entity.boss.enderdragon.EnderDragon;
+import net.minecraft.world.level.block.Blocks;
+import net.minecraft.world.level.block.state.BlockState;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.util.CraftLocation;
+import org.bukkit.event.entity.EntityExplodeEvent;
@@ -61,7 +60,7 @@
if (f > 0.0F && this.damageCalculator.shouldBlockExplode(this, this.level, blockPos, blockState, f)) {
set.add(blockPos);
+ // Paper start - prevent headless pistons from forming
+ if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowHeadlessPistons && blockState.getBlock() == Blocks.MOVING_PISTON) {
+ if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowHeadlessPistons && blockState.is(Blocks.MOVING_PISTON)) {
+ net.minecraft.world.level.block.entity.BlockEntity extension = this.level.getBlockEntity(blockPos);
+ if (extension instanceof net.minecraft.world.level.block.piston.PistonMovingBlockEntity blockEntity && blockEntity.isSourcePiston()) {
+ net.minecraft.core.Direction direction = blockState.getValue(net.minecraft.world.level.block.piston.PistonHeadBlock.FACING);
@@ -78,7 +77,7 @@
int floor5 = Mth.floor(this.center.z + f + 1.0);
-
- for (Entity entity : this.level.getEntities(this.source, new AABB(floor, floor2, floor4, floor1, floor3, floor5))) {
+ List <Entity> list = this.level.getEntities(excludeSourceFromDamage ? this.source : null, new AABB(floor, floor2, floor4, floor1, floor3, floor5), (com.google.common.base.Predicate<Entity>) entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source
+ List <Entity> list = this.level.getEntities(excludeSourceFromDamage ? this.source : null, new AABB(floor, floor2, floor4, floor1, floor3, floor5), entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source
+ for (Entity entity : list) { // Paper - used in loop
if (!entity.ignoreExplosion(this)) {
double d = Math.sqrt(entity.distanceToSqr(this.center)) / f;
@@ -95,10 +94,10 @@
+
+ // Special case ender dragon only give knockback if no damage is cancelled
+ // Thinks to note:
+ // - Setting a velocity to a ComplexEntityPart is ignored (and therefore not needed)
+ // - Damaging ComplexEntityPart while forward the damage to EntityEnderDragon
+ // - Setting a velocity to a EnderDragonPart is ignored (and therefore not needed)
+ // - Damaging EnderDragonPart while forward the damage to EnderDragon
+ // - Damaging EntityEnderDragon does nothing
+ // - EntityEnderDragon hitbock always covers the other parts and is therefore always present
+ // - EnderDragon hitbock always covers the other parts and is therefore always present
+ if (entity instanceof EnderDragonPart) {
+ continue;
+ }
@@ -106,10 +105,10 @@
+ entity.lastDamageCancelled = false;
+
+ if (entity instanceof EnderDragon) {
+ for (EnderDragonPart entityComplexPart : ((EnderDragon) entity).subEntities) {
+ for (EnderDragonPart dragonPart : ((EnderDragon) entity).getSubEntities()) {
+ // Calculate damage separately for each EntityComplexPart
+ if (list.contains(entityComplexPart)) {
+ entityComplexPart.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity, f1));
+ if (list.contains(dragonPart)) {
+ dragonPart.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity, f1));
+ }
+ }
+ } else {

View File

@@ -128,7 +128,7 @@
+ // CraftBukkit start
+ //this.popExperience(level, pos, i);
+ return i;
+ // Craftbukkit end
+ // CraftBukkit end
+ }
+ return 0; // CraftBukkit
+ }

View File

@@ -5,6 +5,6 @@
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> blockEntityType) {
- return createTickerHelper(blockEntityType, BlockEntityType.HANGING_SIGN, SignBlockEntity::tick);
+ return null; // Craftbukkit - remove unnecessary sign ticking
+ return null; // CraftBukkit - remove unnecessary sign ticking
}
}

View File

@@ -7,7 +7,7 @@
- if (random.nextInt((int)(25.0F / growthSpeed) + 1) == 0) {
- level.setBlock(pos, this.getStateForAge(age + 1), 2);
+ // Spigot start
+ int modifier;
+ int modifier = 100;
+ if (this == Blocks.BEETROOTS) {
+ modifier = level.spigotConfig.beetrootModifier;
+ } else if (this == Blocks.CARROTS) {
@@ -18,7 +18,7 @@
+ } else if (this == Blocks.TORCHFLOWER_CROP) {
+ modifier = level.spigotConfig.torchFlowerModifier;
+ // Paper end - Fix Spigot growth modifiers
+ } else {
+ } else if (this == Blocks.WHEAT) {
+ modifier = level.spigotConfig.wheatModifier;
+ }
+

View File

@@ -5,7 +5,7 @@
if (enderChestInventory != null && level.getBlockEntity(pos) instanceof EnderChestBlockEntity enderChestBlockEntity) {
BlockPos blockPos = pos.above();
- if (level.getBlockState(blockPos).isRedstoneConductor(level, blockPos)) {
+ if (level.getBlockState(blockPos).isRedstoneConductor(level, blockPos)) { // Paper - diff on change; make sure that EnderChest#isBlocked uses the same logic
+ if (level.getBlockState(blockPos).isRedstoneConductor(level, blockPos)) { // Paper - diff on change; make sure that EnderChest#isBlocked uses the same logic
return InteractionResult.SUCCESS;
} else {
- if (level instanceof ServerLevel serverLevel) {

View File

@@ -1,23 +1,23 @@
--- a/net/minecraft/world/level/block/GrowingPlantHeadBlock.java
+++ b/net/minecraft/world/level/block/GrowingPlantHeadBlock.java
@@ -44,14 +_,31 @@
@@ -44,13 +_,31 @@
@Override
protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
- if (state.getValue(AGE) < 25 && random.nextDouble() < this.growPerTickProbability) {
+ // Spigot start
+ int modifier;
+ int modifier = 100;
+ if (this == Blocks.KELP) {
+ modifier = level.spigotConfig.kelpModifier;
+ } else if (this == Blocks.TWISTING_VINES) {
+ modifier = level.spigotConfig.twistingVinesModifier;
+ } else if (this == Blocks.WEEPING_VINES) {
+ modifier = level.spigotConfig.weepingVinesModifier;
+ } else {
+ } else if (this == Blocks.CAVE_VINES) {
+ modifier = level.spigotConfig.caveVinesModifier;
+ }
+ if ((Integer) state.getValue(GrowingPlantHeadBlock.AGE) < 25 && random.nextDouble() < ((modifier / 100.0D) * this.growPerTickProbability)) { // Spigot - SPIGOT-7159: Better modifier resolution
+ // Spigot end
+ if (state.getValue(AGE) < 25 && random.nextDouble() < ((modifier / 100.0D) * this.growPerTickProbability)) { // Spigot - SPIGOT-7159: Better modifier resolution
+ // Spigot end
BlockPos blockPos = pos.relative(this.growthDirection);
if (this.canGrowInto(level.getBlockState(blockPos))) {
- level.setBlockAndUpdate(blockPos, this.getGrowIntoState(state, level.random));
@@ -25,12 +25,12 @@
}
}
}
+
+ // Paper start - Fix Spigot growth modifiers
+ protected BlockState getGrowIntoState(BlockState state, RandomSource random, @javax.annotation.Nullable Level level) {
+ return this.getGrowIntoState(state, random);
+ }
+ // Paper end - Fix Spigot growth modifiers
protected BlockState getGrowIntoState(BlockState state, RandomSource random) {
return state.cycle(AGE);
}

View File

@@ -86,7 +86,7 @@
- private TeleportTransition getExitPortal(ServerLevel level, Entity entity, BlockPos pos, BlockPos exitPos, boolean isNether, WorldBorder worldBorder) {
- Optional<BlockPos> optional = level.getPortalForcer().findClosestPortalPosition(exitPos, isNether, worldBorder);
+ private TeleportTransition getExitPortal(ServerLevel level, Entity entity, BlockPos pos, BlockPos exitPos, boolean isNether, WorldBorder worldBorder, int searchRadius, boolean canCreatePortal, int createRadius) { // CraftBukkit
+ Optional<BlockPos> optional = level.getPortalForcer().findClosestPortalPosition(exitPos, worldBorder, searchRadius); // Craftbukkit
+ Optional<BlockPos> optional = level.getPortalForcer().findClosestPortalPosition(exitPos, worldBorder, searchRadius); // CraftBukkit
BlockUtil.FoundRectangle largestRectangleAround;
TeleportTransition.PostTeleportTransition postTeleportTransition;
if (optional.isPresent()) {

View File

@@ -7,7 +7,7 @@
- && canOpen(state, level, pos, shulkerBoxBlockEntity)) {
- player.openMenu(shulkerBoxBlockEntity);
+ && canOpen(state, level, pos, shulkerBoxBlockEntity) // Paper - Fix InventoryOpenEvent cancellation - expand if for belows check
+ && player.openMenu(shulkerBoxBlockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
+ && player.openMenu(shulkerBoxBlockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.OPEN_SHULKER_BOX);
PiglinAi.angerNearbyPiglins(serverLevel, player, true);
}

View File

@@ -48,6 +48,6 @@
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> blockEntityType) {
- return createTickerHelper(blockEntityType, BlockEntityType.SIGN, SignBlockEntity::tick);
+ return null; // Craftbukkit - remove unnecessary sign ticking
+ return null; // CraftBukkit - remove unnecessary sign ticking
}
}

View File

@@ -5,6 +5,6 @@
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> blockEntityType) {
- return createTickerHelper(blockEntityType, BlockEntityType.HANGING_SIGN, SignBlockEntity::tick);
+ return null; // Craftbukkit - remove unnecessary sign ticking
+ return null; // CraftBukkit - remove unnecessary sign ticking
}
}

View File

@@ -83,7 +83,7 @@
if (blockEntity.lastCheckY >= height) {
blockEntity.lastCheckY = level.getMinY() - 1;
@@ -224,36 +_,99 @@
@@ -224,35 +_,99 @@
@Override
public void setRemoved() {
@@ -177,7 +177,6 @@
}
}
- }
-
+ return list;
+ }
+
@@ -195,13 +194,13 @@
+ apiBlock, apiEffect, (org.bukkit.entity.Player) player.getBukkitEntity(), isPrimary
+ );
+ if (!event.callEvent()) continue;
+ player.addEffect(org.bukkit.craftbukkit.potion.CraftPotionUtil.fromBukkit(event.getEffect()));
+ player.addEffect(org.bukkit.craftbukkit.potion.CraftPotionUtil.fromBukkit(event.getEffect()), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON);
+ }
+ }
+ // Paper end - BeaconEffectEvent
public static void playSound(Level level, BlockPos pos, SoundEvent sound) {
level.playSound(null, pos, sound, SoundSource.BLOCKS, 1.0F, 1.0F);
}
@@ -282,7 +_,7 @@
private static Holder<MobEffect> loadEffect(CompoundTag tag, String key) {
if (tag.contains(key, 8)) {

View File

@@ -208,7 +208,7 @@
boolean flag = false;
boolean isEmpty = destination.isEmpty();
if (item.isEmpty()) {
+ // Spigot start - SPIGOT-6693, InventorySubcontainer#setItem
+ // Spigot start - SPIGOT-6693, SimpleContainer#setItem
+ ItemStack leftover = ItemStack.EMPTY; // Paper - Make hoppers respect inventory max stack size
+ if (!stack.isEmpty() && stack.getCount() > destination.getMaxStackSize()) {
+ leftover = stack; // Paper - Make hoppers respect inventory max stack size

View File

@@ -35,7 +35,7 @@
}
replaceMissingSections(biomeRegistry, this.sections);
+ this.biomeRegistry = biomeRegistry; // Craftbukkit
+ this.biomeRegistry = biomeRegistry; // CraftBukkit
}
private static void replaceMissingSections(Registry<Biome> biomeRegistry, LevelChunkSection[] sections) {

View File

@@ -106,7 +106,7 @@
public FluidState getFluidState(int x, int y, int z) {
- try {
+ // try { // Paper start - Perf: Optimise Chunk#getFluid
+ // try { // Paper start - Perf: Optimise Chunk#getFluid
int sectionIndex = this.getSectionIndex(y);
if (sectionIndex >= 0 && sectionIndex < this.sections.length) {
LevelChunkSection levelChunkSection = this.sections[sectionIndex];

View File

@@ -57,7 +57,7 @@
+ } else {
+ long days;
+ if (level.paperConfig().entities.behavior.pillagerPatrols.start.perPlayer) {
+ days = player.getStats().getValue(net.minecraft.stats.Stats.CUSTOM.get(net.minecraft.stats.Stats.PLAY_TIME)) / 24000L; // PLAY_ONE_MINUTE is actually counting in ticks, a misnomer by Mojang
+ days = player.getStats().getValue(net.minecraft.stats.Stats.CUSTOM.get(net.minecraft.stats.Stats.PLAY_TIME)) / 24000L; // PLAY_TIME is counting in ticks
+ } else {
+ days = level.getDayTime() / 24000L;
+ }

View File

@@ -55,7 +55,7 @@
+ // Paper end - PhantomPreSpawnEvent
Phantom phantom = EntityType.PHANTOM.create(level, EntitySpawnReason.NATURAL);
if (phantom != null) {
+ phantom.setSpawningEntity(serverPlayer.getUUID()); // Paper - PhantomPreSpawnEvent
+ phantom.spawningEntity = serverPlayer.getUUID(); // Paper - PhantomPreSpawnEvent
phantom.moveTo(blockPos1, 0.0F, 0.0F);
spawnGroupData = phantom.finalizeSpawn(
level, currentDifficultyAt, EntitySpawnReason.NATURAL, spawnGroupData

View File

@@ -41,7 +41,7 @@
for (Direction direction : Direction.Plane.HORIZONTAL) {
BlockPos blockPos = mutableBlockPos.setWithOffset(pos, direction);
- BlockState blockState = level.getBlockState(blockPos);
+ BlockState blockState = level.getBlockStateIfLoaded(mutableBlockPos); // Paper - Prevent chunk loading from fluid flowing
+ BlockState blockState = level.getBlockStateIfLoaded(blockPos); // Paper - Prevent chunk loading from fluid flowing
+ if (blockState == null) continue; // Paper - Prevent chunk loading from fluid flowing
FluidState fluidState = blockState.getFluidState();
if (fluidState.getType().isSame(this) && canPassThroughWall(direction, level, pos, state, blockPos, blockState)) {

View File

@@ -23,10 +23,10 @@
+ }
+ // CraftBukkit end
state.handleNeighborChanged(level, pos, neighborBlock, orientation, movedByPiston);
+ // Spigot Start
+ // Spigot start
+ } catch (StackOverflowError ex) {
+ level.lastPhysicsProblem = new BlockPos(pos);
+ // Spigot End
+ // Spigot end
} catch (Throwable var9) {
CrashReport crashReport = CrashReport.forThrowable(var9, "Exception while updating neighbours");
CrashReportCategory crashReportCategory = crashReport.addCategory("Block being updated");

View File

@@ -49,26 +49,26 @@
- File file = new File(this.playerDir, player.getStringUUID() + suffix);
+ private Optional<CompoundTag> load(String name, String stringUuid, String suffix) { // CraftBukkit
+ File file = new File(this.playerDir, stringUuid + suffix); // CraftBukkit
+ // Spigot Start
+ // Spigot start
+ boolean usingWrongFile = false;
+ if (org.bukkit.Bukkit.getOnlineMode() && !file.exists()) { // Paper - Check online mode first
+ file = new File(file, java.util.UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(java.nio.charset.StandardCharsets.UTF_8)).toString() + suffix);
+ if (file.exists()) {
+ usingWrongFile = true;
+ org.bukkit.Bukkit.getServer().getLogger().warning("Using offline mode UUID file for player " + name + " as it is the only copy we can find.");
+ LOGGER.warn("Using offline mode UUID file for player {} as it is the only copy we can find.", name);
+ }
+ }
+ // Spigot End
+ // Spigot end
if (file.exists() && file.isFile()) {
try {
- return Optional.of(NbtIo.readCompressed(file.toPath(), NbtAccounter.unlimitedHeap()));
+ // Spigot Start
+ // Spigot start
+ Optional<CompoundTag> optional = Optional.of(NbtIo.readCompressed(file.toPath(), NbtAccounter.unlimitedHeap()));
+ if (usingWrongFile) {
+ file.renameTo(new File(file.getPath() + ".offline-read"));
+ }
+ return optional;
+ // Spigot End
+ // Spigot end
} catch (Exception var5) {
- LOGGER.warn("Failed to load player data for {}", player.getName().getString());
+ LOGGER.warn("Failed to load player data for {}", name); // CraftBukkit