net.minecraft.client.renderer.BlockModelShapes Java Examples
The following examples show how to use
net.minecraft.client.renderer.BlockModelShapes.
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: CustomParticleHandler.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 6 votes |
@OnlyIn (Dist.CLIENT) public static boolean handleRunningEffects(World world, BlockPos pos, BlockState state, Entity entity) { //Spoof a raytrace from the feet. BlockRayTraceResult traceResult = new BlockRayTraceResult(entity.getPositionVec().add(0, 1, 0), Direction.UP, pos, false); BlockModelShapes modelShapes = Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelShapes(); IBakedModel model = modelShapes.getModel(state); if (model instanceof IModelParticleProvider) { IModelData modelData = ModelDataManager.getModelData(world, pos); ParticleManager particleManager = Minecraft.getInstance().particles; List<TextureAtlasSprite> sprites = new ArrayList<>(((IModelParticleProvider) model).getHitEffects(traceResult, state, world, pos, modelData)); TextureAtlasSprite rolledSprite = sprites.get(world.rand.nextInt(sprites.size())); double x = entity.getPosX() + (world.rand.nextFloat() - 0.5D) * entity.getWidth(); double y = entity.getBoundingBox().minY + 0.1D; double z = entity.getPosZ() + (world.rand.nextFloat() - 0.5D) * entity.getWidth(); particleManager.addEffect(new CustomBreakingParticle(world, x, y, z, -entity.getMotion().x * 4.0D, 1.5D, -entity.getMotion().z * 4.0D, rolledSprite)); return true; } return false; }
Example #2
Source File: CustomParticleHandler.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 6 votes |
@OnlyIn (Dist.CLIENT) public static void addLandingEffects(World world, BlockPos pos, BlockState state, Vector3 entityPos, int numParticles) { //Spoof a raytrace from the feet. BlockRayTraceResult traceResult = new BlockRayTraceResult(new Vec3d(entityPos.x, pos.getY() + 1, entityPos.z), Direction.UP, pos, false); ParticleManager manager = Minecraft.getInstance().particles; Random randy = new Random(); BlockModelShapes modelShapes = Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelShapes(); IBakedModel model = modelShapes.getModel(state); if (model instanceof IModelParticleProvider) { IModelData modelData = ModelDataManager.getModelData(world, pos); List<TextureAtlasSprite> sprites = new ArrayList<>(((IModelParticleProvider) model).getHitEffects(traceResult, state, world, pos, modelData)); double speed = 0.15000000596046448D; if (numParticles != 0) { for (int i = 0; i < numParticles; i++) { double mX = randy.nextGaussian() * speed; double mY = randy.nextGaussian() * speed; double mZ = randy.nextGaussian() * speed; manager.addEffect(CustomBreakingParticle.newLandingParticle(world, entityPos.x, entityPos.y, entityPos.z, mX, mY, mZ, sprites.get(randy.nextInt(sprites.size())))); } } } }
Example #3
Source File: HydroponicTESR.java From EmergingTechnology with MIT License | 5 votes |
public void renderWaterLevel(HydroponicTileEntity tileEntity, double x, double y, double z, float partialTicks, int destroyStage, float partial, BufferBuilder buffer) { final float PX = 1f / 16f; final float YOFF = 12 * PX; final float BORDER = 1f * PX; final float MAXHEIGHT = 2 * PX; boolean hasWater = tileEntity.fluidHandler.getFluidAmount() > 0; if (!hasWater) { return; } float actualHeight = MAXHEIGHT + YOFF; BlockModelShapes bm = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes(); IBlockState blockState = tileEntity.fluidHandler.getFluid().getFluid().getBlock().getDefaultState(); TextureAtlasSprite texture = bm.getTexture(blockState); // Lightmap calculations int upCombined = getWorld().getCombinedLight(tileEntity.getPos().up(), 0); int upLMa = upCombined >> 16 & 65535; int upLMb = upCombined & 65535; buffer.setTranslation(x, y, z); // UP face buffer.pos(BORDER, actualHeight, BORDER).color(1f, 1f, 1f, 0.8f).tex(texture.getMinU(), texture.getMinV()) .lightmap(upLMa, upLMb).endVertex(); buffer.pos(1 - BORDER, actualHeight, BORDER).color(1f, 1f, 1f, 0.8f).tex(texture.getMaxU(), texture.getMinV()) .lightmap(upLMa, upLMb).endVertex(); buffer.pos(1 - BORDER, actualHeight, 1 - BORDER).color(1f, 1f, 1f, 0.8f) .tex(texture.getMaxU(), texture.getMaxV()).lightmap(upLMa, upLMb).endVertex(); buffer.pos(BORDER, actualHeight, 1 - BORDER).color(1f, 1f, 1f, 0.8f).tex(texture.getMinU(), texture.getMaxV()) .lightmap(upLMa, upLMb).endVertex(); }
Example #4
Source File: HydroponicTESR.java From EmergingTechnology with MIT License | 5 votes |
public void renderGrowthMedium(HydroponicTileEntity tileEntity, double x, double y, double z, float partialTicks, int destroyStage, float partial, BufferBuilder buffer) { // I was hella lazy here, could be improved final float PX = 1f / 16f; final float YOFF = 12 * PX; final float BORDER = 6f * PX; final float MAXHEIGHT = 4 * PX; float actualHeight = MAXHEIGHT + YOFF; TextureAtlasSprite containerTexture = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(CONTAINER_TEXTURE); TextureAtlasSprite texture = containerTexture; int mediumId = tileEntity.getGrowthMediumId(); if (mediumId > 0) { IBlockState growthMediaBlockState = HydroponicHelper.getMediumBlockStateFromId(mediumId); BlockModelShapes bm = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes(); texture = bm.getTexture(growthMediaBlockState); } // Lightmap calculations int upCombined = getWorld().getCombinedLight(tileEntity.getPos().up(), 0); int upLMa = upCombined >> 16 & 65535; int upLMb = upCombined & 65535; buffer.setTranslation(x,y,z); //UP face buffer.pos(BORDER, actualHeight, BORDER).color(1f,1f,1f,1f).tex(texture.getMinU(), texture.getMinV()).lightmap(upLMa,upLMb).endVertex(); buffer.pos(1 - BORDER, actualHeight, BORDER).color(1f,1f,1f,1f).tex(texture.getMaxU(), texture.getMinV()).lightmap(upLMa,upLMb).endVertex(); buffer.pos(1 - BORDER, actualHeight, 1 - BORDER).color(1f,1f,1f,1f).tex(texture.getMaxU(), texture.getMaxV()).lightmap(upLMa,upLMb).endVertex(); buffer.pos(BORDER, actualHeight, 1 - BORDER).color(1f,1f,1f,1f).tex(texture.getMinU(), texture.getMaxV()).lightmap(upLMa,upLMb).endVertex(); }
Example #5
Source File: CustomParticleHandler.java From CodeChickenLib with GNU Lesser General Public License v2.1 | 5 votes |
/** * {@link Block#addHitEffects} * Provided the model bound is an instance of IModelParticleProvider, you will have landing particles just handled for you. * Use the default PerspectiveModel implementations inside CCL, Destroy effects will just be handled for you. * * @param world The world. * @param pos The position of the block. * @param manager The ParticleManager. * @return True if particles were added, basically just return the result of this method inside {@link Block#addHitEffects} */ @OnlyIn (Dist.CLIENT) public static boolean handleDestroyEffects(World world, BlockPos pos, BlockState state, ParticleManager manager) { BlockModelShapes modelShapes = Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelShapes(); IBakedModel model = modelShapes.getModel(state); if (model instanceof IModelParticleProvider) { IModelData modelData = ModelDataManager.getModelData(world, pos); Cuboid6 bounds = new Cuboid6(state.getShape(world, pos).getBoundingBox()); addBlockDestroyEffects(world, bounds.add(pos), new ArrayList<>(((IModelParticleProvider) model).getDestroyEffects(state, world, pos, modelData)), manager); return true; } return false; }
Example #6
Source File: WidgetSchematicVerificationResult.java From litematica with GNU Lesser General Public License v3.0 | 4 votes |
public void render(int x, int y, int zLevel, Minecraft mc) { if (this.stateExpected != null && this.stateFound != null) { GlStateManager.pushMatrix(); int x1 = x + 10; int x2 = x + this.columnWidthExpected + 30; RenderUtils.drawOutlinedBox(x, y, this.totalWidth, this.totalHeight, 0xFF000000, GuiBase.COLOR_HORIZONTAL_BAR, zLevel); RenderUtils.drawRect(x1, y + 16, 16, 16, 0x50C0C0C0, zLevel); // light background for the item RenderUtils.drawRect(x2, y + 16, 16, 16, 0x50C0C0C0, zLevel); // light background for the item FontRenderer textRenderer = mc.fontRenderer; String pre = GuiBase.TXT_WHITE + GuiBase.TXT_BOLD; String strExpected = pre + StringUtils.translate("litematica.gui.label.schematic_verifier.expected") + GuiBase.TXT_RST; String strFound = pre + StringUtils.translate("litematica.gui.label.schematic_verifier.found") + GuiBase.TXT_RST; GlStateManager.translate(0f, 0f, zLevel + 0.1f); y += 4; textRenderer.drawString(strExpected, x1, y, 0xFFFFFFFF); textRenderer.drawString(strFound, x2, y, 0xFFFFFFFF); y += 12; GlStateManager.disableLighting(); RenderUtils.enableGuiItemLighting(); boolean useBlockModelConfig = Configs.Visuals.SCHEMATIC_VERIFIER_BLOCK_MODELS.getBooleanValue(); boolean hasModelExpected = this.stateExpected.getRenderType() == EnumBlockRenderType.MODEL; boolean hasModelFound = this.stateFound.getRenderType() == EnumBlockRenderType.MODEL; boolean isAirItemExpected = this.stackExpected.isEmpty(); boolean isAirItemFound = this.stackFound.isEmpty(); boolean useBlockModelExpected = hasModelExpected && (isAirItemExpected || useBlockModelConfig || this.stateExpected.getBlock() == Blocks.FLOWER_POT); boolean useBlockModelFound = hasModelFound && (isAirItemFound || useBlockModelConfig || this.stateFound.getBlock() == Blocks.FLOWER_POT); BlockModelShapes blockModelShapes = mc.getBlockRendererDispatcher().getBlockModelShapes(); //mc.getRenderItem().zLevel += 100; IBakedModel model; if (useBlockModelExpected) { model = blockModelShapes.getModelForState(this.stateExpected); RenderUtils.renderModelInGui(x1, y, zLevel + 1, model, this.stateExpected); } else { mc.getRenderItem().renderItemAndEffectIntoGUI(mc.player, this.stackExpected, x1, y); mc.getRenderItem().renderItemOverlayIntoGUI(textRenderer, this.stackExpected, x1, y, null); } if (useBlockModelFound) { model = blockModelShapes.getModelForState(this.stateFound); RenderUtils.renderModelInGui(x2, y, zLevel + 1, model, this.stateFound); } else { mc.getRenderItem().renderItemAndEffectIntoGUI(mc.player, this.stackFound, x2, y); mc.getRenderItem().renderItemOverlayIntoGUI(textRenderer, this.stackFound, x2, y, null); } //mc.getRenderItem().zLevel -= 100; //GlStateManager.disableBlend(); RenderUtils.disableItemLighting(); textRenderer.drawString(this.nameExpected, x1 + 20, y + 4, 0xFFFFFFFF); textRenderer.drawString(this.nameFound, x2 + 20, y + 4, 0xFFFFFFFF); y += 20; textRenderer.drawString(this.blockRegistrynameExpected, x1, y, 0xFF4060FF); textRenderer.drawString(this.blockRegistrynameFound, x2, y, 0xFF4060FF); y += StringUtils.getFontHeight() + 4; List<String> propsExpected = BlockUtils.getFormattedBlockStateProperties(this.stateExpected, " = "); List<String> propsFound = BlockUtils.getFormattedBlockStateProperties(this.stateFound, " = "); RenderUtils.renderText(x1, y, 0xFFB0B0B0, propsExpected); RenderUtils.renderText(x2, y, 0xFFB0B0B0, propsFound); GlStateManager.popMatrix(); } }