From c743dbdb58b6067130a5f2ff13b8abbcc8bf7888 Mon Sep 17 00:00:00 2001 From: IzzelAliz Date: Sat, 5 Aug 2023 13:36:09 +0800 Subject: [PATCH] Update to forge 40.2.10 --- .../core/network/ServerPlayNetHandlerMixin.java | 8 ++++++-- .../core/world/entity/EntityTypeMixin.java | 2 -- .../mixin/core/world/item/BucketItemMixin.java | 17 ++++++----------- build.gradle | 2 +- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerPlayNetHandlerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerPlayNetHandlerMixin.java index bc03de77..62d949b6 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerPlayNetHandlerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerPlayNetHandlerMixin.java @@ -1207,7 +1207,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB // CraftBukkit end InteractionResult enuminteractionresult = interaction.run(player, entity, hand); - if (ForgeHooks.onInteractEntityAt(player, entity, entity.position(), hand) != null) return; + // if (ForgeHooks.onInteractEntityAt(player, entity, entity.position(), hand) != null) return; // CraftBukkit start if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) { @@ -1233,7 +1233,11 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB @Override public void onInteraction(InteractionHand hand, Vec3 vec) { - this.performInteraction(hand, (player, e, h) -> e.interactAt(player, vec, h), + this.performInteraction(hand, (player, e, h) -> { + var interactionResult = ForgeHooks.onInteractEntityAt(player, entity, vec, hand); + if (interactionResult != null) return interactionResult; + return e.interactAt(player, vec, h); + }, new PlayerInteractAtEntityEvent(getCraftPlayer(), ((EntityBridge) entity).bridge$getBukkitEntity(), new org.bukkit.util.Vector(vec.x, vec.y, vec.z), (hand == InteractionHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND)); } diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/EntityTypeMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/EntityTypeMixin.java index 5a9f55be..ac0e4690 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/EntityTypeMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/entity/EntityTypeMixin.java @@ -49,8 +49,6 @@ public abstract class EntityTypeMixin implements EntityTypeBri public T spawn(ServerLevel worldIn, @Nullable CompoundTag compound, @Nullable Component customName, @Nullable Player playerIn, BlockPos pos, MobSpawnType reason, boolean p_220342_7_, boolean p_220342_8_, CreatureSpawnEvent.SpawnReason spawnReason) { T t = this.create(worldIn, compound, customName, playerIn, pos, reason, p_220342_7_, p_220342_8_); if (t != null) { - if (t instanceof net.minecraft.world.entity.Mob && net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn((net.minecraft.world.entity.Mob) t, worldIn, pos.getX(), pos.getY(), pos.getZ(), null, reason)) - return null; ((IWorldWriterBridge) worldIn).bridge$pushAddEntityReason(spawnReason); worldIn.addFreshEntityWithPassengers(t); return t.isRemoved() ? null : t; diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/BucketItemMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/BucketItemMixin.java index 89e0cbc4..32448477 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/BucketItemMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/world/item/BucketItemMixin.java @@ -35,7 +35,7 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture; public abstract class BucketItemMixin { // @formatter:off - @Shadow public abstract boolean emptyContents(@javax.annotation.Nullable Player player, Level worldIn, BlockPos posIn, @javax.annotation.Nullable BlockHitResult rayTrace); + @Shadow(remap = false) public abstract boolean emptyContents(@javax.annotation.Nullable Player player, Level worldIn, BlockPos posIn, @javax.annotation.Nullable BlockHitResult rayTrace, ItemStack stack); // @formatter:on @Inject(method = "use", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/BucketPickup;pickupBlock(Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/item/ItemStack;")) @@ -54,11 +54,10 @@ public abstract class BucketItemMixin { } } - @Inject(method = "use", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/BucketItem;emptyContents(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/phys/BlockHitResult;)Z")) + @Inject(method = "use", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(value = "INVOKE", remap = false, target = "Lnet/minecraft/world/item/BucketItem;emptyContents(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/phys/BlockHitResult;Lnet/minecraft/world/item/ItemStack;)Z")) private void arclight$capture(Level worldIn, Player playerIn, InteractionHand handIn, CallbackInfoReturnable> cir, ItemStack stack, BlockHitResult result) { arclight$direction = result.getDirection(); arclight$click = result.getBlockPos(); - arclight$stack = stack; } @Inject(method = "use", at = @At("RETURN")) @@ -66,7 +65,6 @@ public abstract class BucketItemMixin { arclight$captureItem = null; arclight$direction = null; arclight$click = null; - arclight$stack = null; } private transient org.bukkit.inventory.@Nullable ItemStack arclight$captureItem; @@ -79,25 +77,22 @@ public abstract class BucketItemMixin { public boolean emptyContents(Player entity, Level world, BlockPos pos, @Nullable BlockHitResult result, Direction direction, BlockPos clicked, ItemStack itemstack) { arclight$direction = direction; arclight$click = clicked; - arclight$stack = itemstack; try { - return this.emptyContents(entity, world, pos, result); + return this.emptyContents(entity, world, pos, result, itemstack); } finally { arclight$direction = null; arclight$click = null; - arclight$stack = null; } } private transient Direction arclight$direction; private transient BlockPos arclight$click; - private transient ItemStack arclight$stack; - @Inject(method = "emptyContents", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/dimension/DimensionType;ultraWarm()Z")) - private void arclight$bucketEmpty(Player player, Level worldIn, BlockPos posIn, BlockHitResult rayTrace, CallbackInfoReturnable cir) { + @Inject(method = "emptyContents(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/phys/BlockHitResult;Lnet/minecraft/world/item/ItemStack;)Z", remap = false, cancellable = true, at = @At(value = "INVOKE", remap = true, target = "Lnet/minecraft/world/level/dimension/DimensionType;ultraWarm()Z")) + private void arclight$bucketEmpty(Player player, Level worldIn, BlockPos posIn, BlockHitResult rayTrace, ItemStack itemStack, CallbackInfoReturnable cir) { if (!DistValidate.isValid(worldIn)) return; if (player != null) { - PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent((ServerLevel) worldIn, player, posIn, arclight$click, arclight$direction, arclight$stack); + PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent((ServerLevel) worldIn, player, posIn, arclight$click, arclight$direction, itemStack); if (event.isCancelled()) { ((ServerPlayer) player).connection.send(new ClientboundBlockUpdatePacket(worldIn, posIn)); ((ServerPlayerEntityBridge) player).bridge$getBukkitEntity().updateInventory(); diff --git a/build.gradle b/build.gradle index 7f28d2dd..10c077c3 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ allprojects { ext { agpVersion = '1.23' minecraftVersion = '1.18.2' - forgeVersion = '40.2.1' + forgeVersion = '40.2.10' apiVersion = '1.4.0' toolsVersion = '1.3.+' mixinVersion = '0.8.5'