Поворот модели и увеличение блока

Версия Minecraft
1.12.2
1,470
19
189
1) Как мне повернуть модель относительно игрока?
2) У меня есть модель 2х1, но вторя половина проходима. Как убрать эту проходимость?
 
1,470
19
189
Не поворачивается
Модель
JSON:
{
    "parent": "block/orientable",
    "textures": {
        "particle": "blocks/wool_colored_black",
        "texture": "blocks/wool_colored_black",
        "texture1": "rcc:blocks/medium_tv/tv_pic1",
        "texture2": "rcc:blocks/medium_tv/tv_pic2"
    },
    "elements": [
        {
            "__comment": "Cube3",
            "from": [ 29, 0, 1 ],
            "to": [ 30, 16, 2 ],
            "faces": {
                "down": { "uv": [ 13, 14, 14, 15 ], "texture": "#texture" },
                "up": { "uv": [ 13, 1, 14, 2 ], "texture": "#texture" },
                "north": { "uv": [ 2, 0, 3, 16 ], "texture": "#texture" },
                "south": { "uv": [ 13, 0, 14, 16 ], "texture": "#texture" },
                "west": { "uv": [ 1, 0, 2, 16 ], "texture": "#texture" },
                "east": { "uv": [ 14, 0, 15, 16 ], "texture": "#texture" }
            }
        },
        {
            "__comment": "Cube2",
            "from": [ 15, 1, 1 ],
            "to": [ 29, 15, 2 ],
            "faces": {
                "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture2", "rotation": 180 },
                "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture2" },
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture2" },
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture2" },
                "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture2", "rotation": 180 },
                "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture2", "rotation": 180 }
            }
        },
        {
            "__comment": "Cube5",
            "from": [ 1, 0, 1 ],
            "to": [ 29, 1, 2 ],
            "faces": {
                "down": { "uv": [ 1.5, 13.5, 2.5, 14.5 ], "texture": "#texture" },
                "up": { "uv": [ 1.5, 1.5, 2.5, 2.5 ], "texture": "#texture" },
                "north": { "uv": [ 13.5, 0, 14.5, 1 ], "texture": "#texture" },
                "south": { "uv": [ 1.5, 0, 2.5, 1 ], "texture": "#texture" },
                "west": { "uv": [ 1.5, 0, 2.5, 1 ], "texture": "#texture" },
                "east": { "uv": [ 13.5, 0, 14.5, 1 ], "texture": "#texture" }
            }
        },
        {
            "__comment": "Cube3",
            "from": [ 0, 0, 1 ],
            "to": [ 1, 16, 2 ],
            "faces": {
                "down": { "uv": [ 0, 14, 1, 15 ], "texture": "#texture" },
                "up": { "uv": [ 0, 1, 1, 2 ], "texture": "#texture" },
                "north": { "uv": [ 15, 0, 16, 16 ], "texture": "#texture" },
                "south": { "uv": [ 0, 0, 1, 16 ], "texture": "#texture" },
                "west": { "uv": [ 1, 0, 2, 16 ], "texture": "#texture" },
                "east": { "uv": [ 14, 0, 15, 16 ], "texture": "#texture" }
            }
        },
        {
            "__comment": "Cube5",
            "from": [ 1, 15, 1 ],
            "to": [ 29, 16, 2 ],
            "faces": {
                "down": { "uv": [ 1.5, 13.5, 2.5, 14.5 ], "texture": "#texture" },
                "up": { "uv": [ 1.5, 1.5, 2.5, 2.5 ], "texture": "#texture" },
                "north": { "uv": [ 13.5, 0, 14.5, 1 ], "texture": "#texture" },
                "south": { "uv": [ 1.5, 0, 2.5, 1 ], "texture": "#texture" },
                "west": { "uv": [ 1.5, 0, 2.5, 1 ], "texture": "#texture" },
                "east": { "uv": [ 13.5, 0, 14.5, 1 ], "texture": "#texture" }
            }
        },
        {
            "__comment": "Cube2",
            "from": [ 0, 0, 0 ],
            "to": [ 16, 16, 1 ],
            "faces": {
                "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" },
                "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 90 },
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 180 },
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 180 },
                "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 270 },
                "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 90 }
            }
        },
        {
            "__comment": "Cube2",
            "from": [ 1, 1, 1 ],
            "to": [ 15, 15, 2 ],
            "faces": {
                "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture1", "rotation": 180 },
                "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture1" },
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture1" },
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture1" },
                "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 180 },
                "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 180 }
            }
        },
        {
            "__comment": "Cube2",
            "from": [ 16, 0, 0 ],
            "to": [ 30, 16, 1 ],
            "faces": {
                "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" },
                "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 90 },
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 180 },
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 180 },
                "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 270 },
                "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "rotation": 90 }
            }
        }
    ],
    "display": {
        "fixed": {
            "scale":  [ 0.5, 0.5, 0.5 ]
        }
    }
}

