Jump to content

Aviator737

Members
  • Posts

    9
  • Joined

  • Last visited

Everything posted by Aviator737

  1. Thanks, it worked. Now I would like to know how can I disable rendering of specific sides for these blockstates.
  2. 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(); }
  3. 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)); }
  4. 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
  5. 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; } }
  6. Try to update foamfix. (you have 0.9.4, the newest is 0.10.3) http://charset.asie.pl/download/
  7. How then to load a model for an itemblock if there is no model in the "models/block" or "model/item" folder
  8. Is there any recommended way to generate blockstate json and write it into assets?
  9. 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?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.