Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class VikingSword extends TridentItem {
- public VikingSword(Properties p_i48788_1_) {
- super(p_i48788_1_);
- }
- @Override
- public boolean isDamageable(ItemStack stack) {
- return false;
- }
- @Override
- public boolean canDisableShield(ItemStack stack, ItemStack shield, LivingEntity entity, LivingEntity attacker) {
- return true;
- }
- @Override
- public boolean isRepairable(ItemStack stack) {
- return false;
- }
- @Override
- public UseAction getUseAnimation(ItemStack p_77661_1_) {
- return UseAction.SPEAR;
- }
- @Override
- public ActionResult<ItemStack> use(World worldIn, PlayerEntity playerIn, Hand handIn) {
- if (InputMappings.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_KEY_LEFT_SHIFT)) {
- playerIn.addEffect(new EffectInstance(Effects.MOVEMENT_SPEED, 200, 1));
- playerIn.addEffect(new EffectInstance(Effects.DAMAGE_BOOST, 200, 1));
- worldIn.setRainLevel(3);
- worldIn.setThunderLevel(3);
- playerIn.isInvulnerableTo(DamageSource.LIGHTNING_BOLT);
- playerIn.abilities.invulnerable = true;
- LightningBoltEntity lightningHam = new LightningBoltEntity(EntityType.LIGHTNING_BOLT, worldIn);
- lightningHam.setPos(playerIn.getX(),playerIn.getY(),playerIn.getZ());
- worldIn.addFreshEntity(lightningHam);
- if (!playerIn.isCreative()){
- playerIn.abilities.invulnerable = false;
- }
- }
- else {
- Double rayLength = new Double(100);
- Vector3d playerRotation = playerIn.getViewVector(0);
- Vector3d rayPath = playerRotation.scale(rayLength);
- Vector3d from = playerIn.getEyePosition(0);
- Vector3d to = from.add(rayPath);
- RayTraceContext rayCtx = new RayTraceContext(from, to, RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.ANY, null);
- BlockRayTraceResult rayHit = worldIn.clip(rayCtx);
- if (rayHit.getType() == RayTraceResult.Type.MISS) {
- } else {
- Vector3d hitLocation = rayHit.getLocation();
- LightningBoltEntity lightning = new LightningBoltEntity(EntityType.LIGHTNING_BOLT, worldIn);
- if (!playerIn.getCooldowns().isOnCooldown(this)) {
- worldIn.isThundering();
- lightning.setPos(hitLocation.x, hitLocation.y, hitLocation.z);
- worldIn.addFreshEntity(lightning);
- playerIn.getCooldowns().addCooldown(this, 200);
- return ActionResult.success(playerIn.getItemInHand(handIn));
- }
- }
- }
- return ActionResult.fail(playerIn.getItemInHand(handIn));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement