Skip to content

Commit

Permalink
Update to forge 40.2.10
Browse files Browse the repository at this point in the history
  • Loading branch information
IzzelAliz committed Aug 5, 2023
1 parent 473aa47 commit c743dbd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@ private void performInteraction(InteractionHand hand, ServerGamePacketListenerIm
// 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) {
Expand All @@ -1233,7 +1233,11 @@ public void onInteraction(InteractionHand hand) {

@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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
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;"))
Expand All @@ -54,19 +54,17 @@ 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) {
arclight$direction = result.getDirection();
arclight$click = result.getBlockPos();
arclight$stack = stack;
}

@Inject(method = "use", at = @At("RETURN"))
private void arclight$clean(Level worldIn, Player playerIn, InteractionHand handIn, CallbackInfoReturnable<InteractionResultHolder<ItemStack>> cir) {
arclight$captureItem = null;
arclight$direction = null;
arclight$click = null;
arclight$stack = null;
}

private transient org.bukkit.inventory.@Nullable ItemStack arclight$captureItem;
Expand All @@ -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<Boolean> 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<Boolean> 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();
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit c743dbd

Please sign in to comment.