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 9038033..9ef018d 100644 --- a/src/main/java/su/a71/new_soviet/blocks/LandMineBlock.java +++ b/src/main/java/su/a71/new_soviet/blocks/LandMineBlock.java @@ -30,11 +30,18 @@ import su.a71.new_soviet.NewSoviet; public class LandMineBlock extends HorizontalFacingBlock implements Waterloggable { public static final BooleanProperty WATERLOGGED; protected static final VoxelShape SHAPE; - public float explosion_power = 4.0f; + public float explosion_power; + public boolean creates_fire; + public World.ExplosionSourceType explosion_type; // None for no destruction, TNT for destruction + public boolean mob_detonation; - public LandMineBlock(Settings settings) { + public LandMineBlock(Settings settings, float explosion_power, World.ExplosionSourceType explosion_type, boolean creates_fire, boolean mob_detonation) { super(settings); this.setDefaultState(this.stateManager.getDefaultState().with(WATERLOGGED, false).with(Properties.HORIZONTAL_FACING, Direction.NORTH)); + this.explosion_type = explosion_type; + this.creates_fire = creates_fire; + this.explosion_power = explosion_power; + this.mob_detonation = mob_detonation; } public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { @@ -47,16 +54,20 @@ public class LandMineBlock extends HorizontalFacingBlock implements Waterloggabl @Override public void onLandedUpon(World world, BlockState state, BlockPos pos, Entity entity, float fallDistance) { - if (!world.isClient && entity.canModifyAt(world, pos)) { - explode(world, pos); + if (!world.isClient && entity.canModifyAt(world, pos) && (this.mob_detonation || entity instanceof PlayerEntity)) { + if (!((PlayerEntity) entity).isCreative()) { + explode(world, pos); + } } super.onLandedUpon(world, state, pos, entity, fallDistance); } @Override public void onSteppedOn(World world, BlockPos pos, BlockState state, Entity entity) { - if (!world.isClient) { - explode(world, pos); + if (!world.isClient && entity.canModifyAt(world, pos) && (this.mob_detonation || entity instanceof PlayerEntity)) { + if (!((PlayerEntity) entity).isCreative()) { + explode(world, pos); + } } super.onSteppedOn(world, pos, state, entity); } @@ -80,11 +91,11 @@ public class LandMineBlock extends HorizontalFacingBlock implements Waterloggabl super.onBreak(world, pos, state, player); } - // Only chain explode every 20% of times to prevent instant&long explosion chains + // Only chain explode every 10% of times to prevent instant&long explosion chains @Override public void onDestroyedByExplosion(World world, BlockPos pos, Explosion explosion) { if (!world.isClient) { - int chance = NewSoviet.RANDOM.nextBetween(1, 5); + int chance = NewSoviet.RANDOM.nextBetween(1, 10); if (chance == 1) { explode(world, pos); } @@ -106,7 +117,7 @@ public class LandMineBlock extends HorizontalFacingBlock implements Waterloggabl // On contact explode public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { - if (!world.isClient) { + if (!world.isClient && player.canModifyAt(world, pos)) { explode(world, pos); } return ActionResult.success(world.isClient); @@ -115,7 +126,7 @@ public class LandMineBlock extends HorizontalFacingBlock implements Waterloggabl public void explode(World world, BlockPos pos) { if (world.isClient()) return; world.removeBlock(pos, false); - world.createExplosion(null, pos.getX(), pos.getY(), pos.getZ(), explosion_power, World.ExplosionSourceType.TNT); + world.createExplosion(null, pos.getX(), pos.getY(), pos.getZ(), explosion_power, creates_fire, explosion_type); } @Nullable 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 91f2bab..1ca351c 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 @@ -17,6 +17,7 @@ import net.minecraft.util.DyeColor; import net.minecraft.util.Identifier; import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.world.World; import su.a71.new_soviet.NewSoviet; import su.a71.new_soviet.blocks.*; import su.a71.new_soviet.blocks.lamps.GoldenTableLampBlock; @@ -71,7 +72,9 @@ public class NSE_Custom extends NSE_BaseRegistration { public static final SirenBlock SIREN = new SirenBlock(); - public static final LandMineBlock LANDMINE = new LandMineBlock(FabricBlockSettings.create().mapColor(MapColor.LIGHT_GRAY).offset(AbstractBlock.OffsetType.XZ).dynamicBounds()); + // incendiary - creates fire + // HE - destroys blocks + public static final LandMineBlock AP_LANDMINE = new LandMineBlock(FabricBlockSettings.create().mapColor(MapColor.LIGHT_GRAY).offset(AbstractBlock.OffsetType.XZ).dynamicBounds(), 4.0f, World.ExplosionSourceType.NONE, false, false); public static final CheckerBlock WHITE_CHECKER = new CheckerBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.DECORATED_POT).hardness(0.1f).nonOpaque().mapColor(MapColor.WHITE)); public static final CheckerBlock BLACK_CHECKER = new CheckerBlock(FabricBlockSettings.create().sounds(BlockSoundGroup.DECORATED_POT).hardness(0.1f).nonOpaque().mapColor(MapColor.BLACK)); @@ -114,7 +117,7 @@ public class NSE_Custom extends NSE_BaseRegistration { registerBlock("lamp_post_base", () -> LAMP_POST_BASE, NSE_CUSTOM_TAB); registerBlock("ceiling_fan", () -> CEILING_FAN, NSE_CUSTOM_TAB); registerBlock("siren", () -> SIREN, NSE_CUSTOM_TAB); - registerBlock("landmine", () -> LANDMINE, NSE_CUSTOM_TAB); + registerBlock("ap_landmine", () -> AP_LANDMINE, NSE_CUSTOM_TAB); registerBlock("switch", () -> SWITCH, NSE_CUSTOM_TAB); registerBlock("dark_switch", () -> DARK_SWITCH, NSE_CUSTOM_TAB); registerBlock("white_checker", () -> WHITE_CHECKER, NSE_CUSTOM_TAB); diff --git a/src/main/resources/assets/new_soviet/blockstates/landmine.json b/src/main/resources/assets/new_soviet/blockstates/ap_landmine.json similarity index 100% rename from src/main/resources/assets/new_soviet/blockstates/landmine.json rename to src/main/resources/assets/new_soviet/blockstates/ap_landmine.json diff --git a/src/main/resources/assets/new_soviet/lang/en_us.json b/src/main/resources/assets/new_soviet/lang/en_us.json index 443b837..70182dd 100644 --- a/src/main/resources/assets/new_soviet/lang/en_us.json +++ b/src/main/resources/assets/new_soviet/lang/en_us.json @@ -469,5 +469,9 @@ "block.new_soviet.barbed_wire": "Barbed Wire", "advancement.new_soviet.root.name": "A New Era", - "advancement.new_soviet.root.desc": "Time to create something great" + "advancement.new_soviet.root.desc": "Time to create something great", + "advancement.new_soviet.sickle.name": "Tool of a worker", + "advancement.new_soviet.sickle.desc": "Acquire a sickle", + "advancement.new_soviet.sickle_kill.name": "Kolkhoz Warrior", + "advancement.new_soviet.sickle_kill.desc": "Kill someone with a sickle" } \ No newline at end of file diff --git a/src/main/resources/assets/new_soviet/models/item/landmine.json b/src/main/resources/assets/new_soviet/models/item/ap_landmine.json similarity index 100% rename from src/main/resources/assets/new_soviet/models/item/landmine.json rename to src/main/resources/assets/new_soviet/models/item/ap_landmine.json