Jump to content

ToxeNRald351

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by ToxeNRald351

  1. I'm sorry, I didn't quite catch that. What do I do with it? What should I put in that function?
  2. Hello! I'm following a tutorial at moddingtutorials.org where they suggest I make an item that turns blocks into dirt on use. It works perfectly until I try to use the item on the block that is too far or out of my mining range or is too far. The block of dirt replaces the block I pointed to for just a fraction of a second and then goes back to its original state. I have no idea, how to fix this, other than setting the range of the item to match the mining range. Any suggestions? Here's my code for this: public class DirtStaff extends Item { public DirtStaff(Properties properties) { super(properties); } protected static BlockHitResult rayTrace(Level world, Player player, ClipContext.Fluid fluidMode) { float f = player.getXRot(); float f1 = player.getYRot(); Vec3 vec3 = player.getEyePosition(); float f2 = Mth.cos(-f1 * ((float)Math.PI / 180F) - (float)Math.PI); float f3 = Mth.sin(-f1 * ((float)Math.PI / 180F) - (float)Math.PI); float f4 = -Mth.cos(-f * ((float)Math.PI / 180F)); float f5 = Mth.sin(-f * ((float)Math.PI / 180F)); float f6 = f3 * f4; float f7 = f2 * f4; double d0 = 15; // range Vec3 vec31 = vec3.add((double)f6 * d0, (double)f5 * d0, (double)f7 * d0); return world.clip(new ClipContext(vec3, vec31, ClipContext.Block.OUTLINE, fluidMode, player)); } @Override public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) { BlockHitResult ray = rayTrace(world, player, ClipContext.Fluid.NONE); BlockPos lookPos = ray.getBlockPos(); world.setBlock(lookPos, Blocks.DIRT.defaultBlockState(), 1024); return super.use(world, player, hand); } }
×
×
  • Create New...

Important Information

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