
Everything posted by Aviator737
-
How to render block from blockstate [1.16.5]
Thanks, it worked. Now I would like to know how can I disable rendering of specific sides for these blockstates.
-
How to render block from blockstate [1.16.5]
I'm making a wallpaper mod and I want to change the side of a block by rendering needed block with a little offset. To do this, I save the blockstate of the wanted blocks for each side and in the render() function I read blockstate from nbt and try to render these blockstates for the each side. Blocks are not rendered. Obviously I'm missing something but I can't figure out what. @Override public void render(TileEntity tileEntity, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer renderTypeBuffer, int combinedLight, int combinedOverlay) { CompoundNBT compoundNBT = tileEntity.getTileData(); BlockState camoStateUp = NBTUtil.readBlockState(compoundNBT.getCompound("camo_state_up")); BlockState camoStateDown = NBTUtil.readBlockState(compoundNBT.getCompound("camo_state_down")); BlockState camoStateNorth = NBTUtil.readBlockState(compoundNBT.getCompound("camo_state_north")); BlockState camoStateSouth = NBTUtil.readBlockState(compoundNBT.getCompound("camo_state_south")); BlockState camoStateEast = NBTUtil.readBlockState(compoundNBT.getCompound("camo_state_east")); BlockState camoStateWest = NBTUtil.readBlockState(compoundNBT.getCompound("camo_state_west")); matrixStack.pushPose(); if (camoStateUp != Blocks.AIR.defaultBlockState()) { matrixStack.translate(0, 0.1, 0); mc().getBlockRenderer().renderBlock(camoStateUp, matrixStack, renderTypeBuffer, combinedLight, combinedOverlay, EmptyModelData.INSTANCE); } if (camoStateDown != Blocks.AIR.defaultBlockState()) { matrixStack.translate(0, -0.2, 0); mc().getBlockRenderer().renderBlock(camoStateDown, matrixStack, renderTypeBuffer, combinedLight, combinedOverlay, EmptyModelData.INSTANCE); matrixStack.translate(0, 0.2, 0); } if (camoStateNorth != Blocks.AIR.defaultBlockState()) { matrixStack.translate(0, 0, -0.1); mc().getBlockRenderer().renderBlock(camoStateNorth, matrixStack, renderTypeBuffer, combinedLight, combinedOverlay, EmptyModelData.INSTANCE); } if (camoStateSouth != Blocks.AIR.defaultBlockState()) { matrixStack.translate(0, 0, 0.2); mc().getBlockRenderer().renderBlock(camoStateSouth, matrixStack, renderTypeBuffer, combinedLight, combinedOverlay, EmptyModelData.INSTANCE); matrixStack.translate(0, -0.1, -0.2); } if (camoStateEast != Blocks.AIR.defaultBlockState()) { matrixStack.translate(0.1, 0, 0); mc().getBlockRenderer().renderBlock(camoStateEast, matrixStack, renderTypeBuffer, combinedLight, combinedOverlay, EmptyModelData.INSTANCE); } if (camoStateWest != Blocks.AIR.defaultBlockState()) { matrixStack.translate(-0.2, 0, 0); mc().getBlockRenderer().renderBlock(camoStateWest, matrixStack, renderTypeBuffer, combinedLight, combinedOverlay, EmptyModelData.INSTANCE); } matrixStack.popPose(); }
-
[1.16.5] Apply transformation to obj model
Here is the solution. Set the air model for block default state. Then, in the render method, take the state with the model and render it. blockstate: { "variants": { "model=true": { "model": "almodels:block/double_bed_1" }, "model=false": { "model": "minecraft:block/air" } } } render method: @Override public void render(TileEntity tileEntityIn, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) { BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRendererDispatcher(); BlockState state = tileEntityIn.getBlockState().getBlock().getDefaultState().with(DoubleBed1Block.MODEL, true); IBakedModel model = dispatcher.getModelForState(state); Direction direction = tileEntityIn.getBlockState().get(HORIZONTAL_FACING); float angle = 0; matrixStackIn.push(); IVertexBuilder vertexBuffer = bufferIn.getBuffer(RenderType.getSolid()); float brightness = 0.87F; switch (direction) { default: case SOUTH: angle = 0; break; case NORTH: angle = 180; break; case EAST: angle = 90; break; case WEST: angle = 270; break; } matrixStackIn.rotate(Vector3f.YP.rotationDegrees(angle)); dispatcher.getBlockModelRenderer().renderModel( matrixStackIn.getLast(), vertexBuffer, state, model, brightness, brightness, brightness, combinedLightIn, combinedOverlayIn, EmptyModelData.INSTANCE ); matrixStackIn.pop(); } block: public DoubleBed1Block(final Properties properties) { super(properties); this.setDefaultState(this.getDefaultState().with(HORIZONTAL_FACING, Direction.NORTH).with(MODEL, false)); }
-
[1.16.5] Apply transformation to obj model
I am trying to make the model lighter and scale it. Registered ClientRegistry.bindTileEntityRenderer and in the render method I do the following: public class ObjRenderer extends TileEntityRenderer<TileEntity> { public ObjRenderer(TileEntityRendererDispatcher tileEntityRendererDispatcher) { super(tileEntityRendererDispatcher); } @Override public void render(TileEntity tileEntityIn, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) { BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRendererDispatcher(); BlockState state = tileEntityIn.getBlockState(); IBakedModel model = dispatcher.getModelForState(state); matrixStackIn.push(); matrixStackIn.scale(2,2,2); IVertexBuilder vertexBuffer = bufferIn.getBuffer(RenderType.getSolid()); float brightness = 0.87F; dispatcher.getBlockModelRenderer().renderModel( matrixStackIn.getLast(), vertexBuffer, state, model, brightness, brightness, brightness, combinedLightIn, combinedOverlayIn, EmptyModelData.INSTANCE ); matrixStackIn.pop(); } } After that, both the old and new model are rendered with the applied parameters on the new one, but I only need to change the main model. How to do this? full code: https://github.com/alterland/almodels
-
[1.16] Large collision box is not working correctly
I made test 3x3 collision. For convenience, I have marked with colors the areas of the cube (see screenshots). Bounding box shows up correctly but collision works strange. I can't fly horizontally through yellow blocks but I can fall through them. Сorner blocks (red) don't work at all. And I can't fall or walk into blue area. Forge 1.16.5 - 35.1.37 public class TestTileEntityBlock extends TileEntityBlock<TestTileEntity> { private static final VoxelShape SHAPE = makeCuboidShape(-16, -16, -16, 32, 32, 32); public TestTileEntityBlock(Properties properties) { super(properties); } @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { return new TestTileEntity(); } @SuppressWarnings("deprecation") @Override public VoxelShape getCollisionShape(final BlockState state, final IBlockReader world, final BlockPos pos, final ISelectionContext context) { return SHAPE; } @SuppressWarnings("deprecation") @Override public VoxelShape getShape(final BlockState state, final IBlockReader world, final BlockPos pos, final ISelectionContext context) { return SHAPE; } }
-
Crash on a modded 1.12.2 game
Try to update foamfix. (you have 0.9.4, the newest is 0.10.3) http://charset.asie.pl/download/
-
[1.12.2] How to avoid creating a blockstate for each texture?
How then to load a model for an itemblock if there is no model in the "models/block" or "model/item" folder
-
[1.12.2] How to avoid creating a blockstate for each texture?
Is there any recommended way to generate blockstate json and write it into assets?
-
[1.12.2] How to avoid creating a blockstate for each texture?
Good day. I have 500 simple blocks with different textures. At 1.7.10 I could just put the texture in assets folder with name of the block and it worked. How can I simply do this in 1.12.2 without creating a lot of blockstates?
IPS spam blocked by CleanTalk.