diff --git a/src/main/generated/data/minecraft/tags/blocks/mineable/shovel.json b/src/main/generated/data/minecraft/tags/blocks/mineable/shovel.json new file mode 100644 index 0000000..102da8a --- /dev/null +++ b/src/main/generated/data/minecraft/tags/blocks/mineable/shovel.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "new_soviet:landmine" + ] +} \ No newline at end of file diff --git a/src/main/generated/data/new_soviet/loot_tables/blocks/landmine.json b/src/main/generated/data/new_soviet/loot_tables/blocks/landmine.json new file mode 100644 index 0000000..2a1a08a --- /dev/null +++ b/src/main/generated/data/new_soviet/loot_tables/blocks/landmine.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "new_soviet:landmine" + } + ], + "rolls": 1.0 + } + ] +} \ No newline at end of file diff --git a/src/main/java/su/a71/new_soviet/DataGeneration.java b/src/main/java/su/a71/new_soviet/DataGeneration.java index 7bbcf1b..19ae9e9 100644 --- a/src/main/java/su/a71/new_soviet/DataGeneration.java +++ b/src/main/java/su/a71/new_soviet/DataGeneration.java @@ -179,6 +179,7 @@ public class DataGeneration implements DataGeneratorEntrypoint { addDrop(NSE_Custom.SIREN); addDrop(NSE_Custom.LAMP); addDrop(NSE_Custom.CEILING_FAN); + addDrop(NSE_Custom.LANDMINE); } } @@ -310,6 +311,9 @@ public class DataGeneration implements DataGeneratorEntrypoint { .add(NSE_Blocks.CYAN_LINOLEUM) .add(NSE_Blocks.CROSS_ORANGE_LINOLEUM) .add(NSE_Blocks.CROSS_BROWN_LINOLEUM); + + getOrCreateTagBuilder(BlockTags.SHOVEL_MINEABLE) + .add(NSE_Custom.LANDMINE); } } diff --git a/src/main/java/su/a71/new_soviet/blocks/LandMineBlock.java b/src/main/java/su/a71/new_soviet/blocks/LandMineBlock.java index 77abae4..a519d6f 100644 --- a/src/main/java/su/a71/new_soviet/blocks/LandMineBlock.java +++ b/src/main/java/su/a71/new_soviet/blocks/LandMineBlock.java @@ -17,9 +17,7 @@ import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3d; -import net.minecraft.util.math.random.Random; import net.minecraft.util.shape.VoxelShape; -import net.minecraft.util.shape.VoxelShapes; import net.minecraft.world.BlockView; import net.minecraft.world.World; import net.minecraft.world.WorldAccess; @@ -28,19 +26,14 @@ import net.minecraft.world.explosion.Explosion; import org.jetbrains.annotations.Nullable; import su.a71.new_soviet.NewSoviet; -import net.minecraft.block.BrushableBlock; -import net.minecraft.block.TorchBlock; -import net.minecraft.item.BrushItem; - - -public class LandMineBlock extends Block implements Waterloggable { +public class LandMineBlock extends HorizontalFacingBlock implements Waterloggable { public static final BooleanProperty WATERLOGGED; protected static final VoxelShape SHAPE; public LandMineBlock(Settings settings) { super(settings); - this.setDefaultState(this.stateManager.getDefaultState().with(WATERLOGGED, false)); + this.setDefaultState(this.stateManager.getDefaultState().with(WATERLOGGED, false).with(Properties.HORIZONTAL_FACING, Direction.NORTH)); } public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { @@ -71,24 +64,22 @@ public class LandMineBlock extends Block implements Waterloggable { public void onProjectileHit(World world, BlockState state, BlockHitResult hit, ProjectileEntity projectile) { if (!world.isClient) { BlockPos blockPos = hit.getBlockPos(); - if (projectile.canModifyAt(world, blockPos)) { + if (projectile.canModifyAt(world, blockPos)) explode(world, blockPos); - } } - } - // With a shovel, 25% chance of explosion on break + // We would have a 25% chance of explosion on break with a shovel, but I can't implement brushing yet. public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) { - if (!world.isClient() && !player.isCreative() && !(player.getHandItems().iterator().next().getItem() instanceof ShovelItem)) { - if (NewSoviet.RANDOM.nextBetween(1, 4) != 1) { - explode(world, pos); - } - } +// if (!world.isClient() && !player.isCreative() && !(player.getHandItems().iterator().next().getItem() instanceof ShovelItem)) { +// if (NewSoviet.RANDOM.nextBetween(1, 4) != 1) { +// explode(world, pos); +// } +// } super.onBreak(world, pos, state, player); } - // Only explode every 2/3rd of times to prevent instant explosion chains + // Only chain explode every 2/3rd of times to nerf instant long range explosions @Override public void onDestroyedByExplosion(World world, BlockPos pos, Explosion explosion) { if (!world.isClient) { @@ -100,7 +91,7 @@ public class LandMineBlock extends Block implements Waterloggable { super.onDestroyedByExplosion(world, pos, explosion); } - // Without a shovel, 80% chance of explosion on contact + // Without a shovel, 80% chance of explosion on breaking start @Override public void onBlockBreakStart(BlockState state, World world, BlockPos pos, PlayerEntity player) { if (!world.isClient() && !(player.getHandItems().iterator().next().getItem() instanceof ShovelItem)) @@ -130,7 +121,7 @@ public class LandMineBlock extends Block implements Waterloggable { @Nullable public BlockState getPlacementState(ItemPlacementContext ctx) { FluidState fluidState = ctx.getWorld().getFluidState(ctx.getBlockPos()); - return (BlockState)this.getDefaultState().with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER); + return (BlockState)this.getDefaultState().with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER).with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite()); } public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) { @@ -139,7 +130,7 @@ public class LandMineBlock extends Block implements Waterloggable { } protected void appendProperties(StateManager.Builder builder) { - builder.add(WATERLOGGED); + builder.add(WATERLOGGED, Properties.HORIZONTAL_FACING); } public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { diff --git a/src/main/java/su/a71/new_soviet/registration/NSE_Custom.java b/src/main/java/su/a71/new_soviet/registration/NSE_Custom.java index 31edb3a..de95104 100644 --- a/src/main/java/su/a71/new_soviet/registration/NSE_Custom.java +++ b/src/main/java/su/a71/new_soviet/registration/NSE_Custom.java @@ -5,6 +5,7 @@ import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder; +import net.minecraft.block.AbstractBlock; import net.minecraft.block.Block; import net.minecraft.block.MapColor; import net.minecraft.block.entity.BlockEntityType; @@ -44,7 +45,7 @@ public class NSE_Custom { public static final SirenBlock SIREN = new SirenBlock(); public static final SoundEvent SIREN_SOUND = SoundEvent.of(new Identifier(NewSoviet.MOD_ID, "siren_sound")); - public static final LandMineBlock LANDMINE = new LandMineBlock(FabricBlockSettings.create().mapColor(MapColor.LIGHT_GRAY)); + public static final LandMineBlock LANDMINE = new LandMineBlock(FabricBlockSettings.create().mapColor(MapColor.LIGHT_GRAY).offset(AbstractBlock.OffsetType.XZ).dynamicBounds().strength(3f, 2f)); private static final ItemGroup NSE_CUSTOM_TAB = FabricItemGroup.builder() .icon(() -> new ItemStack(TV)) diff --git a/src/main/resources/assets/new_soviet/blockstates/landmine.json b/src/main/resources/assets/new_soviet/blockstates/landmine.json index d6823f3..44fc0d4 100644 --- a/src/main/resources/assets/new_soviet/blockstates/landmine.json +++ b/src/main/resources/assets/new_soviet/blockstates/landmine.json @@ -1,7 +1,8 @@ { "variants": { - "": { - "model": "new_soviet:block/landmine" - } + "facing=north": { "model": "new_soviet:block/landmine", "uvlock": true }, + "facing=east": { "model": "new_soviet:block/landmine", "y": 90, "uvlock": false }, + "facing=south": { "model": "new_soviet:block/landmine", "y": 180, "uvlock": false }, + "facing=west": { "model": "new_soviet:block/landmine", "y": 270, "uvlock": false } } -} \ No newline at end of file +}