Allow modifying mob burning behavior
This commit is contained in:
parent
261ad5e69a
commit
ecb58ffa76
|
@ -1,6 +1,9 @@
|
||||||
package io.gitlab.jfronny.combit;
|
package io.gitlab.jfronny.combit;
|
||||||
|
|
||||||
import io.gitlab.jfronny.libjf.config.api.*;
|
import io.gitlab.jfronny.libjf.config.api.Entry;
|
||||||
|
import io.gitlab.jfronny.libjf.config.api.JfConfig;
|
||||||
|
import io.gitlab.jfronny.libjf.config.api.Preset;
|
||||||
|
import io.gitlab.jfronny.libjf.config.api.Verifier;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
import net.minecraft.entity.damage.DamageSource;
|
import net.minecraft.entity.damage.DamageSource;
|
||||||
|
|
||||||
|
@ -8,28 +11,33 @@ import java.util.HashSet;
|
||||||
|
|
||||||
public class CombitConfig implements JfConfig {
|
public class CombitConfig implements JfConfig {
|
||||||
// Invulnerability
|
// Invulnerability
|
||||||
@Entry public static Integer iFrameInterval = 0;
|
@Entry public static Integer iFrameInterval = -1;
|
||||||
@Entry(min=Double.MIN_VALUE, max = 1) public static Double attackCancelThreshold = 0.1;
|
@Entry(min=-1, max = 1) public static Double attackCancelThreshold = -1d;
|
||||||
@Entry(min=Double.MIN_VALUE, max = 1) public static Double knockbackCancelThreshold = 0.75;
|
@Entry(min=-1, max = 1) public static Double knockbackCancelThreshold = -1d;
|
||||||
@Entry public static HashSet<String> attackerWhitelist = null;
|
@Entry public static HashSet<String> attackerWhitelist = null;
|
||||||
@Entry public static HashSet<String> damageSourceWhitelist = null;
|
@Entry public static HashSet<String> damageSourceWhitelist = null;
|
||||||
@Entry public static HashSet<String> targetEntityWhitelist = null;
|
@Entry public static HashSet<String> targetEntityWhitelist = null;
|
||||||
@Entry public static Boolean excludeAllMobs = false;
|
@Entry public static Boolean excludeAllMobs = false;
|
||||||
@Entry public static Boolean excludePlayers = false;
|
@Entry public static Boolean excludePlayers = false;
|
||||||
|
// Entity Modification
|
||||||
|
@Entry public static Boolean skeletonsBurn = true;
|
||||||
|
@Entry public static Boolean zombiesBurn = true;
|
||||||
|
@Entry public static Boolean creepersBurn = false;
|
||||||
|
@Entry public static Boolean creepersExplodeWhenBurning = false;
|
||||||
// Health
|
// Health
|
||||||
@Entry public static Double entityHealthFactor = 1.5;
|
@Entry public static Double entityHealthFactor = 1.5;
|
||||||
@Entry public static HashSet<String> entityHealthBlacklist = null;
|
@Entry public static HashSet<String> entityHealthBlacklist = null;
|
||||||
// Weapons
|
// Weapons
|
||||||
@Entry public static Double cooldownProgressOverride = 0.8;
|
@Entry public static Double cooldownProgressOverride = -1d;
|
||||||
@Entry public static Double cooldownProgressPerTickOverride = Double.MIN_VALUE;
|
@Entry public static Double cooldownProgressPerTickOverride = -1d;
|
||||||
@Entry public static Double weaponAttackDamageFactor = 0.6;
|
@Entry public static Double weaponAttackDamageFactor = 1d;
|
||||||
@Entry public static Double axeAttackDamageFactor = 0.5;
|
@Entry public static Double axeAttackDamageFactor = 1d;
|
||||||
// Knockback
|
// Knockback
|
||||||
@Entry public static Double snowballKnockbackFactor = -1.0;
|
@Entry public static Double snowballKnockbackFactor = 0d;
|
||||||
@Entry public static Float snowballDamage = 1.0f;
|
@Entry public static Float snowballDamage = 0f;
|
||||||
@Entry public static Double eggKnockbackFactor = -1.0;
|
@Entry public static Double eggKnockbackFactor = 0d;
|
||||||
@Entry public static Float eggDamage = 1.0f;
|
@Entry public static Float eggDamage = 0f;
|
||||||
@Entry public static Double fishingBobberPullFactor = 2.0;
|
@Entry public static Double fishingBobberPullFactor = 1d;
|
||||||
// Debug
|
// Debug
|
||||||
@Entry public static Boolean debug = FabricLoader.getInstance().isDevelopmentEnvironment();
|
@Entry public static Boolean debug = FabricLoader.getInstance().isDevelopmentEnvironment();
|
||||||
|
|
||||||
|
@ -70,36 +78,50 @@ public class CombitConfig implements JfConfig {
|
||||||
targetEntityWhitelist = null;
|
targetEntityWhitelist = null;
|
||||||
excludeAllMobs = false;
|
excludeAllMobs = false;
|
||||||
excludePlayers = false;
|
excludePlayers = false;
|
||||||
|
skeletonsBurn = true;
|
||||||
|
zombiesBurn = true;
|
||||||
|
creepersBurn = false;
|
||||||
|
creepersExplodeWhenBurning = false;
|
||||||
entityHealthFactor = 1.0;
|
entityHealthFactor = 1.0;
|
||||||
entityHealthBlacklist = null;
|
entityHealthBlacklist = null;
|
||||||
cooldownProgressOverride = 0.8;
|
cooldownProgressOverride = 0.8;
|
||||||
cooldownProgressPerTickOverride = Double.MIN_VALUE;
|
cooldownProgressPerTickOverride = Double.MIN_VALUE;
|
||||||
weaponAttackDamageFactor = 1.0;
|
weaponAttackDamageFactor = 1d;
|
||||||
axeAttackDamageFactor = 0.5;
|
axeAttackDamageFactor = 0.5;
|
||||||
snowballKnockbackFactor = 1.0;
|
snowballKnockbackFactor = 1d;
|
||||||
snowballDamage = 0.0f;
|
snowballDamage = 0f;
|
||||||
eggKnockbackFactor = 1.0;
|
eggKnockbackFactor = 1d;
|
||||||
eggDamage = 0.0f;
|
eggDamage = 0f;
|
||||||
fishingBobberPullFactor = 1.0;
|
fishingBobberPullFactor = 1d;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Preset public static void madness() {
|
||||||
|
iFrameInterval = 0;
|
||||||
|
attackCancelThreshold = 0d;
|
||||||
|
knockbackCancelThreshold = 0d;
|
||||||
|
attackerWhitelist = new HashSet<>();
|
||||||
|
damageSourceWhitelist = new HashSet<>();
|
||||||
|
targetEntityWhitelist = new HashSet<>();
|
||||||
|
excludeAllMobs = false;
|
||||||
|
excludePlayers = false;
|
||||||
|
skeletonsBurn = false;
|
||||||
|
zombiesBurn = false;
|
||||||
|
creepersBurn = true;
|
||||||
|
creepersExplodeWhenBurning = true;
|
||||||
|
entityHealthFactor = 10d;
|
||||||
|
entityHealthBlacklist = null;
|
||||||
|
cooldownProgressOverride = 1d;
|
||||||
|
cooldownProgressPerTickOverride = Double.MAX_VALUE;
|
||||||
|
weaponAttackDamageFactor = 0.5;
|
||||||
|
axeAttackDamageFactor = 5d;
|
||||||
|
snowballKnockbackFactor = -1d;
|
||||||
|
snowballDamage = 0f;
|
||||||
|
eggKnockbackFactor = -5d;
|
||||||
|
eggDamage = 1f;
|
||||||
|
fishingBobberPullFactor = 2d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Preset public static void noInvulnerability() {
|
@Preset public static void noInvulnerability() {
|
||||||
iFrameInterval = 0;
|
iFrameInterval = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Preset public static void disable() {
|
|
||||||
iFrameInterval = -1;
|
|
||||||
excludeAllMobs = true;
|
|
||||||
excludePlayers = true;
|
|
||||||
entityHealthFactor = 1.0;
|
|
||||||
cooldownProgressOverride = -1.0;
|
|
||||||
cooldownProgressPerTickOverride = -1.0;
|
|
||||||
weaponAttackDamageFactor = 1.0;
|
|
||||||
axeAttackDamageFactor = 1.0;
|
|
||||||
snowballKnockbackFactor = 0.0;
|
|
||||||
snowballDamage = 0f;
|
|
||||||
eggKnockbackFactor = 0.0;
|
|
||||||
eggDamage = 0.0f;
|
|
||||||
fishingBobberPullFactor = 1.0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package io.gitlab.jfronny.combit.mixin;
|
||||||
|
|
||||||
|
import io.gitlab.jfronny.combit.CombitConfig;
|
||||||
|
import net.minecraft.entity.EntityType;
|
||||||
|
import net.minecraft.entity.mob.AbstractSkeletonEntity;
|
||||||
|
import net.minecraft.entity.mob.HostileEntity;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
@Mixin(AbstractSkeletonEntity.class)
|
||||||
|
public class AbstractSkeletonEntityMixin extends HostileEntity {
|
||||||
|
protected AbstractSkeletonEntityMixin(EntityType<? extends HostileEntity> entityType, World world) {
|
||||||
|
super(entityType, world);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "tickMovement()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/mob/AbstractSkeletonEntity;isAffectedByDaylight()Z"))
|
||||||
|
private boolean redirectAffectedByDaylight(AbstractSkeletonEntity instance) {
|
||||||
|
return CombitConfig.skeletonsBurn && isAffectedByDaylight();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
package io.gitlab.jfronny.combit.mixin;
|
||||||
|
|
||||||
|
import io.gitlab.jfronny.combit.CombitConfig;
|
||||||
|
import net.minecraft.entity.EntityType;
|
||||||
|
import net.minecraft.entity.EquipmentSlot;
|
||||||
|
import net.minecraft.entity.mob.CreeperEntity;
|
||||||
|
import net.minecraft.entity.mob.HostileEntity;
|
||||||
|
import net.minecraft.entity.mob.PathAwareEntity;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(HostileEntity.class)
|
||||||
|
public class HostileEntityMixin extends PathAwareEntity {
|
||||||
|
protected HostileEntityMixin(EntityType<? extends PathAwareEntity> entityType, World world) {
|
||||||
|
super(entityType, world);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "tickMovement()V", at = @At("HEAD"))
|
||||||
|
private void creeperFireTick(CallbackInfo ci) {
|
||||||
|
if ((Object)this instanceof CreeperEntity ce) {
|
||||||
|
boolean shouldBurn = CombitConfig.creepersBurn && isAffectedByDaylight();
|
||||||
|
if (shouldBurn) {
|
||||||
|
ItemStack itemStack = getEquippedStack(EquipmentSlot.HEAD);
|
||||||
|
if (!itemStack.isEmpty()) {
|
||||||
|
if (itemStack.isDamageable()) {
|
||||||
|
itemStack.setDamage(itemStack.getDamage() + this.random.nextInt(2));
|
||||||
|
if (itemStack.getDamage() >= itemStack.getMaxDamage()) {
|
||||||
|
sendEquipmentBreakStatus(EquipmentSlot.HEAD);
|
||||||
|
equipStack(EquipmentSlot.HEAD, ItemStack.EMPTY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
shouldBurn = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shouldBurn) {
|
||||||
|
this.setOnFireFor(8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CombitConfig.creepersExplodeWhenBurning && isOnFire()) {
|
||||||
|
ce.ignite();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package io.gitlab.jfronny.combit.mixin;
|
||||||
|
|
||||||
|
import io.gitlab.jfronny.combit.CombitConfig;
|
||||||
|
import net.minecraft.entity.EntityType;
|
||||||
|
import net.minecraft.entity.mob.HostileEntity;
|
||||||
|
import net.minecraft.entity.mob.ZombieEntity;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
|
@Mixin(ZombieEntity.class)
|
||||||
|
public class ZombieEntityMixin extends HostileEntity {
|
||||||
|
protected ZombieEntityMixin(EntityType<? extends HostileEntity> entityType, World world) {
|
||||||
|
super(entityType, world);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "tickMovement()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/mob/ZombieEntity;isAffectedByDaylight()Z"))
|
||||||
|
private boolean redirectAffectedByDaylight(ZombieEntity instance) {
|
||||||
|
return CombitConfig.skeletonsBurn && isAffectedByDaylight();
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,6 +18,15 @@
|
||||||
"combit.jfconfig.excludePlayers": "Exclude Players",
|
"combit.jfconfig.excludePlayers": "Exclude Players",
|
||||||
"combit.jfconfig.excludePlayers.tooltip": "Still apply I-Frames to players",
|
"combit.jfconfig.excludePlayers.tooltip": "Still apply I-Frames to players",
|
||||||
|
|
||||||
|
"combit.jfconfig.skeletonsBurn": "Skeletons Burn",
|
||||||
|
"combit.jfconfig.skeletonsBurn.tooltip": "Causes Skeletons to burn in sunlight",
|
||||||
|
"combit.jfconfig.zombiesBurn": "Zombies Burn",
|
||||||
|
"combit.jfconfig.zombiesBurn.tooltip": "Causes Zombies to burn in sunlight",
|
||||||
|
"combit.jfconfig.creepersBurn": "Creepers Burn",
|
||||||
|
"combit.jfconfig.creepersBurn.tooltip": "Causes Creepers to burn in sunlight",
|
||||||
|
"combit.jfconfig.creepersExplodeWhenBurning": "Creepers explode when burning",
|
||||||
|
"combit.jfconfig.creepersExplodeWhenBurning.tooltip": "Causes creepers to explode when on fire. Do not combine with creepersBurn!",
|
||||||
|
|
||||||
"combit.jfconfig.entityHealthFactor": "Entity Health Factor",
|
"combit.jfconfig.entityHealthFactor": "Entity Health Factor",
|
||||||
"combit.jfconfig.entityHealthFactor.tooltip": "Factor to apply to the maximum health of entities",
|
"combit.jfconfig.entityHealthFactor.tooltip": "Factor to apply to the maximum health of entities",
|
||||||
"combit.jfconfig.entityHealthBlacklist": "Entity Health Blacklist",
|
"combit.jfconfig.entityHealthBlacklist": "Entity Health Blacklist",
|
||||||
|
@ -47,6 +56,6 @@
|
||||||
"combit.jfconfig.debug.tooltip": "Enable Debug Logging",
|
"combit.jfconfig.debug.tooltip": "Enable Debug Logging",
|
||||||
|
|
||||||
"combit.jfconfig.v189": "Minecraft 1.8.9",
|
"combit.jfconfig.v189": "Minecraft 1.8.9",
|
||||||
"combit.jfconfig.noInvulnerability": "No Invulnerability",
|
"combit.jfconfig.madness": "Pure Madness",
|
||||||
"combit.jfconfig.disable": "Disable"
|
"combit.jfconfig.noInvulnerability": "No Invulnerability"
|
||||||
}
|
}
|
|
@ -4,12 +4,15 @@
|
||||||
"package": "io.gitlab.jfronny.combit.mixin",
|
"package": "io.gitlab.jfronny.combit.mixin",
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
"AbstractSkeletonEntityMixin",
|
||||||
"EggEntityMixin",
|
"EggEntityMixin",
|
||||||
"FishingBobberEntityMixin",
|
"FishingBobberEntityMixin",
|
||||||
|
"HostileEntityMixin",
|
||||||
"LivingEntityMixin",
|
"LivingEntityMixin",
|
||||||
"MiningToolItemMixin",
|
"MiningToolItemMixin",
|
||||||
"PlayerEntityMixin",
|
"PlayerEntityMixin",
|
||||||
"SnowballEntityMixin"
|
"SnowballEntityMixin",
|
||||||
|
"ZombieEntityMixin"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
"InGameHudMixin"
|
"InGameHudMixin"
|
||||||
|
|
Loading…
Reference in New Issue