client config rewrite

This commit is contained in:
Jenny 2025-02-12 12:57:56 +01:00
parent 5c5ab8c3dc
commit 89a7ea18db
Signed by: Jenny
GPG Key ID: 2072A14E40940632
9 changed files with 22 additions and 34 deletions

View File

@ -38,7 +38,7 @@ mod_name=Enhanced Explosives
# 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.13.0
mod_version=0.13.1
# 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

View File

@ -1,8 +1,7 @@
package com.jenny.enhancedexplosives.blocks;
import com.jenny.enhancedexplosives.entities.tnt.enderPrimedTNT;
import com.jenny.enhancedexplosives.config.ConfigClient;
import com.jenny.enhancedexplosives.entities.tnt.enderPrimedTNT;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.particles.ParticleTypes;
@ -15,7 +14,6 @@ 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;
@ -95,7 +93,7 @@ public class enderTNTBlock extends TntBlock {
}
public static void spawnParticles(Level level, BlockPos blockPos) {
if (ConfigClient.tntParticles) {
if (ConfigClient.tntParticles.get()) {
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;

View File

@ -1,6 +1,5 @@
package com.jenny.enhancedexplosives.blocks;
import com.jenny.enhancedexplosives.entities.tnt.blackHolePrimedTNT;
import com.jenny.enhancedexplosives.entities.tnt.repulsivePrimedTNT;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;

View File

@ -1,42 +1,37 @@
package com.jenny.enhancedexplosives.config;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.config.ModConfigEvent;
import static com.jenny.enhancedexplosives.EnhancedExplosives.MODID;
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class ConfigClient {
private static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
public static final ForgeConfigSpec SPEC;
private static final ForgeConfigSpec.ConfigValue<Boolean> C_ARROW_PARTICLES =
BUILDER.comment("whether to spawn client-side particles for arrows")
.define("arrowParticles", true);
public static final ForgeConfigSpec.ConfigValue<Boolean> arrowParticles;
public static final ForgeConfigSpec.ConfigValue<Boolean> tntParticles;
private static final ForgeConfigSpec.ConfigValue<Double> particlePercent;
private static final ForgeConfigSpec.ConfigValue<Boolean> C_TNT_PARTICLES =
BUILDER.comment("weather to spawn client-side particles for tnt")
.define("tntParticles", true);
static {
private static final ForgeConfigSpec.ConfigValue<Double> C_PARTICLE_PERCENT =
BUILDER.comment("amount of particles to spawn (0.0 = None, 1.0 = normal, values higher are valid too)")
.define("arrowParticleCount", 1.0D);
public static final ForgeConfigSpec SPEC = BUILDER.build();
arrowParticles =
BUILDER.comment("particles from arrows arrows")
.define("arrow_particles", true);
tntParticles =
BUILDER.comment("particles from tnt")
.define("tnt_particles", true);
particlePercent =
BUILDER.comment("amount of spawned particles (0.0 = None, 1.0 = normal, values higher are valid too)")
.define("particle_amount", 1.0D);
public static boolean arrowParticles, tntParticles;
public static float particlePercent;
SPEC = BUILDER.build();
@SubscribeEvent
static void onLoad(final ModConfigEvent event)
{
arrowParticles = C_ARROW_PARTICLES.get();
tntParticles = C_TNT_PARTICLES.get();
particlePercent = C_PARTICLE_PERCENT.get().floatValue();
}
public static int calcPCount(int pCount) {
return Math.round(pCount * particlePercent);
return (int) Math.round(pCount * particlePercent.get());
}
}

View File

@ -1,5 +1,6 @@
package com.jenny.enhancedexplosives.entities.arrows;
import com.jenny.enhancedexplosives.config.ConfigClient;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.projectile.AbstractArrow;
@ -26,7 +27,7 @@ public class baseArrow extends AbstractArrow {
public void tick() {
super.tick();
if (this.level().isClientSide) {
if (!this.inGround) {
if (!this.inGround && ConfigClient.arrowParticles.get()) {
spawnParticles(0);
}
this.tick++;

View File

@ -1,6 +1,5 @@
package com.jenny.enhancedexplosives.entities.client;
import com.jenny.enhancedexplosives.config.ConfigClient;
import com.jenny.enhancedexplosives.entities.tnt.basePrimedTNT;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;

View File

@ -1,8 +1,6 @@
package com.jenny.enhancedexplosives.entities.client;
import com.jenny.enhancedexplosives.entities.arrows.baseArrow;
import com.jenny.enhancedexplosives.config.*;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;
import net.minecraft.client.renderer.MultiBufferSource;
@ -13,7 +11,6 @@ import net.minecraft.client.renderer.entity.TntMinecartRenderer;
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Blocks;
import org.jetbrains.annotations.NotNull;
public class TNTArrowRenderer extends EntityRenderer<baseArrow> {

View File

@ -2,7 +2,6 @@ package com.jenny.enhancedexplosives.entities.throwable;
import com.jenny.enhancedexplosives.entities.entities;
import com.jenny.enhancedexplosives.entities.tnt.basePrimedTNT;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;

View File

@ -67,7 +67,7 @@ public abstract class basePrimedTNT extends Entity implements TraceableEntity {
public void tick() {
if (level().isClientSide) {
if (ConfigClient.tntParticles) {
if (ConfigClient.tntParticles.get()) {
spawnParticles();
}
}