9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2026-01-04 15:41:31 +00:00

Apply carpet protocol

This commit is contained in:
violetc
2024-05-22 22:41:01 +08:00
parent 0ad1d49f74
commit 0d3dee8ee9
17 changed files with 34 additions and 156 deletions

View File

@@ -8,15 +8,6 @@ carpet-extra(https://github.com/gnembon/carpet-extra)
MasaGadget(https://github.com/plusls/MasaGadget)
litematica(https://github.com/maruohon/litematica)
diff --git a/.gitignore b/.gitignore
index 1ad93453221244f880855b510e888e759275b640..3811c0d849a3eb028ed1a6b7a2d4747f7f570448 100644
--- a/.gitignore
+++ b/.gitignore
@@ -46,4 +46,3 @@ dependency-reduced-pom.xml
# vs code
/.vscode
/.factorypath
-
diff --git a/src/main/java/net/minecraft/world/item/BlockItem.java b/src/main/java/net/minecraft/world/item/BlockItem.java
index 96fb69ec6db2e7c8c728435f0c537b076259b2fb..7632d5ac83c84e943654477b3f36e6605e28c9a7 100644
--- a/src/main/java/net/minecraft/world/item/BlockItem.java
@@ -53,7 +44,7 @@ index f8f909ebdad5e96379e8bd8c610164ef0697368e..0b761f3ae15ad4a3b8152f497a604032
if (iblockdata2 != null && this.canPlace(world, iblockdata2, blockposition)) {
iblockdata1 = iblockdata2;
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 e27f2317e4e2f13b6ef12be727046497a750fd3a..41f1a7bf2fb87b6d28d2ca392dfee5d5032d2151 100644
index e27f2317e4e2f13b6ef12be727046497a750fd3a..549f77998274404b1b475230d88568fd3e27ac6d 100644
--- a/src/main/java/net/minecraft/world/level/block/Block.java
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
@@ -412,6 +412,33 @@ public class Block extends BlockBehaviour implements ItemLike {
@@ -65,19 +56,19 @@ index e27f2317e4e2f13b6ef12be727046497a750fd3a..41f1a7bf2fb87b6d28d2ca392dfee5d5
+ public BlockState getRealStateForPlacement(BlockPlaceContext ctx) {
+ BlockState vanillaState = getStateForPlacement(ctx);
+ switch (org.leavesmc.leaves.LeavesConfig.alternativeBlockPlacement) {
+ case "CARPET" -> {
+ case CARPET -> {
+ BlockState tryState = org.leavesmc.leaves.protocol.CarpetAlternativeBlockPlacement.alternativeBlockPlacement(this, ctx);
+ if (tryState != null) {
+ return tryState;
+ }
+ }
+ case "CARPET_FIX" -> {
+ case CARPET_FIX -> {
+ BlockState tryState = org.leavesmc.leaves.protocol.CarpetAlternativeBlockPlacement.alternativeBlockPlacementFix(this, ctx);
+ if (tryState != null) {
+ return tryState;
+ }
+ }
+ case "LITEMATICA" -> {
+ case LITEMATICA -> {
+ if (vanillaState != null) {
+ return org.leavesmc.leaves.protocol.LitematicaEasyPlaceProtocol.applyPlacementProtocol(vanillaState, ctx);
+ }