Jump to content

Recommended Posts

Posted

So I used this code, but its too inaccurate, and because I have only a very small idea what these cos and sin (I know that these return numbers wich are somehow working with the rotation to 360) methods are doing, I can't really change them, sorry for bad Math :/

 

public static MovingObjectPosition getMovingObjectPositionFromPlayer(World world, EntityPlayer entityplayer, boolean flag, double reach)
{
	float f = 1.0F;
	float playerPitch = entityplayer.prevRotationPitch + (entityplayer.rotationPitch - entityplayer.prevRotationPitch) * f;
	float playerYaw = entityplayer.prevRotationYaw + (entityplayer.rotationYaw - entityplayer.prevRotationYaw) * f;
	double playerPosX = entityplayer.prevPosX + (entityplayer.posX - entityplayer.prevPosX) * f;
	double playerPosY = (entityplayer.prevPosY + (entityplayer.posY - entityplayer.prevPosY) * f + 1.6200000000000001D) - entityplayer.getYOffset();
	double playerPosZ = entityplayer.prevPosZ + (entityplayer.posZ - entityplayer.prevPosZ) * f;
	Vec3 vecPlayer = new Vec3(playerPosX, playerPosY, playerPosZ);
	float cosYaw = MathHelper.cos(-playerYaw * 0.01745329F - 3.141593F);
	float sinYaw = MathHelper.sin(-playerYaw * 0.01745329F - 3.141593F);
	float cosPitch = -MathHelper.cos(-playerPitch * 0.01745329F);
	float sinPitch = MathHelper.sin(-playerPitch * 0.01745329F);
	float pointX = sinYaw * cosPitch;
	float pointY = sinPitch;
	float pointZ = cosYaw * cosPitch;
	Vec3 vecPoint = vecPlayer.addVector(pointX * reach, pointY * reach, pointZ * reach);
	MovingObjectPosition movingobjectposition = world.rayTraceBlocks(vecPlayer, vecPoint, false, false, true);
	return movingobjectposition;
}

 

So I have no idea, I know there is a method in entity, but it is only Client side

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

Posted

public static MovingObjectPosition getMovingObjectPositionFromPlayer(World world, EntityPlayer entityplayer, boolean flag, double reach)
{
	Vec3 vecPlayer = entityplsuer.getLookVec();
	MovingObjectPosition movingobjectposition = world.rayTraceBlocks(vecPlayer, vecPoint, false, false, true);
	return movingobjectposition;
}

 

