Merge remote-tracking branch 'origin/mc1.18/fix-deployer-blockitem-onuse' into mc1.18/fix-deployer-blockitem-onuse

# Conflicts:
#	src/main/java/com/simibubi/create/content/kinetics/deployer/DeployerHandler.java
This commit is contained in:
IThundxr 2024-08-17 20:39:08 -04:00
commit b3604306eb
No known key found for this signature in database
GPG Key ID: E291EC97BAF935E6
3 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,27 @@
package com.simibubi.create.foundation.mixin;
import com.simibubi.create.content.kinetics.deployer.DeployerFakePlayer;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(BlockItem.class)
public class BlockItemMixin {
@Inject(method = "place", at = @At("HEAD"), cancellable = true)
private void create$fixDeployerPlacement(BlockPlaceContext pContext, CallbackInfoReturnable<InteractionResult> cir) {
BlockState state = pContext.getLevel().getBlockState(((UseOnContextAccessor) pContext).create$getHitResult().getBlockPos());
if (state != Blocks.AIR.defaultBlockState() && pContext.getPlayer() instanceof DeployerFakePlayer) {
cir.setReturnValue(InteractionResult.PASS);
}
}
}

View File

@ -0,0 +1,14 @@
package com.simibubi.create.foundation.mixin;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.phys.BlockHitResult;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(UseOnContext.class)
public interface UseOnContextAccessor {
@Invoker("getHitResult")
BlockHitResult create$getHitResult();
}

View File

@ -6,6 +6,7 @@
"compatibilityLevel": "JAVA_17",
"refmap": "create.refmap.json",
"mixins": [
"BlockItemMixin",
"ClientboundMapItemDataPacketMixin",
"ContraptionDriverInteractMixin",
"CustomItemUseEffectsMixin",
@ -15,6 +16,7 @@
"MainMixin",
"MapItemSavedDataMixin",
"TestCommandMixin",
"UseOnContextAccessor",
"WaterWheelFluidSpreadMixin",
"accessor.AbstractProjectileDispenseBehaviorAccessor",
"accessor.DispenserBlockAccessor",