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")) {
|
if (Compat.hasCompat("curios")) {
|
||||||
var stack = CuriosApi.getCuriosHelper().findFirstCurio(player, predicate).map(SlotResult::stack);
|
var stack = CuriosApi.getCuriosHelper().findFirstCurio(player, predicate).map(SlotResult::stack);
|
||||||
if (stack.isPresent())
|
if (stack.isPresent())
|
||||||
return stack.get();
|
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);
|
var slot = player.getInventory().getItem(i);
|
||||||
if (!slot.isEmpty() && predicate.test(slot))
|
if (!slot.isEmpty() && predicate.test(slot))
|
||||||
return slot;
|
return slot;
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
|
||||||
private boolean auraPlayerInteraction(Player player, int amount, boolean extract, boolean simulate) {
|
private boolean auraPlayerInteraction(Player player, int amount, boolean extract, boolean simulate) {
|
||||||
if (extract && player.isCreative())
|
if (extract && player.isCreative())
|
||||||
return true;
|
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()) {
|
if (!stack.isEmpty()) {
|
||||||
var container = stack.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).orElse(null);
|
var container = stack.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER).orElse(null);
|
||||||
if (extract) {
|
if (extract) {
|
||||||
|
@ -181,4 +181,5 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
|
||||||
highest = defaultSpot;
|
highest = defaultSpot;
|
||||||
return highest;
|
return highest;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,9 +153,9 @@ public class ClientEvents {
|
||||||
inst.setParticleSpawnRange(32);
|
inst.setParticleSpawnRange(32);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientEvents.heldCache = Helper.getEquippedItem(s -> s.getItem() instanceof ItemAuraCache, 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);
|
ClientEvents.heldEye = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE, mc.player, true);
|
||||||
ClientEvents.heldOcular = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE_IMPROVED, mc.player);
|
ClientEvents.heldOcular = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE_IMPROVED, mc.player, false);
|
||||||
|
|
||||||
if (!ClientEvents.heldOcular.isEmpty() && mc.level.getGameTime() % 20 == 0) {
|
if (!ClientEvents.heldOcular.isEmpty() && mc.level.getGameTime() % 20 == 0) {
|
||||||
ClientEvents.SHOWING_EFFECTS.clear();
|
ClientEvents.SHOWING_EFFECTS.clear();
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class ItemDeathRing extends ItemImpl {
|
||||||
public void onDeath(LivingDeathEvent event) {
|
public void onDeath(LivingDeathEvent event) {
|
||||||
var entity = event.getEntity();
|
var entity = event.getEntity();
|
||||||
if (!entity.level().isClientSide && entity instanceof Player) {
|
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()) {
|
if (!equipped.isEmpty()) {
|
||||||
entity.setHealth(entity.getMaxHealth() / 2);
|
entity.setHealth(entity.getMaxHealth() / 2);
|
||||||
entity.removeAllEffects();
|
entity.removeAllEffects();
|
||||||
|
@ -39,5 +39,7 @@ public class ItemDeathRing extends ItemImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue