Hauteknits

Spawn a Fireball

Jan 22nd, 2021
691
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.idtech.item;
  2.  
  3. import net.minecraft.creativetab.CreativeTabs;
  4. import net.minecraft.entity.player.EntityPlayerMP;
  5. import net.minecraft.entity.projectile.EntityLargeFireball;
  6. import net.minecraft.util.math.Vec3d;
  7.  
  8. import java.lang.ClassCastException;
  9.  
  10. public class Wand extends QuickItem {
  11.     {
  12.         name = "Magic Wand";
  13.         tab= CreativeTabs.TOOLS;
  14.         type=ItemType.HandHeld;
  15.         texture="lightninghammer";
  16.     }
  17.  
  18.     private final double factor = 0.5;
  19.  
  20.     @Override
  21.     protected void onRightClick() {
  22.         EntityPlayerMP p;
  23.         try {
  24.             p = (EntityPlayerMP) player;
  25.         }catch(ClassCastException e){
  26.             return;
  27.         }
  28.         Vec3d look = p.getLookVec();
  29.         System.out.println(look.x + " " + look.y + " " + look.z);
  30.         EntityLargeFireball f = new EntityLargeFireball(world, p, look.x, look.y, look.z);
  31.         f.accelerationX = look.x * factor;
  32.         f.accelerationY = look.y * factor;
  33.         f.accelerationZ = look.z * factor;
  34.         world.spawnEntity(f);
  35.     }
  36. }
  37.  
RAW Paste Data