Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. @Override
  2. public void updateTick(World world, BlockPos pos, IBlockState state, Random rand)
  3. {
  4. world.scheduleBlockUpdate(pos, this, 40, 0);
  5. double angle = 0;
  6.  
  7. Vec3d targetVector = new Vec3d(1, 0, 1);
  8. BlockPos newPos = getBlockPos(world, pos, targetVector);
  9.  
  10. if (world.getBlockState(newPos).getBlock() instanceof BlockFakeLight)
  11. return;
  12. world.setBlockState(newPos.add(-targetVector.x, -targetVector.y, -targetVector.z), LightingDynamicsObjects.FAKE_LIGHT.getDefaultState());
  13. }
  14.  
  15. private BlockPos getBlockPos(World world, BlockPos pos, Vec3d targetVector)
  16. {
  17. Vec3d start = new Vec3d(pos).add(targetVector).addVector(0.5d, 0.5d, 0.5d);
  18. Vec3d end = new Vec3d(pos).addVector(0.5d, 0.5d, 0.5d).add(targetVector.scale(4));
  19.  
  20. System.out.println("Start: " + start);
  21. System.out.println("End : " + end);
  22. RayTraceResult raytrace = world.rayTraceBlocks(start, end, false);
  23. if (raytrace != null && raytrace.typeOfHit != RayTraceResult.Type.MISS)
  24. {
  25. System.out.println("Result:" + raytrace.getBlockPos());
  26. return raytrace.getBlockPos();
  27. }
  28. else
  29. {
  30. return new BlockPos(0, 0, 0);
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement