Files
Purpur/patches/server/0191-Break-individual-slabs-when-sneaking.patch
2021-04-29 14:43:34 -04:00

75 lines
4.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <blake.galbreath@gmail.com>
Date: Tue, 23 Mar 2021 19:38:53 -0500
Subject: [PATCH] Break individual slabs when sneaking
diff --git a/src/main/java/net/minecraft/server/level/PlayerInteractManager.java b/src/main/java/net/minecraft/server/level/PlayerInteractManager.java
index 1746a8c1750b494c47f9f46e83b248d8129d2630..7302554063ac7b5dedaff895cba33b70234008e6 100644
--- a/src/main/java/net/minecraft/server/level/PlayerInteractManager.java
+++ b/src/main/java/net/minecraft/server/level/PlayerInteractManager.java
@@ -410,6 +410,8 @@ public class PlayerInteractManager {
}
return false;
}
+
+ if (this.player.world.purpurConfig.slabHalfBreak && this.player.isSneaking() && iblockdata.getBlock() instanceof net.minecraft.world.level.block.BlockStepAbstract && ((net.minecraft.world.level.block.BlockStepAbstract) iblockdata.getBlock()).halfBreak(iblockdata, blockposition, this.player)) return true; // Purpur
}
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/world/level/block/BlockStepAbstract.java b/src/main/java/net/minecraft/world/level/block/BlockStepAbstract.java
index 12c0fa5072755fd2a4f575b0cc5e4222617490ce..94965b216d50b29b95f09fa9019c177b9c099e14 100644
--- a/src/main/java/net/minecraft/world/level/block/BlockStepAbstract.java
+++ b/src/main/java/net/minecraft/world/level/block/BlockStepAbstract.java
@@ -27,7 +27,7 @@ import net.minecraft.world.phys.shapes.VoxelShapes;
public class BlockStepAbstract extends Block implements IBlockWaterlogged {
- public static final BlockStateEnum<BlockPropertySlabType> a = BlockProperties.aK;
+ public static final BlockStateEnum<BlockPropertySlabType> a = BlockProperties.aK; public static BlockStateEnum<BlockPropertySlabType> slabType() { return a; } // Purpur - OBFHELPER
public static final BlockStateBoolean b = BlockProperties.C;
protected static final VoxelShape c = Block.a(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D);
protected static final VoxelShape d = Block.a(0.0D, 8.0D, 0.0D, 16.0D, 16.0D, 16.0D);
@@ -134,4 +134,25 @@ public class BlockStepAbstract extends Block implements IBlockWaterlogged {
return false;
}
}
+
+ // Purpur start
+ public boolean halfBreak(IBlockData iblockdata, BlockPosition pos, net.minecraft.server.level.EntityPlayer player) {
+ if (iblockdata.get(BlockStepAbstract.slabType()) != BlockPropertySlabType.DOUBLE) {
+ return false;
+ }
+ net.minecraft.world.phys.MovingObjectPosition result = player.getRayTrace(16);
+ if (result == null) {
+ return false;
+ }
+ double hitY = result.getPos().getY();
+ int blockY = org.bukkit.util.NumberConversions.floor(hitY);
+ player.world.setTypeAndData(pos, iblockdata.set(BlockStepAbstract.slabType(), (hitY - blockY > 0.5 || blockY - pos.getY() == 1) ? BlockPropertySlabType.BOTTOM : BlockPropertySlabType.TOP), 3);
+ if (!player.abilities.canInstantlyBuild) {
+ net.minecraft.world.entity.item.EntityItem item = new net.minecraft.world.entity.item.EntityItem(player.world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(getItem()));
+ item.defaultPickupDelay();
+ player.world.addEntity(item);
+ }
+ return true;
+ }
+ // Purpur end
}
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 0c79d6af4604d900bfa33f544ac0e0e56932de50..a927869cdb6e935226a20200827bd297aac4e8b2 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -563,6 +563,11 @@ public class PurpurWorldConfig {
signRightClickEdit = getBoolean("blocks.sign.right-click-edit", signRightClickEdit);
}
+ public boolean slabHalfBreak = false;
+ private void slabSettings() {
+ slabHalfBreak = getBoolean("blocks.slab.break-individual-slabs-when-sneaking", slabHalfBreak);
+ }
+
public boolean spawnerDeactivateByRedstone = false;
private void spawnerSettings() {
spawnerDeactivateByRedstone = getBoolean("blocks.spawner.deactivate-by-redstone", spawnerDeactivateByRedstone);