Jump to content

Recommended Posts

Posted

Well, myitemclass.onLeftClickEntity() allows me to perform different stuff with the entity i clicked. But how do i know the position at wich player clicked? I.e. i want to know if player has clicked front/rear side of my entity. Any ways to do that?

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

Posted

look at the angle between the entity facing direction and the player facing direction

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

  • 2 weeks later...
Posted

Way too complicated. Even considering i'm good at math and trigonometry...

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

Posted
front/rear side of my entity.

suspicious look

 

float angleDifference = entity1.rotationYaw-entity2.rotationYaw;

if they are facing itll be roughly 180, if its on the side itll be roughly 90 or 270 (depending on sides)

if its from the back itll be roughly 0

 

 

... now you're just mean. be honest, tell me if you dont want my help

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

You code is obviously not going to work. If you think it will, take a look at the picture:

 

mE0soQs.jpg

 

E — wagon with front and rear couplers; P1, P2 — players; rY — entity rotationYaw; players have equal rotationYaw, that in this case is zero.

If i use your code it will work next way:

angleDifference_1 = rY - 0;

angleDifference_2 = rY - 0;

angleDifference_1 = angleDifference_2 =>

it will return that both players have clicked same couplers, what is false.

 

Next time think a little, before advising something that is not working and saying i'm „just mean“ and „dont want your help“.

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

Posted

You code is obviously not going to work. If you think it will, take a look at the picture:

 

mE0soQs.jpg

 

E — wagon with front and rear couplers; P1, P2 — players; rY — entity rotationYaw; players have equal rotationYaw, that in this case is zero.

If i use your code it will work next way:

angleDifference_1 = rY - 0;

angleDifference_2 = rY - 0;

angleDifference_1 = angleDifference_2 =>

it will return that both players have clicked same couplers, that is false.

 

Next time think a little, before advising something that is not working and saying i'm „just mean“ and „dont want our help“.

 

I don't want another rage fight to happen (had one on FB last night, no ones business xD).

 

By looking at your drawing, it seems to be that you are right. BUT!!!!! You did not specify wether you wanted a front or back of the same thing, thus not fully explaining your question. For what WAS asked, you where given the answer. For what you didn't ask, you obviously weren't given an answer.

 

Therefore the lessons we can ALL take away from this is: Ask the ENTIRE question you want answered, don't jump to conclusions, and for me, don't jump into random business (except for that fact that hydroflame is technically my boss in a way is my coworker...).

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Posted
You did not specify wether you wanted a front or back of the same thing
Haven't i wrote i want to know if player has clicked front/rear side of my entity ? Are my eyes and memory tricking me?

thus not fully explaining your question. For what WAS asked, you where given the answer. For what you didn't ask, you obviously weren't given an answer.

 

Therefore the lessons we can ALL take away from this is: Ask the ENTIRE question you want answered, don't jump to conclusions, and for me, don't jump into random business (except for that fact that hydroflame is technically my boss in a way is my coworker...).

The lesson you should take from this — read more attentively, and don't be a smart-ass.

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

Posted

fuck it you're on my blacklist, maybe someone else has time to put up with your shit.

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

hydroflame, huh, what happened now? Have i unfairly offended you or what?

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

Posted

hydroflame, huh, what happened now? Have i unfairly offended you or what?

 

I am sorry I did not explain well enough. You never said that you had a mirrored model. Therefore, it still gives you the side you clicked on. And double checking your drawing, it is well and truly wrong...

I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Posted

wth. why does your post have a thank you from me?o_o

 

anyway, you can use hydroflame's suggestion. you just have to tweak it a little. since you say you're good in math, you should be able to understand this:

 

take the player's position to be a point of origin then check what quadrant the entity's position is in relative to that point. if it's in quadrant 1, the difference in angle (hydroflame's suggestion) should be x degrees. if it's in quadrant 2, it should be something different, and so on

Posted

I would use getLookVec() from EntityLivingBase.

This is a code I made for Battlegear's dagger backstab ability:

protected boolean performBackStab(Item item, EntityLivingBase entityHit, EntityLivingBase entityHitting) {
        //Get victim and murderer vector views at hit time
        double[] victimView = new double[]{entityHit.getLookVec().xCoord,entityHit.getLookVec().zCoord};
        double[] murdererView = new double[]{entityHitting.getLookVec().xCoord,entityHitting.getLookVec().zCoord};
        //back-stab conditions: vectors are closely enough aligned, (fuzzy parameter might need testing)
        //but not in opposite directions (face to face or sideways)
        if(Math.abs(victimView[0]*murdererView[1]-victimView[1]*murdererView[0])<backstabFuzzy &&
                Math.signum(victimView[0])==Math.signum(murdererView[0]) &&
                Math.signum(victimView[1])==Math.signum(murdererView[1])){
            return ((IBackStabbable)item).onBackStab(entityHit, entityHitting);//Perform back stab effect
        }
        return false;
    }

I use a fuzzy parameter (close to 0) to allow player some chance of doing it.

Hope that helped.

