Skip to content

Commit

Permalink
Added better and additional forced drop options for Bee, Blaze, Chick…
Browse files Browse the repository at this point in the history
…en, Drowned, Enderman, Slime, MagmaCube, Piglin, Pillager, Wither, Wither Skeleton, Zombie and Zombie Piglin.

Improved loot manager to support armor and weapon drops with configurable drop chances.
  • Loading branch information
MarkusBordihn committed Oct 27, 2023
1 parent 71d0916 commit bcf8d6f
Show file tree
Hide file tree
Showing 12 changed files with 523 additions and 103 deletions.
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"calorite",
"catchable",
"catched",
"CHESTPLATE",
"Clientbound",
"Configurator",
"cookingtime",
Expand Down Expand Up @@ -130,6 +131,7 @@
"UNBREAKING",
"Uncraftable",
"unobtainium",
"unstackable",
"unstored",
"untrack",
"vibranium",
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
This change log includes the summarized changes.
For the full changelog, please go to the [Git Hub History][history] instead.

### 2023.10.28

- Added better and additional forced drop options for Bee, Blaze, Chicken, Drowned, Enderman, Slime, MagmaCube, Piglin, Pillager, Wither, Wither Skeleton, Zombie and Zombie Piglin.
- Improved loot manager to support armor and weapon drops with configurable drop chances.

### 2023.10.23

Thanks a lot to cringoleg for all of the valuable and detailed bug reports. 👍
Expand All @@ -20,7 +25,7 @@ Thanks a lot to cringoleg for all of the valuable and detailed bug reports. 👍

- Fixed Allow dynamic filter options for Iron Golem Farm. #38
- Fixed Fishing Net (Small) catches all mobs #39
- Fixed Curseforge Client Changelog link is invalid #40
- Fixed Curseforge Client Changelog link is invalid #40
- Fixed Advancements and Recipes don't work as expected #41
- Fixed Change naming convention for config variables #42

Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ vendor_name=markusbordihn
forge_version=47.2.1
mc_version=1.20.1

version_major=6
version_minor=9
version_patch=1
version_major=7
version_minor=0
version_patch=0

curseforge_release_type=release
curseforge_project_id=563464
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,23 +220,23 @@ private void processResult(ItemStack capturedMob, ItemStack weaponItem, ItemStac
// - No weapon: 10% chance
// - Weapon: 20% chance
// - Weapon with sharpness or looting enchantment: 33% chance
int experienceDropChange = 0;
int experienceDropChance = 0;
if (hasWeaponItem) {
if (weaponItem.getEnchantmentLevel(Enchantments.SHARPNESS) > 0
|| weaponItem.getEnchantmentLevel(Enchantments.MOB_LOOTING) > 0) {
experienceDropChange =
this.random.nextInt(COMMON.experienceDropChangeWithEnchantedWeapon.get());
experienceDropChance =
this.random.nextInt(COMMON.experienceDropChanceWithEnchantedWeapon.get());
} else {
experienceDropChange = this.random.nextInt(COMMON.experienceDropChangeWithWeapon.get());
experienceDropChance = this.random.nextInt(COMMON.experienceDropChanceWithWeapon.get());
}
} else {
experienceDropChange = this.random.nextInt(COMMON.experienceDropChangeNoWeapon.get());
experienceDropChance = this.random.nextInt(COMMON.experienceDropChanceNoWeapon.get());
}

// Check if we should repair mending items with experience or convert glass bottles to
// experience bottles.
boolean hasExperienceItem = experienceItem != null && !experienceItem.isEmpty();
if ((hasWeaponItem || hasExperienceItem) && experienceDropChange == 0) {
if ((hasWeaponItem || hasExperienceItem) && experienceDropChance == 0) {

// Repair mending items with experience, if damaged.
if (hasWeaponItem && weaponItem.isDamageableItem() && weaponItem.getDamageValue() > 0
Expand Down
152 changes: 118 additions & 34 deletions src/main/java/de/markusbordihn/easymobfarm/config/CommonConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ private static final String getDeniedMobsText(String itemName) {
+ ". (Use empty list to allow all mobs!)";
}

private static final String getForcedDropChanceText(String itemName, String mobName) {
return "Defines the forced drop change of " + itemName + " from " + mobName
+ ". (0 = disabled, lower number = higher change, 1 = every drop)";
}

// General config
public final ForgeConfigSpec.BooleanValue informOwnerAboutFullStorage;
public final ForgeConfigSpec.BooleanValue logFullStorage;
Expand All @@ -128,9 +133,9 @@ private static final String getDeniedMobsText(String itemName) {
public final ForgeConfigSpec.ConfigValue<List<String>> generalDeniedMobs;

// Experience Settings
public final ForgeConfigSpec.IntValue experienceDropChangeNoWeapon;
public final ForgeConfigSpec.IntValue experienceDropChangeWithWeapon;
public final ForgeConfigSpec.IntValue experienceDropChangeWithEnchantedWeapon;
public final ForgeConfigSpec.IntValue experienceDropChanceNoWeapon;
public final ForgeConfigSpec.IntValue experienceDropChanceWithWeapon;
public final ForgeConfigSpec.IntValue experienceDropChanceWithEnchantedWeapon;
public final ForgeConfigSpec.IntValue experienceDropMendingRepairAmount;

// Copper Mob Farm
Expand Down Expand Up @@ -358,27 +363,48 @@ private static final String getDeniedMobsText(String itemName) {
public final ForgeConfigSpec.ConfigValue<List<String>> witchBottleDeniedMobs;

// Drop Settings
public final ForgeConfigSpec.IntValue forceBeeDropHoneycombChance;

public final ForgeConfigSpec.BooleanValue forceBeeDropHoneycomb;
public final ForgeConfigSpec.IntValue forceBlazeDropBlazeRodChance;

public final ForgeConfigSpec.BooleanValue forceBlazeDropBlazeRod;

public final ForgeConfigSpec.BooleanValue forceChickenDropEggs;
public final ForgeConfigSpec.IntValue forceChickenDropEggChance;
public final ForgeConfigSpec.BooleanValue disableChickenDropRawChicken;

public final ForgeConfigSpec.BooleanValue disableCowDropRawBeef;

public final ForgeConfigSpec.BooleanValue forceEndermanDropEnderPearl;
public final ForgeConfigSpec.IntValue forceDrownedDropArmorChance;
public final ForgeConfigSpec.IntValue forceDrownedDropCopperIngotChance;
public final ForgeConfigSpec.IntValue forceDrownedDropTridentChance;
public final ForgeConfigSpec.IntValue forceDrownedDropNautilusShellChance;

public final ForgeConfigSpec.IntValue forceEndermanDropEnderPearlChance;

public final ForgeConfigSpec.BooleanValue disableIronGolemDropPoppy;

public final ForgeConfigSpec.BooleanValue disableSheepDropRawMutton;

public final ForgeConfigSpec.BooleanValue forceSlimeDropSlime;
public final ForgeConfigSpec.IntValue forceSlimeDropSlimeBallChance;

public final ForgeConfigSpec.IntValue forceMagmaCubeDropMagmaCreamChance;

public final ForgeConfigSpec.IntValue forcePiglinDropArmorChance;
public final ForgeConfigSpec.IntValue forcePiglinDropWeaponChance;

public final ForgeConfigSpec.IntValue forcePillagerDropArmorChance;
public final ForgeConfigSpec.IntValue forcePillagerDropEmeraldChance;
public final ForgeConfigSpec.IntValue forcePillagerDropEnchantedBookChance;
public final ForgeConfigSpec.IntValue forcePillagerDropWeaponChance;

public final ForgeConfigSpec.IntValue forceWitherDropNetherStarChance;

public final ForgeConfigSpec.BooleanValue forceMagmaCubeDropMagmaCream;
public final ForgeConfigSpec.IntValue forceWitherSkeletonDropWitherSkeletonSkullChance;

public final ForgeConfigSpec.BooleanValue forceWitherDropNetherStar;
public final ForgeConfigSpec.IntValue forceZombieDropArmorChance;
public final ForgeConfigSpec.IntValue forceZombieDropWeaponChance;

public final ForgeConfigSpec.IntValue forceZombifiedPiglinDropGoldIngotChance;
public final ForgeConfigSpec.IntValue forceZombifiedPiglinDropGoldNuggetChance;
public final ForgeConfigSpec.IntValue forceZombifiedPiglinDropWeaponChance;

Config(ForgeConfigSpec.Builder builder) {
builder.comment(Constants.MOD_NAME);
Expand Down Expand Up @@ -408,15 +434,15 @@ private static final String getDeniedMobsText(String itemName) {
builder.pop();

builder.push("Experience Dropping");
experienceDropChangeNoWeapon = builder.comment(
experienceDropChanceNoWeapon = builder.comment(
"Defines the change of dropping experience without a weapon. (lower number = higher change)")
.defineInRange("experienceDropChangeNoWeapon", 10, 1, 100);
experienceDropChangeWithWeapon = builder.comment(
.defineInRange("experienceDropChanceNoWeapon", 10, 1, 100);
experienceDropChanceWithWeapon = builder.comment(
"Defines the change of dropping experience with a weapon. (lower number = higher change)")
.defineInRange("experienceDropChangeWithWeapon", 5, 1, 100);
experienceDropChangeWithEnchantedWeapon = builder.comment(
.defineInRange("experienceDropChanceWithWeapon", 5, 1, 100);
experienceDropChanceWithEnchantedWeapon = builder.comment(
"Defines the change of dropping experience with an enchanted weapon. (lower number = higher change)")
.defineInRange("experienceDropChangeWithEnchantedWeapon", 3, 1, 100);
.defineInRange("experienceDropChanceWithEnchantedWeapon", 3, 1, 100);
experienceDropMendingRepairAmount = builder.comment(
"Defines the max amount to repair a mending weapon with experience points. (higher number = more repair)")
.defineInRange("experienceDropMendingRepairAmount", 10, 1, 100);
Expand Down Expand Up @@ -979,31 +1005,44 @@ private static final String getDeniedMobsText(String itemName) {
builder.comment("Configuration for drops like forced and disabled drops.");

builder.push("Bee Drop Settings");
forceBeeDropHoneycomb = builder.comment("Enable/Disable forced honeycomb drops.")
.define("forceBeeDropHoneycomb", true);
forceBeeDropHoneycombChance = builder.comment(getForcedDropChanceText("honeycomb", "bee"))
.defineInRange("forceBeeDropHoneycombChance", 2, 0, 100);
builder.pop();

builder.push("Blaze Drop Settings");
forceBlazeDropBlazeRod = builder.comment("Enable/Disable forced blaze rod drops.")
.define("forceBlazeDropBlazeRod", false);
forceBlazeDropBlazeRodChance = builder.comment(getForcedDropChanceText("blaze rod", "blaze"))
.defineInRange("forceBlazeDropBlazeRodChance", 4, 0, 100);
builder.pop();

builder.push("Chicken Drop Settings");
disableChickenDropRawChicken = builder.comment("Disable raw chicken drops.")
.define("disableChickenDropRawChicken", false);
forceChickenDropEggs = builder.comment("Enable/Disable forced chicken egg drops.")
.define("forceChickenDropEggs", true);
forceChickenDropEggChance = builder.comment(getForcedDropChanceText("egg", "chicken"))
.defineInRange("forceChickenDropEggChance", 2, 0, 100);
builder.pop();

builder.push("Cow Drop Settings");
disableCowDropRawBeef =
builder.comment("Disable cow raw beef drops.").define("disableCowDropRawBeef", false);
builder.pop();

builder.push("Drowned Drop Settings");
forceDrownedDropArmorChance = builder.comment(getForcedDropChanceText("armor", "drowned"))
.defineInRange("forceDrownedDropArmorChance", 12, 0, 100);
forceDrownedDropCopperIngotChance =
builder.comment(getForcedDropChanceText("copper ingot", "drowned"))
.defineInRange("forceDrownedDropCopperIngotChance", 10, 0, 100);
forceDrownedDropNautilusShellChance =
builder.comment(getForcedDropChanceText("nautilus shell", "drowned"))
.defineInRange("forceDrownedDropNautilusShellChance", 30, 0, 100);
forceDrownedDropTridentChance = builder.comment(getForcedDropChanceText("trident", "drowned"))
.defineInRange("forceDrownedDropTridentChance", 18, 0, 100);
builder.pop();

builder.push("Enderman Drop Settings");
forceEndermanDropEnderPearl =
builder.comment("Enable/Disable forced enderman ender pearl drops.")
.define("forceEndermanDropEnderPearl", false);
forceEndermanDropEnderPearlChance =
builder.comment(getForcedDropChanceText("ender pearl", "enderman"))
.defineInRange("forceEndermanDropEnderPearlChance", 2, 0, 100);
builder.pop();

builder.push("Iron Golem Drop Settings");
Expand All @@ -1017,20 +1056,65 @@ private static final String getDeniedMobsText(String itemName) {
builder.pop();

builder.push("Slime Drop Settings");
forceSlimeDropSlime = builder.comment("Enable/Disable forced slime drops regardless of size.")
.define("forceSlimeDropSlime", true);
forceSlimeDropSlimeBallChance = builder.comment(getForcedDropChanceText("slime", "slime"))
.defineInRange("forceSlimeDropSlimeBallChance", 2, 0, 100);
builder.pop();

builder.push("Magma Cube Drop Settings");
forceMagmaCubeDropMagmaCream =
builder.comment("Enable/Disable forced magma cream drops regardless of size.")
.define("forceMagmaCubeDropMagmaCream", true);
forceMagmaCubeDropMagmaCreamChance =
builder.comment(getForcedDropChanceText("magma cream", "magma cube"))
.defineInRange("forceMagmaCubeDropMagmaCreamChance", 2, 0, 100);
builder.pop();

builder.push("Piglin Drop Settings");
forcePiglinDropArmorChance = builder.comment(getForcedDropChanceText("armor", "piglin"))
.defineInRange("forcePiglinDropArmorChance", 12, 0, 100);
forcePiglinDropWeaponChance = builder.comment(getForcedDropChanceText("weapon", "piglin"))
.defineInRange("forcePiglinDropWeaponChance", 12, 0, 100);
builder.pop();

builder.push("Pillager Drop Settings");
forcePillagerDropArmorChance = builder.comment(getForcedDropChanceText("armor", "pillager"))
.defineInRange("forcePillagerDropArmorChance", 16, 0, 100);
forcePillagerDropEmeraldChance =
builder.comment(getForcedDropChanceText("emerald", "pillager"))
.defineInRange("forcePillagerDropEmeraldChance", 8, 0, 100);
forcePillagerDropEnchantedBookChance =
builder.comment(getForcedDropChanceText("enchanted book", "pillager"))
.defineInRange("forcePillagerDropEnchantedBookChance", 20, 0, 100);
forcePillagerDropWeaponChance = builder.comment(getForcedDropChanceText("weapon", "pillager"))
.defineInRange("forcePillagerDropWeaponChance", 16, 0, 100);
builder.pop();

builder.push("Wither Drop Settings");
forceWitherDropNetherStar =
builder.comment("Enable/Disable forced nether star drops from wither.")
.define("forceWitherDropNetherStar", false);
forceWitherDropNetherStarChance =
builder.comment(getForcedDropChanceText("nether star", "wither"))
.defineInRange("forceWitherDropNetherStarChance", 1, 0, 100);
builder.pop();

builder.push("Wither Skeleton Drop Settings");
forceWitherSkeletonDropWitherSkeletonSkullChance =
builder.comment(getForcedDropChanceText("wither skeleton skull", "wither skeleton"))
.defineInRange("forceWitherSkeletonDropWitherSkeletonSkullChance", 10, 0, 100);
builder.pop();

builder.push("Zombie Drop Settings");
forceZombieDropArmorChance = builder.comment(getForcedDropChanceText("armor", "zombie"))
.defineInRange("forceZombieDropArmorChance", 50, 0, 100);
forceZombieDropWeaponChance = builder.comment(getForcedDropChanceText("weapon", "zombie"))
.defineInRange("forceZombieDropWeaponChance", 100, 0, 100);
builder.pop();

builder.push("Zombified Piglin Drop Settings");
forceZombifiedPiglinDropGoldNuggetChance =
builder.comment(getForcedDropChanceText("gold nugget", "zombified piglin"))
.defineInRange("forceZombifiedPiglinDropGoldNuggetChance", 2, 0, 100);
forceZombifiedPiglinDropGoldIngotChance =
builder.comment(getForcedDropChanceText("gold ingot", "zombified piglin"))
.defineInRange("forceZombifiedPiglinDropGoldIngotChance", 4, 0, 100);
forceZombifiedPiglinDropWeaponChance =
builder.comment(getForcedDropChanceText("weapon", "zombified piglin"))
.defineInRange("forceZombifiedPiglinDropWeaponChance", 12, 0, 100);
builder.pop();

builder.pop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ protected HostileMonster() {}
public static final String CREEPER = "minecraft:creeper";
public static final String ENDERMAN = "minecraft:enderman";
public static final String HUSK = "minecraft:husk";
public static final String PILLAGER = "minecraft:pillager";
public static final String SKELETON = "minecraft:skeleton";
public static final String SLIME = "minecraft:slime";
public static final String SPIDER = "minecraft:spider";
Expand All @@ -37,6 +38,6 @@ protected HostileMonster() {}
public static final String ZOMBIE_VILLAGER = "minecraft:zombie_villager";


public static final Set<String> All = Set.of(CAVE_SPIDER, CREEPER, ENDERMAN, HUSK, SKELETON, SLIME,
SPIDER, WITCH, ZOMBIE, ZOMBIE_VILLAGER);
public static final Set<String> All = Set.of(CAVE_SPIDER, CREEPER, ENDERMAN, HUSK, PILLAGER,
SKELETON, SLIME, SPIDER, WITCH, ZOMBIE, ZOMBIE_VILLAGER);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ public class HostileNetherMonster {
protected HostileNetherMonster() {}

public static final String BLAZE = "minecraft:blaze";
public static final String GHAST = "minecraft:ghast";
public static final String HOGLIN = "minecraft:hoglin";
public static final String MAGMA_CUBE = "minecraft:magma_cube";
public static final String PIGLIN = "minecraft:piglin";
public static final String PIGLIN_BRUTE = "minecraft:piglin_brute";
public static final String STRIDER = "minecraft:strider";
public static final String WITHER_SKELETON = "minecraft:wither_skeleton";
public static final String ZOGLIN = "minecraft:zoglin";
public static final String ZOMBIFIED_PIGLIN = "minecraft:zombified_piglin";
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import net.minecraft.world.item.AirItem;
import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.BedItem;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.BottleItem;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.DyeItem;
Expand Down Expand Up @@ -87,7 +86,7 @@ public static boolean isSupported(ItemStack itemStack) {
} else if (item instanceof AirItem || item instanceof ExperienceBottleItem
|| item instanceof BottleItem || item instanceof MobFarmTemplateItem
|| item instanceof ArmorItem || item instanceof SignItem || item instanceof DyeItem
|| item instanceof BedItem || item instanceof BlockItem || item instanceof SwordItem) {
|| item instanceof BedItem || item instanceof SwordItem) {
return false;
}

Expand Down Expand Up @@ -139,8 +138,6 @@ public static boolean isSupported(ItemStack itemStack) {
}
} else if (item instanceof SpawnEggItem) {
return true;
} else if (!compoundTag.isEmpty()) {
log.warn("Unsupported mob catching Item {} {}: {}", item, itemName, compoundTag);
}
return false;
}
Expand Down
Loading

0 comments on commit bcf8d6f

Please sign in to comment.