Advertisement
Guest User

TridentItem

a guest
Jul 8th, 2021
48
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class VikingSword extends TridentItem {
  2.  
  3.  
  4. public VikingSword(Properties p_i48788_1_) {
  5. super(p_i48788_1_);
  6. }
  7.  
  8. @Override
  9. public boolean isDamageable(ItemStack stack) {
  10. return false;
  11. }
  12.  
  13. @Override
  14. public boolean canDisableShield(ItemStack stack, ItemStack shield, LivingEntity entity, LivingEntity attacker) {
  15. return true;
  16. }
  17.  
  18.  
  19. @Override
  20. public boolean isRepairable(ItemStack stack) {
  21. return false;
  22. }
  23.  
  24. @Override
  25. public UseAction getUseAnimation(ItemStack p_77661_1_) {
  26. return UseAction.SPEAR;
  27. }
  28.  
  29.  
  30.  
  31. @Override
  32. public ActionResult<ItemStack> use(World worldIn, PlayerEntity playerIn, Hand handIn) {
  33. if (InputMappings.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_KEY_LEFT_SHIFT)) {
  34. playerIn.addEffect(new EffectInstance(Effects.MOVEMENT_SPEED, 200, 1));
  35. playerIn.addEffect(new EffectInstance(Effects.DAMAGE_BOOST, 200, 1));
  36. worldIn.setRainLevel(3);
  37. worldIn.setThunderLevel(3);
  38.  
  39.  
  40.  
  41. playerIn.isInvulnerableTo(DamageSource.LIGHTNING_BOLT);
  42. playerIn.abilities.invulnerable = true;
  43. LightningBoltEntity lightningHam = new LightningBoltEntity(EntityType.LIGHTNING_BOLT, worldIn);
  44. lightningHam.setPos(playerIn.getX(),playerIn.getY(),playerIn.getZ());
  45. worldIn.addFreshEntity(lightningHam);
  46.  
  47. if (!playerIn.isCreative()){
  48. playerIn.abilities.invulnerable = false;
  49. }
  50.  
  51.  
  52.  
  53.  
  54. }
  55. else {
  56.  
  57. Double rayLength = new Double(100);
  58. Vector3d playerRotation = playerIn.getViewVector(0);
  59. Vector3d rayPath = playerRotation.scale(rayLength);
  60. Vector3d from = playerIn.getEyePosition(0);
  61. Vector3d to = from.add(rayPath);
  62. RayTraceContext rayCtx = new RayTraceContext(from, to, RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.ANY, null);
  63. BlockRayTraceResult rayHit = worldIn.clip(rayCtx);
  64. if (rayHit.getType() == RayTraceResult.Type.MISS) {
  65.  
  66. } else {
  67. Vector3d hitLocation = rayHit.getLocation();
  68. LightningBoltEntity lightning = new LightningBoltEntity(EntityType.LIGHTNING_BOLT, worldIn);
  69. if (!playerIn.getCooldowns().isOnCooldown(this)) {
  70. worldIn.isThundering();
  71.  
  72.  
  73. lightning.setPos(hitLocation.x, hitLocation.y, hitLocation.z);
  74. worldIn.addFreshEntity(lightning);
  75. playerIn.getCooldowns().addCooldown(this, 200);
  76. return ActionResult.success(playerIn.getItemInHand(handIn));
  77. }
  78.  
  79.  
  80. }
  81.  
  82.  
  83.  
  84. }
  85.  
  86. return ActionResult.fail(playerIn.getItemInHand(handIn));
  87.  
  88. }
  89. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement