use of net.minecraft.client.renderer.block.model.IBakedModel in project HorsePower by GoryMoon.
the class TileEntityHPBaseRenderer method renderBlockDamage.
public void renderBlockDamage(IBlockState state, BlockPos pos, TextureAtlasSprite texture, IBlockAccess blockAccess) {
state = state.getActualState(blockAccess, pos);
IBakedModel ibakedmodel = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(state);
IBakedModel ibakedmodel1 = net.minecraftforge.client.ForgeHooksClient.getDamageModel(ibakedmodel, texture, state, blockAccess, pos);
Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModel(blockAccess, ibakedmodel1, state, pos, Tessellator.getInstance().getBuffer(), true);
}
use of net.minecraft.client.renderer.block.model.IBakedModel in project HorsePower by GoryMoon.
the class TileEntityHandGrindstoneRender method render.
@Override
public void render(TileEntityHandGrindstone te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
BlockRendererDispatcher dispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
IBlockState blockState = te.getWorld().getBlockState(te.getPos());
if (!(blockState.getBlock() instanceof BlockHPBase))
return;
IBlockState centerState = blockState.withProperty(BlockHandGrindstone.PART, HandGrindstoneModels.CENTER);
if (!(centerState.getBlock() instanceof BlockHPBase))
return;
IBakedModel centerModel = dispatcher.getBlockModelShapes().getModelForState(centerState);
preDestroyRender(destroyStage);
setRenderSettings();
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
// The translation ensures the vertex buffer positions are relative to 0,0,0 instead of the block pos
// This makes the translations that follow much easier
buffer.setTranslation(-te.getPos().getX(), -te.getPos().getY(), -te.getPos().getZ());
if (destroyStage >= 0) {
buffer.noColor();
renderBlockDamage(centerState, te.getPos(), getDestroyBlockIcon(destroyStage), te.getWorld());
} else
dispatcher.getBlockModelRenderer().renderModel(te.getWorld(), centerModel, centerState, te.getPos(), buffer, false);
buffer.setTranslation(0, 0, 0);
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
// Apply GL transformations relative to the center of the block: 1) TE rotation and 2) crank rotation
GlStateManager.translate(0.5, 0.5, 0.5);
FacingToRotation.get(te.getForward()).glRotateCurrentMat();
float rotation = te.getVisibleRotation();
GlStateManager.rotate(rotation, 0, 1, 0);
GlStateManager.translate(-0.5, -0.5, -0.5);
tessellator.draw();
GlStateManager.popMatrix();
buffer.setTranslation(0.0D, 0.0D, 0.0D);
postDestroyRender(destroyStage);
RenderHelper.enableStandardItemLighting();
renderItemWithFacing(te.getWorld(), te, te.getStackInSlot(0), x, y, z, 0.8F, 0.7F, 0.5F, 0.7F);
renderItemWithFacing(te.getWorld(), te, te.getStackInSlot(1), x, y, z, 0.2F, 0.7F, 0.5F, 0.7F);
renderItemWithFacing(te.getWorld(), te, te.getStackInSlot(2), x, y, z, 0.5F, 0.7F, 0.2F, 0.7F);
super.render(te, x, y, z, partialTicks, destroyStage, alpha);
}
use of net.minecraft.client.renderer.block.model.IBakedModel in project HorsePower by GoryMoon.
the class TileEntityPressRender method render.
@Override
public void render(TileEntityPress te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
BlockRendererDispatcher dispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
IBlockState blockState = te.getWorld().getBlockState(te.getPos());
if (!(blockState.getBlock() instanceof BlockHPBase))
return;
IBlockState topState = blockState.withProperty(BlockPress.PART, PressModels.TOP);
if (!(topState.getBlock() instanceof BlockHPBase))
return;
IBakedModel pressModel = dispatcher.getBlockModelShapes().getModelForState(topState);
preDestroyRender(destroyStage);
setRenderSettings();
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
// The translation ensures the vertex buffer positions are relative to 0,0,0 instead of the block pos
// This makes the translations that follow much easier
buffer.setTranslation(-te.getPos().getX(), -te.getPos().getY(), -te.getPos().getZ());
if (destroyStage >= 0) {
buffer.noColor();
renderBlockDamage(topState, te.getPos(), getDestroyBlockIcon(destroyStage), te.getWorld());
} else
dispatcher.getBlockModelRenderer().renderModel(te.getWorld(), pressModel, blockState, te.getPos(), buffer, false);
buffer.setTranslation(0, 0, 0);
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
// Apply GL transformations relative to the center of the block: 1) TE rotation and 2) crank rotation
float move = (te.getField(0) / (float) (Configs.general.pointsForPress > 0 ? Configs.general.pointsForPress : 1));
GlStateManager.translate(0.5, 0.5, 0.5);
GlStateManager.translate(0, -(0.58 * move), 0);
GlStateManager.translate(-0.5, -0.5, -0.5);
tessellator.draw();
GlStateManager.popMatrix();
buffer.setTranslation(0.0D, 0.0D, 0.0D);
postDestroyRender(destroyStage);
RenderHelper.enableStandardItemLighting();
if (!(blockState.getBlock() instanceof BlockHPBase))
return;
if (te.hasWorker())
renderLeash(te.getWorker(), x, y, z, 0D, 0.4D, 0D, partialTicks, te.getPos());
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
if (!te.getStackInSlot(0).isEmpty() && move <= 0.25) {
renderItem(te, te.getStackInSlot(0), 0.5F, 0.5F, 0.5F, 1F);
drawString(te, String.valueOf(te.getStackInSlot(0).getCount()), 0, 0.35, 0);
}
if (!te.getStackInSlot(1).isEmpty() && move <= 0.25) {
renderItem(te, te.getStackInSlot(1), 0.5F, 0.5F, 0.5F, 1F);
drawString(te, String.valueOf(te.getStackInSlot(1).getCount()), 0, 0.35, 0);
}
GlStateManager.popMatrix();
super.render(te, x, y + 1, z, partialTicks, destroyStage, alpha);
}
use of net.minecraft.client.renderer.block.model.IBakedModel in project HorsePower by GoryMoon.
the class ModModelManager method replaceChoppingModel.
public static void replaceChoppingModel(ModelResourceLocation modelVariantLocation, ResourceLocation modelLocation, ModelBakeEvent event) {
try {
IModel model = ModelLoaderRegistry.getModel(modelLocation);
IBakedModel standard = event.getModelRegistry().getObject(modelVariantLocation);
if (standard != null) {
IBakedModel finalModel = new BakedChopperModel(standard, model, DefaultVertexFormats.BLOCK);
event.getModelRegistry().putObject(modelVariantLocation, finalModel);
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of net.minecraft.client.renderer.block.model.IBakedModel in project EnderIO by SleepyTrousers.
the class EnchanterModelRenderer method renderBase.
private void renderBase() {
BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
BlockModelShapes modelShapes = blockrendererdispatcher.getBlockModelShapes();
IBakedModel bakedModel = modelShapes.getModelForState(MachineObject.block_enchanter.getBlockNN().getDefaultState().withProperty(EnumRenderMode.RENDER, EnumRenderMode.FRONT));
RenderUtil.bindBlockTexture();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.enableRescaleNormal();
GlStateManager.pushMatrix();
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder vertexbuffer = tessellator.getBuffer();
vertexbuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
for (EnumFacing enumfacing : EnumFacing.values()) {
this.renderQuads(vertexbuffer, bakedModel.getQuads((IBlockState) null, enumfacing, 0L));
}
this.renderQuads(vertexbuffer, bakedModel.getQuads((IBlockState) null, (EnumFacing) null, 0L));
tessellator.draw();
GlStateManager.popMatrix();
GlStateManager.disableRescaleNormal();
}
Aggregations