NaturesAura/src/main/java/de/ellpeck/naturesaura/items/ItemLightStaff.java

29 lines
1.2 KiB
Java
Raw Normal View History

2020-04-27 18:30:44 +02:00
package de.ellpeck.naturesaura.items;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.entities.EntityLightProjectile;
import de.ellpeck.naturesaura.entities.ModEntities;
2021-12-04 15:40:09 +01:00
import net.minecraft.entity.player.Player;
2020-04-27 18:30:44 +02:00
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
2021-12-04 15:40:09 +01:00
import net.minecraft.util.InteractionResult;
2020-04-27 18:30:44 +02:00
import net.minecraft.util.Hand;
2021-12-04 15:40:09 +01:00
import net.minecraft.level.Level;
2020-04-27 18:30:44 +02:00
public class ItemLightStaff extends ItemImpl {
public ItemLightStaff() {
super("light_staff");
}
@Override
2021-12-04 15:40:09 +01:00
public ActionResult<ItemStack> onItemRightClick(Level levelIn, Player playerIn, Hand handIn) {
2020-04-27 18:30:44 +02:00
ItemStack stack = playerIn.getHeldItem(handIn);
2021-12-04 15:40:09 +01:00
if (!levelIn.isClientSide && NaturesAuraAPI.instance().extractAuraFromPlayer(playerIn, 1000, false)) {
EntityLightProjectile projectile = new EntityLightProjectile(ModEntities.LIGHT_PROJECTILE, playerIn, levelIn);
2020-09-22 03:17:02 +02:00
projectile.func_234612_a_(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0, 1.5F, 0);
2021-12-04 15:40:09 +01:00
levelIn.addEntity(projectile);
2020-04-27 18:30:44 +02:00
}
2021-12-04 15:40:09 +01:00
return new ActionResult<>(InteractionResult.SUCCESS, stack);
2020-04-27 18:30:44 +02:00
}
}