ender tnt particles + more control over particle count
This commit is contained in:
parent
31306bb116
commit
129c27ba47
@ -1,8 +1,11 @@
|
||||
package com.jenny.enhancedexplosives.blocks;
|
||||
|
||||
import com.jenny.enhancedexplosives.entities.tnt.enderPrimedTNT;
|
||||
import com.jenny.enhancedexplosives.config.ConfigClient;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
@ -12,6 +15,7 @@ import net.minecraft.world.level.block.TntBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -47,6 +51,9 @@ public class enderTNTBlock extends TntBlock {
|
||||
level.gameEvent(entity, GameEvent.PRIME_FUSE, blockPos);
|
||||
}
|
||||
}
|
||||
else {
|
||||
spawnParticles(level, blockPos);
|
||||
}
|
||||
}
|
||||
|
||||
private static BlockPos getSpawnPos(Level level, BlockPos blockPos) {
|
||||
@ -82,5 +89,17 @@ public class enderTNTBlock extends TntBlock {
|
||||
level.addFreshEntity(primedtnt);
|
||||
}
|
||||
}
|
||||
else {
|
||||
spawnParticles(level, blockPos);
|
||||
}
|
||||
}
|
||||
|
||||
public static void spawnParticles(Level level, BlockPos blockPos) {
|
||||
for (int i = 1; i<=ConfigClient.calcPCount(30); i++) {
|
||||
float x = blockPos.getX() + (float) level.getRandom().nextIntBetweenInclusive(-10, 10) / 10 + 0.5F;
|
||||
float y = blockPos.getY() + (float) level.getRandom().nextIntBetweenInclusive(-10, 10) / 10;
|
||||
float z = blockPos.getZ() + (float) level.getRandom().nextIntBetweenInclusive(-10, 10) / 10 + 0.5F;
|
||||
level.addParticle(ParticleTypes.GLOW, x, y, z, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,19 +15,23 @@ public class ConfigClient {
|
||||
BUILDER.comment("weather to spawn client-side particles for arrows")
|
||||
.define("arrowParticles", true);
|
||||
|
||||
private static final ForgeConfigSpec.ConfigValue<Integer> C_ARROW_PARTICLE_COUNT =
|
||||
BUILDER.comment("amount of particles to spawn per arrow per tick")
|
||||
.define("arrowParticleCount", 3);
|
||||
private static final ForgeConfigSpec.ConfigValue<Float> C_PARTICLE_PERCENT =
|
||||
BUILDER.comment("amount of particles to spawn (0.0 = None, 1.0 = normal, values higher are valid too)")
|
||||
.define("arrowParticleCount", 1.0f);
|
||||
|
||||
public static final ForgeConfigSpec SPEC = BUILDER.build();
|
||||
|
||||
public static boolean arrowParticles;
|
||||
public static int arrowParticleCount;
|
||||
public static float particlePercent;
|
||||
|
||||
@SubscribeEvent
|
||||
static void onLoad(final ModConfigEvent event)
|
||||
{
|
||||
arrowParticles = C_ARROW_PARTICLES.get();
|
||||
arrowParticleCount = C_ARROW_PARTICLE_COUNT.get();
|
||||
particlePercent = C_PARTICLE_PERCENT.get();
|
||||
}
|
||||
|
||||
public static int calcPCount(int pCount) {
|
||||
return Math.round(pCount * particlePercent);
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class concussiveArrow extends baseArrow{
|
||||
|
||||
@Override
|
||||
public void spawnParticles(float partialTicks) {
|
||||
for (int i = 1; i <= ConfigClient.arrowParticleCount; i++) {
|
||||
for (int i = 1; i <= ConfigClient.calcPCount(3); i++) {
|
||||
Vec3 pos = getPosition(partialTicks);
|
||||
double x = pos.x + (double) level().getRandom().nextInt(-5, 6) / 10;
|
||||
double y = pos.y + (double) level().getRandom().nextInt(-5, 6) / 10;
|
||||
|
@ -46,7 +46,7 @@ public class tntArrow extends baseArrow {
|
||||
|
||||
@Override
|
||||
public void spawnParticles(float partialTicks) {
|
||||
for (int i = 1; i <= ConfigClient.arrowParticleCount; i++) {
|
||||
for (int i = 1; i <= ConfigClient.calcPCount(3); i++) {
|
||||
Vec3 pos = getPosition(partialTicks);
|
||||
double x = pos.x + (double) level().getRandom().nextInt(-5, 6) / 10;
|
||||
double y = pos.y + (double) level().getRandom().nextInt(-5, 6) / 10;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.jenny.enhancedexplosives;
|
||||
|
||||
import com.jenny.enhancedexplosives.particles.ArrowParticle;
|
||||
import com.jenny.enhancedexplosives.particles.particles;
|
||||
import com.jenny.enhancedexplosives.particles.arrow.*;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.client.event.RegisterParticleProvidersEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.jenny.enhancedexplosives.particles.arrow;
|
||||
package com.jenny.enhancedexplosives.particles;
|
||||
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.particle.*;
|
Loading…
x
Reference in New Issue
Block a user