Add a config option for what enemies count as skeletons (#72)

This commit is contained in:
Nikolay S. authored and GitHub committed 2026-01-28 16:36:07 -06:00
1 parent c980b36e91
commit 704836810c
3 files changed
+41 -14

No files matched your search

@@ -80,6 +80,7 @@ public class Avaritia {
public void endGame(FMLPostInitializationEvent event) {
Compat.compatify();
Gregorizer.balance();
Config.postLoadConfigs();
if (Config.craftingOnly) return;
Mincer.countThoseCalories();
Achievements.achieve();
@@ -1,7 +1,9 @@
package fox.spiteful.avaritia;
import java.io.File;
import java.util.ArrayList;
import net.minecraft.entity.EntityLivingBase;
import net.minecraftforge.common.config.Configuration;
import org.apache.logging.log4j.Level;
@@ -16,6 +18,8 @@ public class Config {
public static boolean endestTileGriefing = true;
public static boolean fractured = false;
public static boolean fast = true;
public static String[] skeletonTypes = { "net.minecraft.entity.monster.EntitySkeleton" };
public static final ArrayList<Class<? extends EntityLivingBase>> skeletons = new ArrayList<>();
public static boolean stepUp = true;
public static boolean thaumic = true;
@@ -108,6 +112,13 @@ public class Config {
"Gotta Go Fast",
fast,
"Disable if the Infinity Boots' speed boost is too ridiculous").getBoolean(true);
skeletonTypes = conf
.get(
"general",
"Skeleton Types",
skeletonTypes,
"The list of class names of entities that count as skeletons for the Skullfire Sword.")
.getStringList();
stepUp = conf
.get("general", "Boots step up", stepUp, "Disable if the Infinity Boots' step assist is annoying")
.getBoolean(true);
@@ -173,4 +184,20 @@ public class Config {
conf.save();
}
}
public static void postLoadConfigs() {
skeletons.clear();
for (String className : skeletonTypes) {
try {
Class<?> clazz = Class.forName(className);
skeletons.add(clazz.asSubclass(EntityLivingBase.class));
} catch (ClassNotFoundException | ClassCastException e) {
Lumberjack.logger.warn(
"The \"Skeleton Types\" config contains the class name \"{}\", which does not represent a killable entity.",
className);
}
}
}
}
@@ -10,7 +10,6 @@ import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
@@ -104,7 +103,7 @@ public class LudicrousEvents {
&& ToolHelper.hammerdrops.containsKey(event.harvester)
&& ToolHelper.hammerdrops.get(event.harvester) != null) {
ArrayList<ItemStack> garbage = new ArrayList<ItemStack>();
ArrayList<ItemStack> garbage = new ArrayList<>();
for (ItemStack drop : event.drops) {
if (isGarbage(drop)) garbage.add(drop);
}
@@ -127,8 +126,8 @@ public class LudicrousEvents {
public static void extraLuck(HarvestDropsEvent event, int mult) {
if (event.block.getMaterial() == Material.rock) {
List<ItemStack> adds = new ArrayList<ItemStack>();
List<ItemStack> removals = new ArrayList<ItemStack>();
List<ItemStack> adds = new ArrayList<>();
List<ItemStack> removals = new ArrayList<>();
for (ItemStack drop : event.drops) {
if (drop.getItem() != Item.getItemFromBlock(event.block) && !(drop.getItem() instanceof ItemBlock)) {
drop.stackSize = Math.min(drop.stackSize * mult, drop.getMaxStackSize());
@@ -195,8 +194,7 @@ public class LudicrousEvents {
@SubscribeEvent
public void onGetHurt(LivingHurtEvent event) {
if (!(event.entityLiving instanceof EntityPlayer)) return;
EntityPlayer player = (EntityPlayer) event.entityLiving;
if (!(event.entityLiving instanceof EntityPlayer player)) return;
if (player.getHeldItem() != null && player.getHeldItem().getItem() == LudicrousItems.infinity_sword
&& player.isUsingItem())
event.setCanceled(true);
@@ -205,9 +203,8 @@ public class LudicrousEvents {
@SubscribeEvent
public void onAttacked(LivingAttackEvent event) {
if (!(event.entityLiving instanceof EntityPlayer)) return;
if (!(event.entityLiving instanceof EntityPlayer player)) return;
if (event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer) return;
EntityPlayer player = (EntityPlayer) event.entityLiving;
if (player.getHeldItem() != null && player.getHeldItem().getItem() == LudicrousItems.infinity_sword
&& player.isUsingItem())
event.setCanceled(true);
@@ -216,9 +213,7 @@ public class LudicrousEvents {
@SubscribeEvent
public void onLivingDrops(LivingDropsEvent event) {
if (event.recentlyHit && event.entityLiving instanceof EntitySkeleton
&& event.source.getEntity() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.source.getEntity();
if (event.recentlyHit && event.source.getEntity() instanceof EntityPlayer player && isSkeleton(event)) {
if (player.getHeldItem() != null && player.getHeldItem().getItem() == LudicrousItems.skull_sword) {
// ok, we need to drop a skull then.
if (event.drops.isEmpty()) {
@@ -229,6 +224,7 @@ public class LudicrousEvents {
for (int i = 0; i < event.drops.size(); i++) {
EntityItem drop = event.drops.get(i);
ItemStack stack = drop.getEntityItem();
if (stack.getItem() == Items.skull) {
if (stack.getItemDamage() == 1) {
skulls++;
@@ -248,6 +244,10 @@ public class LudicrousEvents {
}
}
private static boolean isSkeleton(LivingDropsEvent event) {
return Config.skeletons.contains(event.entityLiving.getClass());
}
@SubscribeEvent
public void diggity(BreakSpeed event) {
if (event.entityPlayer.getHeldItem() != null) {
@@ -259,7 +259,7 @@ public class LudicrousEvents {
event.newSpeed *= 5;
if (held.getTagCompound() != null) {
if (held.getTagCompound().getBoolean("hammer") || held.getTagCompound().getBoolean("destroyer")) {
event.newSpeed *= 0.5;
event.newSpeed *= 0.5f;
}
}
}
@@ -289,8 +289,7 @@ public class LudicrousEvents {
@SubscribeEvent
public void onDeath(LivingDeathEvent event) {
if (event.entityLiving instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.entityLiving;
if (event.entityLiving instanceof EntityPlayer player) {
if (LudicrousItems.isInfinite(player) && !event.source.getDamageType().equals("infinity")) {
event.setCanceled(true);
player.setHealth(player.getMaxHealth());