use of net.minecraft.client.renderer.block.model.IBakedModel in project ImmersiveEngineering by BluSunrize.
the class TileRenderBelljar method renderTileEntityAt.
@Override
public void renderTileEntityAt(TileEntityBelljar tile, double x, double y, double z, float partialTicks, int destroyStage) {
if (tile.dummy != 0 || !tile.getWorld().isBlockLoaded(tile.getPos(), false))
return;
final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
BlockPos blockPos = tile.getPos();
if (!quads.containsKey(tile.getFacing())) {
IBlockState state = getWorld().getBlockState(blockPos);
if (state.getBlock() != IEContent.blockMetalDevice1)
return;
state = state.getActualState(getWorld(), blockPos);
IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(state);
if (state instanceof IExtendedBlockState)
state = ((IExtendedBlockState) state).withProperty(Properties.AnimationProperty, new OBJState(Arrays.asList("glass"), true));
quads.put(tile.getFacing(), model.getQuads(state, null, 0));
}
ClientUtils.bindAtlas();
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
RenderHelper.disableStandardItemLighting();
GlStateManager.blendFunc(770, 771);
GlStateManager.enableBlend();
GlStateManager.disableCull();
if (Minecraft.isAmbientOcclusionEnabled())
GlStateManager.shadeModel(7425);
else
GlStateManager.shadeModel(7424);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
VertexBuffer worldRenderer = Tessellator.getInstance().getBuffer();
GlStateManager.enableCull();
IPlantHandler plantHandler = tile.getCurrentPlantHandler();
if (plantHandler != null) {
GlStateManager.pushMatrix();
GlStateManager.translate(0, 1.0625, 0);
GlStateManager.color(1, 1, 1, 1);
float scale = plantHandler.getRenderSize(tile.getInventory()[1], tile.getInventory()[0], tile.renderGrowth, tile);
GlStateManager.translate((1 - scale) / 2, 0, (1 - scale) / 2);
GlStateManager.scale(scale, scale, scale);
if (!plantHandler.overrideRender(tile.getInventory()[1], tile.getInventory()[0], tile.renderGrowth, tile, blockRenderer)) {
IBlockState[] states = plantHandler.getRenderedPlant(tile.getInventory()[1], tile.getInventory()[0], tile.renderGrowth, tile);
if (states == null || states.length < 1)
return;
for (IBlockState s : states) {
List<BakedQuad> plantQuadList = plantQuads.get(s);
if (plantQuadList == null) {
IBakedModel plantModel = blockRenderer.getModelForState(s);
plantQuadList = plantModel.getQuads(s, null, 0);
for (EnumFacing f : EnumFacing.values()) plantQuadList.addAll(plantModel.getQuads(s, f, 0));
plantQuads.put(s, plantQuadList);
}
if (plantQuadList != null) {
GlStateManager.pushMatrix();
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
ClientUtils.renderModelTESR(plantQuadList, worldRenderer, tile.getWorld().getCombinedLight(tile.getPos(), 0));
Tessellator.getInstance().draw();
GlStateManager.popMatrix();
GlStateManager.translate(0, 1, 0);
}
}
}
GlStateManager.popMatrix();
}
GlStateManager.depthMask(false);
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
ClientUtils.renderModelTESR(quads.get(tile.getFacing()), worldRenderer, tile.getWorld().getCombinedLight(tile.getPos(), 0));
Tessellator.getInstance().draw();
RenderHelper.enableStandardItemLighting();
GlStateManager.disableBlend();
GlStateManager.depthMask(true);
GlStateManager.popMatrix();
RenderHelper.enableStandardItemLighting();
}
use of net.minecraft.client.renderer.block.model.IBakedModel in project ImmersiveEngineering by BluSunrize.
the class TileRenderBottlingMachine method renderTileEntityAt.
@Override
public void renderTileEntityAt(TileEntityBottlingMachine te, double x, double y, double z, float partialTicks, int destroyStage) {
if (!te.formed || te.isDummy() || !te.getWorld().isBlockLoaded(te.getPos(), false))
return;
//Grab model + correct eextended state
final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
BlockPos blockPos = te.getPos();
IBlockState state = getWorld().getBlockState(blockPos);
if (state.getBlock() != IEContent.blockMetalMultiblock)
return;
state = state.getBlock().getActualState(state, getWorld(), blockPos);
state = state.withProperty(IEProperties.DYNAMICRENDER, true);
IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(state);
//Initialize Tesselator and VertexBuffer
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer worldRenderer = tessellator.getBuffer();
//Outer GL Wrapping, initial translation
GlStateManager.pushMatrix();
GlStateManager.translate(x + .5, y + .5, z + .5);
if (te.mirrored)
GlStateManager.scale(te.facing.getFrontOffsetX() == 0 ? -1 : 1, 1, te.facing.getFrontOffsetZ() == 0 ? -1 : 1);
//Item Displacement
float[][] itemDisplays = new float[te.bottlingProcessQueue.size()][];
//Animations
float lift = 0;
for (int i = 0; i < itemDisplays.length; i++) {
BottlingProcess process = te.bottlingProcessQueue.get(i);
if (process == null || process.processTick == process.maxProcessTick)
continue;
//+partialTicks
float processTimer = ((float) process.processTick) / process.maxProcessTick * 120;
//-1;
float itemX = -1.5f;
// -.34375f;
float itemY = -.15625f;
//-.9375f;
float itemZ = 1;
//ClientUtils.mc().thePlayer.ticksExisted%100; //0f;
float itemFill = 0;
if (//slide
processTimer <= 35) {
itemX += processTimer / 35f * 1.5;
} else if (//slide
processTimer <= 85) {
itemX = 0;
if (processTimer <= 55)
lift = (processTimer - 35) / 20f * .125f;
else if (processTimer <= 65) {
lift = .125f;
itemFill = (processTimer - 55) / 10f;
} else {
lift = (85 - processTimer) / 20f * .125f;
itemFill = 1;
}
itemY += lift;
lift += .0625;
} else {
itemX = (processTimer - 85) / 35f * 1.5f;
itemFill = 1;
}
itemDisplays[i] = new float[] { processTimer, itemX, itemY, itemZ, itemFill };
}
ClientUtils.bindAtlas();
GlStateManager.pushMatrix();
GlStateManager.translate(0, lift, 0);
renderModelPart(blockRenderer, tessellator, worldRenderer, te.getWorld(), state, model, blockPos, "lift");
GlStateManager.translate(0, -lift, 0);
RenderHelper.enableStandardItemLighting();
GlStateManager.popMatrix();
switch(te.facing) {
case NORTH:
break;
case SOUTH:
GlStateManager.rotate(180, 0, 1, 0);
break;
case WEST:
GlStateManager.rotate(90, 0, 1, 0);
break;
case EAST:
GlStateManager.rotate(-90, 0, 1, 0);
break;
}
float scale = .0625f;
FluidStack fs = te.tanks[0].getFluid();
if (fs != null) {
GlStateManager.pushMatrix();
float level = fs.amount / (float) te.tanks[0].getCapacity();
GlStateManager.translate(-.21875, .376, 1.21875);
GlStateManager.scale(scale, scale, scale);
float h = level * 9;
ClientUtils.drawRepeatedFluidSprite(fs, 0, 0, 7, h);
GlStateManager.rotate(90, 0, 1, 0);
ClientUtils.drawRepeatedFluidSprite(fs, 0, 0, 7, h);
GlStateManager.rotate(90, 0, 1, 0);
GlStateManager.translate(-7, 0, 7);
ClientUtils.drawRepeatedFluidSprite(fs, 0, 0, 7, h);
GlStateManager.rotate(90, 0, 1, 0);
ClientUtils.drawRepeatedFluidSprite(fs, 0, 0, 7, h);
GlStateManager.rotate(90, 1, 0, 0);
ClientUtils.drawRepeatedFluidSprite(fs, 0, 0, 7, 7);
GlStateManager.translate(0, 0, -h);
ClientUtils.drawRepeatedFluidSprite(fs, 0, 0, 7, 7);
GlStateManager.scale(1 / scale, 1 / scale, 1 / scale);
GlStateManager.translate(0, -1, -1);
GlStateManager.popMatrix();
}
//DRAW ITEMS HERE
for (int i = 0; i < itemDisplays.length; i++) if (itemDisplays[i] != null) {
BottlingProcess process = te.bottlingProcessQueue.get(i);
if (process == null)
continue;
ItemStack display = itemDisplays[i][4] == 0 || process.items[1] == null ? process.items[0] : process.items[1];
scale = .4375f;
GlStateManager.translate(itemDisplays[i][1], itemDisplays[i][2], itemDisplays[i][3]);
GlStateManager.scale(scale, scale, scale);
if (itemDisplays[i][4] == 0)
ClientUtils.mc().getRenderItem().renderItem(process.items[0], ItemCameraTransforms.TransformType.FIXED);
else if (itemDisplays[i][4] == 1)
ClientUtils.mc().getRenderItem().renderItem(display, ItemCameraTransforms.TransformType.FIXED);
else {
float h0 = -.5f;
float h1 = h0 + itemDisplays[i][4];
VertexBuffer worldrenderer = tessellator.getBuffer();
GL11.glEnable(GL11.GL_STENCIL_TEST);
GlStateManager.colorMask(false, false, false, false);
GlStateManager.depthMask(false);
GL11.glStencilFunc(GL11.GL_NEVER, 1, 0xFF);
GL11.glStencilOp(GL11.GL_REPLACE, GL11.GL_KEEP, GL11.GL_KEEP);
GL11.glStencilMask(0xFF);
GlStateManager.clear(GL11.GL_STENCIL_BUFFER_BIT);
GlStateManager.rotate(90.0F - ClientUtils.mc().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
GlStateManager.disableTexture2D();
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
ClientUtils.renderBox(worldrenderer, -.5, h0, -.5, .5, h1, .5);
tessellator.draw();
GlStateManager.enableTexture2D();
GlStateManager.rotate(-(90.0F - ClientUtils.mc().getRenderManager().playerViewY), 0.0F, 1.0F, 0.0F);
GlStateManager.colorMask(true, true, true, true);
GlStateManager.depthMask(true);
GL11.glStencilMask(0x00);
GL11.glStencilFunc(GL11.GL_EQUAL, 0, 0xFF);
ClientUtils.mc().getRenderItem().renderItem(process.items[0], ItemCameraTransforms.TransformType.FIXED);
GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF);
ClientUtils.mc().getRenderItem().renderItem(display, ItemCameraTransforms.TransformType.FIXED);
GL11.glDisable(GL11.GL_STENCIL_TEST);
}
GlStateManager.scale(1 / scale, 1 / scale, 1 / scale);
GlStateManager.translate(-itemDisplays[i][1], -itemDisplays[i][2], -itemDisplays[i][3]);
}
GlStateManager.popMatrix();
}
use of net.minecraft.client.renderer.block.model.IBakedModel in project ImmersiveEngineering by BluSunrize.
the class TileRenderArcFurnace method renderTileEntityAt.
@Override
public void renderTileEntityAt(TileEntityArcFurnace te, double x, double y, double z, float partialTicks, int destroyStage) {
if (!te.formed || te.isDummy() || !te.getWorld().isBlockLoaded(te.getPos(), false))
return;
List<String> renderedParts = null;
for (int i = 0; i < 3; i++) if (te.getInventory()[23 + i] != null) {
if (renderedParts == null)
renderedParts = Lists.newArrayList("electrode" + (i + 1));
else
renderedParts.add("electrode" + (i + 1));
}
if (renderedParts == null)
return;
if (te.shouldRenderAsActive())
renderedParts.add("active");
final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
BlockPos blockPos = te.getPos();
IBlockState state = getWorld().getBlockState(blockPos);
if (state.getBlock() != IEContent.blockMetalMultiblock)
return;
state = state.getBlock().getActualState(state, getWorld(), blockPos);
state = state.withProperty(IEProperties.DYNAMICRENDER, true);
IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(state);
if (state instanceof IExtendedBlockState)
state = ((IExtendedBlockState) state).withProperty(Properties.AnimationProperty, new OBJState(renderedParts, true));
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer worldRenderer = tessellator.getBuffer();
ClientUtils.bindAtlas();
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
GlStateManager.translate(.5, .5, .5);
RenderHelper.disableStandardItemLighting();
GlStateManager.blendFunc(770, 771);
GlStateManager.enableBlend();
GlStateManager.disableCull();
if (Minecraft.isAmbientOcclusionEnabled())
GlStateManager.shadeModel(7425);
else
GlStateManager.shadeModel(7424);
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
worldRenderer.setTranslation(-.5 - blockPos.getX(), -.5 - blockPos.getY(), -.5 - blockPos.getZ());
worldRenderer.color(255, 255, 255, 255);
blockRenderer.getBlockModelRenderer().renderModel(te.getWorld(), model, state, blockPos, worldRenderer, true);
worldRenderer.setTranslation(0.0D, 0.0D, 0.0D);
tessellator.draw();
RenderHelper.enableStandardItemLighting();
GlStateManager.popMatrix();
}
use of net.minecraft.client.renderer.block.model.IBakedModel in project ImmersiveEngineering by BluSunrize.
the class TileRenderMetalPress method renderTileEntityAt.
@Override
public void renderTileEntityAt(TileEntityMetalPress te, double x, double y, double z, float partialTicks, int destroyStage) {
if (!te.formed || te.isDummy() || !te.getWorld().isBlockLoaded(te.getPos(), false))
return;
final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
BlockPos blockPos = te.getPos();
IBlockState state = getWorld().getBlockState(blockPos);
if (state.getBlock() != IEContent.blockMetalMultiblock)
return;
state = state.getBlock().getActualState(state, getWorld(), blockPos);
state = state.withProperty(IEProperties.DYNAMICRENDER, true);
IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(state);
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer worldRenderer = tessellator.getBuffer();
ClientUtils.bindAtlas();
GlStateManager.pushMatrix();
GlStateManager.translate(x + .5, y + .5, z + .5);
float piston = 0;
float[] shift = new float[te.processQueue.size()];
for (int i = 0; i < shift.length; i++) {
MultiblockProcess process = te.processQueue.get(i);
if (process == null)
continue;
float transportTime = 52.5f / (float) process.maxTicks;
float pressTime = 3.75f / (float) process.maxTicks;
float fProcess = (process.processTick + (te.shouldRenderAsActive() ? partialTicks : 0)) / (float) process.maxTicks;
if (fProcess < transportTime)
shift[i] = fProcess / transportTime * .5f;
else if (fProcess < (1 - transportTime))
shift[i] = .5f;
else
shift[i] = .5f + (fProcess - (1 - transportTime)) / transportTime * .5f;
if (te.mold != null)
if (fProcess >= transportTime && fProcess < (1 - transportTime)) {
if (fProcess < (transportTime + pressTime))
piston = (fProcess - transportTime) / pressTime;
else if (fProcess < (1 - transportTime - pressTime))
piston = 1;
else
piston = 1 - (fProcess - (1 - transportTime - pressTime)) / pressTime;
}
}
GlStateManager.translate(0, -piston * .6875f, 0);
RenderHelper.disableStandardItemLighting();
GlStateManager.blendFunc(770, 771);
GlStateManager.enableBlend();
GlStateManager.disableCull();
if (Minecraft.isAmbientOcclusionEnabled())
GlStateManager.shadeModel(7425);
else
GlStateManager.shadeModel(7424);
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
worldRenderer.setTranslation(-.5 - blockPos.getX(), -.5 - blockPos.getY(), -.5 - blockPos.getZ());
worldRenderer.color(255, 255, 255, 255);
blockRenderer.getBlockModelRenderer().renderModel(te.getWorld(), model, state, blockPos, worldRenderer, true);
worldRenderer.setTranslation(0.0D, 0.0D, 0.0D);
tessellator.draw();
RenderHelper.enableStandardItemLighting();
GlStateManager.rotate(te.facing == EnumFacing.SOUTH ? 180 : te.facing == EnumFacing.WEST ? 90 : te.facing == EnumFacing.EAST ? -90 : 0, 0, 1, 0);
if (te.mold != null) {
GlStateManager.pushMatrix();
GlStateManager.translate(0, .34, 0);
GlStateManager.rotate(-90, 1, 0, 0);
float scale = .75f;
GlStateManager.scale(scale, scale, 1);
ClientUtils.mc().getRenderItem().renderItem(te.mold, ItemCameraTransforms.TransformType.FIXED);
GlStateManager.scale(1 / scale, 1 / scale, 1);
GlStateManager.popMatrix();
}
GlStateManager.translate(0, piston * .6875f, 0);
GlStateManager.translate(0, -.35, 1.25);
for (int i = 0; i < shift.length; i++) {
MultiblockProcess process = te.processQueue.get(i);
if (process == null || !(process instanceof MultiblockProcessInWorld))
continue;
GlStateManager.pushMatrix();
GlStateManager.translate(0, 0, -2.5 * shift[i]);
List<ItemStack> displays = ((MultiblockProcessInWorld) process).getDisplayItem();
if (!displays.isEmpty()) {
GlStateManager.rotate(-90, 1, 0, 0);
float scale = .625f;
GlStateManager.scale(scale, scale, 1);
ClientUtils.mc().getRenderItem().renderItem(displays.get(0), ItemCameraTransforms.TransformType.FIXED);
GlStateManager.popMatrix();
}
}
GlStateManager.popMatrix();
}
use of net.minecraft.client.renderer.block.model.IBakedModel in project ImmersiveEngineering by BluSunrize.
the class TileRenderMixer method renderTileEntityAt.
@Override
public void renderTileEntityAt(TileEntityMixer te, double x, double y, double z, float partialTicks, int destroyStage) {
if (!te.formed || te.isDummy() || !te.getWorld().isBlockLoaded(te.getPos(), false))
return;
final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
BlockPos blockPos = te.getPos();
IBlockState state = getWorld().getBlockState(blockPos);
if (state.getBlock() != IEContent.blockMetalMultiblock)
return;
state = state.getBlock().getActualState(state, getWorld(), blockPos);
state = state.withProperty(IEProperties.DYNAMICRENDER, true);
IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(state);
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer worldRenderer = tessellator.getBuffer();
ClientUtils.bindAtlas();
GlStateManager.pushMatrix();
GlStateManager.translate(x + .5, y + .5, z + .5);
if (te.mirrored)
GlStateManager.scale(te.facing.getFrontOffsetX() == 0 ? -1 : 1, 1, te.facing.getFrontOffsetZ() == 0 ? -1 : 1);
GlStateManager.pushMatrix();
GlStateManager.translate(te.facing == EnumFacing.SOUTH || te.facing == EnumFacing.WEST ? -.5 : .5, 0, te.facing == EnumFacing.SOUTH || te.facing == EnumFacing.EAST ? .5 : -.5);
float agitator = te.animation_agitator - (!te.shouldRenderAsActive() ? 0 : (1 - partialTicks) * 9f);
GlStateManager.rotate(agitator, 0, 1, 0);
RenderHelper.disableStandardItemLighting();
GlStateManager.blendFunc(770, 771);
GlStateManager.enableBlend();
GlStateManager.disableCull();
if (Minecraft.isAmbientOcclusionEnabled())
GlStateManager.shadeModel(7425);
else
GlStateManager.shadeModel(7424);
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
worldRenderer.setTranslation(-.5 - blockPos.getX(), -.5 - blockPos.getY(), -.5 - blockPos.getZ());
worldRenderer.color(255, 255, 255, 255);
blockRenderer.getBlockModelRenderer().renderModel(te.getWorld(), model, state, blockPos, worldRenderer, true);
worldRenderer.setTranslation(0.0D, 0.0D, 0.0D);
tessellator.draw();
RenderHelper.enableStandardItemLighting();
GlStateManager.popMatrix();
switch(te.facing) {
case NORTH:
break;
case SOUTH:
GlStateManager.rotate(180, 0, 1, 0);
break;
case WEST:
GlStateManager.rotate(90, 0, 1, 0);
break;
case EAST:
GlStateManager.rotate(-90, 0, 1, 0);
break;
}
GlStateManager.scale(.0625f, 1, .0625f);
GlStateManager.rotate(90, 1, 0, 0);
GlStateManager.translate(8, -8, .625f);
RenderHelper.disableStandardItemLighting();
for (int i = te.tank.getFluidTypes() - 1; i >= 0; i--) {
FluidStack fs = te.tank.fluids.get(i);
if (fs != null && fs.getFluid() != null) {
int col = fs.getFluid().getColor(fs);
GlStateManager.color((col >> 16 & 255) / 255.0f, (col >> 8 & 255) / 255.0f, (col & 255) / 255.0f, 1);
float yy = fs.amount / (float) te.tank.getCapacity() * 1.125f;
GlStateManager.translate(0, 0, -yy);
float w = (i < te.tank.getFluidTypes() - 1 || yy >= .125) ? 26 : 16 + yy / .0125f;
ClientUtils.drawRepeatedFluidSprite(fs, -w / 2, -w / 2, w, w);
}
}
GlStateManager.popMatrix();
}
Aggregations