Update to forge 40.2.10

This commit is contained in:
IzzelAliz 2023-08-05 13:36:09 +08:00
parent 473aa47edb
commit c743dbdb58
No known key found for this signature in database
GPG Key ID: EE50E123A11D8338
4 changed files with 13 additions and 16 deletions

View File

@ -1207,7 +1207,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB
// CraftBukkit end // CraftBukkit end
InteractionResult enuminteractionresult = interaction.run(player, entity, hand); 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 // CraftBukkit start
if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) { if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) {
@ -1233,7 +1233,11 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB
@Override @Override
public void onInteraction(InteractionHand hand, Vec3 vec) { 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 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)); new org.bukkit.util.Vector(vec.x, vec.y, vec.z), (hand == InteractionHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND));
} }

View File

@ -49,8 +49,6 @@ public abstract class EntityTypeMixin<T extends Entity> 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) { 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_); T t = this.create(worldIn, compound, customName, playerIn, pos, reason, p_220342_7_, p_220342_8_);
if (t != null) { 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); ((IWorldWriterBridge) worldIn).bridge$pushAddEntityReason(spawnReason);
worldIn.addFreshEntityWithPassengers(t); worldIn.addFreshEntityWithPassengers(t);
return t.isRemoved() ? null : t; return t.isRemoved() ? null : t;

View File

@ -35,7 +35,7 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
public abstract class BucketItemMixin { public abstract class BucketItemMixin {
// @formatter:off // @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 // @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;")) @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<InteractionResultHolder<ItemStack>> cir, ItemStack stack, BlockHitResult result) { private void arclight$capture(Level worldIn, Player playerIn, InteractionHand handIn, CallbackInfoReturnable<InteractionResultHolder<ItemStack>> cir, ItemStack stack, BlockHitResult result) {
arclight$direction = result.getDirection(); arclight$direction = result.getDirection();
arclight$click = result.getBlockPos(); arclight$click = result.getBlockPos();
arclight$stack = stack;
} }
@Inject(method = "use", at = @At("RETURN")) @Inject(method = "use", at = @At("RETURN"))
@ -66,7 +65,6 @@ public abstract class BucketItemMixin {
arclight$captureItem = null; arclight$captureItem = null;
arclight$direction = null; arclight$direction = null;
arclight$click = null; arclight$click = null;
arclight$stack = null;
} }
private transient org.bukkit.inventory.@Nullable ItemStack arclight$captureItem; 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) { public boolean emptyContents(Player entity, Level world, BlockPos pos, @Nullable BlockHitResult result, Direction direction, BlockPos clicked, ItemStack itemstack) {
arclight$direction = direction; arclight$direction = direction;
arclight$click = clicked; arclight$click = clicked;
arclight$stack = itemstack;
try { try {
return this.emptyContents(entity, world, pos, result); return this.emptyContents(entity, world, pos, result, itemstack);
} finally { } finally {
arclight$direction = null; arclight$direction = null;
arclight$click = null; arclight$click = null;
arclight$stack = null;
} }
} }
private transient Direction arclight$direction; private transient Direction arclight$direction;
private transient BlockPos arclight$click; 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")) @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, CallbackInfoReturnable<Boolean> cir) { private void arclight$bucketEmpty(Player player, Level worldIn, BlockPos posIn, BlockHitResult rayTrace, ItemStack itemStack, CallbackInfoReturnable<Boolean> cir) {
if (!DistValidate.isValid(worldIn)) return; if (!DistValidate.isValid(worldIn)) return;
if (player != null) { 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()) { if (event.isCancelled()) {
((ServerPlayer) player).connection.send(new ClientboundBlockUpdatePacket(worldIn, posIn)); ((ServerPlayer) player).connection.send(new ClientboundBlockUpdatePacket(worldIn, posIn));
((ServerPlayerEntityBridge) player).bridge$getBukkitEntity().updateInventory(); ((ServerPlayerEntityBridge) player).bridge$getBukkitEntity().updateInventory();

View File

@ -14,7 +14,7 @@ allprojects {
ext { ext {
agpVersion = '1.23' agpVersion = '1.23'
minecraftVersion = '1.18.2' minecraftVersion = '1.18.2'
forgeVersion = '40.2.1' forgeVersion = '40.2.10'
apiVersion = '1.4.0' apiVersion = '1.4.0'
toolsVersion = '1.3.+' toolsVersion = '1.3.+'
mixinVersion = '0.8.5' mixinVersion = '0.8.5'