mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-18 17:07:43 +01:00
75 lines
4.3 KiB
Diff
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 e47a743fd3adc62aa47beec722f49eeaded246bc..1f38bc36e957ca386774b615bc8b7a04470ce46c 100644
|
|
--- a/src/main/java/net/minecraft/server/level/PlayerInteractManager.java
|
|
+++ b/src/main/java/net/minecraft/server/level/PlayerInteractManager.java
|
|
@@ -409,6 +409,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 c09c3a326e6ea80f3037a3d9fd6b78f03d8a7ecd..8054d6242358dc2bf212c7aff55ebf011c22e474 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -529,6 +529,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);
|