Raycoms Posted September 1, 2016 Share Posted September 1, 2016 I have a tileEntity which should face the way the player places it. currently I used some constants so it faces north at least. Without the constants if I fill in x and z as posX and posZ the block will follow the player. Without the rotation my block seems upside down. I set all the variables in the block so I am able to get the facing from the block state. But I don't know how to set the renderer up. @SideOnly(Side.CLIENT) public class TileEntityScarecrowRenderer extends TileEntitySpecialRenderer<ScarecrowTileEntity> { /** * The model of the scarecrow. */ private final ModelScarecrowBoth model; /** * Offset to the block middle. */ private static final double BLOCK_MIDDLE = 0.5; /** * Y-Offset in order to have the scarecrow over ground. */ private static final double YOFFSET = 1.5; /** * Which size the scarecrow should have ingame. */ private static final double SIZERATIO = .0625; /** * Rotate the model some degrees. */ private static final int ROTATION = 180; /** * Rotate it on the following x offset. */ private static final float XROTATIONOFFSET = 0.311F; /** * Rotate it on the following y offset. */ private static final float YROTATIONOFFSET = 0.0F; /** * Rotate it on the following z offset. */ private static final float ZROTATIONOFFSET = 2.845F; /** * The public constructor for the renderer. */ public TileEntityScarecrowRenderer() { super(); this.model = new ModelScarecrowBoth(); } @Override public void renderTileEntityAt(ScarecrowTileEntity te, double posX, double posY, double posZ, float partialTicks, int destroyStage) { //Store the transformation GlStateManager.pushMatrix(); //Set viewport to tile entity position to render it GlStateManager.translate(posX+BLOCK_MIDDLE, posY+YOFFSET, posZ+BLOCK_MIDDLE); this.bindTexture(getResourceLocation(te)); GlStateManager.rotate(ROTATION, XROTATIONOFFSET, YROTATIONOFFSET, ZROTATIONOFFSET); this.model.render((float) SIZERATIO); /* ============ Rendering Code stops here =========== */ //Restore the transformation, so other renderer's are not messed up. GlStateManager.popMatrix(); } /** * Returns the ResourceLocation of the scarecrow texture. * @param tileEntity the tileEntity of the scarecrow. * @return the location. */ private static ResourceLocation getResourceLocation(ScarecrowTileEntity tileEntity) { String loc; if(tileEntity.getType() == ScarecrowTileEntity.ScareCrowType.PUMPKINHEAD) { loc = "textures/blocks/blockScarecrowPumpkin.png"; } else { loc = "textures/blocks/blockScarecrowNormal.png"; } return new ResourceLocation(Constants.MOD_ID + ":" + loc); } Quote Link to comment Share on other sites More sharing options...
Mightydanp Posted September 1, 2016 Share Posted September 1, 2016 Dont know anything about this but heres a reference http://www.minecraftforge.net/forum/index.php?topic=41059.0 Quote Link to comment Share on other sites More sharing options...
Raycoms Posted September 1, 2016 Author Share Posted September 1, 2016 But he doesn't use a tileEntityRenderer, I already set the blockStates correct I now have to render it accordingly. Quote Link to comment Share on other sites More sharing options...
Raycoms Posted September 1, 2016 Author Share Posted September 1, 2016 I unfortunately only have a .java model of the scarecrow how should I do it then? Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted September 1, 2016 Share Posted September 1, 2016 I unfortunately only have a .java model of the scarecrow how should I do it then? With the new block model system... Quote 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 More sharing options...
Raycoms Posted September 2, 2016 Author Share Posted September 2, 2016 Let's assume I didn't model that and that also I have no idea of modelling and the guy that models that kind of stuff is not available. Or just assume I plan on animating it later on. How can I let it face the correct direction for now? Quote Link to comment Share on other sites More sharing options...
Raycoms Posted September 2, 2016 Author Share Posted September 2, 2016 I stored the rotation in the BlockState of my custom block and I am able to retrieve it in the tileEntitySpecialRenderer. But the State is an EnumFacing and I don't actually know how I should rotate it. Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted September 2, 2016 Share Posted September 2, 2016 I stored the rotation in the BlockState of my custom block and I am able to retrieve it in the tileEntitySpecialRenderer. But the State is an EnumFacing and I don't actually know how I should rotate it. GL11.rotatef(...) Quote 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 More sharing options...
Raycoms Posted September 2, 2016 Author Share Posted September 2, 2016 I use GlStateManager.rotate(180, 0.3, 0.0 2.845); This fixed variables let my scarecrow face north being in the correct position. What do I have to change to have him show into any EnumFacing? Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted September 2, 2016 Share Posted September 2, 2016 I use GlStateManager.rotate(180, 0.3, 0.0 2.845); This fixed variables let my scarecrow face north being in the correct position. What do I have to change to have him show into any EnumFacing? EnumFacing says which way it is facing so after rotating it to face north, check if it is facing a direction lets say south, if it is rotate it again to the correct position. Quote 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 More sharing options...
Recommended Posts
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.