Jump to content

[Solved] How to make this per-block


Voldemort127

Recommended Posts

Hi, I am working with a block that has a custom model. This block is an eye that always looks at the player. If I place this block somewhere, it will look at me, so it works, but if I place more than one block, both of them will go crazy. If the game only renders one of them (ex. the other eye is behind me) it works without any problem. So my question is how can I make the eye movement per block so if I place more than one eyes next to each other, they would both look at me? Pics and code files below.

 

If only one block is on the screen, it will look at me:

mPObNEH.png

 

If there are more than one eye blocks on the screen, none of them will look at me: (left side of the pic)

U0HRK5s.png

 

This is my TileEntity code: https://gist.github.com/Voldemort127/4c2e1d86fb3f732e2df1

Render code: https://gist.github.com/Voldemort127/46f428cc65f97f7a6c54

Block code: https://gist.github.com/Voldemort127/3d2346d00d9ac698e142

 

Pls tell me if I forgot something

Link to comment
Share on other sites

Well I can tell you right now that this:

 

	@Override
public void updateEntity() {
	this.moveEye();
}

@SideOnly(Side.CLIENT)
public void moveEye() {
	//...
}

 

Will crash the dedicated server.

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.

Link to comment
Share on other sites

How can I fix it?

 

worldObject.isRemote

http://www.minecraftforge.net/forum/index.php/topic,22764.0.html

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.

Link to comment
Share on other sites

I've noticed something while moving around in the front of the blocks: The eye on the left looks exactly where the one on the right should look at and vice versa.

Well, inverse the values...

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

Problem solved! :D

I made a separate method in the model class, that renders the pupil separately.

This is my render code:

EntityPlayer ep = Minecraft.getMinecraft().thePlayer;
float eyeX = Math.max(Math.min((float) ((ac1_rot == 0 ? tee.xCoord : (ac1_rot == 90 ? -tee.zCoord - 1.0F : (ac1_rot == 180 ? -tee.xCoord - 1.0F : tee.zCoord))) + 0.5F - (ac1_rot == 0 ? ep.posX : (ac1_rot == 90 ? -ep.posZ : (ac1_rot == 180 ? -ep.posX : ep.posZ)))), 1.0F), -1.0F) * 1.8F;
float eyeY = Math.max(Math.min((float) ((tee.yCoord) + 0.5F - (ep.posY)), 1.0F), -1.0F) * 1.8F;
this.model.renderModel(0.0625F);
GL11.glTranslatef(eyeX / 12.0F, eyeY / 12.0F, 0.0F);
this.model.renderPupil(0.0625F);

Now, all the eyes are staring at me :)

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.

Announcements



×
×
  • Create New...

Important Information

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