mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 11:53:29 +01:00
parent
01813ed372
commit
f831d48bba
4 changed files with 11 additions and 7 deletions
|
@ -309,13 +309,14 @@ public final class Helper {
|
|||
}
|
||||
}
|
||||
|
||||
public static ItemStack getEquippedItem(Predicate<ItemStack> predicate, Player player) {
|
||||
public static ItemStack getEquippedItem(Predicate<ItemStack> predicate, Player player, boolean hotbarOnly) {
|
||||
if (Compat.hasCompat("curios")) {
|
||||
var stack = CuriosApi.getCuriosHelper().findFirstCurio(player, predicate).map(SlotResult::stack);
|
||||
if (stack.isPresent())
|
||||
return stack.get();
|
||||
}
|
||||
for (var i = 0; i < player.getInventory().getContainerSize(); i++) {
|
||||
var invSize = hotbarOnly ? 9 : player.getInventory().getContainerSize();
|
||||
for (var i = 0; i < invSize; i++) {
|
||||
var slot = player.getInventory().getItem(i);
|
||||
if (!slot.isEmpty() && predicate.test(slot))
|
||||
return slot;
|
||||
|
|
|
@ -37,7 +37,7 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
|
|||
private boolean auraPlayerInteraction(Player player, int amount, boolean extract, boolean simulate) {
|
||||
if (extract && player.isCreative())
|
||||
return true;
|
||||
var stack = Helper.getEquippedItem(s -> s.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).isPresent(), player);
|
||||
var stack = Helper.getEquippedItem(s -> s.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).isPresent(), player, false);
|
||||
if (!stack.isEmpty()) {
|
||||
var container = stack.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).orElse(null);
|
||||
if (extract) {
|
||||
|
@ -181,4 +181,5 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
|
|||
highest = defaultSpot;
|
||||
return highest;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -153,9 +153,9 @@ public class ClientEvents {
|
|||
inst.setParticleSpawnRange(32);
|
||||
}
|
||||
|
||||
ClientEvents.heldCache = Helper.getEquippedItem(s -> s.getItem() instanceof ItemAuraCache, mc.player);
|
||||
ClientEvents.heldEye = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE, mc.player);
|
||||
ClientEvents.heldOcular = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE_IMPROVED, mc.player);
|
||||
ClientEvents.heldCache = Helper.getEquippedItem(s -> s.getItem() instanceof ItemAuraCache, mc.player, false);
|
||||
ClientEvents.heldEye = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE, mc.player, true);
|
||||
ClientEvents.heldOcular = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE_IMPROVED, mc.player, false);
|
||||
|
||||
if (!ClientEvents.heldOcular.isEmpty() && mc.level.getGameTime() % 20 == 0) {
|
||||
ClientEvents.SHOWING_EFFECTS.clear();
|
||||
|
|
|
@ -24,7 +24,7 @@ public class ItemDeathRing extends ItemImpl {
|
|||
public void onDeath(LivingDeathEvent event) {
|
||||
var entity = event.getEntity();
|
||||
if (!entity.level().isClientSide && entity instanceof Player) {
|
||||
var equipped = Helper.getEquippedItem(s -> s.getItem() == ModItems.DEATH_RING, (Player) entity);
|
||||
var equipped = Helper.getEquippedItem(s -> s.getItem() == ModItems.DEATH_RING, (Player) entity, false);
|
||||
if (!equipped.isEmpty()) {
|
||||
entity.setHealth(entity.getMaxHealth() / 2);
|
||||
entity.removeAllEffects();
|
||||
|
@ -39,5 +39,7 @@ public class ItemDeathRing extends ItemImpl {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue