99 lines
6.2 KiB
Diff
99 lines
6.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
|
Date: Mon, 3 Feb 2025 13:51:26 +0800
|
|
Subject: [PATCH] Leaves: Alternative block placement Protocol
|
|
|
|
Co-authored by: violetc <58360096+s-yh-china@users.noreply.github.com>
|
|
As a part of : Leaves (https://github.com/LeavesMC/Leaves)
|
|
Licensed under: MIT
|
|
|
|
This patch is Powered by
|
|
carpet-extra(https://github.com/gnembon/carpet-extra)
|
|
MasaGadget(https://github.com/plusls/MasaGadget)
|
|
litematica(https://github.com/maruohon/litematica)
|
|
|
|
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index 1af966cadec3dd51aae842824e432e20b700d9c9..83c9418ea45b8d7f639c6bf5e134bad90d9ac039 100644
|
|
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -2183,7 +2183,7 @@ public class ServerGamePacketListenerImpl
|
|
if (ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(this.player.level(), pos.getX() >> 4, pos.getZ() >> 4, 8) && this.player.isWithinBlockInteractionRange(pos, 1.0)) { // Folia - do not allow players to interact with blocks outside the current region
|
|
Vec3 distance = location.subtract(Vec3.atCenterOf(pos));
|
|
double limit = 1.0000001;
|
|
- if (Math.abs(distance.x()) < 1.0000001 && Math.abs(distance.y()) < 1.0000001 && Math.abs(distance.z()) < 1.0000001) {
|
|
+ if (fun.bm.lophine.config.modules.function.protocol.AlternativeBlockPlacementProtocolConfig.needIgnoreDistance() ||Math.abs(distance.x()) < 1.0000001 && Math.abs(distance.y()) < 1.0000001 && Math.abs(distance.z()) < 1.0000001) { // Leaves - disableDistanceCheckForUseItem
|
|
Direction direction = blockHit.getDirection();
|
|
this.player.resetLastActionTime();
|
|
int maxY = level.getMaxY();
|
|
diff --git a/net/minecraft/world/item/BlockItem.java b/net/minecraft/world/item/BlockItem.java
|
|
index 3167be4b7c2c61ef725af4a832d759ab6e061af0..2e2a8af12f249ec5bd0935fd13f5acbd0a777b5f 100644
|
|
--- a/net/minecraft/world/item/BlockItem.java
|
|
+++ b/net/minecraft/world/item/BlockItem.java
|
|
@@ -136,7 +136,7 @@ public class BlockItem extends Item {
|
|
}
|
|
|
|
protected @Nullable BlockState getPlacementState(final BlockPlaceContext context) {
|
|
- BlockState stateForPlacement = this.getBlock().getStateForPlacement(context);
|
|
+ BlockState stateForPlacement = this.getBlock().getRealStateForPlacement(context); // Leaves - alternativeBlockPlacement
|
|
return stateForPlacement != null && this.canPlace(context, stateForPlacement) ? stateForPlacement : null;
|
|
}
|
|
|
|
diff --git a/net/minecraft/world/item/StandingAndWallBlockItem.java b/net/minecraft/world/item/StandingAndWallBlockItem.java
|
|
index d5d499226d0b2c2adfae7bbb4c28c96c80411c44..cb0a4a9865df69e5504a86de6c144bc4450bd19a 100644
|
|
--- a/net/minecraft/world/item/StandingAndWallBlockItem.java
|
|
+++ b/net/minecraft/world/item/StandingAndWallBlockItem.java
|
|
@@ -26,14 +26,14 @@ public class StandingAndWallBlockItem extends BlockItem {
|
|
|
|
@Override
|
|
protected @Nullable BlockState getPlacementState(final BlockPlaceContext context) {
|
|
- BlockState wallState = this.wallBlock.getStateForPlacement(context);
|
|
+ BlockState wallState = this.wallBlock.getRealStateForPlacement(context); // Leaves - alternativeBlockPlacement
|
|
BlockState stateForPlacement = null;
|
|
LevelReader level = context.getLevel();
|
|
BlockPos pos = context.getClickedPos();
|
|
|
|
for (Direction direction : context.getNearestLookingDirections()) {
|
|
if (direction != this.attachmentDirection.getOpposite()) {
|
|
- BlockState possibleState = direction == this.attachmentDirection ? this.getBlock().getStateForPlacement(context) : wallState;
|
|
+ BlockState possibleState = direction == this.attachmentDirection ? this.getBlock().getRealStateForPlacement(context) : wallState; // Leaves - alternativeBlockPlacement
|
|
if (possibleState != null && this.canPlace(level, possibleState, pos)) {
|
|
stateForPlacement = possibleState;
|
|
break;
|
|
diff --git a/net/minecraft/world/level/block/Block.java b/net/minecraft/world/level/block/Block.java
|
|
index c5f4e0570a82dfcc2ba88023f3301f69afa41cc5..30f7e8f5e3e9440713e36ee25c90150b6b93c6ff 100644
|
|
--- a/net/minecraft/world/level/block/Block.java
|
|
+++ b/net/minecraft/world/level/block/Block.java
|
|
@@ -516,6 +516,32 @@ public class Block extends BlockBehaviour implements ItemLike {
|
|
public void stepOn(final Level level, final BlockPos pos, final BlockState onState, final Entity entity) {
|
|
}
|
|
|
|
+ // Leaves start - alternativeBlockPlacement
|
|
+ public @Nullable BlockState getRealStateForPlacement(final BlockPlaceContext context) {
|
|
+ BlockState vanillaState = this.getStateForPlacement(context);
|
|
+ switch (fun.bm.lophine.config.modules.function.protocol.AlternativeBlockPlacementProtocolConfig.alternativeBlockPlacement) {
|
|
+ case fun.bm.lophine.enums.EnumAlternativePlaceType.CARPET -> {
|
|
+ BlockState tryState = org.leavesmc.leaves.protocol.CarpetAlternativeBlockPlacement.alternativeBlockPlacement(this, context);
|
|
+ if (tryState != null) {
|
|
+ return tryState;
|
|
+ }
|
|
+ }
|
|
+ case fun.bm.lophine.enums.EnumAlternativePlaceType.CARPET_FIX -> {
|
|
+ BlockState tryState = org.leavesmc.leaves.protocol.CarpetAlternativeBlockPlacement.alternativeBlockPlacementFix(this, context);
|
|
+ if (tryState != null) {
|
|
+ return tryState;
|
|
+ }
|
|
+ }
|
|
+ case fun.bm.lophine.enums.EnumAlternativePlaceType.LITEMATICA -> {
|
|
+ if (vanillaState != null) {
|
|
+ return org.leavesmc.leaves.protocol.LitematicaEasyPlaceProtocol.applyPlacementProtocol(vanillaState, context);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ return vanillaState;
|
|
+ }
|
|
+ // Leaves end - alternativeBlockPlacement
|
|
+
|
|
public @Nullable BlockState getStateForPlacement(final BlockPlaceContext context) {
|
|
return this.defaultBlockState();
|
|
}
|