Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.16.1] Voxel Shapes Broken
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 2
IDuckz_

[1.16.1] Voxel Shapes Broken

By IDuckz_, October 23, 2020 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

IDuckz_    0

IDuckz_

IDuckz_    0

  • Tree Puncher
  • IDuckz_
  • Members
  • 0
  • 13 posts
Posted October 23, 2020 (edited)

Hello, I setup a custom model like this: https://gyazo.com/51fabdfc1ebaee01e766dc20aea486c2 but in game it doesn't show it correctly. It shows the block bound or voxelshape like this: https://gyazo.com/594430fbe27b6941a81afa85319f73b7 The problem is that it has diagonal shape and it doesn't seem to like diagonal shapes and it decides to break.

 

My voxelshape code (It's a lot of code that I can't show it all since it's too big but I think you get the idea): https://gyazo.com/6e7d09f1b467f404b6fa73b5326eb62c

 

If anyone could help, that would be greatly appreciated. Thank you

 

Edited October 23, 2020 by IDuckz_
  • Quote

Share this post


Link to post
Share on other sites

ChampionAsh5357    165

ChampionAsh5357

ChampionAsh5357    165

  • World Shaper
  • ChampionAsh5357
  • Members
  • 165
  • 1038 posts
Posted October 24, 2020

You cannot have a diagonal voxel shape. The closest you can get is approximation. Also, you should use the least amount of voxel shapes as possible. Large amounts of voxel shapes tend to impact the game in a negative way. Finally, I can tell you generated the voxel shape via block bench. This is more of an opinion, but just use VoxelShapes#or instead of constructing the stream. Makes little to no sense to do so in my opinion as the approach is exactly what the method does anyways.

 

If you're talking about the misalignment, that's probably because you need to create a voxel shape for every possible rotation and then change it via it's block state.

  • Thanks 1
  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2417

Draco18s

Draco18s    2417

  • Reality Controller
  • Draco18s
  • Members
  • 2417
  • 16015 posts
Posted October 24, 2020

Your cauldron handle does not need a voxel boundary. Its basically irrelevant.

  • Like 1
  • Quote

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Share this post


Link to post
Share on other sites

IDuckz_    0

IDuckz_

IDuckz_    0

  • Tree Puncher
  • IDuckz_
  • Members
  • 0
  • 13 posts
Posted October 24, 2020 (edited)

Okay, I will try using less voxelshapes in the future and I did remove the stream#of and replaced it with VoxelShapes#or I also removed the return and reduce type at the end so the code wasn't necessary provided by BlockBench when I exported it as VoxelShapes, and it is maybe irrelevant but if I want make more custom blocks in the future it might include diagonal shapes too. Also, one question, how would I create a voxelshape for every possible rotation and change it via it's block state? Also thanks for all the help by the way, greatly appreciated. :)

Edited October 24, 2020 by IDuckz_
  • Quote

Share this post


Link to post
Share on other sites

poopoodice    119

poopoodice

poopoodice    119

  • Dragon Slayer
  • poopoodice
  • Members
  • 119
  • 931 posts
Posted October 24, 2020

Override getShape() (check blocks like torch, button, doors...etc), and return different voxel shape according to the blockstate.

  • Quote

Share this post


Link to post
Share on other sites

IDuckz_    0

IDuckz_

IDuckz_    0

  • Tree Puncher
  • IDuckz_
  • Members
  • 0
  • 13 posts
Posted October 24, 2020
2 hours ago, poopoodice said:

Override getShape() (check blocks like torch, button, doors...etc), and return different voxel shape according to the blockstate.

It seems I have alraedy done that: https://gyazo.com/6062f42293576f15cbf56e95d2656574

  • Quote

Share this post


Link to post
Share on other sites

poopoodice    119

poopoodice

poopoodice    119

  • Dragon Slayer
  • poopoodice
  • Members
  • 119
  • 931 posts
Posted October 24, 2020

Show the whole class.

  • Quote

Share this post


Link to post
Share on other sites

IDuckz_    0

IDuckz_

IDuckz_    0

  • Tree Puncher
  • IDuckz_
  • Members
  • 0
  • 13 posts
Posted October 25, 2020

Um ok here:

package com.iduckz.usefulemeralds.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.HorizontalBlock;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.IBooleanFunction;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraftforge.common.ToolType;

import javax.annotation.Nullable;
import java.util.stream.Stream;

public class WitchCauldron extends Block {

    public WitchCauldron() {
        super(Block.Properties.create(Material.IRON)
            .hardnessAndResistance(2.5f, 3.5f)
            .sound(SoundType.METAL)
            .harvestLevel(2)
            .harvestTool(ToolType.PICKAXE)
            .setRequiresTool());
    }

    private static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
    
    public static final VoxelShape SHAPE_N = VoxelShapes.or(
            Block.makeCuboidShape(14, 6, -2, 15, 7, 7),
            Block.makeCuboidShape(1, 6, -2, 2, 7, 7),
            Block.makeCuboidShape(2, 2.6999999999999993D, -1.4600000000000009D, 14, 3.6999999999999993D, -0.46000000000000085D),
            Block.makeCuboidShape(9, 0, 9, 11, 2, 11),
            Block.makeCuboidShape(10, 0, 11, 11, 2, 12),
            Block.makeCuboidShape(11, 0, 10, 12, 2, 11),
            Block.makeCuboidShape(11, 0, 11, 13, 2, 13),
            Block.makeCuboidShape(12, 0, 13, 13, 2, 14),
            Block.makeCuboidShape(13, 0, 12, 14, 2, 13),
            Block.makeCuboidShape(13, 0, 13, 15, 2, 15),
            Block.makeCuboidShape(3, 0, 13, 4, 2, 14),
            Block.makeCuboidShape(1, 0, 13, 3, 2, 15),
            Block.makeCuboidShape(2, 0, 12, 3, 2, 13),
            Block.makeCuboidShape(3, 0, 11, 5, 2, 13),
            Block.makeCuboidShape(4, 0, 10, 5, 2, 11),
            Block.makeCuboidShape(5, 0, 11, 6, 2, 12),
            Block.makeCuboidShape(5, 0, 9, 7, 2, 11),
            Block.makeCuboidShape(3, 0, 2, 4, 2, 3),
            Block.makeCuboidShape(5, 0, 5, 7, 2, 7),
            Block.makeCuboidShape(3, 0, 3, 5, 2, 5),
            Block.makeCuboidShape(1, 0, 1, 3, 2, 3),
            Block.makeCuboidShape(4, 0, 5, 5, 2, 6),
            Block.makeCuboidShape(5, 0, 4, 6, 2, 5),
            Block.makeCuboidShape(2, 0, 3, 3, 2, 4),
            Block.makeCuboidShape(13, 0, 1, 15, 2, 3),
            Block.makeCuboidShape(9, 0, 5, 11, 2, 7),
            Block.makeCuboidShape(11, 0, 3, 13, 2, 5),
            Block.makeCuboidShape(10, 0, 4, 11, 2, 5),
            Block.makeCuboidShape(11, 0, 5, 12, 2, 6),
            Block.makeCuboidShape(12, 0, 2, 13, 2, 3),
            Block.makeCuboidShape(13, 0, 3, 14, 2, 4),
            Block.makeCuboidShape(7, 0, 9, 9, 2, 16),
            Block.makeCuboidShape(0, 0, 7, 16, 2, 9),
            Block.makeCuboidShape(7, 0, 0, 9, 2, 7),
            Block.makeCuboidShape(2, 2, 2, 14, 3, 14),
            Block.makeCuboidShape(3, 3, 2, 13, 13, 3),
            Block.makeCuboidShape(3, 3, 13, 13, 13, 14),
            Block.makeCuboidShape(13, 3, 2, 14, 13, 14),
            Block.makeCuboidShape(2, 3, 2, 3, 13, 14)
    );

    public static final VoxelShape SHAPE_E = VoxelShapes.or(
            Block.makeCuboidShape(9, 6, 14, 18, 7, 15),
            Block.makeCuboidShape(9, 6, 1, 18, 7, 2),
            Block.makeCuboidShape(16.46f, 2.7f, 2, 17.46f, 3.7f, 14),
            Block.makeCuboidShape(5, 0, 9, 7, 2, 11),
            Block.makeCuboidShape(4, 0, 10, 5, 2, 11),
            Block.makeCuboidShape(5, 0, 11, 6, 2, 12),
            Block.makeCuboidShape(3, 0, 11, 5, 2, 13),
            Block.makeCuboidShape(2, 0, 12, 3, 2, 13),
            Block.makeCuboidShape(3, 0, 13, 4, 2, 14),
            Block.makeCuboidShape(1, 0, 13, 3, 2, 15),
            Block.makeCuboidShape(2, 0, 3, 3, 2, 4),
            Block.makeCuboidShape(1, 0, 1, 3, 2, 3),
            Block.makeCuboidShape(3, 0, 2, 4, 2, 3),
            Block.makeCuboidShape(3, 0, 3, 5, 2, 5),
            Block.makeCuboidShape(5, 0, 4, 6, 2, 5),
            Block.makeCuboidShape(4, 0, 5, 5, 2, 6),
            Block.makeCuboidShape(5, 0, 5, 7, 2, 7),
            Block.makeCuboidShape(13, 0, 3, 14, 2, 4),
            Block.makeCuboidShape(9, 0, 5, 11, 2, 7),
            Block.makeCuboidShape(11, 0, 3, 13, 2, 5),
            Block.makeCuboidShape(13, 0, 1, 15, 2, 3),
            Block.makeCuboidShape(10, 0, 4, 11, 2, 5),
            Block.makeCuboidShape(11, 0, 5, 12, 2, 6),
            Block.makeCuboidShape(12, 0, 2, 13, 2, 3),
            Block.makeCuboidShape(13, 0, 13, 15, 2, 15),
            Block.makeCuboidShape(9, 0, 9, 11, 2, 11),
            Block.makeCuboidShape(11, 0, 11, 13, 2, 13),
            Block.makeCuboidShape(11, 0, 10, 12, 2, 11),
            Block.makeCuboidShape(10, 0, 11, 11, 2, 12),
            Block.makeCuboidShape(13, 0, 12, 14, 2, 13),
            Block.makeCuboidShape(12, 0, 13, 13, 2, 14),
            Block.makeCuboidShape(0, 0, 7, 7, 2, 9),
            Block.makeCuboidShape(7, 0, 0, 9, 2, 16),
            Block.makeCuboidShape(9, 0, 7, 16, 2, 9),
            Block.makeCuboidShape(2, 2, 2, 14, 3, 14),
            Block.makeCuboidShape(13, 3, 3, 14, 13, 13),
            Block.makeCuboidShape(2, 3, 3, 3, 13, 13),
            Block.makeCuboidShape(2, 3, 13, 14, 13, 14),
            Block.makeCuboidShape(2, 3, 2, 14, 13, 3)
    );

    public static final VoxelShape SHAPE_S = VoxelShapes.or(
            Block.makeCuboidShape(1, 6, 9, 2, 7, 18),
            Block.makeCuboidShape(14, 6, 9, 15, 7, 18),
            Block.makeCuboidShape(2, 2.6999999999999993D, 16.46f, 14, 3.6999999999999993D, 17.46f),
            Block.makeCuboidShape(5, 0, 5, 7, 2, 7),
            Block.makeCuboidShape(5, 0, 4, 6, 2, 5),
            Block.makeCuboidShape(4, 0, 5, 5, 2, 6),
            Block.makeCuboidShape(3, 0, 3, 5, 2, 5),
            Block.makeCuboidShape(3, 0, 2, 4, 2, 3),
            Block.makeCuboidShape(2, 0, 3, 3, 2, 4),
            Block.makeCuboidShape(1, 0, 1, 3, 2, 3),
            Block.makeCuboidShape(12, 0, 2, 13, 2, 3),
            Block.makeCuboidShape(13, 0, 1, 15, 2, 3),
            Block.makeCuboidShape(13, 0, 3, 14, 2, 4),
            Block.makeCuboidShape(11, 0, 3, 13, 2, 5),
            Block.makeCuboidShape(11, 0, 5, 12, 2, 6),
            Block.makeCuboidShape(10, 0, 4, 11, 2, 5),
            Block.makeCuboidShape(9, 0, 5, 11, 2, 7),
            Block.makeCuboidShape(12, 0, 13, 13, 2, 14),
            Block.makeCuboidShape(9, 0, 9, 11, 2, 11),
            Block.makeCuboidShape(11, 0, 11, 13, 2, 13),
            Block.makeCuboidShape(13, 0, 13, 15, 2, 15),
            Block.makeCuboidShape(11, 0, 10, 12, 2, 11),
            Block.makeCuboidShape(10, 0, 11, 11, 2, 12),
            Block.makeCuboidShape(13, 0, 12, 14, 2, 13),
            Block.makeCuboidShape(1, 0, 13, 3, 2, 15),
            Block.makeCuboidShape(5, 0, 9, 7, 2, 11),
            Block.makeCuboidShape(3, 0, 11, 5, 2, 13),
            Block.makeCuboidShape(5, 0, 11, 6, 2, 12),
            Block.makeCuboidShape(4, 0, 10, 5, 2, 11),
            Block.makeCuboidShape(3, 0, 13, 4, 2, 14),
            Block.makeCuboidShape(2, 0, 12, 3, 2, 13),
            Block.makeCuboidShape(7, 0, 0, 9, 2, 7),
            Block.makeCuboidShape(0, 0, 7, 16, 2, 9),
            Block.makeCuboidShape(7, 0, 9, 9, 2, 16),
            Block.makeCuboidShape(2, 2, 2, 14, 3, 14),
            Block.makeCuboidShape(3, 3, 13, 13, 13, 14),
            Block.makeCuboidShape(3, 3, 2, 13, 13, 3),
            Block.makeCuboidShape(2, 3, 2, 3, 13, 14),
            Block.makeCuboidShape(13, 3, 2, 14, 13, 14)
    );

    public static final VoxelShape SHAPE_W = VoxelShapes.or(
            Block.makeCuboidShape(-2, 6, 1, 7, 7, 2),
            Block.makeCuboidShape(-2, 6, 14, 7, 7, 15),
            Block.makeCuboidShape(-1.4600000000000009D, 2.6999999999999993D, 2, -0.46000000000000085D, 3.6999999999999993D, 14),
            Block.makeCuboidShape(9, 0, 5, 11, 2, 7),
            Block.makeCuboidShape(11, 0, 5, 12, 2, 6),
            Block.makeCuboidShape(10, 0, 4, 11, 2, 5),
            Block.makeCuboidShape(11, 0, 3, 13, 2, 5),
            Block.makeCuboidShape(13, 0, 3, 14, 2, 4),
            Block.makeCuboidShape(12, 0, 2, 13, 2, 3),
            Block.makeCuboidShape(13, 0, 1, 15, 2, 3),
            Block.makeCuboidShape(13, 0, 12, 14, 2, 13),
            Block.makeCuboidShape(13, 0, 13, 15, 2, 15),
            Block.makeCuboidShape(12, 0, 13, 13, 2, 14),
            Block.makeCuboidShape(11, 0, 11, 13, 2, 13),
            Block.makeCuboidShape(10, 0, 11, 11, 2, 12),
            Block.makeCuboidShape(11, 0, 10, 12, 2, 11),
            Block.makeCuboidShape(9, 0, 9, 11, 2, 11),
            Block.makeCuboidShape(2, 0, 12, 3, 2, 13),
            Block.makeCuboidShape(5, 0, 9, 7, 2, 11),
            Block.makeCuboidShape(3, 0, 11, 5, 2, 13),
            Block.makeCuboidShape(1, 0, 13, 3, 2, 15),
            Block.makeCuboidShape(5, 0, 11, 6, 2, 12),
            Block.makeCuboidShape(4, 0, 10, 5, 2, 11),
            Block.makeCuboidShape(3, 0, 13, 4, 2, 14),
            Block.makeCuboidShape(1, 0, 1, 3, 2, 3),
            Block.makeCuboidShape(5, 0, 5, 7, 2, 7),
            Block.makeCuboidShape(3, 0, 3, 5, 2, 5),
            Block.makeCuboidShape(4, 0, 5, 5, 2, 6),
            Block.makeCuboidShape(5, 0, 4, 6, 2, 5),
            Block.makeCuboidShape(2, 0, 3, 3, 2, 4),
            Block.makeCuboidShape(3, 0, 2, 4, 2, 3),
            Block.makeCuboidShape(9, 0, 7, 16, 2, 9),
            Block.makeCuboidShape(7, 0, 0, 9, 2, 16),
            Block.makeCuboidShape(0, 0, 7, 7, 2, 9),
            Block.makeCuboidShape(2, 2, 2, 14, 3, 14),
            Block.makeCuboidShape(2, 3, 3, 3, 13, 13),
            Block.makeCuboidShape(13, 3, 3, 14, 13, 13),
            Block.makeCuboidShape(2, 3, 2, 14, 13, 3),
            Block.makeCuboidShape(2, 3, 13, 14, 13, 14)
    );

    @Nullable
    @Override
    public BlockState getStateForPlacement(BlockItemUseContext context) { return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite()); }

    @Override
    public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
        switch(state.get(FACING)) {
            case NORTH:
                return SHAPE_N;
            case SOUTH:
                return SHAPE_S;
            case WEST:
                return SHAPE_W;
            default:
                return SHAPE_E;
        }
    }

    @Override
    public BlockState rotate(BlockState state, Rotation rot) {
        return state.with(FACING, rot.rotate(state.get(FACING)));
    }

    @Override
    public BlockState mirror(BlockState state, Mirror mirrorIn) {
        return state.rotate(mirrorIn.toRotation(state.get(FACING)));
    }

    @Override
    protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) { builder.add(FACING); }

    @Override
    public float getAmbientOcclusionLightValue(BlockState state, IBlockReader worldIn, BlockPos pos) {
        return 0.3f;
    }
}

 

  • Quote

