mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-15 20:44:50 +00:00
Implemented anvil repair and item destroyed events for custom items and linked items
This commit is contained in:
1 parent
90bd8aeb02
commit
972e930b31
4 files changed
+108
-3
No files matched your search
@@ -9,9 +9,7 @@ import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.event.entity.item.ItemTossEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||
import net.minecraftforge.event.entity.player.EntityInteractEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerUseItemEvent;
|
||||
import net.minecraftforge.event.entity.player.*;
|
||||
import noppes.npcs.api.IWorld;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.api.item.IItemCustomizable;
|
||||
@@ -224,4 +222,24 @@ public class ScriptItemEventHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
@SubscribeEvent
|
||||
public void invoke(AnvilRepairEvent repairEvent) {
|
||||
IItemStack output = NpcAPI.Instance().getIItemStack(repairEvent.output);
|
||||
if (output instanceof IItemCustomizable) {
|
||||
IPlayer player = (IPlayer) NpcAPI.Instance().getIEntity(repairEvent.entityPlayer);
|
||||
IItemStack left = NpcAPI.Instance().getIItemStack(repairEvent.left);
|
||||
IItemStack right = NpcAPI.Instance().getIItemStack(repairEvent.right);
|
||||
float breakChance = repairEvent.breakChance;
|
||||
EventHooks.onRepairCustomItem((IItemCustomizable) output, player, left, right, breakChance);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void invoke(PlayerDestroyItemEvent destroyItemEvent) {
|
||||
IItemStack itemStack = NpcAPI.Instance().getIItemStack(destroyItemEvent.original);
|
||||
if (itemStack instanceof IItemCustomizable) {
|
||||
IPlayer player = (IPlayer) NpcAPI.Instance().getIEntity(destroyItemEvent.entityPlayer);
|
||||
EventHooks.onBreakCustomItem((IItemCustomizable) itemStack, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user