Jump to content

[1.7.10]Getting the block the player is looking at problem


FLUFFY2

Recommended Posts

I have a dynamic light system that not requires pakets(thanks to diesieben07), but there is something wrong with it.

I have two types of light: "Under the player" and "Where the player is looking at".

The underplayer one works like a charm, but the otherone not so well.

 

The problem is in client side its OK, but on server side other player see the light under me and not where im looking at.

The player who is crating the light always see the light in a correct pos. Only others not.

The problem occourns when the player raytrace is hitting a block. When its not others see the light correctly.

I read it a problem with raytrace that its only client sided, but then i read there is another method via look vectors for both side.

So i made the following:

 

THIS CODE IS ONLY FOR TESTING

 

LightHandler(PlayerTickHandler):

http://pastebin.com/QcCUzykc

 

ExtendedPlayerProperties(Only the raytrace part):

http://pastebin.com/uanxRjQB

 

Thanks for helping me!

Link to comment
Share on other sites

Don't know if this is the problem, but on this line:

if(props.getRayTraceX(distance) != props.getLastPosX2() || props.getRayTraceY(distance) != props.getLastPosY2(){

You don't check for the Z coord. Maybe that's intended, but i may just point it out.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

Hi

 

I don't understand how your code is supposed to work.

 

I think you might be confusing "server side" with other clients.  There doesn't need to be any raytracing on the server, unless you want your server to raytrace each player's line of sight and send the resulting location to all other clients using packets or IExtendedProperties, which seems unnecessary to me.

 

What I think you should be doing is performing your raytracing on the client for each of the other players.  The server has nothing to do with it, except that it communicates between the clients to tell where the other players are looking, which it does already.

 

If you want to stick with the server doing the ray tracing, I suggest you add a few System.out.println statements to your server calculations to se if they're working correctly and narrow down where the problem is.

 

-TGG

 

 

Link to comment
Share on other sites

Hi there

 

So my code is supposed to create the light without pakets to not raise the network usage! So the light is crated client side.

Even if another player is emitting the light its created by your client. And that realy helps to raise the performance of the dynamic lighting. And i have to use that anyway because in 1.7.10 you cannot create light server side anymore.

 

Im using PlayerTickHander and i need ExtendedPlayerProperties because all player is getting the data from the same PlayerTickHander class and if i store data there it becomes realy messed up.

So i need diferent values for each player.

 

I tracked down whats the problem and its that line in my getRayTrace methods:

		
MovingObjectPosition mop = player.worldObj.rayTraceBlocks(pos, addedlook);
if(mop != null && mop.typeOfHit == MovingObjectType.BLOCK)
return mop.blockXYZ;

 

Without that other do see he light correctly but than the light can be in a block because i don't check for block hit.

For some reason the code above only gets data for the client.

 

I do some printLn debug and this is what i get:

Client side , no other player: Correct pos!

Client side, with other player: Correct and bad pos at the same time!

Server side: Always bad pos!

 

I will play around with it a bit more, but if you have any idea please tell me! Thanks!

 

 

 

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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