net.minecraft.client.renderer.IRenderTypeBuffer Java Examples
The following examples show how to use
net.minecraft.client.renderer.IRenderTypeBuffer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RenderUtils.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 6 votes |
public static void renderFluidCuboid(CCRenderState ccrs, Matrix4 mat, RenderType renderType, IRenderTypeBuffer getter, FluidStack stack, Cuboid6 bound, double capacity, double res) { if (stack.isEmpty()) { return; } int alpha = 255; FluidAttributes attributes = stack.getFluid().getAttributes(); if (attributes.isGaseous(stack)) { alpha = (int) (Math.pow(capacity, 0.4) * 255); } else { bound.max.y = bound.min.y + (bound.max.y - bound.min.y) * capacity; } Material material = ForgeHooksClient.getBlockMaterial(attributes.getStillTexture(stack)); ccrs.bind(renderType, getter); ccrs.baseColour = attributes.getColor(stack) << 8 | alpha; makeFluidModel(bound, material.getSprite(), res).render(ccrs, mat); }
Example #2
Source File: RenderTileEnderTank.java From EnderStorage with MIT License | 6 votes |
public static void renderTank(CCRenderState ccrs, Matrix4 mat, IRenderTypeBuffer getter, int rotation, float valveRot, double yToCamera, Frequency freq, int pearlOffset) { renderEndPortal.render(mat, getter, yToCamera); ccrs.reset(); mat.translate(0.5, 0, 0.5); mat.rotate((-90 * (rotation + 2)) * MathHelper.torad, Vector3.Y_POS); ccrs.bind(baseType, getter); tankModel.render(ccrs, mat); Matrix4 valveMat = mat.copy().apply(new Rotation(valveRot, Vector3.Z_POS).at(new Vector3(0, 0.4165, 0))); valveModel.render(ccrs, valveMat, new UVTranslation(0, freq.hasOwner() ? 13 / 64D : 0)); ccrs.bind(buttonType, getter); EnumColour[] colours = freq.toArray(); for (int i = 0; i < 3; i++) { //noinspection IntegerDivisionInFloatingPointContext buttons[i].render(ccrs, mat, new UVTranslation(0.25 * (colours[i].getWoolMeta() % 4), 0.25 * (colours[i].getWoolMeta() / 4))); } double time = ClientUtils.getRenderTime() + pearlOffset; Matrix4 pearlMat = RenderUtils.getMatrix(mat.copy(), new Vector3(0, 0.45 + RenderUtils.getPearlBob(time) * 2, 0), new Rotation(time / 3, Vector3.Y_POS), 0.04); ccrs.brightness = 15728880; ccrs.bind(pearlType, getter); CCModelLibrary.icosahedron4.render(ccrs, pearlMat); ccrs.reset(); }
Example #3
Source File: RenderCustomEndPortal.java From EnderStorage with MIT License | 6 votes |
public void render(Matrix4 mat, IRenderTypeBuffer getter, double yToCamera) { Vec3d projectedView = TileEntityRendererDispatcher.instance.renderInfo.getProjectedView(); mat = mat.copy();//Defensive copy, prevent external modifications. randy.setSeed(31100L); for (int i = 0; i < 16; i++) { RenderType.State state = RENDER_STATES.get(i); EndPortalRenderType renderType = new EndPortalRenderType(i, yToCamera, projectedView, mat, state); IVertexBuilder builder = getter.getBuffer(renderType); float r = (randy.nextFloat() * 0.5F + 0.1F) * renderType.f7; float g = (randy.nextFloat() * 0.5F + 0.4F) * renderType.f7; float b = (randy.nextFloat() * 0.5F + 0.5F) * renderType.f7; if (i == 0) { r = g = b = 1.0F * renderType.f7; } builder.pos(surfaceX1, surfaceY, surfaceZ1).color(r, g, b, 1.0F).endVertex(); builder.pos(surfaceX1, surfaceY, surfaceZ2).color(r, g, b, 1.0F).endVertex(); builder.pos(surfaceX2, surfaceY, surfaceZ2).color(r, g, b, 1.0F).endVertex(); builder.pos(surfaceX2, surfaceY, surfaceZ1).color(r, g, b, 1.0F).endVertex(); } }
Example #4
Source File: TankLayerRenderer.java From EnderStorage with MIT License | 5 votes |
@Override public void render(MatrixStack mStack, IRenderTypeBuffer getter, int packedLight, AbstractClientPlayerEntity entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) { if (UUIDS.contains(entity.getUniqueID())) { CCRenderState ccrs = CCRenderState.instance(); ccrs.brightness = packedLight; ccrs.overlay = OverlayTexture.NO_OVERLAY; Matrix4 mat = new Matrix4(mStack); mat.rotate(MathHelper.torad * 180, Vector3.X_POS); mat.scale(0.5); if (entity.isShiftKeyDown()) { mat.translate(0, -0.5, 0); } if (entity.isElytraFlying()) { headPitch = -45; } mat.rotate(netHeadYaw * MathHelper.torad, Vector3.Y_NEG); mat.rotate(headPitch * MathHelper.torad, Vector3.X_POS); mat.translate(-0.5, 1, -0.5); RenderTileEnderTank.renderTank(ccrs, mat, getter, 0, (float) (MathHelper.torad * 90F), 0, BLANK, 0); FluidStack stack = FluidUtils.water.copy(); float bob = 0.45F + RenderUtils.getPearlBob(ClientUtils.getRenderTime()) * 2; stack.setAmount((int) MathHelper.map(bob, 0.2, 0.6, 1000, 14000)); mat.translate(-0.5, 0, -0.5); RenderTileEnderTank.renderFluid(ccrs, mat, getter, stack); } }
Example #5
Source File: ChoppingBlockRenderer.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void render(ChoppingBlockTileEntity te, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int p_225616_5_, int p_225616_6_) { BlockState state = te.getWorld().getBlockState(te.getPos()); if (!(state.getBlock() instanceof ChoppingBlock)) return; //if (destroyStage < 0) { matrixStack.push(); ItemRenderer itemRenderer = mc.getItemRenderer(); LazyOptional<IItemHandler> linv = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY); linv.ifPresent((inv) -> { ItemStack stack = inv.getStackInSlot(0); if (stack.getCount() > 0) { matrixStack.push(); matrixStack.translate(0.5, 0.5, 0.5); matrixStack.translate(0, -4.5 / 16.0f, 0); matrixStack.scale(2, 2, 2); IBakedModel ibakedmodel = itemRenderer.getItemModelWithOverrides(stack, te.getWorld(), (LivingEntity) null); itemRenderer.renderItem(stack, ItemCameraTransforms.TransformType.GROUND, true, matrixStack, buffer, p_225616_5_, p_225616_6_, ibakedmodel); /*int breakStage = te.getBreakStage(); if (breakStage >= 0) { renderItem(stack, ItemCameraTransforms.TransformType.GROUND, breakStage); }*/ matrixStack.pop(); } }); matrixStack.pop(); } }
Example #6
Source File: CCBlockRendererDispatcher.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void renderBlock(BlockState blockStateIn, MatrixStack matrixStackIn, IRenderTypeBuffer bufferTypeIn, int combinedLightIn, int combinedOverlayIn, IModelData modelData) { Optional<ICCBlockRenderer> renderOpt = BlockRenderingRegistry.getBlockRenderers().stream().filter(e -> e.canHandleEntity(blockStateIn)).findFirst(); if (renderOpt.isPresent()) { renderOpt.get().renderEntity(blockStateIn, matrixStackIn, bufferTypeIn, combinedLightIn, combinedOverlayIn, modelData); } else { parentDispatcher.renderBlock(blockStateIn, matrixStackIn, bufferTypeIn, combinedLightIn, combinedOverlayIn, modelData); } }
Example #7
Source File: CCRenderItem.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void renderItem(ItemStack stack, ItemCameraTransforms.TransformType transformType, boolean leftHand, MatrixStack mStack, IRenderTypeBuffer getter, int packedLight, int packedOverlay, IBakedModel modelIn) { if (modelIn instanceof IItemRenderer) { mStack.push(); IBakedModel handled = ForgeHooksClient.handleCameraTransforms(mStack, modelIn, transformType, leftHand); mStack.translate(-0.5D, -0.5D, -0.5D); //If anyone doesnt return an IItemRenderer from here, your doing it wrong. ((IItemRenderer) handled).renderItem(stack, transformType, mStack, getter, packedLight, packedOverlay); mStack.pop(); } super.renderItem(stack, transformType, leftHand, mStack, getter, packedLight, packedOverlay, modelIn); }
Example #8
Source File: EnderChestItemRender.java From EnderStorage with MIT License | 5 votes |
@Override public void renderItem(ItemStack stack, TransformType transformType, MatrixStack mStack, IRenderTypeBuffer getter, int packedLight, int packedOverlay) { CCRenderState ccrs = CCRenderState.instance(); ccrs.reset(); Frequency freq = Frequency.readFromStack(stack); ccrs.brightness = packedLight; ccrs.overlay = packedOverlay; RenderTileEnderChest.renderChest(ccrs, mStack, getter, 2, 0, freq, 0, 0); }
Example #9
Source File: EnderTankItemRender.java From EnderStorage with MIT License | 5 votes |
@Override public void renderItem(ItemStack stack, TransformType transformType, MatrixStack mStack, IRenderTypeBuffer getter, int packedLight, int packedOverlay) { CCRenderState ccrs = CCRenderState.instance(); ccrs.reset(); ccrs.brightness = packedLight; ccrs.overlay = packedOverlay; Frequency freq = Frequency.readFromStack(stack); FluidStack fluid = TankSynchroniser.getClientLiquid(freq); Matrix4 mat = new Matrix4(mStack); RenderTileEnderTank.renderTank(ccrs, mat, getter, 2, (float) (MathHelper.torad * 90F), 0, freq, 0); mat.translate(-0.5, 0, -0.5); RenderTileEnderTank.renderFluid(ccrs, mat, getter, fluid); }
Example #10
Source File: RenderTileEnderTank.java From EnderStorage with MIT License | 5 votes |
@Override public void render(TileEnderTank enderTank, float partialTicks, MatrixStack mStack, IRenderTypeBuffer getter, int packedLight, int packedOverlay) { CCRenderState ccrs = CCRenderState.instance(); ccrs.brightness = packedLight; ccrs.overlay = packedOverlay; float valveRot = (float) MathHelper.interpolate(enderTank.pressure_state.b_rotate, enderTank.pressure_state.a_rotate, partialTicks) * 0.01745F; int pearlOffset = RenderUtils.getTimeOffset(enderTank.getPos()); Matrix4 mat = new Matrix4(mStack); double yToCamera = enderTank.getPos().getY() - renderDispatcher.renderInfo.getProjectedView().y; renderTank(ccrs, mat.copy(), getter, enderTank.rotation, valveRot, yToCamera, enderTank.getFrequency(), pearlOffset); renderFluid(ccrs, mat, getter, enderTank.liquid_state.c_liquid); ccrs.reset(); }
Example #11
Source File: RenderTileEnderChest.java From EnderStorage with MIT License | 5 votes |
public static void renderChest(CCRenderState ccrs, MatrixStack mStack, IRenderTypeBuffer getter, int rotation, double yToCamera, Frequency freq, float lidAngle, int pearlOffset) { Matrix4 mat = new Matrix4(mStack); if (lidAngle != 0) {//Micro optimization, lid closed, dont render starfield. renderEndPortal.render(mat, getter, yToCamera); } ccrs.reset(); mStack.push(); mStack.translate(0, 1.0, 1.0); mStack.scale(1.0F, -1.0F, -1.0F); mStack.translate(0.5, 0.5, 0.5); mStack.rotate(new Quaternion(0, rotation * 90, 0, true)); mStack.translate(-0.5, -0.5, -0.5); model.chestLid.rotateAngleX = lidAngle; model.render(mStack, getter.getBuffer(chestType), ccrs.brightness, ccrs.overlay, freq.hasOwner()); mStack.pop(); //Buttons ccrs.bind(buttonType, getter); EnumColour[] colours = freq.toArray(); for (int i = 0; i < 3; i++) { CCModel button = ButtonModelLibrary.button.copy(); button.apply(BlockEnderChest.buttonT[i]); button.apply(new Translation(0.5, 0, 0.5)); button.apply(new Rotation(lidAngle, 1, 0, 0).at(new Vector3(0, 9D / 16D, 1 / 16D))); button.apply(new Rotation((-90 * (rotation)) * MathHelper.torad, Vector3.Y_POS).at(new Vector3(0.5, 0, 0.5))); button.render(ccrs, mat, new UVTranslation(0.25 * (colours[i].getWoolMeta() % 4), 0.25 * (colours[i].getWoolMeta() / 4))); } mat.translate(0.5, 0, 0.5); //Pearl if (lidAngle != 0) {//Micro optimization, lid closed, dont render pearl. double time = ClientUtils.getRenderTime() + pearlOffset; Matrix4 pearlMat = RenderUtils.getMatrix(mat.copy(), new Vector3(0, 0.2 + lidAngle * -0.5 + RenderUtils.getPearlBob(time), 0), new Rotation(time / 3, new Vector3(0, 1, 0)), 0.04); ccrs.brightness = 15728880; ccrs.bind(pearlType, getter); CCModelLibrary.icosahedron4.render(ccrs, pearlMat); } ccrs.reset(); }
Example #12
Source File: RenderTileEnderChest.java From EnderStorage with MIT License | 5 votes |
@Override public void render(TileEnderChest enderChest, float partialTicks, MatrixStack mStack, IRenderTypeBuffer getter, int packedLight, int packedOverlay) { CCRenderState ccrs = CCRenderState.instance(); ccrs.brightness = packedLight; ccrs.overlay = packedOverlay; double yToCamera = enderChest.getPos().getY() - renderDispatcher.renderInfo.getProjectedView().y; renderChest(ccrs, mStack, getter, enderChest.rotation, yToCamera, enderChest.getFrequency(), (float) enderChest.getRadianLidAngle(partialTicks), RenderUtils.getTimeOffset(enderChest.getPos())); }
Example #13
Source File: BlockOverlayRender.java From MiningGadgets with MIT License | 5 votes |
public static void render(RenderWorldLastEvent event, ItemStack item) { final Minecraft mc = Minecraft.getInstance(); IRenderTypeBuffer.Impl buffer = Minecraft.getInstance().getRenderTypeBuffers().getBufferSource(); int range = MiningProperties.getBeamRange(item); BlockRayTraceResult lookingAt = VectorHelper.getLookingAt(mc.player, RayTraceContext.FluidMode.NONE, range); if (mc.world.getBlockState(VectorHelper.getLookingAt(mc.player, item, range).getPos()) == Blocks.AIR.getDefaultState()) { return; } List<BlockPos> coords = MiningCollect.collect(mc.player, lookingAt, mc.world, MiningProperties.getRange(item)); Vec3d view = mc.gameRenderer.getActiveRenderInfo().getProjectedView(); MatrixStack matrix = event.getMatrixStack(); matrix.push(); matrix.translate(-view.getX(), -view.getY(), -view.getZ()); IVertexBuilder builder; builder = buffer.getBuffer(MyRenderType.BlockOverlay); coords.forEach(e -> { if (mc.world.getBlockState(e).getBlock() != ModBlocks.RENDER_BLOCK.get()) { matrix.push(); matrix.translate(e.getX(), e.getY(), e.getZ()); matrix.translate(-0.005f, -0.005f, -0.005f); matrix.scale(1.01f, 1.01f, 1.01f); matrix.rotate(Vector3f.YP.rotationDegrees(-90.0F)); Matrix4f positionMatrix = matrix.getLast().getMatrix(); BlockOverlayRender.render(positionMatrix, builder, e, Color.GREEN); matrix.pop(); } }); matrix.pop(); RenderSystem.disableDepthTest(); buffer.finish(MyRenderType.BlockOverlay); }
Example #14
Source File: RenderTileEnderTank.java From EnderStorage with MIT License | 4 votes |
public static void renderFluid(CCRenderState ccrs, Matrix4 mat, IRenderTypeBuffer getter, FluidStack stack) { RenderUtils.renderFluidCuboid(ccrs, mat, RenderUtils.getFluidRenderType(), getter, stack, new Cuboid6(0.22, 0.12, 0.22, 0.78, 0.121 + 0.63, 0.78), stack.getAmount() / (16D * FluidUtils.B), 0.75); }
Example #15
Source File: RenderUtils.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 4 votes |
public static void bufferHitbox(Matrix4 mat, IRenderTypeBuffer getter, ActiveRenderInfo renderInfo, Cuboid6 cuboid) { Vec3d projectedView = renderInfo.getProjectedView(); bufferHitBox(mat.copy().translate(-projectedView.x, -projectedView.y, -projectedView.z), getter, cuboid); }
Example #16
Source File: RenderUtils.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 4 votes |
public static void bufferHitBox(Matrix4 mat, IRenderTypeBuffer getter, Cuboid6 cuboid) { IVertexBuilder builder = new TransformingVertexBuilder(getter.getBuffer(RenderType.getLines()), mat); bufferCuboidOutline(builder, cuboid.copy().expand(0.0020000000949949026D), 0.0F, 0.0F, 0.0F, 0.4F); }
Example #17
Source File: DryingRackRenderer.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void render(DryingRackTileEntity te, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int combinedLightIn, int combinedOverlayIn) { BlockState state = te.getWorld().getBlockState(te.getPos()); if (state.getBlock() != SurvivalistBlocks.RACK.get()) return; te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent((inv) -> { matrixStack.push(); // pushMatrix float angle = -state.get(DryingRackBlock.FACING).getHorizontalAngle(); matrixStack.translate(0.5, 0.5, 0.5); // translate matrixStack.rotate(Vector3f.YP.rotationDegrees(angle)); // rotate matrixStack.translate(-0.5, -0.5, -0.5); // translate //matrixStack.func_227863_a_(Vector3f.field_229183_f_.func_229187_a_(180)); Minecraft mc = Minecraft.getInstance(); ItemRenderer itemRenderer = mc.getItemRenderer(); for (int i = 0; i < 4; i++) { ItemStack stack = inv.getStackInSlot(i); if (stack.getCount() > 0) { matrixStack.push(); // pushMatrix float zz = (i - 1.5f) * 0.1875f; matrixStack.translate(0, 0, zz); // translate matrixStack.scale(0.7f, 0.7f, 0.7f); // scale matrixStack.translate(0.715, 0.93, 0.635); // translate matrixStack.rotate(Vector3f.YP.rotationDegrees(180)); // rotate IBakedModel ibakedmodel = itemRenderer.getItemModelWithOverrides(stack, te.getWorld(), (LivingEntity) null); itemRenderer.renderItem(stack, ItemCameraTransforms.TransformType.FIXED, true, matrixStack, buffer, combinedLightIn, combinedOverlayIn, ibakedmodel); // renderItem matrixStack.pop(); // popMatrix } } matrixStack.pop(); // popMatrix }); }
Example #18
Source File: IItemRenderer.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 2 votes |
/** * Called to render your item with complete control. Bypasses all vanilla rendering of your model. * * @param stack The {@link ItemStack} being rendered. * @param transformType The {@link TransformType} of where we are rendering. * @param mStack The {@link MatrixStack} to get / add transformations to. * @param getter The {@link IRenderTypeBuffer} to retrieve buffers from. * @param packedLight The {@link LightTexture} packed coords. * @param packedOverlay The {@link OverlayTexture} packed coords. */ void renderItem(ItemStack stack, TransformType transformType, MatrixStack mStack, IRenderTypeBuffer getter, int packedLight, int packedOverlay);
Example #19
Source File: ICCBlockRenderer.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 2 votes |
/** * Called for misc entities holding or have blocks as part of their model. * IronGolems, Enderman, Mooshroom, Minecarts, TNT. * * @param state The BlockState to render. * @param nStack The {@link MatrixStack}. * @param builder The {@link IVertexBuilder} * @param packedLight The {@link LightTexture} packed coords. * @param packedOverlay The {@link OverlayTexture} packed coords. * @param data Any ModelData. */ default void renderEntity(BlockState state, MatrixStack nStack, IRenderTypeBuffer builder, int packedLight, int packedOverlay, IModelData data) { }