use of net.minecraft.client.renderer.BlockRendererDispatcher in project SpringFestival by TeamCovertDragon.
the class TESRFuDoor method renderTileEntityFast.
@Override
public void renderTileEntityFast(@Nullable TileFuDoor te, double x, double y, double z, float partialTicks, int destroyStage, float partial, BufferBuilder buffer) {
if (te == null) {
return;
}
{
IBlockState upper = te.getOriginalBlockStateUpper();
IBlockState lower = te.getOriginalBlockStateLower();
if (upper == null || lower == null) {
return;
}
BlockRendererDispatcher dispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
IBakedModel modelUpper = dispatcher.getModelForState(upper);
IBakedModel modelLower = dispatcher.getModelForState(lower);
int brightness = upper.getPackedLightmapCoords(te.getWorld(), te.getPos());
for (EnumFacing facing : EnumFacing.values()) {
List<BakedQuad> quadsUpper = modelUpper.getQuads(upper, facing, MathHelper.getPositionRandom(te.getPos()));
for (BakedQuad quad : quadsUpper) {
buffer.addVertexData(quad.getVertexData());
buffer.putBrightness4(brightness, brightness, brightness, brightness);
buffer.putPosition(x, y, z);
}
List<BakedQuad> quadsLower = modelLower.getQuads(lower, facing, MathHelper.getPositionRandom(te.getPos().down()));
for (BakedQuad quad : quadsLower) {
buffer.addVertexData(quad.getVertexData());
buffer.putBrightness4(brightness, brightness, brightness, brightness);
buffer.putPosition(x, y - 1, z);
}
}
}
EnumFacing doorFacing = te.getWorld().getBlockState(te.getPos()).getValue(BlockFuDoor.FACING);
TextureAtlasSprite sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(FU_TEXTURE_LOCATION);
int light = te.getWorld().getCombinedLight(te.getPos(), 0);
int l1 = light >> 16 & 65535, l2 = light & 65535;
// TODO Handle opening and left/right hinge
switch(doorFacing) {
case EAST:
{
buffer.pos(x + 0.0, y + 0.0, z + 0.0).color(255, 255, 255, 255).tex(sprite.getInterpolatedU(0), sprite.getInterpolatedV(0)).lightmap(l1, l2).endVertex();
buffer.pos(x + 0.0, y + 0.0, z + 1.0).color(255, 255, 255, 255).tex(sprite.getInterpolatedU(16), sprite.getInterpolatedV(0)).lightmap(l1, l2).endVertex();
buffer.pos(x + 0.0, y + 1.0, z + 1.0).color(255, 255, 255, 255).tex(sprite.getInterpolatedU(16), sprite.getInterpolatedV(16)).lightmap(l1, l2).endVertex();
buffer.pos(x + 0.0, y + 1.0, z + 0.0).color(255, 255, 255, 255).tex(sprite.getInterpolatedU(0), sprite.getInterpolatedV(16)).lightmap(l1, l2).endVertex();
break;
}
case WEST:
{
buffer.pos(x + 1.0, y + 0.0, z + 0.0).color(255, 255, 255, 255).tex(sprite.getInterpolatedU(0), sprite.getInterpolatedV(0)).lightmap(l1, l2).endVertex();
buffer.pos(x + 1.0, y + 0.0, z + 1.0).color(255, 255, 255, 255).tex(sprite.getInterpolatedU(16), sprite.getInterpolatedV(0)).lightmap(l1, l2).endVertex();
buffer.pos(x + 1.0, y + 1.0, z + 1.0).color(255, 255, 255, 255).tex(sprite.getInterpolatedU(16), sprite.getInterpolatedV(16)).lightmap(l1, l2).endVertex();
buffer.pos(x + 1.0, y + 1.0, z + 0.0).color(255, 255, 255, 255).tex(sprite.getInterpolatedU(0), sprite.getInterpolatedV(16)).lightmap(l1, l2).endVertex();
break;
}
case SOUTH:
{
buffer.pos(x + 0.0, y + 0.0, z + 0.0).color(255, 255, 255, 255).tex(sprite.getInterpolatedU(0), sprite.getInterpolatedV(0)).lightmap(l1, l2).endVertex();
buffer.pos(x + 1.0, y + 0.0, z + 0.0).color(255, 255, 255, 255).tex(sprite.getInterpolatedU(16), sprite.getInterpolatedV(0)).lightmap(l1, l2).endVertex();
buffer.pos(x + 1.0, y + 1.0, z + 0.0).color(255, 255, 255, 255).tex(sprite.getInterpolatedU(16), sprite.getInterpolatedV(16)).lightmap(l1, l2).endVertex();
buffer.pos(x + 0.0, y + 1.0, z + 0.0).color(255, 255, 255, 255).tex(sprite.getInterpolatedU(0), sprite.getInterpolatedV(16)).lightmap(l1, l2).endVertex();
break;
}
case NORTH:
{
buffer.pos(x + 0.0, y + 0.0, z + 1.0).color(255, 255, 255, 255).tex(sprite.getInterpolatedU(0), sprite.getInterpolatedV(0)).lightmap(l1, l2).endVertex();
buffer.pos(x + 1.0, y + 0.0, z + 1.0).color(255, 255, 255, 255).tex(sprite.getInterpolatedU(16), sprite.getInterpolatedV(0)).lightmap(l1, l2).endVertex();
buffer.pos(x + 1.0, y + 1.0, z + 1.0).color(255, 255, 255, 255).tex(sprite.getInterpolatedU(16), sprite.getInterpolatedV(16)).lightmap(l1, l2).endVertex();
buffer.pos(x + 0.0, y + 1.0, z + 1.0).color(255, 255, 255, 255).tex(sprite.getInterpolatedU(0), sprite.getInterpolatedV(16)).lightmap(l1, l2).endVertex();
break;
}
}
}
use of net.minecraft.client.renderer.BlockRendererDispatcher in project takumicraft by TNTModders.
the class LayerDarkCreeperHeldBlock method doRenderLayer.
@Override
public void doRenderLayer(EntityDarkCreeper entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
IBlockState iblockstate = entitylivingbaseIn.getHeldBlockState();
if (iblockstate != null) {
BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
GlStateManager.enableRescaleNormal();
GlStateManager.pushMatrix();
GlStateManager.translate(0.0F, 0.6875F, -0.75F);
GlStateManager.rotate(20.0F, 1.0F, 0.0F, 0.0F);
GlStateManager.rotate(45.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.translate(0.25F, 0.1875F, 0.25F);
float f = 0.5F;
GlStateManager.scale(-0.5F, -0.5F, 0.5F);
int i = entitylivingbaseIn.getBrightnessForRender();
int j = i % 65536;
int k = i / 65536;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, j, k);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.endermanRenderer.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
blockrendererdispatcher.renderBlockBrightness(iblockstate, 1.0F);
GlStateManager.popMatrix();
GlStateManager.disableRescaleNormal();
}
}
use of net.minecraft.client.renderer.BlockRendererDispatcher in project takumicraft by TNTModders.
the class RenderTakumiTNTPrimed method doRender.
@Override
public void doRender(T entity, double x, double y, double z, float entityYaw, float partialTicks) {
BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
GlStateManager.pushMatrix();
GlStateManager.translate((float) x, (float) y + 0.5F, (float) z);
if (entity.getFuse() - partialTicks + 1.0F < 10.0F) {
float f = 1.0F - (entity.getFuse() - partialTicks + 1.0F) / 10.0F;
f = MathHelper.clamp(f, 0.0F, 1.0F);
f = f * f;
f = f * f;
float f1 = 1.0F + f * 0.3F;
GlStateManager.scale(f1, f1, f1);
}
float f2 = (1.0F - (entity.getFuse() - partialTicks + 1.0F) / 100.0F) * 0.8F;
this.bindEntityTexture(entity);
GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.translate(-0.5F, -0.5F, 0.5F);
blockrendererdispatcher.renderBlockBrightness(TakumiBlockCore.TAKUMI_TNT.getDefaultState(), entity.getBrightness());
GlStateManager.translate(0.0F, 0.0F, 1.0F);
if (this.renderOutlines) {
GlStateManager.enableColorMaterial();
GlStateManager.enableOutlineMode(this.getTeamColor(entity));
blockrendererdispatcher.renderBlockBrightness(TakumiBlockCore.TAKUMI_TNT.getDefaultState(), 1.0F);
GlStateManager.disableOutlineMode();
GlStateManager.disableColorMaterial();
} else if (entity.getFuse() / 5 % 2 == 0) {
GlStateManager.disableTexture2D();
GlStateManager.disableLighting();
GlStateManager.enableBlend();
GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.DST_ALPHA);
GlStateManager.color(1.0F, 1.0F, 1.0F, f2);
GlStateManager.doPolygonOffset(-3.0F, -3.0F);
GlStateManager.enablePolygonOffset();
blockrendererdispatcher.renderBlockBrightness(TakumiBlockCore.TAKUMI_TNT.getDefaultState(), 1.0F);
GlStateManager.doPolygonOffset(0.0F, 0.0F);
GlStateManager.disablePolygonOffset();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.disableBlend();
GlStateManager.enableLighting();
GlStateManager.enableTexture2D();
}
GlStateManager.popMatrix();
super.doRender(entity, x, y, z, entityYaw, partialTicks);
}
use of net.minecraft.client.renderer.BlockRendererDispatcher in project Random-Things by lumien231.
the class RenderFallingBlockSpecial method doRender.
public void doRender(EntityFallingBlockSpecial entity, double x, double y, double z, float entityYaw, float partialTicks) {
if (entity.getBlock() != null) {
IBlockState iblockstate = entity.getBlock();
if (iblockstate.getRenderType() == EnumBlockRenderType.MODEL) {
World world = entity.getWorldObj();
if (iblockstate != world.getBlockState(new BlockPos(entity)) && iblockstate.getRenderType() != EnumBlockRenderType.INVISIBLE) {
this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
GlStateManager.pushMatrix();
GlStateManager.disableLighting();
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuffer();
if (this.renderOutlines) {
GlStateManager.enableColorMaterial();
GlStateManager.enableOutlineMode(this.getTeamColor(entity));
}
bufferbuilder.begin(7, DefaultVertexFormats.BLOCK);
BlockPos blockpos = new BlockPos(entity.posX, entity.getEntityBoundingBox().maxY, entity.posZ);
GlStateManager.translate((float) (x - (double) blockpos.getX() - 0.5D), (float) (y - (double) blockpos.getY()), (float) (z - (double) blockpos.getZ() - 0.5D));
BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
blockrendererdispatcher.getBlockModelRenderer().renderModel(world, blockrendererdispatcher.getModelForState(iblockstate), iblockstate, blockpos, bufferbuilder, false, MathHelper.getPositionRandom(entity.getOrigin()));
tessellator.draw();
if (this.renderOutlines) {
GlStateManager.disableOutlineMode();
GlStateManager.disableColorMaterial();
}
GlStateManager.enableLighting();
GlStateManager.popMatrix();
super.doRender(entity, x, y, z, entityYaw, partialTicks);
}
}
}
}
use of net.minecraft.client.renderer.BlockRendererDispatcher in project Bookshelf by Darkhax-Minecraft.
the class RenderUtils method renderBlock.
/**
* Renders a block state into the world.
*
* @param state The state to render.
* @param world The world context to render into.
* @param pos The position of the block.
* @param matrix The render matrix.
* @param buffer The render buffer.
* @param preferredSides The sides to render, allows faces to be culled.
*/
private static void renderBlock(BlockState state, World world, BlockPos pos, MatrixStack matrix, IRenderTypeBuffer buffer, Direction[] renderSides) {
final BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRenderer();
final IBakedModel model = dispatcher.getBlockModel(state);
final RenderType type = RenderUtils.findRenderType(state);
if (type != null) {
ForgeHooksClient.setRenderLayer(type);
final IVertexBuilder builder = buffer.getBuffer(type);
RenderUtils.renderModel(dispatcher.getModelRenderer(), world, model, state, pos, matrix, builder, renderSides);
ForgeHooksClient.setRenderLayer(null);
}
}
Aggregations