use of mchorse.blockbuster.network.common.structure.PacketStructureRequest in project blockbuster by mchorse.
the class StructureMorph method render.
@Override
@SideOnly(Side.CLIENT)
public void render(EntityLivingBase entity, double x, double y, double z, float entityYaw, float partialTicks) {
StructureRenderer renderer = STRUCTURES.get(this.structure);
if (renderer != null) {
if (renderer.status != StructureStatus.LOADED) {
if (renderer.status == StructureStatus.UNLOADED) {
renderer.status = StructureStatus.LOADING;
Dispatcher.sendToServer(new PacketStructureRequest(this.structure));
}
return;
}
float lastX = OpenGlHelper.lastBrightnessX;
float lastY = OpenGlHelper.lastBrightnessY;
if (GuiModelRenderer.isRendering() && !this.lighting) {
Minecraft.getMinecraft().entityRenderer.enableLightmap();
}
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
/* These states are important to enable */
GlStateManager.pushMatrix();
GlStateManager.enableRescaleNormal();
GlStateManager.translate(x, y, z);
ModelTransform transform = this.pose;
float anchorX = this.anchorX;
float anchorY = this.anchorY;
float anchorZ = this.anchorZ;
if (this.animation.isInProgress()) {
transform = new ModelTransform();
transform.copy(this.pose);
this.animation.apply(transform, partialTicks);
if (this.animation.lastAnchorX != null) {
float factor = this.animation.getFactor(partialTicks);
anchorX = this.animation.interp.interpolate(this.animation.lastAnchorX, anchorX, factor);
anchorY = this.animation.interp.interpolate(this.animation.lastAnchorY, anchorY, factor);
anchorZ = this.animation.interp.interpolate(this.animation.lastAnchorZ, anchorZ, factor);
}
}
transform.transform();
GlStateManager.translate(anchorX, anchorY, anchorZ);
RenderHelper.disableStandardItemLighting();
GlStateManager.shadeModel(GL11.GL_SMOOTH);
GlStateManager.enableAlpha();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
renderer.render(this);
GlStateManager.disableBlend();
GlStateManager.disableAlpha();
GlStateManager.shadeModel(GL11.GL_FLAT);
GlStateManager.enableLighting();
GlStateManager.enableLight(0);
GlStateManager.enableLight(1);
GlStateManager.enableColorMaterial();
GL11.glColor4f(1, 1, 1, 1);
renderer.renderTEs(this);
GlStateManager.popMatrix();
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lastX, lastY);
if (GuiModelRenderer.isRendering() && !this.lighting) {
Minecraft.getMinecraft().entityRenderer.disableLightmap();
}
}
}
use of mchorse.blockbuster.network.common.structure.PacketStructureRequest in project blockbuster by mchorse.
the class StructureMorph method renderOnScreen.
@Override
@SideOnly(Side.CLIENT)
public void renderOnScreen(EntityPlayer player, int x, int y, float scale, float alpha) {
StructureRenderer renderer = STRUCTURES.get(this.structure);
if (renderer != null) {
if (renderer.status != StructureStatus.LOADED) {
if (renderer.status == StructureStatus.UNLOADED) {
renderer.status = StructureStatus.LOADING;
Dispatcher.sendToServer(new PacketStructureRequest(this.structure));
}
return;
}
int max = Math.max(renderer.size.getX(), Math.max(renderer.size.getY(), renderer.size.getZ()));
scale /= 0.65F * max;
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
float lastX = OpenGlHelper.lastBrightnessX;
float lastY = OpenGlHelper.lastBrightnessY;
GlStateManager.enableDepth();
GlStateManager.enableAlpha();
GlStateManager.disableCull();
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, 0);
GlStateManager.scale(scale, scale, scale);
GlStateManager.rotate(45.0F, -1.0F, 0.0F, 0.0F);
GlStateManager.rotate(45.0F, 0.0F, -1.0F, 0.0F);
GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
renderer.render(this);
renderer.renderTEs(this);
GlStateManager.disableLighting();
GlStateManager.popMatrix();
GlStateManager.enableCull();
GlStateManager.disableAlpha();
GlStateManager.disableDepth();
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lastX, lastY);
}
}
Aggregations