Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.telaykussword.power;
- import net.minecraft.entity.EntityType;
- import net.minecraft.entity.EquipmentSlot;
- import net.minecraft.entity.LightningEntity;
- import net.minecraft.entity.LivingEntity;
- import net.minecraft.entity.player.PlayerEntity;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.Hand;
- import net.minecraft.util.TypedActionResult;
- import net.minecraft.util.math.BlockPos;
- import net.minecraft.world.World;
- public class TelaykusSword extends Item {
- public TelaykusSword(Settings settings) {
- super(settings);
- }
- public float getAttackDamage() {
- return 38.0F;
- }
- @Override
- public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
- if (world.isClient) {
- return TypedActionResult.pass(user.getStackInHand(hand));
- }
- BlockPos frontOfPlayer = user.getBlockPos().offset(user.getHorizontalFacing(), 2);
- double offsetX = user.getHorizontalFacing().getOffsetX() * 2.5;
- double offsetZ = user.getHorizontalFacing().getOffsetZ() * 2.5;
- BlockPos targetPos = frontOfPlayer.add((int) offsetX, 0, (int) offsetZ);
- LightningEntity lightningBolt = new LightningEntity(EntityType.LIGHTNING_BOLT, world);
- lightningBolt.refreshPositionAfterTeleport(targetPos.getX(), targetPos.getY(), targetPos.getZ());
- world.spawnEntity(lightningBolt);
- return TypedActionResult.success(user.getStackInHand(hand));
- }
- @Override
- public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attacker) {
- stack.damage(1, attacker, EquipmentSlot.MAINHAND);
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment