Skip to content

Commit

Permalink
Configurable creeper confetti damage
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Dec 28, 2023
1 parent 63fed4c commit eae4ebc
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ public static class EntitiesCategory
@Config.Name("Collision Damage")
public final CollisionDamageCategory COLLISION_DAMAGE = new CollisionDamageCategory();

@Config.LangKey("cfg.universaltweaks.tweaks.entities.creeperconfetti")
@Config.Name("Creeper Confetti")
public final CreeperConfettiCategory CREEPER_CONFETTI = new CreeperConfettiCategory();

@Config.LangKey("cfg.universaltweaks.tweaks.entities.damagevelocity")
@Config.Name("Damage Velocity")
public final DamageVelocityCategory DAMAGE_VELOCITY = new DamageVelocityCategory();
Expand Down Expand Up @@ -331,12 +335,6 @@ public static class EntitiesCategory
@Config.RangeDouble(min = 0.0D, max = 1.0D)
public double utCreeperChargedChance = 0.0D;

@Config.RequiresMcRestart
@Config.Name("Creeper Confetti Spawning Chance")
@Config.Comment("Sets the chance to replace deadly creeper explosions with delightful confetti")
@Config.RangeDouble(min = 0.0D, max = 1.0D)
public double utCreeperConfettiChance = 0.0D;

@Config.RequiresMcRestart
@Config.Name("Critical Arrow Damage")
@Config.Comment
Expand Down Expand Up @@ -504,6 +502,19 @@ public static class CollisionDamageCategory
public int utCollisionDamageFactor = 10;
}

public static class CreeperConfettiCategory
{
@Config.RequiresMcRestart
@Config.Name("[1] Creeper Confetti Chance")
@Config.Comment("Sets the chance to replace deadly creeper explosions with delightful confetti")
@Config.RangeDouble(min = 0.0D, max = 1.0D)
public double utCreeperConfettiChance = 0.0D;

@Config.Name("[2] Creeper Confetti Damage")
@Config.Comment("Sets the damage dealt by confetti explosions")
public double utCreeperConfettiDamage = 0.0D;
}

public static class DamageVelocityCategory
{
@Config.RequiresMcRestart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ public boolean shouldMixinConfigQueue(String mixinConfig)
case "mixins.tweaks.entities.spawning.caps.json":
return UTConfigTweaks.ENTITIES.SPAWN_CAPS.utSpawnCapsToggle;
case "mixins.tweaks.entities.spawning.creeper.confetti.json":
return UTConfigTweaks.ENTITIES.utCreeperConfettiChance != 0.0D;
return UTConfigTweaks.ENTITIES.CREEPER_CONFETTI.utCreeperConfettiChance != 0.0D;
case "mixins.tweaks.entities.spawning.golem.json":
return UTConfigTweaks.ENTITIES.NO_GOLEMS.utNGIronGolemToggle || UTConfigTweaks.ENTITIES.NO_GOLEMS.utNGSnowGolemToggle || UTConfigTweaks.ENTITIES.NO_GOLEMS.utNGWitherToggle;
case "mixins.tweaks.entities.spawning.husk.json":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
Expand Down Expand Up @@ -43,7 +44,7 @@ public UTCreeperConfettiMixin(World worldIn)
@Inject(method = "explode", at = @At("HEAD"), cancellable = true)
public void utCreeperConfetti(CallbackInfo ci)
{
double chargedChance = UTConfigTweaks.ENTITIES.utCreeperConfettiChance;
double chargedChance = UTConfigTweaks.ENTITIES.CREEPER_CONFETTI.utCreeperConfettiChance;
if (chargedChance <= 0.0D || !UTRandomUtil.chance(chargedChance, new Random(this.getUniqueID().getMostSignificantBits() & Long.MAX_VALUE))) return;
if (UTConfigGeneral.DEBUG.utDebugToggle) UniversalTweaks.LOGGER.debug("UTCreeperConfetti ::: Explode");
if (this.world.isRemote) spawnParticles(this.getEntityWorld(), this.getPosition(), this.getPowered());
Expand All @@ -52,6 +53,7 @@ public void utCreeperConfetti(CallbackInfo ci)
this.dead = true;
this.setDead();
this.spawnLingeringCloud();
this.damagePlayers(((EntityCreeper) (Object) this));
}
ci.cancel();
}
Expand Down Expand Up @@ -85,6 +87,14 @@ public NBTTagCompound generateTag(boolean powered)
return fireworkItemTag;
}

@Unique
public void damagePlayers(EntityCreeper creeper)
{
float explosionStrength = (float) (creeper.getPowered() ? UTConfigTweaks.ENTITIES.CREEPER_CONFETTI.utCreeperConfettiDamage * 2 : UTConfigTweaks.ENTITIES.CREEPER_CONFETTI.utCreeperConfettiDamage);
Explosion explosion = new Explosion(creeper.getEntityWorld(), creeper, creeper.posX, creeper.posY, creeper.posZ, 3.0F * explosionStrength, false, false);
explosion.doExplosionA();
}

@Shadow
protected abstract void spawnLingeringCloud();
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static List<String> obsoleteModsMessage()
if (Loader.isModLoaded("collisiondamage") && UTConfigTweaks.ENTITIES.COLLISION_DAMAGE.utCollisionDamageToggle) messages.add("Collision Damage");
if (Loader.isModLoaded("configurablecane") && UTConfigTweaks.BLOCKS.utSugarCaneSize != 3) messages.add("Configurable Cane");
if (Loader.isModLoaded("continousmusic") && UTConfigTweaks.MISC.utInfiniteMusicToggle) messages.add("Infinite Music");
if (Loader.isModLoaded("creeperconfetti") && UTConfigTweaks.ENTITIES.utCreeperConfettiChance > 0) messages.add("Creeper Confetti");
if (Loader.isModLoaded("creeperconfetti") && UTConfigTweaks.ENTITIES.CREEPER_CONFETTI.utCreeperConfettiChance > 0) messages.add("Creeper Confetti");
if (Loader.isModLoaded("damagetilt") && UTConfigTweaks.MISC.utDamageTiltToggle) messages.add("Damage Tilt");
if (Loader.isModLoaded("darkstone") && UTConfigTweaks.PERFORMANCE.utRedstoneLightingToggle) messages.add("Dark Redstone");
if (Loader.isModLoaded("deuf") && UTConfigBugfixes.ENTITIES.utEntityUUIDToggle) messages.add("Duplicate Entity UUID Fix (DEUF)");
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/universaltweaks/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ cfg.universaltweaks.tweaks.blocks.sapling=Sapling Behavior
cfg.universaltweaks.tweaks.entities.attributes=Attributes
cfg.universaltweaks.tweaks.entities.betterburning=Better Burning
cfg.universaltweaks.tweaks.entities.collisiondamage=Collision Damage
cfg.universaltweaks.tweaks.entities.creeperconfetti=Creeper Confetti
cfg.universaltweaks.tweaks.entities.damagevelocity=Damage Velocity
cfg.universaltweaks.tweaks.entities.easybreeding=Easy Breeding
cfg.universaltweaks.tweaks.entities.nogolems=No Golems
Expand Down

0 comments on commit eae4ebc

Please sign in to comment.