ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderTileEntity.java

59 lines
2 KiB
Java
Raw Normal View History

2015-08-29 14:33:25 +02:00
/*
* This file ("RenderTileEntity.java") is part of the Actually Additions Mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
2016-01-03 16:05:51 +01:00
* http://ellpeck.de/actaddlicense/
2015-08-29 14:33:25 +02:00
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2016-01-03 16:05:51 +01:00
* © 2016 Ellpeck
2015-08-29 14:33:25 +02:00
*/
2016-01-05 04:47:35 +01:00
package de.ellpeck.actuallyadditions.mod.blocks.render;
2016-01-05 04:47:35 +01:00
import de.ellpeck.actuallyadditions.mod.blocks.render.model.ModelBaseAA;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
2016-01-08 13:31:58 +01:00
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
public class RenderTileEntity extends TileEntitySpecialRenderer{
public ModelBaseAA theModel;
public ResourceLocation resLoc;
2015-03-07 12:51:28 +01:00
public RenderTileEntity(ModelBaseAA model){
this.theModel = model;
this.resLoc = new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/blocks/models/"+this.theModel.getName()+".png");
}
@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par5, int i){
GlStateManager.pushMatrix();
GlStateManager.translate((float)x+0.5F, (float)y-0.5F, (float)z+0.5F);
GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F);
GlStateManager.translate(0.0F, -2.0F, 0.0F);
this.bindTexture(resLoc);
if(theModel.doesRotate()){
2016-01-08 13:31:58 +01:00
int meta = PosUtil.getMetadata(tile.getPos(), tile.getWorld());
2015-10-03 10:16:18 +02:00
if(meta == 0){
GlStateManager.rotate(180F, 0F, 1F, 0F);
2015-10-03 10:16:18 +02:00
}
if(meta == 1){
GlStateManager.rotate(90F, 0F, 1F, 0F);
2015-10-03 10:16:18 +02:00
}
if(meta == 3){
GlStateManager.rotate(270F, 0F, 1F, 0F);
2015-10-03 10:16:18 +02:00
}
}
theModel.render(0.0625F);
theModel.renderExtra(0.0625F, tile);
GlStateManager.popMatrix();
}
}