Jump to content

Niroxbtw

Members
  • Posts

    5
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Niroxbtw's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Hello, im looking to find the exact location of the right and left foot and since this is depedant on how the player is rotated it seems pretty difficult to do. Thanks in advance.
  2. The checking sorounding blocks works really good and pretty fast. Ty
  3. Maybe my question was bad. What i really want is to find out a yaw/pitch so that when i rayTrace the rayTrace hits the wanted block.
  4. Thanks for your reply. The rotation of the player is not a problem for me. My main problem is to get a required yaw/pitch. Since i thought that it would be pretty hard to calculate i tried to brute force it. That doesnt seem to work. How would i calculate that since pythagoras and basic trig wont work because there are cases where the yaw and pitch of pythagoras (trig) is blocked by another block?
  5. Hello, im trying to make a method that determines a yaw/pitch to look at a certain block. A method with Pythagoras doesn't work because it fails when theres a block in the angle. So my idea was to create a dummy entity at the player position which will try out all yaws/pitches and then ray trace to see what blocks get hit and what yaw/pitch was used to hit that block. So i first created a new EntityLivingBase: EntityLivingBase playerSim = new EntityLivingBase(mc.theWorld) { @Override public ItemStack getHeldItem() { return null; } @Override public ItemStack getEquipmentInSlot(int slotIn) { return null; } @Override public ItemStack getCurrentArmor(int slotIn) { return null; } @Override public void setCurrentItemOrArmor(int slotIn, ItemStack stack) { } @Override public ItemStack[] getInventory() { return new ItemStack[0]; } }; Then i wrote the method that trys out all yaws and pitches: public ArrayList<Pair<BlockPos, Pair<Float, Float>>> getLookForAllVisibleBlocks(EntityLivingBase entityLivingBase) { entityLivingBase.setPosition(mc.thePlayer.getPosition().getX() + 0.5d, mc.thePlayer.getPosition().getY(), mc.thePlayer.getPosition().getZ() + 0.5d ); ArrayList<Pair<BlockPos, Pair<Float, Float>>> visibleBlocksWithLook = new ArrayList<>(); for (int yaw = 0; yaw < 360; yaw++) { for (int pitch = 0; pitch < 180; pitch++) { entityLivingBase.rotationPitch = pitch - 90; entityLivingBase.rotationYawHead = yaw - 180; Vec3 vec3 = entityLivingBase.getPositionEyes(1); Vec3 vec31 = entityLivingBase.getLook(1); Vec3 vec32 = vec3.addVector(vec31.xCoord * 5, vec31.yCoord * 5, vec31.zCoord * 5); MovingObjectPosition playerSimRay = mc.theWorld.rayTraceBlocks(vec3, vec32, false, false, true); boolean add = true; for (Pair<BlockPos, Pair<Float, Float>> visibleBlock: visibleBlocksWithLook) { if (visibleBlock.getLeft().equals(playerSimRay.getBlockPos())) { add = false; } } if (add) { visibleBlocksWithLook.add(Pair.of(playerSimRay.getBlockPos(), Pair.of((float) (yaw - 180), (float) (pitch - 90)))); } } } return visibleBlocksWithLook; } This indeed returns a pitch and a yaw but its failing 50% of the time and i dont have any idea why it does. My guess is that the rotationPitch/rotationYawHead are different from whats used in the f3 menu. I tried out to log the yaw and pitch and the pitch seemed to be exactly the same but the yaw was different but it seemed like it was a multiple of the rotations in deg and since this method only counts up to 360 (for the yaw) it shouldnt be a problem. There also could be something else wrong with this. Thanks for the help in advance. EDIT: The Ray Trace can't be the problem since i tested it out. I also tested the yaw and pitch and they are also correct. I have no clue at all what the problem could be.
×
×
  • Create New...

Important Information

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