?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Well, I don't know if you perform magic to get your vec point, so used the one I already had, and that doen't work at all :(

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

Posted

Is not magic, but I did miss a line.

 

Vec3 vecPlayer = new Vec3 (entityplayer.posX,entityplayer.posY+entityplayer.eyeHeight,entityplayer.posZ);

 

Edit:

Also misnamed one var.  I am on my tablet atm.

So it should look like this

 

public static MovingObjectPosition getMovingObjectPositionFromPlayer(World world, EntityPlayer entityplayer, boolean flag, double reach)
{
	Vec3 vecPoint = entityplsuer.getLookVec();
	Vec3 vecPlayer = new Vec3 (entityplayer.posX,entityplayer.posY+entityplayer.eyeHeight,entityplayer.posZ);
	MovingObjectPosition movingobjectposition = world.rayTraceBlocks(vecPlayer, vecPoint, false, false, true);
	return movingobjectposition;
}

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Well, taht doesn't seem to work, anyway, on server, it seems like the look is sometimes up to 2 blocks in x and z coords wrong, but why, maybe a minecraft problem itself, and if, how fix

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

Posted

This is hurting me to look.

 

Its Minecraft.getMinecraft().objectMouseOver

 

Also if you need a blockPos from it use objectMouseOver.getBlockPos();

 

Whatever that was was cancer

"you seem to be THE best modder I've seen imo."

~spynathan

 

ლ(́◉◞౪◟◉‵ლ

Posted
  On 9/6/2015 at 11:02 PM, thebest108 said:

Its Minecraft.getMinecraft().objectMouseOver

And that will crash your game when used on the SERVER, which is where the OP is trying to get a MovingObjectPosition. Not only that, but the objectMouseOver is limited in range and thus limited in use.

 

@OP What about the code is not working for you? Works fine for me:

Vec3 vec31 = new Vec3(player.posX, player.posY + player.getEyeHeight(), player.posZ);
Vec3 vec32 = new Vec3(i, j, k); // where i, j, k are coordinates of some place in the world, such as the normalized coordinates from the player's look vector multiplied by some amount indicating maximum range, e.g. 100
MovingObjectPosition mop = world.rayTraceBlocks(vec31, vec32);

However, that will only result in a hit on BLOCKS; if you want to check for an entity within the player's line of sight, this is not the solution.

Posted

I had to do something similar with my PowersAPI mod.

 

This website has a good method for getting the MovingObjectPosition client side. (At any distance as well!)

http://jabelarminecraft.blogspot.com/p/minecraft-modding-extending-reach-of.html

 

Of course, this is only client side, so you'll have to send the position over in a message to the server.

With all due respect, sir: I do, what I do, the way I do it. ~ MacGyver

Posted
  On 9/6/2015 at 11:09 PM, coolAlias said:

  Quote

Its Minecraft.getMinecraft().objectMouseOver

And that will crash your game when used on the SERVER, which is where the OP is trying to get a MovingObjectPosition. Not only that, but the objectMouseOver is limited in range and thus limited in use.

 

@OP What about the code is not working for you? Works fine for me:

Vec3 vec31 = new Vec3(player.posX, player.posY + player.getEyeHeight(), player.posZ);
Vec3 vec32 = new Vec3(i, j, k); // where i, j, k are coordinates of some place in the world, such as the normalized coordinates from the player's look vector multiplied by some amount indicating maximum range, e.g. 100
MovingObjectPosition mop = world.rayTraceBlocks(vec31, vec32);

However, that will only result in a hit on BLOCKS; if you want to check for an entity within the player's line of sight, this is not the solution.

 

Well, that doen't work, because, you know, look:

 

I'm not quite sure what you mean with those i, j, k, so I assumed I take the players look coords and multiplie them by 100:

 

Vec3 vec31 = new Vec3(player.posX, player.posY + player.getEyeHeight(), player.posZ);
	Vec3 vec32 = new Vec3(player.getLookVec().xCoord*100, player.getLookVec().yCoord*100, player.getLookVec().zCoord*100);
	MovingObjectPosition mop = world.rayTraceBlocks(vec31, vec32);
	System.out.println(mop);

 

That gives back coords, wich are totally wrong.

 

Also:

 

Vec3 vec31 = new Vec3(player.posX, player.posY + player.getEyeHeight(), player.posZ);
	Vec3 vec32 = player.getLookVec(); 
	MovingObjectPosition mop = world.rayTraceBlocks(vec31, vec32);
	System.out.println(mop);

 

This gives back nothing

 

So I have really no idea what to do

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

Posted
  On 9/7/2015 at 10:32 AM, Kloonder said:

This gives back nothing

 

So I have really no idea what to do

 

Try this. I pulled it from one of Jabelar's turorials, who pulled it from Minecraft's mouse over code:

 

 

  Reveal hidden contents

 

With all due respect, sir: I do, what I do, the way I do it. ~ MacGyver

Posted

Well, I now use this code

 

if(world.isRemote){
					if(player.rayTrace(7, 1) != null){
						if(player.rayTrace(7, 1).hitVec != null){
							MovingObjectPosition mop = player.rayTrace(7, 1);
							Vec3 hit = mop.hitVec;
							int side = mop.sideHit.getIndex();
							MoreMinecraft.network.sendToServer(new MessageToServer(2, hit.xCoord, hit.yCoord, hit.zCoord, side, halfStep ? 1 : 0, rootUp ? 1 : 0));

 

But I somehow have the problem, that it is sometimes wrong about one block in x or z position, any ideas

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

Posted
  On 9/7/2015 at 2:57 PM, Kloonder said:

Well, I now use this code

 

if(world.isRemote){
					if(player.rayTrace(7, 1) != null){
						if(player.rayTrace(7, 1).hitVec != null){
							MovingObjectPosition mop = player.rayTrace(7, 1);
							Vec3 hit = mop.hitVec;
							int side = mop.sideHit.getIndex();
							MoreMinecraft.network.sendToServer(new MessageToServer(2, hit.xCoord, hit.yCoord, hit.zCoord, side, halfStep ? 1 : 0, rootUp ? 1 : 0));

 

But I somehow have the problem, that it is sometimes wrong about one block in x or z position, any ideas

 

Try what I mentioned above. It works, trust me it does.

With all due respect, sir: I do, what I do, the way I do it. ~ MacGyver

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Unlock an Instant $100 OFF with the Exclusive Temu Coupon Code ALF401700! Whether you're a first-time shopper or a loyal returning customer, this verified Temu promo code ALF401700 is your gateway to incredible savings on thousands of products. By applying code ALF401700 at checkout, you’ll receive a guaranteed $100 discount on your purchase, plus enjoy additional savings of up to 50% OFF on selected items. This special coupon is designed to maximize your discounts, making your shopping experience at Temu more affordable than ever. Why Choose Temu Coupon Code ALF401700 in 2025? First-Time Shoppers: Score a massive 50% off your first order plus a flat $100 OFF using promo code ALF401700. Returning Customers: Don’t miss out! Use ALF401700 to claim a generous $100 OFF on your next purchase. Massive Clearance Sales: With Temu’s ongoing 2025 clearance events, this code unlocks up to 90% OFF on select deals. Global Reach: Whether you shop from the USA, Canada, Europe, Asia, or beyond, Temu coupon ALF401700 works worldwide. 2025’s Top Temu Discounts Powered by ALF401700: Temu $100 OFF New User Promo — ALF401700 Temu Exclusive Discount for Returning Shoppers — ALF401700 Memorial Day Special: $100 OFF Using ALF401700 Country-Specific Offers: USA, Japan, Mexico, Chile, Colombia, Malaysia, Philippines, South Korea, Saudi Arabia, Qatar, Germany, France, Israel — all accept code ALF401700 Free Gift Unlocks — Apply ALF401700 Without Referrals Stackable Bundles: Combine ALF401700 for $100 OFF with up to 50% sitewide discounts 100% OFF Flash Deals during Temu Events with ALF401700 How to Redeem Your Temu Coupon Code ALF401700: Visit the official Temu website or open the Temu app. Select your favorite products and add them to your cart. Enter the promo code ALF401700 in the discount code field at checkout. Watch your total instantly drop by $100 and enjoy any additional percentage discounts automatically applied. Complete your order and enjoy huge savings! Key Benefits of Using ALF401700 Temu Promo Code: Verified and Tested: This code is active and guaranteed to work for 2025. Applicable for All Users: New or existing customers get to enjoy the perks. Works Across Multiple Countries: Perfect for international shoppers. No Minimum Purchase Required: Use it anytime to save $100. Perfect for Big and Small Orders: Whether buying essentials or splurging, save big with ALF401700. Temu Coupon Code ALF401700 by Region: 🇺🇸 United States — Save $100 OFF 🇨🇦 Canada — Instant $100 Discount 🇬🇧 United Kingdom — Exclusive $100 OFF 🇯🇵 Japan — Hot $100 OFF Deal 🇲🇽 Mexico — Get $100 OFF 🇨🇱 Chile — 2025 Special Discount 🇰🇷 South Korea — Massive Savings 🇵🇭 Philippines — Extra $100 OFF 🇸🇦 Saudi Arabia — Verified Promo 🇶🇦 Qatar — Top Discount 🇩🇪 Germany — Exclusive Savings 🇫🇷 France — Coupon Works 🇮🇱 Israel — Huge Discount Final Words: Make 2025 your year of unbeatable savings with the Temu coupon code ALF401700. Act now to claim your $100 OFF plus unlock additional discounts on thousands of products. Whether shopping for fashion, electronics, home essentials, or gifts, this is the best Temu promo code to maximize your budget. Download the Temu app today, enter ALF401700 at checkout, and watch the savings roll in!
    • Verified users can now unlock a $100 OFF Temu Coupon Code using the verified promo code [ALF401700]. This Temu $100 OFF code works for both new and existing customers and can be used to redeem up to 50% off your next order. Our exclusive Temu coupon code [ALF401700] delivers a flat $100 OFF on top of existing deals. First-time customers using code ALF401700 can save an extra 100% off select items. Returning users also qualify for an automatic $100 OFF discount just by applying this code at checkout. But wait—there’s more. With our Temu coupon codes for 2025, users can score up to 90% OFF on clearance items. Whether you’re shopping in the USA, Canada, UK, or elsewhere, Temu promo code ALF401700 unlocks extra discounts tailored to your account. Some users are saving 100% on items using this 2025 Temu promo code. 🔥 Temu Coupon Highlights Using Code [ALF401700]: Temu new user code – ALF401700: Save 50% off your first order + $100 OFF. Temu promo for existing customers – ALF401700: Enjoy flat $100 OFF instantly. Global availability: Works in the USA, UK, Canada, Germany, France, Japan, Chile, Colombia, Malaysia, Mexico, South Korea, Philippines, Saudi Arabia, Qatar, Pakistan, and more. Top 2025 Coupon Deal: Get $200 OFF plus 100% bonus discounts using code ALF401700. Top-Ranked Temu Deals for 2025 (Coupon Code: ALF401700): ✅ Temu $100 OFF Memorial Day Sale — Use ALF401700 ✅ Temu First Order Coupon — Use ALF401700 for 50% + $100 OFF ✅ Temu USA Coupon Code — Save $100 instantly with ALF401700 ✅ Temu Japan, Germany, Chile Codes — All support ALF401700 ✅ Temu Reddit Discount – $100 OFF: Valid for both new and old users ✅ Temu Coupon Bundle 2025 — $100 OFF + up to 50% slash ✅ 100% OFF Free Gift Code — Use ALF401700, no invite needed ✅ Temu Sign-Up Bonus Promo — Get a welcome $100 OFF instantly ✅ Free Temu Code for New Users — Use ALF401700, no referral required  Temu Clearance Codes 2025 — Use ALF401700 for 85–100% discounts Why ALF401700 is the Best Temu Code in 2025 Using Temu code ALF401700 is your ticket to massive savings, free shipping, first-order discounts, and stackable coupon bundles. Whether you're browsing electronics, fashion, home goods, or beauty products, this verified Temu discount code offers real savings—up to 90% OFF + $100 OFF on qualified orders. 💡 Pro Tip: Apply ALF401700 during checkout in the Temu app or website to activate your instant $100 discount, even if you’re not a new user. Temu $100 OFF Code by Country (All Use ALF401700): 🇺🇸 Temu USA – ALF401700 🇯🇵 Temu Japan – ALF401700 🇲🇽 Temu Mexico – ALF401700 🇨🇱 Temu Chile – ALF401700 🇨🇴 Temu Colombia – ALF401700 🇲🇾 Temu Malaysia – ALF401700 🇵🇭 Temu Philippines – ALF401700 🇰🇷 Temu Korea – ALF401700 🇵🇰 Temu Pakistan – ALF401700 🇫🇮 Temu Finland – ALF401700 🇸🇦 Temu Saudi Arabia – ALF401700 🇶🇦 Temu Qatar – ALF401700 🇫🇷 Temu France – ALF401700 🇩🇪 Temu Germany – ALF401700 🇮🇱 Temu Israel – ALF401700 Temu Coupon Code [ALF401700] Summary for SEO: Temu $100 OFF Code  Temu First Order Discount Code 2025  Temu Verified Promo Code ALF401700  Temu 50% OFF + $100 Bonus  Temu 100% OFF Code 2025  Temu App Promo ALF401700  Temu Working Discount Code 2025 
    • Hey there, nothing to do with the code, I am just suggesting you use Intelij IDEA. Trust me, it is the best.
    • Hey there, nothing to do with the code, I am just suggesting you use Intelij IDEA. Trust me, it is the best.
    • You can check the config of Geckolib and Mowzie's Mobs - maybe there is a way to disable some render features
  • Topics

×
×
  • Create New...

Important Information

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