Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 19:10:09 +01:00
c0936a71bd
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 01aa02eb PR-858: Add LivingEntity#playHurtAnimation() 9421320f PR-884: Refinements to new ban API for improved compatibility and correctness 37a60b45 SPIGOT-6455, SPIGOT-7030, PR-750: Improve ban API 4eeb174b All smithing inventories are now the new smithing inventory f2bb168e PR-880: Add methods to get/set FallingBlock CancelDrop e7a807fa PR-879: Add Player#sendHealthUpdate() 692b8e96 SPIGOT-7370: Remove float value conversion in plugin.yml 2d033390 SPIGOT-7403: Add direct API for waxed signs 16a08373 PR-876: Add missing Raider API and 'no action ticks' CraftBukkit Changes: b60a95c8c PR-1189: Add LivingEntity#playHurtAnimation() 95c335c63 PR-1226: Fix VehicleEnterEvent not being called for certain entities 0a0fc3bee PR-1227: Refinements to new ban API for improved compatibility and correctness 0d0b1e5dc Revert bad change to PathfinderGoalSit causing all cats to sit 648196070 SPIGOT-6455, SPIGOT-7030, PR-1054: Improve ban API 31fe848d6 All smithing inventories are now the new smithing inventory 9a919a143 SPIGOT-7416: SmithItemEvent not firing in Smithing Table 9f64f0d22 PR-1221: Add methods to get/set FallingBlock CancelDrop 3be9ac171 PR-1220: Add Player#sendHealthUpdate() c1279f775 PR-1209: Clean up various patches c432e4397 Fix Raider#setCelebrating() implementation 504d96665 SPIGOT-7403: Add direct API for waxed signs c68c1f1b3 PR-1216: Add missing Raider API and 'no action ticks' 85b89c3dd Increase outdated build delay Spigot Changes: 9ebce8af Rebuild patches 64b565e6 Rebuild patches
170 Zeilen
11 KiB
Diff
170 Zeilen
11 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Wed, 13 May 2020 23:01:26 -0400
|
|
Subject: [PATCH] Protect Bedrock and End Portal/Frames from being destroyed
|
|
|
|
This fixes exploits that let players destroy bedrock by Pistons, explosions
|
|
and Mushrooom/Tree generation.
|
|
|
|
These blocks are designed to not be broken except by creative players/commands.
|
|
So protect them from a multitude of methods of destroying them.
|
|
|
|
A config is provided if you rather let players use these exploits, and let
|
|
them destroy the worlds End Portals and get on top of the nether easy.
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
|
index 75d827f1eecb24f7ab985bdea2bbf65b8478fc8c..d646660f988994d4fdb05901349c5946a2f6c48c 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
|
@@ -168,6 +168,7 @@ public class Explosion {
|
|
for (float f1 = 0.3F; f > 0.0F; f -= 0.22500001F) {
|
|
BlockPos blockposition = BlockPos.containing(d4, d5, d6);
|
|
BlockState iblockdata = this.level.getBlockState(blockposition);
|
|
+ if (!iblockdata.isDestroyable()) continue; // Paper
|
|
FluidState fluid = iblockdata.getFluidState(); // Paper
|
|
|
|
if (!this.level.isInWorldBounds(blockposition)) {
|
|
@@ -369,7 +370,7 @@ public class Explosion {
|
|
}
|
|
// CraftBukkit end
|
|
|
|
- if (!iblockdata.isAir()) {
|
|
+ if (!iblockdata.isAir() && iblockdata.isDestroyable()) { // Paper
|
|
BlockPos blockposition1 = blockposition.immutable();
|
|
|
|
this.level.getProfiler().push("explosion_blocks");
|
|
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
|
index fd4de9ace0cce48b7c73bbe1d351db4053915a9a..7dc9b87c50590422e9912e4385c9983bcac343b8 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
@@ -434,6 +434,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
|
public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth) {
|
|
// CraftBukkit start - tree generation
|
|
if (this.captureTreeGeneration) {
|
|
+ // Paper start
|
|
+ BlockState type = getBlockState(pos);
|
|
+ if (!type.isDestroyable()) return false;
|
|
+ // Paper end
|
|
CraftBlockState blockstate = this.capturedBlockStates.get(pos);
|
|
if (blockstate == null) {
|
|
blockstate = CapturedBlockState.getTreeBlockState(this, pos, flags);
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java
|
|
index 7646b66bc5ba0288608de0d836c7307e02eebe67..36b196c8834c4eb873bfca0b12f1fc2b421ea071 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/Block.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
|
|
@@ -88,6 +88,19 @@ public class Block extends BlockBehaviour implements ItemLike {
|
|
protected final StateDefinition<Block, BlockState> stateDefinition;
|
|
private BlockState defaultBlockState;
|
|
// Paper start
|
|
+ public final boolean isDestroyable() {
|
|
+ return io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowPermanentBlockBreakExploits ||
|
|
+ this != Blocks.BEDROCK &&
|
|
+ this != Blocks.END_PORTAL_FRAME &&
|
|
+ this != Blocks.END_PORTAL &&
|
|
+ this != Blocks.END_GATEWAY &&
|
|
+ this != Blocks.COMMAND_BLOCK &&
|
|
+ this != Blocks.REPEATING_COMMAND_BLOCK &&
|
|
+ this != Blocks.CHAIN_COMMAND_BLOCK &&
|
|
+ this != Blocks.BARRIER &&
|
|
+ this != Blocks.STRUCTURE_BLOCK &&
|
|
+ this != Blocks.JIGSAW;
|
|
+ }
|
|
public co.aikar.timings.Timing timing;
|
|
public co.aikar.timings.Timing getTiming() {
|
|
if (timing == null) {
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
|
index 9e70f5ba6ff0935d245f357131b062c1cc7058fc..4f6b7ed4809086811f0460544ba2ec0606f0f5da 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
|
@@ -199,6 +199,12 @@ public class PistonBaseBlock extends DirectionalBlock {
|
|
@Override
|
|
public boolean triggerEvent(BlockState state, Level world, BlockPos pos, int type, int data) {
|
|
Direction enumdirection = (Direction) state.getValue(PistonBaseBlock.FACING);
|
|
+ // Paper start - prevent retracting when we're facing the wrong way (we were replaced before retraction could occur)
|
|
+ Direction directionQueuedAs = Direction.from3DDataValue(data & 7); // Paper - copied from below
|
|
+ if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowPermanentBlockBreakExploits && enumdirection != directionQueuedAs) {
|
|
+ return false;
|
|
+ }
|
|
+ // Paper end - prevent retracting when we're facing the wrong way
|
|
BlockState iblockdata1 = (BlockState) state.setValue(PistonBaseBlock.EXTENDED, true);
|
|
|
|
if (!world.isClientSide) {
|
|
@@ -232,7 +238,7 @@ public class PistonBaseBlock extends DirectionalBlock {
|
|
BlockState iblockdata2 = (BlockState) ((BlockState) Blocks.MOVING_PISTON.defaultBlockState().setValue(MovingPistonBlock.FACING, enumdirection)).setValue(MovingPistonBlock.TYPE, this.isSticky ? PistonType.STICKY : PistonType.DEFAULT);
|
|
|
|
world.setBlock(pos, iblockdata2, 20);
|
|
- world.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(pos, iblockdata2, (BlockState) this.defaultBlockState().setValue(PistonBaseBlock.FACING, Direction.from3DDataValue(data & 7)), enumdirection, false, true));
|
|
+ world.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(pos, iblockdata2, (BlockState) this.defaultBlockState().setValue(PistonBaseBlock.FACING, Direction.from3DDataValue(data & 7)), enumdirection, false, true)); // Paper - diff on change
|
|
world.blockUpdated(pos, iblockdata2.getBlock());
|
|
iblockdata2.updateNeighbourShapes(world, pos, 2);
|
|
if (this.isSticky) {
|
|
@@ -261,7 +267,14 @@ public class PistonBaseBlock extends DirectionalBlock {
|
|
}
|
|
}
|
|
} else {
|
|
- world.removeBlock(pos.relative(enumdirection), false);
|
|
+ // Paper start - fix headless pistons breaking blocks
|
|
+ BlockPos headPos = pos.relative(enumdirection);
|
|
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowPermanentBlockBreakExploits || world.getBlockState(headPos) == Blocks.PISTON_HEAD.defaultBlockState().setValue(FACING, enumdirection)) { // double check to make sure we're not a headless piston.
|
|
+ world.removeBlock(headPos, false);
|
|
+ } else {
|
|
+ ((ServerLevel)world).getChunkSource().blockChanged(headPos); // ... fix client desync
|
|
+ }
|
|
+ // Paper end - fix headless pistons breaking blocks
|
|
}
|
|
|
|
world.playSound((Player) null, pos, SoundEvents.PISTON_CONTRACT, SoundSource.BLOCKS, 0.5F, world.random.nextFloat() * 0.15F + 0.6F);
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
|
index 2451bb61e304fbe5cdfd6bbb248575e9e1135075..74f84bfcb1da6186c7a6783512c2fc7ba995215f 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
|
@@ -229,7 +229,7 @@ public abstract class BlockBehaviour implements FeatureElement {
|
|
/** @deprecated */
|
|
@Deprecated
|
|
public boolean canBeReplaced(BlockState state, BlockPlaceContext context) {
|
|
- return state.canBeReplaced() && (context.getItemInHand().isEmpty() || !context.getItemInHand().is(this.asItem()));
|
|
+ return state.canBeReplaced() && (context.getItemInHand().isEmpty() || !context.getItemInHand().is(this.asItem())) && (state.isDestroyable() || (context.getPlayer() != null && context.getPlayer().getAbilities().instabuild)); // Paper;
|
|
}
|
|
|
|
/** @deprecated */
|
|
@@ -891,6 +891,12 @@ public abstract class BlockBehaviour implements FeatureElement {
|
|
return this.legacySolid;
|
|
}
|
|
|
|
+ // Paper start
|
|
+ public final boolean isDestroyable() {
|
|
+ return getBlock().isDestroyable();
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
public boolean isValidSpawn(BlockGetter world, BlockPos pos, EntityType<?> type) {
|
|
return this.getBlock().properties.isValidSpawn.test(this.asState(), world, pos, type);
|
|
}
|
|
@@ -994,7 +1000,7 @@ public abstract class BlockBehaviour implements FeatureElement {
|
|
}
|
|
|
|
public PushReaction getPistonPushReaction() {
|
|
- return this.pushReaction;
|
|
+ return !this.isDestroyable() ? PushReaction.BLOCK : this.pushReaction; // Paper
|
|
}
|
|
|
|
public boolean isSolidRender(BlockGetter world, BlockPos pos) {
|
|
diff --git a/src/main/java/net/minecraft/world/level/portal/PortalForcer.java b/src/main/java/net/minecraft/world/level/portal/PortalForcer.java
|
|
index 389b63605d416678d35666bbd46e0fa05a02f898..33a6fda1e8f2df61b44f0e3ddda356ffa386f2df 100644
|
|
--- a/src/main/java/net/minecraft/world/level/portal/PortalForcer.java
|
|
+++ b/src/main/java/net/minecraft/world/level/portal/PortalForcer.java
|
|
@@ -221,6 +221,13 @@ public class PortalForcer {
|
|
for (int j = -1; j < 3; ++j) {
|
|
for (int k = -1; k < 4; ++k) {
|
|
temp.setWithOffset(pos, portalDirection.getStepX() * j + enumdirection1.getStepX() * distanceOrthogonalToPortal, k, portalDirection.getStepZ() * j + enumdirection1.getStepZ() * distanceOrthogonalToPortal);
|
|
+ // Paper start - prevent destroying unbreakable blocks
|
|
+ if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowPermanentBlockBreakExploits) {
|
|
+ if (!this.level.getBlockState(temp).isDestroyable()) {
|
|
+ return false;
|
|
+ }
|
|
+ }
|
|
+ // Paper end - prevent destroying unbreakable blocks
|
|
if (k < 0 && !this.level.getBlockState(temp).isSolid()) {
|
|
return false;
|
|
}
|