Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.Leftmostchain21.scanner_ai.events;
- import com.Leftmostchain21.scanner_ai.scanner_ai;
- import net.minecraft.world.entity.Entity;
- import net.minecraft.world.item.ItemStack;
- import net.minecraft.world.phys.AABB;
- import net.minecraft.world.phys.Vec3;
- import net.minecraftforge.event.TickEvent;
- import net.minecraftforge.eventbus.api.SubscribeEvent;
- import net.minecraftforge.fml.common.Mod;
- import java.util.List;
- @Mod.EventBusSubscriber(modid = scanner_ai.MODID)
- public class ModEvents {
- @SubscribeEvent
- public static <RayTraceResult> void getPositionOfPlayerToChat(TickEvent.PlayerTickEvent event) {
- // Print time
- System.out.println("============================================" + System.currentTimeMillis() + "========================================");
- // Set the bounding box of the player
- AABB playerBox = new AABB(event.player.getX() - 35, event.player.getY() - 25, event.player.getZ() - 35, event.player.getX() + 35, event.player.getY() + 25, event.player.getZ() + 35);
- List<Entity> total_entities = event.player.level.getEntities(null, playerBox);
- // Get player's health and send it to the chat
- System.out.println("Player health is: " + event.player.getHealth());
- // Get the player's location, and print it to the chat
- System.out.println("Player is at: " + event.player.position());
- // Get the player's looking direction, and print it to the chat. E.G. (0.73, -0.54)
- System.out.println("Player is facing: " + event.player.getXRot() + ", " + event.player.getYRot());
- // State the dimension they are in
- System.out.println("Player is in dimension: " + event.player.level.dimension().location());
- // State if the player is on fire
- System.out.println("Player is on fire: " + event.player.isOnFire());
- // State if the player is in water
- System.out.println("Player is in water: " + event.player.isInWater());
- // State if the player is in lava
- System.out.println("Player is in lava: " + event.player.isInLava());
- // State if the player is in the air
- System.out.println("Player is in the air: " + event.player.isDescending());
- // State if the player is crouched
- System.out.println("Player is crouched: " + event.player.isCrouching());
- // State if the player is sprinting
- System.out.println("Player is sprinting: " + event.player.isSprinting());
- // State if the player is flying
- System.out.println("Player is flying: " + event.player.isFallFlying());
- // State if the player is dead or dying
- System.out.println("Player is dead or dying: " + event.player.isDeadOrDying());
- // State if the player is freezing
- System.out.println("Player is freezing: " + event.player.isFreezing());
- try {
- // State if the player is wearing any golden armor
- Iterable<ItemStack> armor = event.player.getArmorSlots();
- if (armor.toString().contains("GOLD")) {
- System.out.println("Player is wearing golden armor");
- }
- } catch (Exception e) {
- System.out.println("Player is not wearing any golden armor");
- }
- try {
- System.out.println("Selected armor: " + event.player.getArmorSlots());
- } catch (Exception e) {
- System.out.println("No armor");
- }
- // Loop through their inventory and print each item to the chat
- for (int i = 0; i < 36; i++) {
- try {
- ItemStack current_item = event.player.getSlot(i).get();
- if (!(current_item.getItem().toString().equals("air"))) {
- System.out.println("Item in slot " + i + ": " + current_item.getItem());
- }
- } catch (Exception e) {
- System.out.println("No item in slot " + i);
- }
- }
- // Now output all the entities in the world to the chat
- System.out.println("Entities in the world: " + total_entities.size());
- // Get all the entities in the world
- // First remove the player from the list of entities
- total_entities.remove(event.player);
- for (Entity entity : total_entities) {
- // Get the Entity's location, and print it to the chat
- System.out.println("Entity is at: " + entity.position());
- // Get the Entity's looking direction, and print it to the chat. E.G. (0.73, -0.54)
- System.out.println("Entity is facing: " + entity.getXRot() + ", " + entity.getYRot());
- // State the dimension they are in
- System.out.println("Entity is in dimension: " + entity.level.dimension().location());
- // State if the Entity is on fire
- System.out.println("Entity is on fire: " + entity.isOnFire());
- // State if the Entity is in water
- System.out.println("Entity is in water: " + entity.isInWater());
- // State if the Entity is in lava
- System.out.println("Entity is in lava: " + entity.isInLava());
- // State if the Entity is in the air
- System.out.println("Entity is in the air: " + entity.isDescending());
- // State if the Entity is crouched
- System.out.println("Entity is crouched: " + entity.isCrouching());
- // State if the Entity is sprinting
- System.out.println("Entity is sprinting: " + entity.isSprinting());
- // State if the Entity is freezing
- System.out.println("Entity is freezing: " + entity.isFreezing());
- // Now print the distance between the player and the entity
- System.out.println("Distance between player and entity: " + event.player.distanceTo(entity));
- try {
- // Print the entity's selected slot to the chat
- System.out.println("Selected primary hand: " + entity.getHandSlots().iterator().next().getItem());
- // Print the entity's selected offhand slot to the chat
- System.out.println("Selected offhand hand: " + entity.getHandSlots());
- } catch (Exception e) {
- System.out.println("No offhand hand");
- }
- // Print the entity's selected armor slot to the chat
- try {
- System.out.println("Selected armor: " + entity.getArmorSlots());
- } catch (Exception e) {
- System.out.println("No armor");
- }
- // Loop through their inventory and print each item to the chat
- for (int i = 0; i < 36; i++) {
- try {
- ItemStack current_item = entity.getSlot(i).get();
- if (!(current_item.getItem().toString().equals("air"))) {
- System.out.println("Item in slot " + i + ": " + current_item.getItem());
- }
- } catch (Exception e) {
- System.out.println("No item in slot " + i);
- }
- }
- }
- // Now print the blocks in the world to the chat
- // The way this will work is by casting raycasts from the player to the world and printing the block that is hit
- // First, create the raycasts
- // Ray length
- int ray_length = 50;
- // Create the raycasts from the player's position to the world
- // So loop 10 * 10 times
- for (int i = -5; i < 5; i++) {
- for (int j = -5; j < 5; j++) {
- // Find where the raycast will hit
- Vec3 applier = new Vec3(i, 0, j);
- Vec3 player_rotation = event.player.getViewVector(0).add(applier);
- Vec3 rayPath = player_rotation.scale(ray_length);
- //RAY START AND END POINTS
- Vec3 from = event.player.getEyePosition(0);
- Vec3 to = from.add(rayPath);
- //CREATE THE RAY AND GET THE BLOCKS IT HITS
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement