Jump to content

[1.11] Special tile entity renderer


luckie12

Recommended Posts

Hi!

I made a oak shelf, i am able to add items on it with right click, but as you can see in the picture, the items are on one side only in the right position...

 

As you can see:

 

50a88106858744c898cb8b7e0e880321.png

 

And yes, its pretty obvious, because i use static translates

this is my SpecialTileEntity renderer part:

 

private static final EntityItem ITEM = new EntityItem(Minecraft.getMinecraft().world, 0, 0, 0, new ItemStack(ModItems.tinApple));

@Override
public void renderTileEntityAt(TileEntityOakShelf te, double x, double y, double z, float partialTicks,
		int destroyStage) {
	super.renderTileEntityAt(te, x, y, z, partialTicks, destroyStage);

	ITEM.hoverStart = 0F;

	GlStateManager.pushMatrix();
	{
		GlStateManager.translate(x, y, z);
		GlStateManager.rotate(90F, 1, 90F, 0);
		GlStateManager.translate(-0.22, 0.5, .15);
		GlStateManager.scale(.5, .5, .5);
		for(int i = 0; i < te.itemCount; i++){
			Minecraft.getMinecraft().getRenderManager().doRenderEntity(ITEM, 0, 0, 0, 0F, 0F, false);
			GlStateManager.translate(-0.3625, 0, 0);
		}
	}
	GlStateManager.popMatrix();		
}

}

 

How would i make it that it goes to the right side evertime?

 

Thanks a bunch!

Link to comment
Share on other sites

Make an EnumFacing variable in your tile entity, and then in put in a if(te.getFacing() == EnumFacing.*) in your TESR and then rotate the items differently and place them different

 

So, i went off on the code way you told me here,

 

i ended up with this:

 

My TileEntity:

 

public EnumFacing getFacing(){
	EnumFacing face = (EnumFacing) EnumFacing.NORTH;
	return face;
}

 

and my Special Renderer

	if(te.getFacing() == EnumFacing.NORTH){
		GlStateManager.pushMatrix();
		{
			GlStateManager.translate(x, y, z);
			GlStateManager.rotate(90F, 1, 90F, 0);
			GlStateManager.translate(-0.22, 0.5, .15);
			GlStateManager.scale(.5, .5, .5);
			for(int i = 0; i < te.itemCount; i++){
				Minecraft.getMinecraft().getRenderManager().doRenderEntity(ITEM, 0, 0, 0, 0F, 0F, false);
				GlStateManager.translate(-0.3625, 0, 0);
			}
		}
		GlStateManager.popMatrix();	
	}

 

But i cant seem to find how to get the facing of the block right there... because i told it to keep on NORTH

Link to comment
Share on other sites

What you need to do is access the BlockState of your block where the TileEntity is and check the FACING property and get the Facing from that.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

What you need to do is access the BlockState of your block where the TileEntity is and check the FACING property and get the Facing from that.

 

As a newb im looking into these things on google, not much luck yet with this

 

public IBlockState getState(){
	IBlockState state = (IBlockState) super.getUpdateTag();
	return state;
}

 

Why isnt there a simple method like: getFacing(); that returns the face haha

Link to comment
Share on other sites

As a newb im looking into these things on google, not much luck yet with this

 

public IBlockState getState(){
	IBlockState state = (IBlockState) super.getUpdateTag();
	return state;
}

 

Why isnt there a simple method like: getFacing(); that returns the face haha

 

o_O

The getUpdateTag method returns some Packet object. Why on earth are you trying to cast that to an IBlockState? There's nothing even in the method's name to suggest that it might be even tangentially related to what you're trying to do.

 

There isn't a simple method like getFacing because you have to create it yourself.

Don't make mods if you don't know Java.

Check out my website: http://shadowfacts.net

Developer of many mods

Link to comment
Share on other sites

As a newb im looking into these things on google, not much luck yet with this

 

public IBlockState getState(){
	IBlockState state = (IBlockState) super.getUpdateTag();
	return state;
}

 

Why isnt there a simple method like: getFacing(); that returns the face haha

 

o_O

The getUpdateTag method returns some Packet object. Why on earth are you trying to cast that to an IBlockState? There's nothing even in the method's name to suggest that it might be even tangentially related to what you're trying to do.

 

There isn't a simple method like getFacing because you have to create it yourself.

 

Well, i put that there because i was testing all the super.  statements, i ended on getUpdateTag(), not that i am specificly using it.

 

How much Java do you know?

 

Not much.

Well, i cant learn by 'reading' so i tend to learn from tutorials.

Link to comment
Share on other sites

I would suggest watching some tutorials on some Object Oriented Programming so you can learn the concepts, I would recommend it being Java over other obviously.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

I would suggest watching some tutorials on some Object Oriented Programming so you can learn the concepts, I would recommend it being Java over other obviously.

Yeah... as im coming from a PHP/JS/HTML/CSS background.. :P

Yeah that is not quite the best for this....Once you have those OOP concepts down you should be able to tackle this problem with barely any effort.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

I would suggest watching some tutorials on some Object Oriented Programming so you can learn the concepts, I would recommend it being Java over other obviously.

Yeah... as im coming from a PHP/JS/HTML/CSS background.. :P

Yeah that is not quite the best for this....Once you have those OOP concepts down you should be able to tackle this problem with barely any effort.

 

I hope so :D

 

Any recommendations of a tutorial i should look into, and by that i mean a creators name?

Link to comment
Share on other sites

I would suggest watching some tutorials on some Object Oriented Programming so you can learn the concepts, I would recommend it being Java over other obviously.

Yeah... as im coming from a PHP/JS/HTML/CSS background.. :P

Yeah that is not quite the best for this....Once you have those OOP concepts down you should be able to tackle this problem with barely any effort.

 

I hope so :D

 

Any recommendations of a tutorial i should look into, and by that i mean a creators name?

I do not have any recommendations because I just jumped in and learned as I went, but you can just go on to youtube and search for "java concepts tutorial for beginners" or "java for beginners" and that should work.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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.