Posted
I am sorry I did not explain well enough. You never said that you had a mirrored model. Therefore, it still gives you the side you clicked on. And double checking your drawing, it is well and truly wrong...
I don't understand wtf you are talking about, especially 'mirrored model' and following part. And why you are quoting my question about such anger, presented to hydroplane.

 

pelep, GotoLink, thanks for suggestions, but i suddenly got an idea, that will definitely work and which i like more, because i have half of it already done before. I'm currently developing it and i'll share the result if anybody wants...

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

Posted

So, i'm almost done with it. Currently the code works fine only on flat plane, because it's one o'clock am, i'm tired and don't remember how to write line equations in three dimensions. Also, it will work fine only in my or similar case, because i don't really need side-detection, rather than point-detection ('cause i represent wagon couplers as points where they are located).

 

My draft:

width=800 height=1067wAEv612.jpg?1 [/img]

 

So, since couplers are points that are placed on wagon axis and rotate together with it, i can define their global positions by wagon position, it's rotation and preset distances between couplers and wagon centre. See the top of the draft.

 

//This is what i've made before
//somewhere in my wagon class
rotationCos = Math.cos(Math.toRadians(this.rotationYaw + 90)); //note that i add 90 degrees, because 
rotationSin = Math.sin(Math.toRadians(this.rotationYaw + 90)); //rotationYaw equals zero when parallel to Z-axis
frontCouplerX = posX + rotationCos * frontCouplerShift);
frontCouplerZ = posZ + rotationSin * frontCouplerShift);
rearCouplerX = posX + rotationCos * rearCouplerShift);
rearCouplerZ = posZ + rotationSin * rearCouplerShift);

 

Then i define distance between the front/rear point and the line of player's sight direction (which is length of a perpendicular passing from point to line). Lesser value indicates needed coupler. See the top middle of the draft.

To define that distance i've written a function, because i've not found anything about it in MC sources. Maybe i was searching bad, idk. I'm bad at explaining, but however: both given line and it's perpendicular could be described by angular coefficient equations, which look like y = kx + b, where k is angular coefficient (or a tangent of the angle between line and X-axis) and b is y-intercept of the line.

After equations are made, they are combined and then solved, so we know coordinates of the interception point H. Finally, i use Pythagorean to define the distance between given and intersection points. See the bottom of the draft.

 

public float dist_point2line(float mx, float mz, float qx, float qz, float angle){
//[b]mx-mz[/b] - coordinates of the separate point (coupler), [b]qx-qz[/b] - coordinates of any point that belongs to the line
//in my case it's player position. [b]angle[/b] = angle between the line and X-axis.
float k  = (float) Math.tan(Math.toRadians(angle));
float k1 = (float) Math.tan(Math.toRadians(angle + 90F));
float b  = (float) (qz - k * qx);
float b1  = (float) (mz - k1 * mx);
float hx = (b - b1)/(k1 - k);
float hz = k * hx + b;
return (float) Math.sqrt((hx - mx) * (hx - mx) + (hz - mz) * (hz - mz));
//this was not optimized, because written to show the algorithm.
}

 

And the last piece of code:

 

float dist_front = dist_point2line(cart.frontCouplerX, cart.frontCouplerZ, 
(float) player.posX, (float) player.posZ, player.rotationYaw + 90);
float dist_rear = dist_point2line(cart.rearCouplerX, cart.rearCouplerZ, 
(float) player.posX, (float) player.posZ, player.rotationYaw + 90);
if(dist_front < dist_rear) player.addChatMessage("Clicked on front coupler");
else player.addChatMessage("Clicked on rear coupler");

 

 

