use of stevekung.mods.moreplanets.util.blocks.BlockAncientChestMP in project MorePlanets by SteveKunG.
the class TileEntityAncientChestRendererMP method render.
@Override
public void render(TileEntityAncientChestMP tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
int meta;
if (!tile.hasWorld()) {
meta = 0;
} else {
Block block = tile.getBlockType();
meta = tile.getBlockMetadata();
if (block instanceof BlockAncientChestMP && meta == 0) {
((BlockAncientChestMP) block).checkForSurroundingChests(tile.getWorld(), tile.getPos(), tile.getWorld().getBlockState(tile.getPos()));
meta = tile.getBlockMetadata();
}
tile.checkForAdjacentChests();
}
if (tile.adjacentChestZNeg == null && tile.adjacentChestXNeg == null) {
ModelChest modelchest;
if (tile.adjacentChestXPos == null && tile.adjacentChestZPos == null) {
modelchest = this.simpleChest;
if (destroyStage >= 0) {
this.bindTexture(DESTROY_STAGES[destroyStage]);
GlStateManager.matrixMode(5890);
GlStateManager.pushMatrix();
GlStateManager.scale(4.0F, 4.0F, 1.0F);
GlStateManager.translate(0.0625F, 0.0625F, 0.0625F);
GlStateManager.matrixMode(5888);
} else if (CalendarHelper.isChristmasDay()) {
this.bindTexture(this.textureChristmas);
} else if (CalendarHelper.isMorePlanetsBirthDay()) {
this.bindTexture(this.morePlanetsChestNormal);
} else {
this.bindTexture(this.textureNormal);
}
} else {
modelchest = this.largeChest;
if (destroyStage >= 0) {
this.bindTexture(DESTROY_STAGES[destroyStage]);
GlStateManager.matrixMode(5890);
GlStateManager.pushMatrix();
GlStateManager.scale(8.0F, 4.0F, 1.0F);
GlStateManager.translate(0.0625F, 0.0625F, 0.0625F);
GlStateManager.matrixMode(5888);
} else if (CalendarHelper.isChristmasDay()) {
this.bindTexture(this.textureChristmasDouble);
} else if (CalendarHelper.isMorePlanetsBirthDay()) {
this.bindTexture(this.morePlanetsLargeChestNormal);
} else {
this.bindTexture(this.textureNormalDouble);
}
}
GlStateManager.pushMatrix();
GlStateManager.enableRescaleNormal();
if (destroyStage < 0) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
}
GlStateManager.translate((float) x, (float) y + 1.0F, (float) z + 1.0F);
GlStateManager.scale(1.0F, -1.0F, -1.0F);
GlStateManager.translate(0.5F, 0.5F, 0.5F);
short short1 = 0;
if (meta == 2) {
short1 = 180;
}
if (meta == 3) {
short1 = 0;
}
if (meta == 4) {
short1 = 90;
}
if (meta == 5) {
short1 = -90;
}
if (meta == 2 && tile.adjacentChestXPos != null) {
GlStateManager.translate(1.0F, 0.0F, 0.0F);
}
if (meta == 5 && tile.adjacentChestZPos != null) {
GlStateManager.translate(0.0F, 0.0F, -1.0F);
}
GlStateManager.rotate(short1, 0.0F, 1.0F, 0.0F);
GlStateManager.translate(-0.5F, -0.5F, -0.5F);
float f1 = tile.prevLidAngle + (tile.lidAngle - tile.prevLidAngle) * partialTicks;
float f2;
if (tile.adjacentChestZNeg != null) {
f2 = tile.adjacentChestZNeg.prevLidAngle + (tile.adjacentChestZNeg.lidAngle - tile.adjacentChestZNeg.prevLidAngle) * partialTicks;
if (f2 > f1) {
f1 = f2;
}
}
if (tile.adjacentChestXNeg != null) {
f2 = tile.adjacentChestXNeg.prevLidAngle + (tile.adjacentChestXNeg.lidAngle - tile.adjacentChestXNeg.prevLidAngle) * partialTicks;
if (f2 > f1) {
f1 = f2;
}
}
f1 = 1.0F - f1;
f1 = 1.0F - f1 * f1 * f1;
modelchest.chestLid.rotateAngleX = -(f1 * (float) Math.PI / 2.0F);
modelchest.renderAll();
GlStateManager.disableRescaleNormal();
GlStateManager.popMatrix();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
if (destroyStage >= 0) {
GlStateManager.matrixMode(5890);
GlStateManager.popMatrix();
GlStateManager.matrixMode(5888);
}
}
}
Aggregations