Блокстейт
JSON:
{
  "variants": {
    "facing=north": { "model": "rcc:tv_wall_medium" },
    "facing=south": { "model": "rcc:tv_wall_medium", "y": 180 },
    "facing=west":  { "model": "rcc:tv_wall_medium", "y": 270 },
    "facing=east":  { "model": "rcc:tv_wall_medium", "y": 90 },
    "inventory":    {"model": "rcc:tv_wall_medium" }
  }
}
 
1,470
19
189
Модель поворачивается, но БаундБоксы не меняются. Что делать, чтобы Баунды следовали за моделью?
 
1,470
19
189
Сделал такой код, но крашит

Java:
private AxisAlignedBB[] SYSTEM_BLOCK_AABB = {
            new AxisAlignedBB(0.0D, 1.0D, 0.1875D, 0.0D, 1.0D, 0.8125D),
            new AxisAlignedBB(0.1875D, 1.0D, 0.0D, 0.8125D, 1.0D, 0.0D),
            new AxisAlignedBB(0.1875D, 1.0D, 0.0D, 0.8125D, 1.0D, 0.0D),
            new AxisAlignedBB(0.0D, 1.0D, 0.1875D, 0.0D, 1.0D, 0.8125D)
    };

    /** Whether this fence connects in the northern direction */
    public static final PropertyBool NORTH = PropertyBool.create("north");
    /** Whether this fence connects in the eastern direction */
    public static final PropertyBool EAST = PropertyBool.create("east");
    /** Whether this fence connects in the southern direction */
    public static final PropertyBool SOUTH = PropertyBool.create("south");
    /** Whether this fence connects in the western direction */
    public static final PropertyBool WEST = PropertyBool.create("west");

    public SystemBlock(String name) {
        super(Material.GLASS);
        setUnlocalizedName(name);
        setRegistryName(name);
        setCreativeTab(RCC.rccDeco);
        blockSoundType = SoundType.GLASS;
    }

    @SideOnly(Side.CLIENT)
    public BlockRenderLayer getBlockLayer()
    {
        return BlockRenderLayer.CUTOUT;
    }

    @Override
    public boolean isOpaqueCube(IBlockState state){
        return false;
    }

    @Override
    public boolean isFullCube(IBlockState state){
        return false;
    }

    public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean isActualState)
    {
        if (!isActualState)
        {
            state = state.getActualState(worldIn, pos);
        }

        if (((Boolean)state.getValue(NORTH)).booleanValue())
        {
            addCollisionBoxToList(pos, entityBox, collidingBoxes, SYSTEM_BLOCK_AABB[0]);
        }

        if (((Boolean)state.getValue(EAST)).booleanValue())
        {
            addCollisionBoxToList(pos, entityBox, collidingBoxes, SYSTEM_BLOCK_AABB[1]);
        }

        if (((Boolean)state.getValue(SOUTH)).booleanValue())
        {
            addCollisionBoxToList(pos, entityBox, collidingBoxes, SYSTEM_BLOCK_AABB[2]);
        }

        if (((Boolean)state.getValue(WEST)).booleanValue())
        {
            addCollisionBoxToList(pos, entityBox, collidingBoxes, SYSTEM_BLOCK_AABB[3]);
        }
    }

    public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
    {
        state = this.getActualState(state, source, pos);
        return SYSTEM_BLOCK_AABB[getBoundingBoxIdx(state)];
    }

    private static int getBoundingBoxIdx(IBlockState state)
    {
        int i = 0;

        if (((Boolean)state.getValue(NORTH)).booleanValue())
        {
            i |= 1 << EnumFacing.NORTH.getHorizontalIndex();
        }

        if (((Boolean)state.getValue(EAST)).booleanValue())
        {
            i |= 1 << EnumFacing.EAST.getHorizontalIndex();
        }

        if (((Boolean)state.getValue(SOUTH)).booleanValue())
        {
            i |= 1 << EnumFacing.SOUTH.getHorizontalIndex();
        }

        if (((Boolean)state.getValue(WEST)).booleanValue())
        {
            i |= 1 << EnumFacing.WEST.getHorizontalIndex();
        }

        return i;
    }

    public static final PropertyDirection FACING = BlockHorizontal.FACING;

    /**
     * Called after the block is set in the Chunk data, but before the Tile Entity is set
     */
    public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
    {
        this.setDefaultFacing(worldIn, pos, state);
    }

    private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state)
    {
        if (!worldIn.isRemote)
        {
            IBlockState iblockstate = worldIn.getBlockState(pos.north());
            IBlockState iblockstate1 = worldIn.getBlockState(pos.south());
            IBlockState iblockstate2 = worldIn.getBlockState(pos.west());
            IBlockState iblockstate3 = worldIn.getBlockState(pos.east());
            EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);

            if (enumfacing == EnumFacing.NORTH && iblockstate.isFullBlock() && !iblockstate1.isFullBlock())
            {
                enumfacing = EnumFacing.SOUTH;
            }
            else if (enumfacing == EnumFacing.SOUTH && iblockstate1.isFullBlock() && !iblockstate.isFullBlock())
            {
                enumfacing = EnumFacing.NORTH;
            }
            else if (enumfacing == EnumFacing.WEST && iblockstate2.isFullBlock() && !iblockstate3.isFullBlock())
            {
                enumfacing = EnumFacing.EAST;
            }
            else if (enumfacing == EnumFacing.EAST && iblockstate3.isFullBlock() && !iblockstate2.isFullBlock())
            {
                enumfacing = EnumFacing.WEST;
            }

            worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
        }
    }

    public static void setState(boolean active, World worldIn, BlockPos pos)
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        worldIn.setBlockState(pos, RegBlocks.tvWallMedium.getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)), 3);

    }

    /**
     * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
     * IBlockstate
     */
    public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
    {
        return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
    }

    /**
     * Called by ItemBlocks after a block is set in the world, to allow post-place logic
     */
    public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
    {
        worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);
    }

    /**
     * The type of render function called. MODEL for mixed tesr and static model, MODELBLOCK_ANIMATED for TESR-only,
     * LIQUID for vanilla liquids, INVISIBLE to skip all rendering
     */
    public EnumBlockRenderType getRenderType(IBlockState state)
    {
        return EnumBlockRenderType.MODEL;
    }

    /**
     * Convert the given metadata into a BlockState for this Block
     */
    public IBlockState getStateFromMeta(int meta)
    {
        EnumFacing enumfacing = EnumFacing.getFront(meta);

        if (enumfacing.getAxis() == EnumFacing.Axis.Y)
        {
            enumfacing = EnumFacing.NORTH;
        }

        return this.getDefaultState().withProperty(FACING, enumfacing);
    }

    /**
     * Convert the BlockState into the correct metadata value
     */
    public int getMetaFromState(IBlockState state)
    {
        return ((EnumFacing)state.getValue(FACING)).getIndex();
    }

    /**
     * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed
     * blockstate.
     */
    public IBlockState withRotation(IBlockState state, Rotation rot)
    {
        return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING)));
    }

    /**
     * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed
     * blockstate.
     */
    public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
    {
        return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING)));
    }

    protected BlockStateContainer createBlockState()
    {
        return new BlockStateContainer(this, new IProperty[] {FACING});
    }
Код:
java.lang.IllegalArgumentException: Cannot get property PropertyBool{name=north, clazz=class java.lang.Boolean, values=[true, false]} as it does not exist in BlockStateContainer{block=rcc:system_block, properties=[facing]}
    at net.minecraft.block.state.BlockStateContainer$StateImplementation.getValue(BlockStateContainer.java:204)
    at com.rcp.rcc.blocks.deco.SystemBlock.addCollisionBoxToList(SystemBlock.java:76)
    at net.minecraft.block.state.BlockStateContainer$StateImplementation.addCollisionBoxToList(BlockStateContainer.java:463)
    at net.minecraft.world.World.getCollisionBoxes(World.java:1462)
    at net.minecraft.world.World.getCollisionBoxes(World.java:1489)
    at net.minecraft.entity.Entity.move(Entity.java:827)
    at net.minecraft.entity.EntityLivingBase.travel(EntityLivingBase.java:2160)
    at net.minecraft.entity.player.EntityPlayer.travel(EntityPlayer.java:1976)
    at net.minecraft.entity.EntityLivingBase.onLivingUpdate(EntityLivingBase.java:2611)
    at net.minecraft.entity.player.EntityPlayer.onLivingUpdate(EntityPlayer.java:577)
    at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:2393)
    at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:272)
    at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:423)
    at net.minecraft.network.NetHandlerPlayServer.update(NetHandlerPlayServer.java:185)
    at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:212)
    at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:307)
    at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:196)
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:863)
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:741)
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:590)
    at java.lang.Thread.run(Thread.java:748)
 
1,470
19
189
1,470
19
189
Сделал так, но баунды меняются в двух направлениях
Java:
public class SystemBlock extends Block {
    private AxisAlignedBB[] SYSTEM_BLOCK_AABB = {
            new AxisAlignedBB(0.0D, 0.0D, 0.1875D, 1.0D, 1.0D, 0.8125D),
            new AxisAlignedBB(0.1875D, 0.0D, 0.0D, 0.8125D, 1.0D, 1.0D),
            new AxisAlignedBB(0.0D, 0.0D, 0.1875D, 1.0D, 1.0D, 0.8125D),
            new AxisAlignedBB(0.1875D, 0.0D, 0.0D, 0.8125D, 1.0D, 1.0D)
    };

    public SystemBlock(String name) {
        super(Material.GLASS);
        setUnlocalizedName(name);
        setRegistryName(name);
        setCreativeTab(RCC.rccDeco);
        blockSoundType = SoundType.GLASS;
    }

    @SideOnly(Side.CLIENT)
    public BlockRenderLayer getBlockLayer()
    {
        return BlockRenderLayer.CUTOUT;
    }

    @Override
    public boolean isOpaqueCube(IBlockState state){
        return false;
    }

    @Override
    public boolean isFullCube(IBlockState state){
        return false;
    }

    public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
    {
        switch (state.getValue(FACING)){
            case SOUTH:
                return this.SYSTEM_BLOCK_AABB[0];
            case NORTH:
                default:
                return this.SYSTEM_BLOCK_AABB[1];
            case WEST:
                return this.SYSTEM_BLOCK_AABB[2];
            case EAST:
                return this.SYSTEM_BLOCK_AABB[3];
        }
    }

    //Model Rotation
    public static final PropertyDirection FACING = BlockHorizontal.FACING;

    /**
     * Called after the block is set in the Chunk data, but before the Tile Entity is set
     */
    public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
    {
        this.setDefaultFacing(worldIn, pos, state);
    }

    private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state)
    {
        if (!worldIn.isRemote)
        {
            IBlockState iblockstate = worldIn.getBlockState(pos.north());
            IBlockState iblockstate1 = worldIn.getBlockState(pos.south());
            IBlockState iblockstate2 = worldIn.getBlockState(pos.west());
            IBlockState iblockstate3 = worldIn.getBlockState(pos.east());
            EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);

            if (enumfacing == EnumFacing.NORTH && iblockstate.isFullBlock() && !iblockstate1.isFullBlock())
            {
                enumfacing = EnumFacing.SOUTH;
            }
            else if (enumfacing == EnumFacing.SOUTH && iblockstate1.isFullBlock() && !iblockstate.isFullBlock())
            {
                enumfacing = EnumFacing.NORTH;
            }
            else if (enumfacing == EnumFacing.WEST && iblockstate2.isFullBlock() && !iblockstate3.isFullBlock())
            {
                enumfacing = EnumFacing.EAST;
            }
            else if (enumfacing == EnumFacing.EAST && iblockstate3.isFullBlock() && !iblockstate2.isFullBlock())
            {
                enumfacing = EnumFacing.WEST;
            }

            worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2);
        }
    }

    public static void setState(boolean active, World worldIn, BlockPos pos)
    {
        IBlockState iblockstate = worldIn.getBlockState(pos);
        worldIn.setBlockState(pos, RegBlocks.tvWallMedium.getDefaultState().withProperty(FACING, iblockstate.getValue(FACING)), 3);

    }

    /**
     * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
     * IBlockstate
     */
    public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
    {
        return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
    }

    /**
     * Called by ItemBlocks after a block is set in the world, to allow post-place logic
     */
    public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
    {
        worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);
    }

    /**
     * The type of render function called. MODEL for mixed tesr and static model, MODELBLOCK_ANIMATED for TESR-only,
     * LIQUID for vanilla liquids, INVISIBLE to skip all rendering
     */
    public EnumBlockRenderType getRenderType(IBlockState state)
    {
        return EnumBlockRenderType.MODEL;
    }

    /**
     * Convert the given metadata into a BlockState for this Block
     */
    public IBlockState getStateFromMeta(int meta)
    {
        EnumFacing enumfacing = EnumFacing.getFront(meta);

        if (enumfacing.getAxis() == EnumFacing.Axis.Y)
        {
            enumfacing = EnumFacing.NORTH;
        }

        return this.getDefaultState().withProperty(FACING, enumfacing);
    }

    /**
     * Convert the BlockState into the correct metadata value
     */
    public int getMetaFromState(IBlockState state)
    {
        return ((EnumFacing)state.getValue(FACING)).getIndex();
    }

    /**
     * Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed
     * blockstate.
     */
    public IBlockState withRotation(IBlockState state, Rotation rot)
    {
        return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING)));
    }

    /**
     * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed
     * blockstate.
     */
    public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
    {
        return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING)));
    }

    protected BlockStateContainer createBlockState()
    {
        return new BlockStateContainer(this, new IProperty[] {FACING});
    }
}
 
Последнее редактирование:
Сверху