This commit is contained in:
Jenny committed 2025-08-17 11:38:54 +02:00
1 parent f91e44e846
commit 0b57f36d41
28 files changed
+396 -105

No files matched your search

@@ -1,16 +1,19 @@
package com.jenny.enhancedexplosives;
import com.jenny.enhancedexplosives.entities.entities;
import com.jenny.enhancedexplosives.particles.ArrowParticle;
import com.jenny.enhancedexplosives.particles.particles;
import net.minecraft.client.Minecraft;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.RegisterParticleProvidersEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import static com.jenny.enhancedexplosives.EnhancedExplosives.MODID;
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class eventBusEvents {
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class ClientEvents {
@SubscribeEvent
public static void registerParticleFactories(final RegisterParticleProvidersEvent event) {
Minecraft.getInstance().particleEngine.register(particles.CONCUSSIVE_ARROW_PARTICLE.get(),
@@ -22,4 +25,9 @@ public class eventBusEvents {
Minecraft.getInstance().particleEngine.register(particles.TUNNEL_ARROW_PARTICLE.get(),
ArrowParticle.Provider::new);
}
@SubscribeEvent
public static void onClientSetup(FMLClientSetupEvent event) {
entities.registerRenderers();
}
}
@@ -7,7 +7,6 @@ import com.jenny.enhancedexplosives.entities.entities;
import com.jenny.enhancedexplosives.items.items;
import com.jenny.enhancedexplosives.particles.particles;
import com.mojang.logging.LogUtils;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.server.ServerStartingEvent;
import net.minecraftforge.eventbus.api.IEventBus;
@@ -15,7 +14,6 @@ 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;
import org.slf4j.Logger;
@@ -54,14 +52,4 @@ public class EnhancedExplosives {
public void onServerStarting(ServerStartingEvent event) {
}
// You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public static class ClientModEvents {
@SubscribeEvent
public static void onClientSetup(FMLClientSetupEvent event) {
entities.registerRenderers();
}
}
}
@@ -0,0 +1,59 @@
package com.jenny.enhancedexplosives.blocks;
import com.jenny.enhancedexplosives.entities.tnt.bedrockPrimedTNT;
import com.jenny.enhancedexplosives.entities.tnt.selectivePrimedTNT;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.TntBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.gameevent.GameEvent;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
public class bedrockTNTBlock extends TntBlock {
public final float pRadius;
public final int fuseTime;
public bedrockTNTBlock(Properties p_57422_, float pRadius, int fuseTime) {
super(p_57422_);
this.pRadius = pRadius;
this.fuseTime = fuseTime;
}
@Override
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);
}
@Deprecated
public static void explode(Level p_57434_, BlockPos p_57435_, float pRadius, int fuseTime) {
explode(p_57434_, p_57435_, (LivingEntity)null, pRadius, fuseTime);
}
@Deprecated
private static void explode(Level p_57437_, BlockPos p_57438_, @Nullable LivingEntity p_57439_, float pRadius, int fuseTime) {
if (!p_57437_.isClientSide) {
bedrockPrimedTNT primedtnt = new bedrockPrimedTNT(p_57437_, (double)p_57438_.getX() + (double)0.5F, (double)p_57438_.getY(), (double)p_57438_.getZ() + (double)0.5F, p_57439_, pRadius, fuseTime);
p_57437_.addFreshEntity(primedtnt);
p_57437_.playSound((Player)null, primedtnt.getX(), primedtnt.getY(), primedtnt.getZ(), SoundEvents.TNT_PRIMED, SoundSource.BLOCKS, 1.0F, 1.0F);
p_57437_.gameEvent(p_57439_, GameEvent.PRIME_FUSE, p_57438_);
}
}
@Override
public void wasExploded(Level level, @NotNull BlockPos blockPos, @NotNull Explosion pExplosion) {
if (!level.isClientSide) {
int ft = (short) (level.random.nextInt(fuseTime / 4) + fuseTime / 8);
bedrockPrimedTNT primedtnt = new bedrockPrimedTNT(level, (double) blockPos.getX() + (double) 0.5F, (double) blockPos.getY(), (double) blockPos.getZ() + (double) 0.5F, pExplosion.getIndirectSourceEntity(), pRadius, ft);
level.addFreshEntity(primedtnt);
}
}
}
@@ -61,6 +61,12 @@ public class blocks {
public static final RegistryObject<Block> TNT_REPULSIVE = BLOCKS.register("tnt_repulsive", () -> new repulsiveTNTBlock(DEFAULT_PROPS, 4.0f, 80, 1));
public static final RegistryObject<Item> TNT_REPULSIVE_ITEM = ITEMS.register("tnt_repulsive", () -> new BlockItemTooltip(TNT_REPULSIVE.get(), new Item.Properties()));
public static final RegistryObject<Block> TNT_BEDROCK = BLOCKS.register("tnt_bedrock", () -> new bedrockTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 4.0f, 80));
public static final RegistryObject<Item> TNT_BEDROCK_ITEM = ITEMS.register("tnt_bedrock", () -> new BlockItemTooltip(TNT_BEDROCK.get(), new Item.Properties()));
public static final RegistryObject<Block> TNT_ENTITY = BLOCKS.register("tnt_entity", () -> new entityTNTBlock(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_RED), 4.0f, 80));
public static final RegistryObject<Item> TNT_ENTITY_ITEM = ITEMS.register("tnt_entity", () -> new BlockItemTooltip(TNT_ENTITY.get(), new Item.Properties()));
public static void register(IEventBus bus) {
BLOCKS.register(bus);
@@ -0,0 +1,59 @@
package com.jenny.enhancedexplosives.blocks;
import com.jenny.enhancedexplosives.entities.tnt.EntityPrimedTNT;
import com.jenny.enhancedexplosives.entities.tnt.bedrockPrimedTNT;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.TntBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.gameevent.GameEvent;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
public class entityTNTBlock extends TntBlock {
public final float pRadius;
public final int fuseTime;
public entityTNTBlock(Properties p_57422_, float pRadius, int fuseTime) {
super(p_57422_);
this.pRadius = pRadius;
this.fuseTime = fuseTime;
}
@Override
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);
}
@Deprecated
public static void explode(Level p_57434_, BlockPos p_57435_, float pRadius, int fuseTime) {
explode(p_57434_, p_57435_, (LivingEntity)null, pRadius, fuseTime);
}
@Deprecated
private static void explode(Level p_57437_, BlockPos p_57438_, @Nullable LivingEntity p_57439_, float pRadius, int fuseTime) {
if (!p_57437_.isClientSide) {
EntityPrimedTNT primedtnt = new EntityPrimedTNT(p_57437_, (double)p_57438_.getX() + (double)0.5F, (double)p_57438_.getY(), (double)p_57438_.getZ() + (double)0.5F, p_57439_, pRadius, fuseTime);
p_57437_.addFreshEntity(primedtnt);
p_57437_.playSound((Player)null, primedtnt.getX(), primedtnt.getY(), primedtnt.getZ(), SoundEvents.TNT_PRIMED, SoundSource.BLOCKS, 1.0F, 1.0F);
p_57437_.gameEvent(p_57439_, GameEvent.PRIME_FUSE, p_57438_);
}
}
@Override
public void wasExploded(Level level, @NotNull BlockPos blockPos, @NotNull Explosion pExplosion) {
if (!level.isClientSide) {
int ft = (short) (level.random.nextInt(fuseTime / 4) + fuseTime / 8);
EntityPrimedTNT primedtnt = new EntityPrimedTNT(level, (double) blockPos.getX() + (double) 0.5F, (double) blockPos.getY(), (double) blockPos.getZ() + (double) 0.5F, pExplosion.getIndirectSourceEntity(), pRadius, ft);
level.addFreshEntity(primedtnt);
}
}
}
@@ -31,6 +31,8 @@ public class ModBlockStateProvider extends BlockStateProvider {
sideTopBottom(blocks.TNT_128);
sideTopBottom(blocks.TNT_ENDER);
sideTopBottom(blocks.TNT_CLAYMORE);
sideTopBottom(blocks.TNT_BEDROCK);
sideTopBottom(blocks.TNT_ENTITY);
SideTop(blocks.TNT_BLACK_HOLE);
SideTop(blocks.TNT_REPULSIVE);
SideOnlyTNT(blocks.TNT_CLUSTER_2);
@@ -36,7 +36,6 @@ public class tntArrow extends baseArrow {
@Override
public void spawnParticles(float partialTicks) {
for (int i = 1; i <= ConfigClient.calcPCount(5); i++) {
double m = (double) level().getRandom().nextIntBetweenInclusive(- 100, 100) / 100;
Vec3 DeltaMovement = getDeltaMovement();
Vec3 pos = particlePos(0.5);
level().addParticle(particles.TNT_ARROW_PARTICLE.get(), pos.x, pos.y, pos.z, DeltaMovement.x, DeltaMovement.y, DeltaMovement.z);
@@ -50,6 +50,15 @@ public class entities {
ENTITY_TYPES.register("tnt_repulsive", () -> EntityType.Builder.<repulsivePrimedTNT>of(repulsivePrimedTNT::new, MobCategory.MISC)
.fireImmune().sized(0.98F, 0.98F).clientTrackingRange(10).updateInterval(10).build("tnt_repulsive"));
public static final RegistryObject<EntityType<bedrockPrimedTNT>> TNT_BEDROCK =
ENTITY_TYPES.register("tnt_bedrock", () -> EntityType.Builder.<bedrockPrimedTNT>of(bedrockPrimedTNT::new, MobCategory.MISC)
.sized(0.98F, 0.7F).fireImmune().clientTrackingRange(8).build("tnt_bedrock"));
public static final RegistryObject<EntityType<EntityPrimedTNT>> TNT_ENTITY =
ENTITY_TYPES.register("tnt_entity", () -> EntityType.Builder.<EntityPrimedTNT>of(EntityPrimedTNT::new, MobCategory.MISC)
.sized(0.98F, 0.7F).fireImmune().clientTrackingRange(8).build("tnt_entity"));
public static final RegistryObject<EntityType<tntArrow>> ARROW_TNT =
ENTITY_TYPES.register("arrow_tnt", () -> EntityType.Builder.<tntArrow>of(tntArrow::new, MobCategory.MISC)
.sized(0.48F, 0.48F).clientTrackingRange(64).build("arrow_tnt"));
@@ -89,6 +98,8 @@ public class entities {
EntityRenderers.register(TNT_CLAYMORE.get(), BaseTNTRenderer::new);
EntityRenderers.register(TNT_ENDER.get(), BaseTNTRenderer::new);
EntityRenderers.register(TNT_REPULSIVE.get(), BaseTNTRenderer::new);
EntityRenderers.register(TNT_BEDROCK.get(), BaseTNTRenderer::new);
EntityRenderers.register(TNT_ENTITY.get(), BaseTNTRenderer::new);
EntityRenderers.register(TNT_SELECTIVE.get(), SelectiveTNTRenderer::new);
@@ -0,0 +1,53 @@
package com.jenny.enhancedexplosives.entities.tnt;
import com.jenny.enhancedexplosives.blocks.blocks;
import com.jenny.enhancedexplosives.entities.entities;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.ExplosionDamageCalculator;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
import java.util.Objects;
public class EntityPrimedTNT extends basePrimedTNT {
static class noEntityExplosionCalculator extends ExplosionDamageCalculator {
public boolean shouldBlockExplode(@NotNull Explosion pExplosion, @NotNull BlockGetter pReader, @NotNull BlockPos pPos, @NotNull BlockState pState, float pPower) {
return false;
}
}
public EntityPrimedTNT(Level pLevel, double pX, double pY, double pZ, @Nullable LivingEntity pOwner, float power, int fuse) {
super(entities.TNT_ENTITY.get(), pLevel, pOwner, new Vec3(pX, pY, pZ), fuse, power);
}
public EntityPrimedTNT(EntityType<EntityPrimedTNT> entityType, Level level) {
super(entityType, level, null);
}
@Override
protected void explode() {
noEntityExplosionCalculator dmgCalc = new noEntityExplosionCalculator();
this.level().explode(this, null, dmgCalc, position(), getPower(), false, Level.ExplosionInteraction.TNT);
}
public BlockPos getBlockBelow() {
return new BlockPos((int) Math.floor(getX()), (int) Math.floor(getY()) - 1, (int) Math.floor(getZ()));
}
public String getBlock() {
return level().getBlockState(getBlockBelow()).getBlock().toString();
}
@Override
public Block renderBlock() {
return blocks.TNT_ENTITY.get();
}
}
@@ -0,0 +1,61 @@
package com.jenny.enhancedexplosives.entities.tnt;
import com.jenny.enhancedexplosives.blocks.blocks;
import com.jenny.enhancedexplosives.entities.entities;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.ExplosionDamageCalculator;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
import java.util.Objects;
public class bedrockPrimedTNT extends basePrimedTNT {
static class noExplosionCalculator extends ExplosionDamageCalculator {
public boolean shouldBlockExplode(@NotNull Explosion pExplosion, @NotNull BlockGetter pReader, @NotNull BlockPos pPos, @NotNull BlockState pState, float pPower) {
return false;
}
}
public bedrockPrimedTNT(Level pLevel, double pX, double pY, double pZ, @Nullable LivingEntity pOwner, float power, int fuse) {
super(entities.TNT_BEDROCK.get(), pLevel, pOwner, new Vec3(pX, pY, pZ), fuse, power);
}
public bedrockPrimedTNT(EntityType<bedrockPrimedTNT> entityType, Level level) {
super(entityType, level, null);
}
@Override
protected void explode() {
noExplosionCalculator dmgCalc = new noExplosionCalculator();
this.level().explode(this, null, dmgCalc, position(), getPower(), false, Level.ExplosionInteraction.TNT);
explodeBelow();
}
public BlockPos getBlockBelow() {
return new BlockPos((int) Math.floor(getX()), (int) Math.floor(getY()) - 1, (int) Math.floor(getZ()));
}
public String getBlock() {
return level().getBlockState(getBlockBelow()).getBlock().toString();
}
private void explodeBelow()
{
if (Objects.equals(getBlock(), Blocks.BEDROCK.toString())) {
level().destroyBlock(getBlockBelow(), false);
}
}
@Override
public Block renderBlock() {
return blocks.TNT_BEDROCK.get();
}
}