diff --git a/gradle.properties b/gradle.properties index 7e08599..d86b058 100644 --- a/gradle.properties +++ b/gradle.properties @@ -26,7 +26,7 @@ loader_version_range=[47,) # # Parchment is an unofficial project maintained by ParchmentMC, separate from Minecraft Forge. # Additional setup is needed to use their mappings, see https://parchmentmc.org/docs/getting-started -mapping_channel=official +mapping_channel=parchment # The mapping version to query from the mapping channel. # This must match the format required by the mapping channel. mapping_version=1.20.1 @@ -38,7 +38,7 @@ mod_name=Compressed TNT # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=All Rights Reserved # The mod version. See https://semver.org/ -mod_version=0.0.1 +mod_version=0.1.0 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/com/jenny/compressedtnt/Compressedtnt.java b/src/main/java/com/jenny/compressedtnt/Compressedtnt.java index 237be7a..aad0ccf 100644 --- a/src/main/java/com/jenny/compressedtnt/Compressedtnt.java +++ b/src/main/java/com/jenny/compressedtnt/Compressedtnt.java @@ -18,9 +18,7 @@ import net.minecraftforge.event.BuildCreativeModeTabContentsEvent; import net.minecraftforge.event.server.ServerStartingEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @@ -46,18 +44,26 @@ public class Compressedtnt { public static final RegistryObject TNT_8 = BLOCKS.register("tnt_8", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE), 8.0f, 80)); public static final RegistryObject TNT_8_ITEM = ITEMS.register("tnt_8", () -> new BlockItem(TNT_8.get(), new Item.Properties())); - public static final RegistryObject TNT_16 = BLOCKS.register("tnt_16", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE), 16.0f, 80)); + public static final RegistryObject TNT_16 = BLOCKS.register("tnt_16", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 16.0f, 80)); public static final RegistryObject TNT_16_ITEM = ITEMS.register("tnt_16", () -> new BlockItem(TNT_16.get(), new Item.Properties())); - public static final RegistryObject TNT_32 = BLOCKS.register("tnt_32", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE), 32.0f, 80)); + public static final RegistryObject TNT_32 = BLOCKS.register("tnt_32", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 32.0f, 80)); public static final RegistryObject TNT_32_ITEM = ITEMS.register("tnt_32", () -> new BlockItem(TNT_32.get(), new Item.Properties())); - public static final RegistryObject TNT_64 = BLOCKS.register("tnt_64", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE), 64.0f, 80)); + public static final RegistryObject TNT_64 = BLOCKS.register("tnt_64", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 64.0f, 80)); public static final RegistryObject TNT_64_ITEM = ITEMS.register("tnt_64", () -> new BlockItem(TNT_64.get(), new Item.Properties())); - public static final RegistryObject TNT_128 = BLOCKS.register("tnt_128", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE), 128.0f, 80)); + public static final RegistryObject TNT_128 = BLOCKS.register("tnt_128", () -> new strongerTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 128.0f, 80)); public static final RegistryObject TNT_128_ITEM = ITEMS.register("tnt_128", () -> new BlockItem(TNT_128.get(), new Item.Properties())); + public static final RegistryObject TNT_CLUSTER_2 = BLOCKS.register("tnt_cluster_2", () -> new ClusterTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 4.0f, 80, 2, 10)); + public static final RegistryObject TNT_CLUSTER__2ITEM = ITEMS.register("tnt_cluster_2", () -> new BlockItem(TNT_CLUSTER_2.get(), new Item.Properties())); + + public static final RegistryObject TNT_CLUSTER_4 = BLOCKS.register("tnt_cluster_4", () -> new ClusterTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 4.0f, 80, 4, 10)); + public static final RegistryObject TNT_CLUSTER_4_ITEM = ITEMS.register("tnt_cluster_4", () -> new BlockItem(TNT_CLUSTER_4.get(), new Item.Properties())); + + public static final RegistryObject TNT_CLUSTER_8 = BLOCKS.register("tnt_cluster_8", () -> new ClusterTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 4.0f, 80, 8, 10)); + public static final RegistryObject TNT_CLUSTER_8_ITEM = ITEMS.register("tnt_cluster_8", () -> new BlockItem(TNT_CLUSTER_8.get(), new Item.Properties())); public static final RegistryObject CREATIVE_TAB = CREATIVE_MODE_TABS.register("compressedtnt", () -> CreativeModeTab.builder().withTabsBefore(CreativeModeTabs.COMBAT).icon(() -> TNT_8_ITEM.get().getDefaultInstance()).displayItems((parameters, output) -> { output.accept(TNT_8.get()); @@ -65,6 +71,9 @@ public class Compressedtnt { output.accept(TNT_32.get()); output.accept(TNT_64.get()); output.accept(TNT_128.get()); + output.accept(TNT_CLUSTER_2.get()); + output.accept(TNT_CLUSTER_4.get()); + output.accept(TNT_CLUSTER_8.get()); }).title(Component.literal("Compressed TNT")).build()); public Compressedtnt() { diff --git a/src/main/java/com/jenny/compressedtnt/blocks/ClusterPrimedTNT.java b/src/main/java/com/jenny/compressedtnt/blocks/ClusterPrimedTNT.java new file mode 100644 index 0000000..4ac6e27 --- /dev/null +++ b/src/main/java/com/jenny/compressedtnt/blocks/ClusterPrimedTNT.java @@ -0,0 +1,25 @@ +package com.jenny.compressedtnt.blocks; + +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.item.PrimedTnt; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; + +import javax.annotation.Nullable; + +public class ClusterPrimedTNT extends PrimedTnt { + final float pRadius; + + public ClusterPrimedTNT (Level pLevel, double pX, double pY, double pZ, @Nullable LivingEntity pOwner, float pRadius, int fuseTime, Vec3 move) { + super(pLevel, pX, pY, pZ, pOwner); + this.pRadius = pRadius; + this.setFuse(fuseTime); + this.addDeltaMovement(move); + } + + @Override + protected void explode() { + float $$0 = pRadius; + this.level().explode(this, this.getX(), this.getY((double)0.0625F), this.getZ(), pRadius, Level.ExplosionInteraction.TNT); + } +} diff --git a/src/main/java/com/jenny/compressedtnt/blocks/ClusterTNTBlock.java b/src/main/java/com/jenny/compressedtnt/blocks/ClusterTNTBlock.java new file mode 100644 index 0000000..54ee9ff --- /dev/null +++ b/src/main/java/com/jenny/compressedtnt/blocks/ClusterTNTBlock.java @@ -0,0 +1,60 @@ +package com.jenny.compressedtnt.blocks; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; +import net.minecraft.util.RandomSource; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.TntBlock; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.gameevent.GameEvent; +import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.NotNull; + +import javax.annotation.Nullable; + +public class ClusterTNTBlock extends TntBlock { + public final float pRadius; + public final int fuseTime; + public final int childCount; + public final int childRange; + + public ClusterTNTBlock(BlockBehaviour.Properties p_57422_, float pRadius, int fuseTime, int childCount, int childRange) { + super(p_57422_); + this.pRadius = pRadius; + this.fuseTime = fuseTime; + this.childCount = childCount; + this.childRange = childRange; + } + + + public void onCaughtFire(@NotNull BlockState state, @NotNull Level world, @NotNull BlockPos pos, @Nullable Direction face, @Nullable LivingEntity igniter) { + explode(world, pos, igniter, this.pRadius, this.fuseTime, this.childCount, this.childRange); + } + + @Deprecated + public static void explode(Level p_57434_, BlockPos p_57435_, float pRadius, int fuseTime, int childCount, int childRange) { + explode(p_57434_, p_57435_, (LivingEntity)null, pRadius, fuseTime, childCount, childRange); + } + + @Deprecated + private static void explode(Level level, BlockPos blockPos, @Nullable LivingEntity entity, float pRadius, int fuseTime, int childCount, int childRange) { + RandomSource rng = level.getRandom(); + float offsetX, offsetZ; + if (!level.isClientSide) { + for (int i = 0; i < childCount; i++) { + offsetX = (float) rng.nextInt(- childRange, childRange + 1) / 15; + offsetZ = (float) rng.nextInt(- childRange, childRange + 1) / 15; + Vec3 move = new Vec3(offsetX, 0, offsetZ); + ClusterPrimedTNT primedtnt = new ClusterPrimedTNT(level, (double) blockPos.getX() + (double) 0.5F, (double) blockPos.getY(), (double) blockPos.getZ() + (double) 0.5F, entity, pRadius, fuseTime, move); + level.addFreshEntity(primedtnt); + level.gameEvent(entity, GameEvent.PRIME_FUSE, blockPos); + } + level.playSound((Player) null, blockPos.getX(), blockPos.getY(), blockPos.getZ(), SoundEvents.TNT_PRIMED, SoundSource.BLOCKS, 1.0F, 1.0F); + } + } +} diff --git a/src/main/java/com/jenny/compressedtnt/blocks/strongerTNTBlock.java b/src/main/java/com/jenny/compressedtnt/blocks/strongerTNTBlock.java index 8f2520c..b0296e2 100644 --- a/src/main/java/com/jenny/compressedtnt/blocks/strongerTNTBlock.java +++ b/src/main/java/com/jenny/compressedtnt/blocks/strongerTNTBlock.java @@ -34,7 +34,6 @@ public class strongerTNTBlock extends TntBlock { explode(p_57434_, p_57435_, (LivingEntity)null, pRadius, fuseTime); } - /** @deprecated */ @Deprecated private static void explode(Level p_57437_, BlockPos p_57438_, @Nullable LivingEntity p_57439_, float pRadius, int fuseTime) { if (!p_57437_.isClientSide) { diff --git a/src/main/java/com/jenny/compressedtnt/datagen/ModBlockStateProvider.java b/src/main/java/com/jenny/compressedtnt/datagen/ModBlockStateProvider.java index 21cad70..663d169 100644 --- a/src/main/java/com/jenny/compressedtnt/datagen/ModBlockStateProvider.java +++ b/src/main/java/com/jenny/compressedtnt/datagen/ModBlockStateProvider.java @@ -25,6 +25,9 @@ public class ModBlockStateProvider extends BlockStateProvider { sideTopBottom(Compressedtnt.TNT_32.get()); sideTopBottom(Compressedtnt.TNT_64.get()); sideTopBottom(Compressedtnt.TNT_128.get()); + sideTopBottom(Compressedtnt.TNT_CLUSTER_2.get()); + sideTopBottom(Compressedtnt.TNT_CLUSTER_4.get()); + sideTopBottom(Compressedtnt.TNT_CLUSTER_8.get()); } private void blockWithItem(RegistryObject blockRegistryObject) { diff --git a/src/main/resources/assets/compressedtnt/blockstates/tnt_cluster_2.json b/src/main/resources/assets/compressedtnt/blockstates/tnt_cluster_2.json new file mode 100644 index 0000000..a953723 --- /dev/null +++ b/src/main/resources/assets/compressedtnt/blockstates/tnt_cluster_2.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "compressedtnt:block/tnt_cluster_2" + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/compressedtnt/blockstates/tnt_cluster_4.json b/src/main/resources/assets/compressedtnt/blockstates/tnt_cluster_4.json new file mode 100644 index 0000000..f56c1fd --- /dev/null +++ b/src/main/resources/assets/compressedtnt/blockstates/tnt_cluster_4.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "compressedtnt:block/tnt_cluster_4" + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/compressedtnt/blockstates/tnt_cluster_8.json b/src/main/resources/assets/compressedtnt/blockstates/tnt_cluster_8.json new file mode 100644 index 0000000..e6d169c --- /dev/null +++ b/src/main/resources/assets/compressedtnt/blockstates/tnt_cluster_8.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "compressedtnt:block/tnt_cluster_8" + } + } +} \ No newline at end of file diff --git a/src/main/resources/data/compressedtnt/recipes/tnt_cluster_2.json b/src/main/resources/data/compressedtnt/recipes/tnt_cluster_2.json new file mode 100644 index 0000000..1050673 --- /dev/null +++ b/src/main/resources/data/compressedtnt/recipes/tnt_cluster_2.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "redstone", + "ingredients":[ + { + "item": "minecraft:tnt", + "count": 2 + } + ], + "result": { + "item": "compressedtnt:tnt_cluster_2" + } +} \ No newline at end of file diff --git a/src/main/resources/data/compressedtnt/recipes/tnt_cluster_4.json b/src/main/resources/data/compressedtnt/recipes/tnt_cluster_4.json new file mode 100644 index 0000000..bae3777 --- /dev/null +++ b/src/main/resources/data/compressedtnt/recipes/tnt_cluster_4.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "redstone", + "ingredients":[ + { + "item": "minecraft:tnt", + "count": 4 + } + ], + "result": { + "item": "compressedtnt:tnt_cluster_4" + } +} \ No newline at end of file diff --git a/src/main/resources/data/compressedtnt/recipes/tnt_cluster_4_from_c2.json b/src/main/resources/data/compressedtnt/recipes/tnt_cluster_4_from_c2.json new file mode 100644 index 0000000..c354ee2 --- /dev/null +++ b/src/main/resources/data/compressedtnt/recipes/tnt_cluster_4_from_c2.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "redstone", + "ingredients":[ + { + "item": "compressedtnt:tnt_cluster_2", + "count": 2 + } + ], + "result": { + "item": "compressedtnt:tnt_cluster_4" + } +} \ No newline at end of file diff --git a/src/main/resources/data/compressedtnt/recipes/tnt_cluster_8.json b/src/main/resources/data/compressedtnt/recipes/tnt_cluster_8.json new file mode 100644 index 0000000..e2edc0e --- /dev/null +++ b/src/main/resources/data/compressedtnt/recipes/tnt_cluster_8.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "redstone", + "ingredients":[ + { + "item": "minecraft:tnt", + "count": 8 + } + ], + "result": { + "item": "compressedtnt:tnt_cluster_8" + } +} \ No newline at end of file diff --git a/src/main/resources/data/compressedtnt/recipes/tnt_cluster_8_from_c2.json b/src/main/resources/data/compressedtnt/recipes/tnt_cluster_8_from_c2.json new file mode 100644 index 0000000..5f86a93 --- /dev/null +++ b/src/main/resources/data/compressedtnt/recipes/tnt_cluster_8_from_c2.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "redstone", + "ingredients":[ + { + "item": "compressedtnt:tnt_cluster_2", + "count": 4 + } + ], + "result": { + "item": "compressedtnt:tnt_cluster_8" + } +} \ No newline at end of file diff --git a/src/main/resources/data/compressedtnt/recipes/tnt_cluster_8_from_c4.json b/src/main/resources/data/compressedtnt/recipes/tnt_cluster_8_from_c4.json new file mode 100644 index 0000000..f2a5934 --- /dev/null +++ b/src/main/resources/data/compressedtnt/recipes/tnt_cluster_8_from_c4.json @@ -0,0 +1,13 @@ +{ + "type": "minecraft:crafting_shapeless", + "category": "redstone", + "ingredients":[ + { + "item": "compressedtnt:tnt_cluster_4", + "count": 2 + } + ], + "result": { + "item": "compressedtnt:tnt_cluster_8" + } +} \ No newline at end of file