Share this post


Link to post
Share on other sites

ChampionAsh5357    165

ChampionAsh5357

ChampionAsh5357    165

  • World Shaper
  • ChampionAsh5357
  • Members
  • 165
  • 1038 posts
Posted October 25, 2020

You've created a shape for every single rotation and it will change dependent on it. There is nothing wrong here, you've already done what you asked. However, once again, that's a bit too many defined and combined VoxelShapes for one block.

 

As for non-related critiques, do not hardcode the property parameter within the constructor, and the property should be public in case you would like to access or set the state in a location from outside the block itself.

  • Quote

Share this post


Link to post
Share on other sites

IDuckz_    0

IDuckz_

IDuckz_    0

  • Tree Puncher
  • IDuckz_
  • Members
  • 0
  • 13 posts
Posted October 26, 2020

I will try changing the block to use less VoxelShapes but for now I want to see how I could fix this issue. If I have already done what I asked for how come is it misaligned? Unless I misunderstood.

19 hours ago, ChampionAsh5357 said:

As for non-related critiques, do not hardcode the property parameter within the constructor, and the property should be public in case you would like to access or set the state in a location from outside the block itself.

Ok I will fix that. Thanks

  • Quote

Share this post


Link to post
Share on other sites

ChampionAsh5357    165

ChampionAsh5357

