Update forge to 43.1.47

This commit is contained in:
IzzelAliz 2022-10-29 17:05:37 +08:00
parent ec4791afcf
commit 7ce41083cd
8 changed files with 58 additions and 5 deletions

View File

@ -6,7 +6,7 @@ A Bukkit server implementation utilizing Mixin.
| Release | Forge | Status | Build |
|:-------------:|:-------:|:------:|:------------------------------------------------------------------------------------------------------------------------------------------------------:|
| Horn (1.19.x) | 43.1.3 | ACTIVE | [![1.19 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-19?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-19) |
| Horn (1.19.x) | 43.1.47 | ACTIVE | [![1.19 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-19?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-19) |
| 1.18.x | 40.1.80 | LTS | [![1.18 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-18?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-18) |
| 1.16.x | 36.2.39 | LTS | [![1.16 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-16?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-16) |

View File

@ -1298,7 +1298,6 @@ 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;
// CraftBukkit start
if (!itemInHand.isEmpty() && itemInHand.getCount() <= -1) {
@ -1324,7 +1323,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 onInteractEntityAtResult = ForgeHooks.onInteractEntityAt(player, entity, vec, hand);
if (onInteractEntityAtResult != null) return onInteractEntityAtResult;
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));
}

View File

@ -919,7 +919,7 @@ public abstract class LivingEntityMixin extends EntityMixin implements LivingEnt
org.bukkit.inventory.EquipmentSlot bukkitHand = null;
for (InteractionHand hand : InteractionHand.values()) {
itemstack1 = this.getItemInHand(hand);
if (itemstack1.getItem() == Items.TOTEM_OF_UNDYING) {
if (itemstack1.is(Items.TOTEM_OF_UNDYING) && ForgeHooks.onLivingUseTotem((LivingEntity) (Object) this, damageSourceIn, itemstack1, hand)) {
itemstack = itemstack1.copy();
bukkitHand = CraftEquipmentSlot.getHand(hand);
// itemstack1.shrink(1);

View File

@ -22,6 +22,7 @@ import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.event.entity.living.LivingChangeTargetEvent;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
@ -140,6 +141,12 @@ public abstract class MobMixin extends LivingEntityMixin implements MobEntityBri
} else {
livingEntity = null;
}
var changeTargetEvent = ForgeHooks.onLivingChangeTarget((LivingEntity) (Object) this, livingEntity, LivingChangeTargetEvent.LivingTargetType.MOB_TARGET);
if (changeTargetEvent.isCanceled()) {
arclight$targetSuccess = false;
return;
}
livingEntity = changeTargetEvent.getNewTarget();
}
this.target = livingEntity;
ForgeHooks.onLivingSetAttackTarget((Mob) (Object) this, this.target);

View File

@ -5,6 +5,8 @@ import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.ai.behavior.StartAttacking;
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.event.entity.living.LivingChangeTargetEvent;
import org.bukkit.craftbukkit.v.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v.event.CraftEventFactory;
import org.bukkit.event.entity.EntityTargetEvent;
@ -25,7 +27,14 @@ public class StartAttackingMixin<E extends Mob> {
return;
}
livingEntity = ((event.getTarget() != null) ? ((CraftLivingEntity) event.getTarget()).getHandle() : null);
var changeTargetEvent = ForgeHooks.onLivingChangeTarget(mob, livingEntity, LivingChangeTargetEvent.LivingTargetType.BEHAVIOR_TARGET);
if (changeTargetEvent.isCanceled()) {
return;
}
livingEntity = changeTargetEvent.getNewTarget();
mob.getBrain().setMemory(MemoryModuleType.ATTACK_TARGET, livingEntity);
mob.getBrain().eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE);
// noinspection removal
ForgeHooks.onLivingSetAttackTarget(mob, livingEntity, LivingChangeTargetEvent.LivingTargetType.BEHAVIOR_TARGET); // TODO: Remove in 1.20
}
}

View File

@ -0,0 +1,33 @@
package io.izzel.arclight.common.mixin.core.world.item;
import io.izzel.arclight.common.bridge.core.entity.player.ServerPlayerEntityBridge;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.item.StandingAndWallBlockItem;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.block.state.BlockState;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v.block.CraftBlock;
import org.bukkit.craftbukkit.v.block.data.CraftBlockData;
import org.bukkit.event.block.BlockCanBuildEvent;
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(StandingAndWallBlockItem.class)
public class StandingAndWallBlockItemMixin {
@Inject(method = "getPlacementState", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD, at = @At("RETURN"))
private void arclight$blockCanPlace(BlockPlaceContext context, CallbackInfoReturnable<BlockState> cir, BlockState place, BlockState defaultReturn) {
if (defaultReturn != null) {
var result = cir.getReturnValue() != null;
var player = (context.getPlayer() instanceof ServerPlayerEntityBridge bridge) ? bridge.bridge$getBukkitEntity() : null;
var event = new BlockCanBuildEvent(CraftBlock.at(context.getLevel(), context.getClickedPos()), player, CraftBlockData.fromData(defaultReturn), result);
Bukkit.getPluginManager().callEvent(event);
cir.setReturnValue(event.isBuildable() ? defaultReturn : null);
}
}
}

View File

@ -304,6 +304,7 @@
"world.item.ShearsItemMixin",
"world.item.SnowballItemMixin",
"world.item.SpawnEggItemMixin",
"world.item.StandingAndWallBlockItemMixin",
"world.item.TridentItemMixin",
"world.item.crafting.BlastingRecipeMixin",
"world.item.crafting.CampfireCookingRecipeMixin",

View File

@ -14,7 +14,7 @@ allprojects {
ext {
agpVersion = '1.23'
minecraftVersion = '1.19.2'
forgeVersion = '43.1.3'
forgeVersion = '43.1.47'
apiVersion = '1.5.0'
toolsVersion = '1.3.0'
mixinVersion = '0.8.5'