izukuboi

view only visible blocks

Aug 5th, 2023
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | Source Code | 0 0
  1. from mcpi.minecraft import Minecraft
  2. from mcpi.vec3 import Vec3
  3.  
  4. # Connect to the Minecraft server (replace 'localhost' and '4711' with your server's IP and port)
  5. mc = Minecraft.create("localhost", 4711)
  6.  
  7. # Define the region you want to scan (replace these coordinates with your desired region)
  8. min_x, min_y, min_z = -10, 0, -10
  9. max_x, max_y, max_z = 10, 10, 10
  10.  
  11. # Function to check if a block is visible
  12. def is_block_visible(x, y, z):
  13. player_x, player_y, player_z = 0, 0, 0 # Replace with your code to get the player's position
  14.  
  15. max_distance = 10 # Adjust this value as needed for your use case
  16.  
  17. distance = ((x - player_x) ** 2 + (y - player_y) ** 2 + (z - player_z) ** 2) ** 0.5
  18.  
  19. return distance <= max_distance
  20.  
  21. # Function to scan blocks and print block data for visible blocks
  22. def scan_visible_blocks():
  23. for x in range(min_x, max_x + 1):
  24. for y in range(min_y, max_y + 1):
  25. for z in range(min_z, max_z + 1):
  26. if is_block_visible(x, y, z):
  27. block_data = mc.getBlockWithData(x, y, z)
  28. print(f"Visible Block at ({x}, {y}, {z}): ID={block_data.id}, Data={block_data.data}")
  29.  
  30. if __name__ == "__main__":
  31. scan_visible_blocks()
  32.  
Advertisement
Add Comment
Please, Sign In to add comment