package com.jenny.advancedarrows.entities; import com.jenny.advancedarrows.items.items; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; public class ricochetArrow extends baseArrow{ public ricochetArrow(EntityType pEntityType, Level pLevel) { super(pEntityType, pLevel); } public ricochetArrow(Level pLevel, LivingEntity pShooter) { super(pLevel, pShooter, entities.ARROW_RICOCHET.get()); } @Override public void tick() { Vec3 pos = position(); Vec3 delta = getDeltaMovement(); super.tick(); if (this.inGround && !level().isClientSide) { if (delta.length() > 0.5) { //setOnGround(false); setPos(pos); setDeltaMovement(delta.scale(-7).multiply( (double) level().random.nextIntBetweenInclusive(90, 100) / 100, (double) level().random.nextIntBetweenInclusive(90, 100) / 100, (double) level().random.nextIntBetweenInclusive(90, 100) / 100)); } } } @NotNull protected ItemStack getPickupItem() { return new ItemStack(items.ARROW_RICOCHET.get()); } }