fix allowPermanentBlockBreakExploits config

This commit is contained in:
Lulu13022002 2024-12-18 23:35:47 +01:00
parent c71ada60db
commit 5922e6334b
No known key found for this signature in database
GPG key ID: 491C8F0B8ACDEB01
18 changed files with 31 additions and 50 deletions

View file

@ -11,7 +11,7 @@ import org.jetbrains.annotations.Nullable;
/**
* Thrown whenever a LivingEntity dies
*/
public class EntityDeathEvent extends EntityEvent implements org.bukkit.event.Cancellable { // Paper - make cancellable
public class EntityDeathEvent extends EntityEvent implements org.bukkit.event.Cancellable { // Paper - make cancellable
private static final HandlerList handlers = new HandlerList();
private final DamageSource damageSource;
private final List<ItemStack> drops;

View file

@ -25,7 +25,7 @@ public final class EquipmentSlotGroup implements Predicate<EquipmentSlot> {
public static final EquipmentSlotGroup LEGS = get("legs", EquipmentSlot.LEGS);
public static final EquipmentSlotGroup CHEST = get("chest", EquipmentSlot.CHEST);
public static final EquipmentSlotGroup HEAD = get("head", EquipmentSlot.HEAD);
public static final EquipmentSlotGroup ARMOR = get("armor", (test) -> test == EquipmentSlot.FEET || test == EquipmentSlot.LEGS || test == EquipmentSlot.CHEST || test == EquipmentSlot.HEAD || test == EquipmentSlot.BODY, EquipmentSlot.CHEST); // Paper - add missing slot type
public static final EquipmentSlotGroup ARMOR = get("armor", (test) -> test == EquipmentSlot.FEET || test == EquipmentSlot.LEGS || test == EquipmentSlot.CHEST || test == EquipmentSlot.HEAD || test == EquipmentSlot.BODY, EquipmentSlot.CHEST); // Paper - add missing slot type
public static final EquipmentSlotGroup BODY = get("body", EquipmentSlot.BODY); // Paper - add missing slot group
//
private final String key;

View file

@ -786,14 +786,14 @@ index 7c0862c50b44555fb27ce7dc46f4ec95a3eb0022..774ca9e0b56fd175ae246051de762d0c
public void tick() {
super.tick();
diff --git a/net/minecraft/world/entity/vehicle/MinecartHopper.java b/net/minecraft/world/entity/vehicle/MinecartHopper.java
index c553cf0592dfa606dbbb1e6854d3377b9feb5efb..dec705ec57e4f63ef2ccaa87c5400c116aee9b35 100644
index c553cf0592dfa606dbbb1e6854d3377b9feb5efb..8341e7f01606fca90e69384c16fc19bb9e20d1b7 100644
--- a/net/minecraft/world/entity/vehicle/MinecartHopper.java
+++ b/net/minecraft/world/entity/vehicle/MinecartHopper.java
@@ -47,6 +47,7 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper
if (flag != this.isEnabled()) {
this.setEnabled(flag);
}
+ this.immunize(); // Paper
+ this.immunize(); // Paper
}
public boolean isEnabled() {
@ -801,13 +801,13 @@ index c553cf0592dfa606dbbb1e6854d3377b9feb5efb..dec705ec57e4f63ef2ccaa87c5400c11
public boolean suckInItems() {
if (HopperBlockEntity.suckInItems(this.level(), this)) {
+ this.immunize(); // Paper
+ this.immunize(); // Paper
return true;
} else {
for (ItemEntity itemEntity : this.level()
.getEntitiesOfClass(ItemEntity.class, this.getBoundingBox().inflate(0.25, 0.0, 0.25), EntitySelector.ENTITY_STILL_ALIVE)) {
if (HopperBlockEntity.addItem(this, itemEntity)) {
+ this.immunize(); // Paper
+ this.immunize(); // Paper
return true;
}
}

View file

@ -7,7 +7,7 @@ Inline bit operations and reduce instruction count to make these hot
operations faster
diff --git a/net/minecraft/core/BlockPos.java b/net/minecraft/core/BlockPos.java
index 98f0b1cf19d7a035849a9a2fa25e2be3a4c5a980..0822a0faf7af9e746e7936ac17597b1f51e40a92 100644
index 98f0b1cf19d7a035849a9a2fa25e2be3a4c5a980..a81694a22e94cca6f7110f7d5b205d1303f4e071 100644
--- a/net/minecraft/core/BlockPos.java
+++ b/net/minecraft/core/BlockPos.java
@@ -51,15 +51,17 @@ public class BlockPos extends Vec3i {
@ -62,7 +62,7 @@ index 98f0b1cf19d7a035849a9a2fa25e2be3a4c5a980..0822a0faf7af9e746e7936ac17597b1f
public static int getZ(long packedPos) {
- return (int)(packedPos << 64 - Z_OFFSET - PACKED_HORIZONTAL_LENGTH >> 64 - PACKED_HORIZONTAL_LENGTH);
+ return (int) ((packedPos << 26) >> 38); // Paper - simplify/inline
+ return (int) ((packedPos << 26) >> 38); // Paper - simplify/inline
}
public static BlockPos of(long packedPos) {

View file

@ -10,7 +10,7 @@
@Override
public final void addPlayerListener(PlayerAdvancements playerAdvancements, CriterionTrigger.Listener<T> listener) {
- this.players.computeIfAbsent(playerAdvancements, advancements -> Sets.newHashSet()).add(listener);
+ playerAdvancements.criterionData.computeIfAbsent(this, managerx -> Sets.newHashSet()).add(listener); // Paper - fix PlayerAdvancements leak
+ playerAdvancements.criterionData.computeIfAbsent(this, managerx -> Sets.newHashSet()).add(listener); // Paper - fix PlayerAdvancements leak
}
@Override

View file

@ -5,7 +5,7 @@
public static ClientboundBlockEntityDataPacket create(BlockEntity blockEntity, BiFunction<BlockEntity, RegistryAccess, CompoundTag> dataGetter) {
RegistryAccess registryAccess = blockEntity.getLevel().registryAccess();
- return new ClientboundBlockEntityDataPacket(blockEntity.getBlockPos(), blockEntity.getType(), dataGetter.apply(blockEntity, registryAccess));
+ return new ClientboundBlockEntityDataPacket(blockEntity.getBlockPos(), blockEntity.getType(), blockEntity.sanitizeSentNbt(dataGetter.apply(blockEntity, registryAccess))); // Paper - Sanitize sent data
+ return new ClientboundBlockEntityDataPacket(blockEntity.getBlockPos(), blockEntity.getType(), blockEntity.sanitizeSentNbt(dataGetter.apply(blockEntity, registryAccess))); // Paper - Sanitize sent data
}
public static ClientboundBlockEntityDataPacket create(BlockEntity blockEntity) {

View file

@ -511,7 +511,7 @@
private boolean isPvpAllowed() {
- return this.server.isPvpAllowed();
+ return this.level().pvpMode; // CraftBukkit - this.server.isPvpAllowed() -> this.world.pvpMode
+ return this.level().pvpMode; // CraftBukkit - this.server.isPvpAllowed() -> this.world.pvpMode
}
- public TeleportTransition findRespawnPositionAndUseSpawnBlock(boolean useCharge, TeleportTransition.PostTeleportTransition postTeleportTransition) {
@ -541,7 +541,7 @@
} else {
- return new TeleportTransition(this.server.overworld(), this, postTeleportTransition);
- }
+ teleportTransition = new TeleportTransition(this.server.overworld(), this, postTeleportTransition); // CraftBukkit
+ teleportTransition = new TeleportTransition(this.server.overworld(), this, postTeleportTransition); // CraftBukkit
+ }
+ // CraftBukkit start
+ if (respawnReason == null) {
@ -1123,7 +1123,7 @@
for (MobEffectInstance mobEffectInstance : that.getActiveEffects()) {
- this.addEffect(new MobEffectInstance(mobEffectInstance));
+ // this.addEffect(new MobEffectInstance(mobEffectInstance)); // CraftBukkit
+ // this.addEffect(new MobEffectInstance(mobEffectInstance)); // CraftBukkit
}
this.getInventory().replaceWith(that.getInventory());
@ -1203,7 +1203,7 @@
+ // Paper end
if (this.acceptsChatMessages()) {
- message.sendToPlayer(this, filtered, boundType);
+ message.sendToPlayer(this, filtered, boundType, unsigned); // Paper
+ message.sendToPlayer(this, filtered, boundType, unsigned); // Paper
}
}

View file

@ -26,7 +26,7 @@
this(EntityType.TNT, level);
this.setPos(x, y, z);
- double d = level.random.nextDouble() * (float) (Math.PI * 2);
+ double d = this.random.nextDouble() * (float) (Math.PI * 2); // Paper - Don't use level random in entity constructors
+ double d = this.random.nextDouble() * (float) (Math.PI * 2); // Paper - Don't use level random in entity constructors
this.setDeltaMovement(-Math.sin(d) * 0.02, 0.2F, -Math.cos(d) * 0.02);
this.setFuse(80);
this.xo = x;

View file

@ -66,7 +66,7 @@
}
if (i > 5) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.UNSPAWNABLE); // CraftBukkit
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.UNSPAWNABLE); // CraftBukkit
this.stop();
break;
}

View file

@ -34,7 +34,7 @@
- itemInHand.consume(1, player);
- player.awardStat(Stats.ITEM_USED.get(this));
+ // Paper start - PlayerElytraBoostEvent
+ final Projectile.Delayed<FireworkRocketEntity> delayed = Projectile.spawnProjectileDelayed(new FireworkRocketEntity(level, itemInHand, player), serverLevel, itemInHand, f -> f.spawningEntity = player.getUUID()); // Paper - firework api - assign spawning entity uuid
+ final Projectile.Delayed<FireworkRocketEntity> delayed = Projectile.spawnProjectileDelayed(new FireworkRocketEntity(level, itemInHand, player), serverLevel, itemInHand, f -> f.spawningEntity = player.getUUID()); // Paper - firework api - assign spawning entity uuid
+ com.destroystokyo.paper.event.player.PlayerElytraBoostEvent event = new com.destroystokyo.paper.event.player.PlayerElytraBoostEvent((org.bukkit.entity.Player) player.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemInHand), (org.bukkit.entity.Firework) delayed.projectile().getBukkitEntity(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand));
+ if (event.callEvent() && delayed.attemptSpawn()) {
+ player.awardStat(Stats.ITEM_USED.get(this)); // Moved up from below

View file

@ -25,7 +25,7 @@
Direction direction = state.getValue(FACING);
+ // Paper start - Protect Bedrock and End Portal/Frames from being destroyed; prevent retracting when we're facing the wrong way (we were replaced before retraction could occur)
+ Direction directionQueuedAs = Direction.from3DDataValue(param & 7); // Paper - copied from below
+ if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowPermanentBlockBreakExploits && directionQueuedAs != directionQueuedAs) {
+ if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowPermanentBlockBreakExploits && direction != directionQueuedAs) {
+ return false;
+ }
+ // Paper end - Protect Bedrock and End Portal/Frames from being destroyed

View file

@ -53,7 +53,7 @@
protected boolean canBeReplaced(BlockState state, BlockPlaceContext useContext) {
- return state.canBeReplaced() && (useContext.getItemInHand().isEmpty() || !useContext.getItemInHand().is(this.asItem()));
+ return state.canBeReplaced() && (useContext.getItemInHand().isEmpty() || !useContext.getItemInHand().is(this.asItem()))&& (state.isDestroyable() || (useContext.getPlayer() != null && useContext.getPlayer().getAbilities().instabuild)); // Paper - Protect Bedrock and End Portal/Frames from being destroyed
+ return state.canBeReplaced() && (useContext.getItemInHand().isEmpty() || !useContext.getItemInHand().is(this.asItem())) && (state.isDestroyable() || (useContext.getPlayer() != null && useContext.getPlayer().getAbilities().instabuild)); // Paper - Protect Bedrock and End Portal/Frames from being destroyed
}
protected boolean canBeReplaced(BlockState state, Fluid fluid) {

View file

@ -51,7 +51,7 @@
- boolean flag = i == -z || i == z;
+ // Paper start - Perf: iterate over border chunks instead of entire square chunk area
+ final int radius = z;
+ boolean flag = i == -z || i == z; final boolean onBorderAlongZAxis = flag; // Paper - OBFHELPER
+ boolean flag = i == -z || i == z; final boolean onBorderAlongZAxis = flag; // Paper - OBFHELPER
- for (int i1 = -z; i1 <= z; i1++) {
- boolean flag1 = i1 == -z || i1 == z;
@ -82,7 +82,7 @@
+ long featurePopulationSeed = l;
+ final long configFeatureSeed = level.getMinecraftWorld().paperConfig().featureSeeds.features.getLong(placedFeature.feature());
+ if (configFeatureSeed != -1) {
+ featurePopulationSeed = worldgenRandom.setDecorationSeed(configFeatureSeed, blockPos.getX(), blockPos.getZ()); // See seededrandom.setDecorationSeed from above
+ featurePopulationSeed = worldgenRandom.setDecorationSeed(configFeatureSeed, blockPos.getX(), blockPos.getZ()); // See WorldgenRandom.setDecorationSeed from above
+ }
+ worldgenRandom.setFeatureSeed(featurePopulationSeed, i3, i);
+ // Paper end - Configurable feature seeds

View file

@ -265,7 +265,7 @@
public boolean isEmpty() {
return false;
}
@@ -711,23 +_,25 @@
@@ -711,23 +_,24 @@
if (this.blockEntity.getType().isValid(blockState)) {
this.ticker.tick(LevelChunk.this.level, this.blockEntity.getBlockPos(), blockState, this.blockEntity);
this.loggedInvalidBlockState = false;
@ -278,17 +278,15 @@
- LogUtils.defer(this::getPos),
- blockState
- );
- }
+ // Paper start - Remove the Block Entity if it's invalid
+ } else {
+ LevelChunk.this.removeBlockEntity(this.getPos());
+ if (!this.loggedInvalidBlockState) {
+ this.loggedInvalidBlockState = true;
+ LevelChunk.LOGGER.warn("Block entity {} @ {} state {} invalid for ticking:", new Object[]{LogUtils.defer(this::getType), LogUtils.defer(this::getPos), blockState});
+ LevelChunk.LOGGER.warn("Block entity {} @ {} state {} invalid for ticking:", LogUtils.defer(this::getType), LogUtils.defer(this::getPos), blockState);
+ }
+ // Paper end - Remove the Block Entity if it's invalid
+ }
+
}
profilerFiller.pop();
} catch (Throwable var5) {

View file

@ -1,13 +1,5 @@
--- a/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java
+++ b/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java
@@ -8,6 +_,7 @@
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtOps;
+import net.minecraft.nbt.Tag;
import net.minecraft.resources.ResourceKey;
import net.minecraft.tags.BiomeTags;
import net.minecraft.util.RandomSource;
@@ -401,10 +_,13 @@
BlockPos worldPos = this.getWorldPos(1, 0, i8);
if (box.isInside(worldPos) && this.isInterior(level, 1, 0, i8, box)) {

View file

@ -1,13 +1,5 @@
--- a/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java
+++ b/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java
@@ -25,6 +_,7 @@
import net.minecraft.nbt.IntTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.NbtUtils;
+import net.minecraft.nbt.Tag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.RandomSource;
import net.minecraft.world.Clearable;
@@ -54,6 +_,10 @@
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.BitSetDiscreteVoxelShape;
@ -108,7 +100,7 @@
if (!settings.isIgnoreEntities()) {
this.placeEntities(
- serverLevel,
+ wrappedAccess, // CraftBukkit
+ wrappedAccess, // CraftBukkit
offset,
settings.getMirror(),
settings.getRotation(),
@ -143,15 +135,14 @@
return NbtUtils.addCurrentDataVersion(tag);
}
@@ -720,6 +_,13 @@
@@ -720,6 +_,12 @@
this.entityInfoList.add(new StructureTemplate.StructureEntityInfo(vec3, blockPos, compound1));
}
}
+
+ // CraftBukkit start - PDC
+ Tag base = tag.get("BukkitValues");
+ if (base instanceof CompoundTag) {
+ this.persistentDataContainer.putAll((CompoundTag) base);
+ if (tag.get("BukkitValues") instanceof CompoundTag compoundTag) {
+ this.persistentDataContainer.putAll(compoundTag);
+ }
+ // CraftBukkit end
}

View file

@ -1252,12 +1252,12 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
// Paper start - missing entity api
@Override
public boolean isInvisible() { // Paper - moved up from LivingEntity
public boolean isInvisible() { // Paper - moved up from LivingEntity
return this.getHandle().isInvisible();
}
@Override
public void setInvisible(boolean invisible) { // Paper - moved up from LivingEntity
public void setInvisible(boolean invisible) { // Paper - moved up from LivingEntity
this.getHandle().persistentInvisibility = invisible;
this.getHandle().setSharedFlag(Entity.FLAG_INVISIBLE, invisible);
}

View file

@ -28,7 +28,7 @@ class CraftAsyncTask extends CraftTask {
// Paper start - name threads according to running plugin
final String nameBefore = thread.getName();
thread.setName(nameBefore + " - " + this.getOwner().getName());
try { synchronized (this.workers) { // Paper end - name threads according to running plugin
try { synchronized (this.workers) { // Paper end - name threads according to running plugin
if (this.getPeriod() == CraftTask.CANCEL) {
// Never continue running after cancelled.
// Checking this with the lock is important!