Jump to content

Vamaka12

Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by Vamaka12

  1. I am trying to spawn Fireball when player right clicks, I was following 1.12.2 tutorial but I am modding for 1.18.1. So I changed up code but it doesn't works This is my code: package com.vamaka12.magiccraft.objects.tools; import net.minecraft.core.BlockPos; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.projectile.LargeFireball; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.Vec3; public class FireStaff extends Item { public FireStaff(Properties properties) { super(properties); } // @Override Gives error, It was in tutorial public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { ItemStack item = player.getItemInHand(hand); Vec3 aim = player.getLookAngle(); LargeFireball fireBall = new LargeFireball(level, player, 1, 1, 1); // gives error "Cannot resolve constructor", I don't know why fireBall.setPos(player.position().x + aim.x * 1.5D, player.position().y + aim.y * 1.5D, player.position().z + aim.z * 1.5D); // fireBall.accelerationX = aim.x * 0.1; fireBall.accelerationY = aim.y * 0.1; fireBall.accelerationZ = aim.z * 0.1; acceleration doesn't exists // level.spawnEntity doesn't exists item.setDamageValue(1); return InteractionResult.SUCCESS; } } Tutorial code: public class FireStaff extends ItemBase { public FireStaff(String name) { super(name); } @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { ItemStack item = playerIn.getHeldItem(handIn); Vec3d aim = playerIn.getLookVec(); EntityLargeFireBall fireball = new EntityLargeFirball(worldIn, playerIn, 1, 1 , 1); fireball.setPosition(playerIn.posX + aim.x * 1.5D, playerIn.posY + aim.y * 1.5D, playerIn.posZ + aim.z * 1.5D); fireBall.accelerationX = aim.x * 0.1; fireBall.accelerationY = aim.y * 0.1; fireBall.accelerationZ = aim.z * 0.1; worldIn.spawnEntity(fireball); item.damageItem(1, playerIn); return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, item); } } Somebody please help, I spended already 1 day
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.