Final note: this code was written especially for my case, if you want something more or less specific, i don't promise good results...

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

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

    • So am trying to make a custom 1.19.2 modpack and everything works until I add Oculus. I have tried Oculus+Embedium and Oculus+Rubdium and by themselves they work but as soon as I add anything it crashes no matter what it is. The modpack works fine with just Embedium and Rubdium. Can you help me to see if this is something i can fix or do i just have to deal with not having shaders. Here is the crash log. Thank you for your time. https://paste.ee/p/WXfNZ24K
    • New users at Temureceive a 40 Off discount on orders over 40 Off Use the code [{acx318439}]] during checkout to get TemuDiscount 40 Off For New Users. You n save 40 Off off your first order with the Promo Code available for a limited time only. Extra 30% off for new and existing customers + Up to $40 Off % off & more. Temu Promo Codes for New users- [{acx318439}]] Temudiscount code for New customers- [{acx318439}]] Temu $40 Off Promo Code- [{acx318439}]] what are Temu codes- acx318439 does Temu give you $40 Off - [{acx318439}]] Yes Verified Temu Promo Code january 2025- {acx318439} TemuNew customer offer {acx318439} Temudiscount codejanuary 2025 {acx318439} 40 off Promo Code Temu {acx318439} Temu 40% off any order {acx318439} 40 dollar off Temu code {acx318439} TemuCoupon $40 Off off for New customers There are a number of discounts and deals shoppers n take advantage of with the Teemu Coupon Bundle [{acx318439}]]. TemuCoupon $40 Off off for New customers [{acx318439}]] will save you $40 Off on your order. To get a discount, click on the item to purchase and enter the code. You n think of it as a supercharged savings pack for all your shopping needs Temu Promo Code 80% off – [{acx318439}]] Free Temu codes 50% off – [{acx318439}]] TemuCoupon $40 Off off – [{acx318439}]] Temu buy to get ₱39 – [{acx318439}]] Temu 129 coupon bundle – [{acx318439}]] Temu buy 3 to get €99 – [{acx318439}]] Exclusive $40 Off Off TemuDiscount Code Temu $40 Off Off Promo Code : (acx318439) Temu Discount Code $40 Off Bundle acx318439) acx318439 Temu $40 Off off Promo Code for Exsting users : acx318439) Temu Promo Code $40 Off off Temu 40 Off coupon code (acx318439) will save you 40 Off on your order. To get a discount, click on the item to purchase and enter the code. Yes, Temu offers 40 Off Coupon Code “acx318439” for Existing Customers.  You can get a 40 Off bonus plus 30% off any purchase at Temu with the 40 Off Coupon Bundle at Temu if you sign up with the referral code [{acx318439}]] and make a first purchase of $40 Off or more. Temu Promo Code 40 off-{acx318439} Temu Promo Code -{acx318439} Temu Promo Code $40 Off off-{acx318439} kubonus code -{acx318439} Get ready to unlock a world of savings with our free Temu UK coupons! We’ve got you covered with a wide range of Temu UK coupon code options that will help you maximize your shopping experience.30% Off Temu UK Coupons, Promo Codes + 25% Cash Back [ acx318439]   Yes, Temu offers 40 off coupon code {acx318439} for first-time users. You can get a $40 bonus plus 40% off any purchase at Temu with the $40 Coupon Bundle if you sign up with the referral code [{acx318439}]] and make a first purchase of $40 or more. If you are who wish to join Temu, then you should use this exclusive TemuCoupon code 40 off (acx318439) and get 40 off on your purchase with Temu. You can get a 40% discount with TemuCoupon code {acx318439}. This exclusive offer is for existing customers and can be used for a 40 reduction on your total purchase. Enter coupon code {acx318439} at checkout to avail of the discount. You can use the code {acx318439} to get a 40 off TemuCoupon as a new customer. Apply this TemuCoupon code $40 off (acx318439) to get a $40 discount on your shopping with Temu. If you’re a first-time user and looking for a TemuCoupon code $40 first time user(acx318439) then using this code will give you a flat $40 Off and a 90% discount on your Temu shopping.     •    acx318439: Enjoy flat 40% off on your first Temu order.     •    acx318439: Download the Temu app and get an additional 40% off.     •    acx318439: Celebrate spring with up to 90% discount on selected items.     •    acx318439: Score up to 90% off on clearance items.     •    acx318439: Beat the heat with hot summer savings of up to 90% off.     •    acx318439: Temu UK Coupon Code to 40% off on Appliances at Temu. How to Apply Temu Coupon Code? Using the TemuCoupon code $40 off is a breeze. All you need to do is follow these simple steps:     1    Visit the Temu website or app and browse through the vast collection of products.     2    Once you’ve added the items you wish to purchase to your cart, proceed to the checkout page.     3    During the checkout process, you’ll be prompted to enter a coupon code or promo code.     4    Type in the coupon code: [{acx318439}]] and click “Apply.”     5    Voila! You’ll instantly see the $40 discount reflected in your total purchase amount. Temu New User Coupon: Up To 90% OFF For Existing Customers Temu Existing customer’s coupon codes are designed just for new customers, offering the biggest discounts 90% and the best deals currently available on Temu. To maximize your savings, download the Temu app and apply our Temu new user coupon during checkout.     •    acx318439: New users can get up to 80% extra off.     •    acx318439: Get a massive 40% off your first order!     •    acx318439: Get 20% off on your first order; no minimum spending required.     •    acx318439: Take an extra 15% off your first order on top of existing discounts.     •    acx318439: Temu UK Enjoy a 40% discount on your entire first purchase.  
    • What do I do now when it says "1 error"?
    • Hello everyone new here how are you all?
    • I haven't tested it but under https://minecraft.wiki/w/Items_model_definition it says now:   So I guess the resource location must have changed with 1.24.4, which means you need to move your models/item/ to the new source. But as I said I haven't tested this so it also may be that this wont work. Nevertheless give it a try      EDIT (important) So now I tested it and found out how it works   Let the model files (e.g. the .json from blockbench) within "assets/<your_mod_id>/models/item" In addition to that do the following: Every model you added will need a new file under "assets/<your_mod_id>/items" That file is also a JSON and looks like this: { "model": { "type": "minecraft:model", "model": "your_mod_id:item/custom_item" } } - "type" can be minecraft:model, minecraft:composite, minecraft:condition, minecraft:select, minecraft:range_dispatch, minecraft:empty, minecraft:bundle/selected_item or minecraft:special. (In most cases you would need minecraft:model) - "model" is the path to your actual model for this item. For example the value above would point to "assets/your_mod_id/models/item/custom_item"
  • Topics

×
×
  • Create New...

Important Information

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