Skip to content

Commit

Permalink
Fix build.
Browse files Browse the repository at this point in the history
Signed-off-by: 秋雨落 <i@rain.cx>
  • Loading branch information
qyl27 committed Aug 9, 2024
1 parent 053fef1 commit 92cd092
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.item.ArrowItem;
import net.minecraft.world.item.BowItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand All @@ -19,7 +16,7 @@ public interface ItemBridge {
return charge;
}

default AbstractArrow bridge$forge$customArrow(BowItem bowItem, ItemStack itemStack, AbstractArrow arrow) {
default AbstractArrow bridge$forge$customArrow(BowItem bowItem, ItemStack weapon, ItemStack projectile, AbstractArrow arrow) {
return arrow;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class EntityArgumentMixin implements EntityArgumentBridge {

public EntitySelector parse(StringReader reader, boolean overridePermissions) throws CommandSyntaxException {
int i = 0;
EntitySelectorParser entityselectorparser = new EntitySelectorParser(reader);
EntitySelectorParser entityselectorparser = new EntitySelectorParser(reader, true);
EntitySelector entityselector = ((EntitySelectorParserBridge) entityselectorparser).bridge$parse(overridePermissions);
if (entityselector.getMaxResults() > 1 && this.single) {
if (this.playersOnly) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.bukkit.craftbukkit.v.inventory.CraftInventoryView;
import org.bukkit.craftbukkit.v.inventory.CraftItemStack;
import org.bukkit.event.inventory.PrepareAnvilEvent;
import org.bukkit.inventory.view.AnvilView;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand Down Expand Up @@ -44,7 +45,7 @@ public abstract class AnvilMenuMixin extends ItemCombinerMixin implements AnvilM

@Decorate(method = "createResult", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/inventory/ResultContainer;setItem(ILnet/minecraft/world/item/ItemStack;)V"))
private void arclight$prepareAnvilEvent(ResultContainer instance, int i, ItemStack itemStack) throws Throwable {
var event = new PrepareAnvilEvent(getBukkitView(), CraftItemStack.asCraftMirror(itemStack).clone());
var event = new PrepareAnvilEvent((AnvilView) getBukkitView(), CraftItemStack.asCraftMirror(itemStack).clone());
Bukkit.getServer().getPluginManager().callEvent(event);
DecorationOps.callsite().invoke(instance, i, CraftItemStack.asNMSCopy(event.getResult()));
}
Expand All @@ -71,7 +72,7 @@ public CraftInventoryView getBukkitView() {
}

CraftInventory inventory = new CraftInventoryAnvil(
((IWorldPosCallableBridge) this.access).bridge$getLocation(), this.inputSlots, this.resultSlots, (AnvilMenu) (Object) this);
((IWorldPosCallableBridge) this.access).bridge$getLocation(), this.inputSlots, this.resultSlots);
bukkitEntity = new CraftInventoryView(((PlayerEntityBridge) this.player).bridge$getBukkitEntity(), inventory, (AbstractContainerMenu) (Object) this);
return bukkitEntity;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.bukkit.entity.Player;
import org.bukkit.event.enchantment.EnchantItemEvent;
import org.bukkit.event.enchantment.PrepareItemEnchantEvent;
import org.bukkit.inventory.view.EnchantmentView;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand Down Expand Up @@ -96,7 +97,7 @@ public abstract class EnchantmentContainerMixin extends AbstractContainerMenuMix
offers[j] = (enchantment != null) ? new EnchantmentOffer(enchantment, this.levelClue[j], this.costs[j]) : null;
}

PrepareItemEnchantEvent event = new PrepareItemEnchantEvent(((ServerPlayerEntityBridge) this.playerInventory.player).bridge$getBukkitEntity(), this.getBukkitView(), ((IWorldPosCallableBridge) this.access).bridge$getLocation().getBlock(), item, offers, arclight$power);
PrepareItemEnchantEvent event = new PrepareItemEnchantEvent(((ServerPlayerEntityBridge) this.playerInventory.player).bridge$getBukkitEntity(), (EnchantmentView) this.getBukkitView(), ((IWorldPosCallableBridge) this.access).bridge$getLocation().getBlock(), item, offers, arclight$power);
event.setCancelled(!arclight$enchantable);
Bukkit.getPluginManager().callEvent(event);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public class CustomRecipeMixin implements RecipeBridge {

@Override
public Recipe bridge$toBukkitRecipe(NamespacedKey id) {
return new org.bukkit.craftbukkit.v.inventory.CraftComplexRecipe(id, (CustomRecipe) (Object) this);
return new org.bukkit.craftbukkit.v.inventory.CraftComplexRecipe(id, null, (CustomRecipe) (Object) this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.izzel.arclight.common.mod.server.ArclightServer;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeHolder;
import net.minecraft.world.item.crafting.RecipeInput;
import org.bukkit.NamespacedKey;
import org.bukkit.craftbukkit.v.inventory.CraftComplexRecipe;
import org.bukkit.craftbukkit.v.inventory.CraftItemStack;
Expand All @@ -16,7 +17,7 @@ public class ArclightSpecialRecipe extends CraftComplexRecipe {
private final Recipe<?> recipe;

public ArclightSpecialRecipe(NamespacedKey id, Recipe<?> recipe) {
super(id, null);
super(id, null, null);
this.recipe = recipe;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
public class ItemMixin_Forge implements ItemBridge {

@Override
public AbstractArrow bridge$forge$customArrow(BowItem bowItem, ItemStack itemStack, AbstractArrow arrow) {
public AbstractArrow bridge$forge$customArrow(BowItem bowItem, ItemStack weapon, ItemStack projectile, AbstractArrow arrow) {
return bowItem.customArrow(arrow);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.neoforged.neoforge.common.CommonHooks;
import net.neoforged.neoforge.common.damagesource.DamageContainer;
import net.neoforged.neoforge.event.EventHooks;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -37,7 +38,7 @@ public abstract class LivingEntityMixin_NeoForge extends EntityMixin_NeoForge im

@Inject(method = "hurt", cancellable = true, at = @At("HEAD"))
private void arclight$livingHurt(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
if (!CommonHooks.onLivingAttack((LivingEntity) (Object) this, source, amount)) {
if (!CommonHooks.onEntityIncomingDamage((LivingEntity) (Object) this, new DamageContainer(source, amount))) {
cir.setReturnValue(false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.neoforged.neoforge.common.CommonHooks;
import net.neoforged.neoforge.common.damagesource.DamageContainer;
import net.neoforged.neoforge.common.extensions.IPlayerExtension;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -28,7 +29,7 @@ public abstract class PlayerMixin_NeoForge extends LivingEntityMixin_NeoForge im

@Inject(method = "hurt", cancellable = true, at = @At("HEAD"))
private void arclight$onPlayerAttack(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
if (!CommonHooks.onPlayerAttack((Player) (Object) this, source, amount)) {
if (!CommonHooks.onEntityIncomingDamage((Player) (Object) this, new DamageContainer(source, amount))) {
cir.setReturnValue(false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
public abstract class ItemMixin_NeoForge implements ItemBridge {

@Override
public AbstractArrow bridge$forge$customArrow(BowItem bowItem, ItemStack itemStack, AbstractArrow arrow) {
return bowItem.customArrow(arrow, itemStack);
public AbstractArrow bridge$forge$customArrow(BowItem bowItem, ItemStack weapon, ItemStack projectile, AbstractArrow arrow) {
return bowItem.customArrow(arrow, projectile, weapon);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public abstract class ItemEntityMixin_ActivationRange_NeoForge extends EntityMix
@Override
public void bridge$forge$optimization$discardItemEntity() {
if (!this.level().isClientSide && this.age >= this.lifespan) {
int hook = EventHooks.onItemExpire((ItemEntity) (Object) this, this.getItem());
int hook = EventHooks.onItemExpire((ItemEntity) (Object) this);
if (hook < 0) this.discard();
else this.lifespan += hook;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class ItemEntityEventDispatcher {

@SubscribeEvent(receiveCanceled = true)
public void onExpire(ItemExpireEvent event) {
event.setCanceled(CraftEventFactory.callItemDespawnEvent(event.getEntity()).isCancelled());
if (CraftEventFactory.callItemDespawnEvent(event.getEntity()).isCancelled()) {
event.setExtraLife(1);
}
}
}

0 comments on commit 92cd092

Please sign in to comment.