ChampionAsh5357    165

  • World Shaper
  • ChampionAsh5357
  • Members
  • 165
  • 1038 posts
Posted October 26, 2020
7 hours ago, IDuckz_ said:

If I have already done what I asked for how come is it misaligned?

That probably means that your VoxelShapes for the other rotations are either not being rotated or the model itself isn't rotating. It could also be you rotated the model in the opposite direction of the VoxelShape.

  • Quote

Share this post


Link to post
Share on other sites

IDuckz_    0

IDuckz_

IDuckz_    0

  • Tree Puncher
  • IDuckz_
  • Members
  • 0
  • 13 posts
Posted October 27, 2020

Okay, I will try rotating it to the other way.

  • Quote

Share this post


Link to post
Share on other sites

IDuckz_    0

IDuckz_

IDuckz_    0

  • Tree Puncher
  • IDuckz_
  • Members
  • 0
  • 13 posts
Posted October 30, 2020

Incredibly sorry for late response, did not work while rotating it to the other way, I guess there is no possible way to do this, thanks for all the help anyways. Greatly appreciated ❤️

  • Quote

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 2
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • diesieben07
      A problem occurred running the Server launcher.java.lang.reflect.InvocationTargetException

      By diesieben07 · Posted 1 hour ago

      1.12 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
    • diesieben07
      Please help

      By diesieben07 · Posted 1 hour ago

      Really old Minecraft versions are no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
    • diesieben07
      Game Crashing Exit Code: -1

      By diesieben07 · Posted 1 hour ago

      1.12 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
    • diesieben07
      Have a question as to how I get my gfs forge to start

      By diesieben07 · Posted 1 hour ago

      1.12 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
    • diesieben07
      When I generate a world it stays at 100%

      By diesieben07 · Posted 1 hour ago

      Post logs.
  • Topics

    • diseasedworm
      1
      A problem occurred running the Server launcher.java.lang.reflect.InvocationTargetException

      By diseasedworm
      Started 4 hours ago

    • RETARDETH
      1
      Please help

      By RETARDETH
      Started 7 hours ago

    • Gordan
      1
      Game Crashing Exit Code: -1

      By Gordan
      Started 9 hours ago

    • seekaydoubleyew
      1
      Have a question as to how I get my gfs forge to start

      By seekaydoubleyew
      Started 10 hours ago

    • StormyRiley1
      1
      When I generate a world it stays at 100%

      By StormyRiley1
      Started 11 hours ago

  • Who's Online (See full list)

    • diesieben07
    • Sainthozier
    • Tavi007
    • Choonster
    • randomdude12300
    • CookieLukas
    • LordEnderNether
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.16.1] Voxel Shapes Broken
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community