Merge pull request #6911 from IThundxr/mc1.20.1/deployer-fix

Fix deployers not replacing replacable blocks like water
This commit is contained in:
simibubi 2024-10-07 16:35:40 +02:00 committed by GitHub
commit 1dc32f94e7
Failed to generate hash of commit

View file

@ -9,7 +9,6 @@ import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@ -22,7 +21,7 @@ public class BlockItemMixin {
@Inject(method = "place", at = @At("HEAD"), cancellable = true) @Inject(method = "place", at = @At("HEAD"), cancellable = true)
private void create$fixDeployerPlacement(BlockPlaceContext pContext, CallbackInfoReturnable<InteractionResult> cir) { private void create$fixDeployerPlacement(BlockPlaceContext pContext, CallbackInfoReturnable<InteractionResult> cir) {
BlockState state = pContext.getLevel().getBlockState(((UseOnContextAccessor) pContext).create$getHitResult().getBlockPos()); BlockState state = pContext.getLevel().getBlockState(((UseOnContextAccessor) pContext).create$getHitResult().getBlockPos());
if (state != Blocks.AIR.defaultBlockState() && pContext.getPlayer() instanceof DeployerFakePlayer) { if (!state.canBeReplaced() && pContext.getPlayer() instanceof DeployerFakePlayer) {
cir.setReturnValue(InteractionResult.PASS); cir.setReturnValue(InteractionResult.PASS);
} }
} }