mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-28 03:56:59 -05:00
Merge remote-tracking branch 'architectury/1.19.4' into 1.20
This commit is contained in:
@@ -23,21 +23,24 @@ import dev.architectury.event.events.common.BlockEvent;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
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;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@Mixin(BlockItem.class)
|
||||
public abstract class MixinBlockItem {
|
||||
@Inject(method = "place",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/item/context/BlockPlaceContext;getClickedPos()Lnet/minecraft/core/BlockPos;"),
|
||||
target = "Lnet/minecraft/world/item/BlockItem;placeBlock(Lnet/minecraft/world/item/context/BlockPlaceContext;Lnet/minecraft/world/level/block/state/BlockState;)Z"),
|
||||
locals = LocalCapture.CAPTURE_FAILHARD,
|
||||
cancellable = true)
|
||||
private void place(BlockPlaceContext context, CallbackInfoReturnable<InteractionResult> cir) {
|
||||
var result = BlockEvent.PLACE.invoker().placeBlock(context.getLevel(), context.getClickedPos(), context.getLevel().getBlockState(context.getClickedPos()), context.getPlayer());
|
||||
if (result.isPresent()) {
|
||||
cir.setReturnValue(result.isTrue() ? InteractionResult.SUCCESS : InteractionResult.FAIL);
|
||||
private void place(BlockPlaceContext _0, CallbackInfoReturnable<InteractionResult> cir, BlockPlaceContext context, BlockState placedState) {
|
||||
var result = BlockEvent.PLACE.invoker().placeBlock(context.getLevel(), context.getClickedPos(), placedState, context.getPlayer());
|
||||
if (result.isFalse()) {
|
||||
cir.setReturnValue(InteractionResult.FAIL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ import java.util.OptionalInt;
|
||||
public class MixinServerPlayer {
|
||||
@Inject(method = "restoreFrom", at = @At("RETURN"))
|
||||
private void restoreFrom(ServerPlayer serverPlayer, boolean bl, CallbackInfo ci) {
|
||||
PlayerEvent.PLAYER_CLONE.invoker().clone((ServerPlayer) (Object) this, serverPlayer, bl);
|
||||
PlayerEvent.PLAYER_CLONE.invoker().clone(serverPlayer, (ServerPlayer) (Object) this, bl);
|
||||
}
|
||||
|
||||
@Inject(method = "openMenu", at = @At("RETURN"))
|
||||
|
||||
Reference in New Issue
Block a user