Jump to content

marinz

Members
  • Posts

    67
  • Joined

  • Last visited

Everything posted by marinz

  1. EnumProperty? public static final EnumProperty<?> VARIANT = EnumProperty.create()
  2. I don't know what vanilla class to use
  3. Is this something? public static final VariantProperty VARIANT = VariantProperty.valueOf("variant");
  4. I don't know... I am sorry I'm trying to figure it out but It's not going anywhere
  5. Where do I even find that I new to this I don't get the most of this
  6. Does that mean I have to make class for that property too? Is this good? public static final VariantProperty VARIANT = new VariantProperty();
  7. yeah I get that but what to use exept
  8. Then I don't know how to even start
  9. Soo to use VariantPropertyBuilder or?
  10. Randomly placing different variants of rock. This is my rock block class package com.tzs.asm.blocks; import java.util.stream.Stream; import net.minecraft.block.AbstractBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.material.MaterialColor; import net.minecraft.item.BlockItemUseContext; import net.minecraft.state.DirectionProperty; import net.minecraft.state.StateContainer.Builder; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.util.Direction; 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.minecraft.world.IWorld; public class rockBlock extends Block { public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; public rockBlock() { super(AbstractBlock.Properties.of(Material.STONE, MaterialColor.COLOR_GRAY).speedFactor(0.3f) .friction(0.5f).harvestLevel(1).sound(SoundType.STONE).noOcclusion()); this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH)); } @SuppressWarnings("deprecation") @Override public BlockState mirror(BlockState state, Mirror mirrorIn) { return state.rotate(mirrorIn.getRotation(state.getValue(FACING))); } @Override public BlockState rotate(BlockState state, IWorld world, BlockPos pos, Rotation direction) { return state.setValue(FACING, direction.rotate(state.getValue(FACING))); } @Override public BlockState getStateForPlacement(BlockItemUseContext context) { return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite()); } @Override protected void createBlockStateDefinition(Builder<Block, BlockState> builder) { super.createBlockStateDefinition(builder); builder.add(FACING); } private static final VoxelShape rockN = Stream.of( Block.box(8.450000000000001, 0, 5.275, 9.450000000000001, 0.40000000000000036, 5.975), Block.box(6.850000000000001, 0, 5.975, 9.850000000000001, 1, 10.975), Block.box(5.850000000000001, 0, 8.575, 6.850000000000001, 0.40000000000000036, 10.674999999999999), Block.box(7.350000000000001, 0, 6.775, 9.350000000000001, 0.40000000000000036, 9.775) ).reduce((v1, v2) -> VoxelShapes.join(v1, v2, IBooleanFunction.OR)).get(); private static final VoxelShape rockE = Stream.of( Block.box(10.025000000000002, 0, 8.45, 10.725000000000001, 0.40000000000000036, 9.45), Block.box(5.025000000000002, 0, 6.85, 10.025000000000002, 1, 9.85), Block.box(5.325000000000003, 0, 5.85, 7.4250000000000025, 0.40000000000000036, 6.85), Block.box(6.225000000000001, 0, 7.35, 9.225000000000001, 0.40000000000000036, 9.35) ).reduce((v1, v2) -> VoxelShapes.join(v1, v2, IBooleanFunction.OR)).get(); private static final VoxelShape rockS = Stream.of( Block.box(6.5500000000000025, 0, 10.025, 7.5500000000000025, 0.40000000000000036, 10.725), Block.box(6.150000000000002, 0, 5.025, 9.150000000000002, 1, 10.025), Block.box(9.150000000000002, 0, 5.325000000000001, 10.150000000000002, 0.40000000000000036, 7.425000000000001), Block.box(6.650000000000002, 0, 6.225, 8.650000000000002, 0.40000000000000036, 9.225) ).reduce((v1, v2) -> VoxelShapes.join(v1, v2, IBooleanFunction.OR)).get(); private static final VoxelShape rockW = Stream.of( Block.box(5.275000000000002, 0, 6.550000000000001, 5.975000000000001, 0.40000000000000036, 7.550000000000001), Block.box(5.975000000000001, 0, 6.15, 10.975000000000001, 1, 9.15), Block.box(8.575000000000001, 0, 9.15, 10.675, 0.40000000000000036, 10.15), Block.box(6.775000000000002, 0, 6.65, 9.775000000000002, 0.40000000000000036, 8.65) ).reduce((v1, v2) -> VoxelShapes.join(v1, v2, IBooleanFunction.OR)).get(); @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { switch(state.getValue(FACING)) { case EAST: return rockE; case SOUTH: return rockS; case WEST: return rockW; default: return rockN; } } }
  11. Thats what I had in mind to get random variant from those two
  12. Now it just places the second model not the first one and is there a way to have seperated hit boxes cuz second model is not the same as the first one
  13. So if I just do this it should work: { "variants": { "facing=north": {"model": "asm:block/rock1"}, "facing=east": {"model": "asm:block/rock1", "y": 90}, "facing=south": {"model": "asm:block/rock1", "y": 180}, "facing=west": {"model": "asm:block/rock1", "y": 270}, "facing=north": {"model": "asm:block/rock2"}, "facing=east": {"model": "asm:block/rock2", "y": 90}, "facing=south": {"model": "asm:block/rock2", "y": 180}, "facing=west": {"model": "asm:block/rock2", "y": 270} } }
  14. First how sould I do different models all with different facing but with one item
  15. Is this what you are talking about? { "variants": { "": [ { "model": "minecraft:block/stone" }, { "model": "minecraft:block/stone_mirrored" }, { "model": "minecraft:block/stone", "y": 180 }, { "model": "minecraft:block/stone_mirrored", "y": 180 } ] } }
  16. I am using eclipse, I tried every search option and open type and got nothing. Is there any other way to search I am not that familiar with that.
  17. I did it and it works but there is another question. My block is rock, I have 1 model for it and I did the facing, but I would like to add more variants(few more models so when I click with rock item on ground it puts a random model) with facing and that to spawn in every biome.
  18. I've made a block smaller then 16x16 but the bounding box or hitbox(I don't know what it's actually called) is still 16x16 or full cube block. How do I change that. Do I have to make seperate class for that block or can I just do something with this code below. public class BlockInit{ public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, asmMain.MODID); public static final RegistryObject<Block> ROCK = BLOCKS.register("rock", () -> new Block(AbstractBlock.Properties.of(Material.STONE, MaterialColor.COLOR_GRAY).speedFactor(0.3f) .friction(0.5f).harvestLevel(1).sound(SoundType.STONE).noOcclusion())); }
×
×
  • Create New...

Important Information

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