Skip to content

Commit

Permalink
Fixed unstackable item drops from mob farms #45
Browse files Browse the repository at this point in the history
Fixed Magma Slimes mot working with Creative or Netherite Mob Farms #44
Added Experience Drop Config Options #43
Added Slime and Magma Cube render with size support.
Improved loot table and drop prediction for mob farms.
Improved logging and removed some debug messages.
  • Loading branch information
MarkusBordihn committed Oct 23, 2023
1 parent 204c67d commit f1ce528
Show file tree
Hide file tree
Showing 12 changed files with 215 additions and 54 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@
This change log includes the summarized changes.
For the full changelog, please go to the [Git Hub History][history] instead.

### 2023.10.23

Thanks a lot to cringoleg for all of the valuable and detailed bug reports. 👍

- Fixed unstackable item drops from mob farms #45
- Fixed Magma Slimes mot working with Creative or Netherite Mob Farms #44
- Added Experience Drop Config Options #43
- Added Slime and Magma Cube render with size support.
- Improved loot table and drop prediction for mob farms.
- Improved logging and removed some debug messages.

### 2023.10.20

- Fixed Allow dynamic filter options for Iron Golem Farm. #38
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ forge_version=47.2.1
mc_version=1.20.1

version_major=6
version_minor=8
version_minor=9
version_patch=0

curseforge_release_type=release
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,13 @@ private void processResult(ItemStack capturedMob, ItemStack weaponItem, ItemStac
if (hasWeaponItem) {
if (weaponItem.getEnchantmentLevel(Enchantments.SHARPNESS) > 0
|| weaponItem.getEnchantmentLevel(Enchantments.MOB_LOOTING) > 0) {
experienceDropChange = this.random.nextInt(3);
experienceDropChange =
this.random.nextInt(COMMON.experienceDropChangeWithEnchantedWeapon.get());
} else {
experienceDropChange = this.random.nextInt(5);
experienceDropChange = this.random.nextInt(COMMON.experienceDropChangeWithWeapon.get());
}
} else {
experienceDropChange = this.random.nextInt(10);
experienceDropChange = this.random.nextInt(COMMON.experienceDropChangeNoWeapon.get());
}

// Check if we should repair mending items with experience or convert glass bottles to
Expand All @@ -240,7 +241,7 @@ private void processResult(ItemStack capturedMob, ItemStack weaponItem, ItemStac
// Repair mending items with experience, if damaged.
if (hasWeaponItem && weaponItem.isDamageableItem() && weaponItem.getDamageValue() > 0
&& weaponItem.getEnchantmentLevel(Enchantments.MENDING) > 0) {
int repairAmount = this.random.nextInt(10);
int repairAmount = this.random.nextInt(COMMON.experienceDropMendingRepairAmount.get());
if (repairAmount > 0) {
weaponItem.setDamageValue(weaponItem.getDamageValue() - repairAmount);
}
Expand Down Expand Up @@ -363,23 +364,29 @@ public void setItem(int index, ItemStack itemStack) {

// Update and cache data based on captured mob
if (itemStack.getItem() instanceof CapturedMob) {
this.farmMobName = CapturedMob.getCapturedMob(itemStack);
this.farmMobType = CapturedMob.getCapturedMobType(itemStack);
this.farmMobSubType = CapturedMob.getCapturedMobSubType(itemStack);
this.farmMobColor = CapturedMob.getCapturedMobColor(itemStack);
this.farmMobEntityType = CapturedMob.getCapturedMobEntityType(itemStack);
this.farmMobName = CapturedMob.getCapturedMob(itemStack);
this.farmMobShearedStatus = CapturedMob.getCapturedMobShearedStatus(itemStack);
this.farmMobSize = CapturedMob.getCapturedMobSize(itemStack);
this.farmMobSubType = CapturedMob.getCapturedMobSubType(itemStack);
this.farmMobType = CapturedMob.getCapturedMobType(itemStack);
} else if (CapturedMobVirtual.isSupported(itemStack)) {
this.farmMobName = CapturedMobVirtual.getCapturedMob(itemStack);
this.farmMobType = CapturedMobVirtual.getCapturedMobType(itemStack);
this.farmMobSubType = CapturedMobVirtual.getCapturedMobSubType(itemStack);
this.farmMobColor = CapturedMobVirtual.getCapturedMobColor(itemStack);
this.farmMobEntityType = CapturedMobVirtual.getCapturedMobEntityType(itemStack);
this.farmMobName = CapturedMobVirtual.getCapturedMob(itemStack);
this.farmMobShearedStatus = CapturedMobVirtual.getCapturedMobShearedStatus(itemStack);
this.farmMobSize = CapturedMobVirtual.getCapturedMobSize(itemStack);
this.farmMobSubType = CapturedMobVirtual.getCapturedMobSubType(itemStack);
this.farmMobType = CapturedMobVirtual.getCapturedMobType(itemStack);
} else {
this.farmMobName = "";
this.farmMobType = "";
this.farmMobSubType = "";
this.farmMobColor = null;
this.farmMobEntityType = null;
this.farmMobName = "";
this.farmMobShearedStatus = false;
this.farmMobSize = 1;
this.farmMobSubType = "";
this.farmMobType = "";
}

// Set Farm processing time, if there is any mob type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public class MobFarmBlockEntityData extends BaseContainerBlockEntity {
public DyeColor farmMobColor = null;
public EntityType<?> farmMobEntityType = null;
public boolean farmMobShearedStatus = false;
public int farmMobSize = 1;
public RedstoneMode farmRedstoneMode = RedstoneMode.DISABLED;

// Item Storage
Expand Down Expand Up @@ -206,6 +207,10 @@ public boolean getFarmMobShearedStatus() {
return this.farmMobShearedStatus;
}

public int getFarmMobSize() {
return this.farmMobSize;
}

public int getFarmProcessingTime() {
return 0;
}
Expand Down Expand Up @@ -365,6 +370,7 @@ public void load(CompoundTag compoundTag) {
this.farmMobSubType = CapturedMobVirtual.getCapturedMobSubType(capturedMob);
this.farmMobColor = CapturedMobVirtual.getCapturedMobColor(capturedMob);
this.farmMobShearedStatus = CapturedMobVirtual.getCapturedMobShearedStatus(capturedMob);
this.farmMobSize = CapturedMobVirtual.getCapturedMobSize(capturedMob);
this.farmMobEntityType = CapturedMobVirtual.getCapturedMobEntityType(capturedMob);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class RenderHelper {
private RenderModels renderModels;
private DyeColor entityColor;
private boolean entitySheared;
private int entitySize;

public RenderHelper(int renderId, Minecraft minecraft, BlockEntity blockEntity) {
this.minecraft = minecraft;
Expand Down Expand Up @@ -111,6 +112,13 @@ public boolean getEntityShearedStatus() {
return this.entitySheared;
}

public int getEntitySize() {
if (this.entitySize <= 0 && this.blockEntity instanceof MobFarmBlockEntity mobFarmBlockEntity) {
this.entitySize = mobFarmBlockEntity.getFarmMobSize();
}
return this.entitySize;
}

public void renderCustomEntity(EntityType<?> entityType, PoseStack poseStack,
MultiBufferSource buffer, int combinedLight) {
Entity entity = this.renderModels.getCustomEntity(entityType);
Expand Down Expand Up @@ -203,7 +211,7 @@ public void renderIronGolem(PoseStack poseStack, MultiBufferSource buffer, float
public void renderMagmaCube(PoseStack poseStack, MultiBufferSource buffer, float scale, double x,
double y, double z, int combinedLight) {
renderModel(poseStack, buffer, scale, x, y, z, combinedLight,
this.renderModels.getMagmaCubeRenderer(), this.renderModels.getMagmaCube());
this.renderModels.getMagmaCubeRenderer(), this.renderModels.getMagmaCube(getEntitySize()));
}

public void renderPanda(PoseStack poseStack, MultiBufferSource buffer, float scale, double x,
Expand Down Expand Up @@ -243,6 +251,12 @@ public void renderSkeleton(PoseStack poseStack, MultiBufferSource buffer, float
this.renderModels.getSkeletonRenderer(), this.renderModels.getSkeleton());
}

public void renderSlime(PoseStack poseStack, MultiBufferSource buffer, float scale, double x,
double y, double z, int combinedLight) {
renderModel(poseStack, buffer, scale, x, y, z, combinedLight,
this.renderModels.getSlimeRenderer(), this.renderModels.getSlime(getEntitySize()));
}

@SuppressWarnings("unchecked")
public void renderSpider(PoseStack poseStack, MultiBufferSource buffer, float scale, double x,
double y, double z, int combinedLight) {
Expand Down Expand Up @@ -336,11 +350,14 @@ public boolean renderMonster(PoseStack poseStack, MultiBufferSource buffer, int
renderEnderman(poseStack, buffer, 0.25F, 0D, 0D, 2D / 16D, combinedLight);
break;
case HostileNetherMonster.MAGMA_CUBE:
renderMagmaCube(poseStack, buffer, 0.25F, 0D, 0D, 2D / 16D, combinedLight);
renderMagmaCube(poseStack, buffer, 0.20F, 0D, 0D, 2D / 16D, combinedLight);
break;
case HostileMonster.SKELETON:
renderSkeleton(poseStack, buffer, 0.25F, 0D, 0D, 2D / 16D, combinedLight);
break;
case HostileMonster.SLIME:
renderSlime(poseStack, buffer, 0.25F, 0D, 0D, 2D / 16D, combinedLight);
break;
case HostileMonster.SPIDER:
renderSpider(poseStack, buffer, 0.35F, 0D, 15D / 16D, 2D / 16D, combinedLight);
break;
Expand All @@ -358,7 +375,7 @@ public boolean renderSpecialEntity(PoseStack poseStack, MultiBufferSource buffer
// Render Special Entity using their specific Renderer and predefined scaling and position.
switch (farmMobType) {
case NeutralMonster.IRON_GOLEM:
renderIronGolem(poseStack, buffer, 0.25F, 0D, 0D, 2D / 16D, combinedLight);
renderIronGolem(poseStack, buffer, 0.3F, 0D, 0D, 2D / 16D, combinedLight);
break;
default:
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import net.minecraft.client.renderer.entity.SalmonRenderer;
import net.minecraft.client.renderer.entity.SheepRenderer;
import net.minecraft.client.renderer.entity.SkeletonRenderer;
import net.minecraft.client.renderer.entity.SlimeRenderer;
import net.minecraft.client.renderer.entity.SpiderRenderer;
import net.minecraft.client.renderer.entity.SquidRenderer;
import net.minecraft.client.renderer.entity.ZombieRenderer;
Expand All @@ -72,6 +73,7 @@
import net.minecraft.world.entity.monster.EnderMan;
import net.minecraft.world.entity.monster.MagmaCube;
import net.minecraft.world.entity.monster.Skeleton;
import net.minecraft.world.entity.monster.Slime;
import net.minecraft.world.entity.monster.Spider;
import net.minecraft.world.entity.monster.Zombie;
import net.minecraft.world.item.DyeColor;
Expand Down Expand Up @@ -132,6 +134,8 @@ public class RenderModels {
private SheepRenderer sheepRenderer = null;
private Skeleton skeleton = null;
private SkeletonRenderer skeletonRenderer = null;
private Slime slime = null;
private SlimeRenderer slimeRenderer = null;
private Spider spider = null;
private SpiderRenderer<?> spiderRenderer = null;
private Squid squid = null;
Expand Down Expand Up @@ -359,6 +363,19 @@ public IronGolemRenderer getIronGolemRenderer() {
return this.ironGolemRenderer;
}

public MagmaCube getMagmaCube(int size) {
if (this.magmaCube == null) {
this.magmaCube = new MagmaCube(EntityType.MAGMA_CUBE, getLevel());
if (size > 1) {
CompoundTag compoundTag = new CompoundTag();
this.magmaCube.save(compoundTag);
compoundTag.putInt("Size", size);
this.magmaCube.load(compoundTag);
}
}
return this.magmaCube;
}

public MagmaCube getMagmaCube() {
if (this.magmaCube == null) {
this.magmaCube = new MagmaCube(EntityType.MAGMA_CUBE, getLevel());
Expand Down Expand Up @@ -474,6 +491,33 @@ public SkeletonRenderer getSkeletonRenderer() {
return this.skeletonRenderer;
}

public Slime getSlime(int size) {
if (this.slime == null) {
this.slime = new Slime(EntityType.MAGMA_CUBE, getLevel());
if (size > 1) {
CompoundTag compoundTag = new CompoundTag();
this.slime.save(compoundTag);
compoundTag.putInt("Size", size);
this.slime.load(compoundTag);
}
}
return this.slime;
}

public Slime getSlime() {
if (this.slime == null) {
this.slime = new Slime(EntityType.MAGMA_CUBE, getLevel());
}
return this.slime;
}

public SlimeRenderer getSlimeRenderer() {
if (this.slimeRenderer == null) {
this.slimeRenderer = new SlimeRenderer(getEntityRendererContext());
}
return this.slimeRenderer;
}

public Spider getSpider() {
if (this.spider == null) {
this.spider = new Spider(EntityType.SPIDER, getLevel());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ private static final String getDeniedMobsText(String itemName) {
public final ForgeConfigSpec.ConfigValue<List<String>> generalAllowedMobs;
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 experienceDropMendingRepairAmount;

// Copper Mob Farm
public final ForgeConfigSpec.IntValue copperAnimalPlainsFarmProcessTime;
public final ForgeConfigSpec.ConfigValue<String> copperAnimalPlainsFarmDropSound;
Expand Down Expand Up @@ -370,6 +376,8 @@ private static final String getDeniedMobsText(String itemName) {

public final ForgeConfigSpec.BooleanValue forceSlimeDropSlime;

public final ForgeConfigSpec.BooleanValue forceMagmaCubeDropMagmaCream;

public final ForgeConfigSpec.BooleanValue forceWitherDropNetherStar;

Config(ForgeConfigSpec.Builder builder) {
Expand Down Expand Up @@ -399,6 +407,21 @@ private static final String getDeniedMobsText(String itemName) {
.define("generalDeniedMobs", new ArrayList<String>(BossMonster.All));
builder.pop();

builder.push("Experience Dropping");
experienceDropChangeNoWeapon = builder.comment(
"Defines the change of dropping experience without a weapon. (lower number = higher change)")
.defineInRange("experienceDropChangeNoWeapon", 10, 1, 100);
experienceDropChangeWithWeapon = builder.comment(
"Defines the change of dropping experience with a weapon. (lower number = higher change)")
.defineInRange("experienceDropChangeWithWeapon", 5, 1, 100);
experienceDropChangeWithEnchantedWeapon = builder.comment(
"Defines the change of dropping experience with an enchanted weapon. (lower number = higher change)")
.defineInRange("experienceDropChangeWithEnchantedWeapon", 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);
builder.pop();

// == Copper Mob Farms
builder.push("Copper Mob Farms");
builder.comment("Configuration for the copper mob farms.");
Expand Down Expand Up @@ -454,8 +477,9 @@ private static final String getDeniedMobsText(String itemName) {
.defineInRange("copperMonsterPlainsCaveFarmProcessTime", 600, 10, 3600);
copperMonsterPlainsCaveFarmDropSound = builder.comment(DROP_SOUND_TEXT)
.define("copperMonsterPlainsCaveFarmDropSound", "minecraft:block.cave_vines.fall");
copperMonsterPlainsCaveFarmAllowedMobs = builder.comment(SUPPORTED_MOBS_PLAINS_CAVE_FARM)
.define("copperMonsterPlainsCaveFarmAllowedMobs", new ArrayList<String>(PlainsCave.Hostile));
copperMonsterPlainsCaveFarmAllowedMobs =
builder.comment(SUPPORTED_MOBS_PLAINS_CAVE_FARM).define(
"copperMonsterPlainsCaveFarmAllowedMobs", new ArrayList<String>(PlainsCave.Hostile));
copperMonsterPlainsCaveFarmDeniedMobs = builder.comment(DENIED_MOBS_PLAINS_CAVE_FARM)
.define("copperMonsterPlainsCaveFarmDeniedMobs", new ArrayList<String>());
builder.pop();
Expand Down Expand Up @@ -548,8 +572,9 @@ private static final String getDeniedMobsText(String itemName) {
.defineInRange("ironMonsterPlainsCaveFarmProcessTime", 300, 10, 3600);
ironMonsterPlainsCaveFarmDropSound = builder.comment(DROP_SOUND_TEXT)
.define("ironMonsterPlainsCaveFarmDropSound", "minecraft:block.cave_vines.fall");
ironMonsterPlainsCaveFarmAllowedMobs = builder.comment(SUPPORTED_MOBS_PLAINS_CAVE_FARM)
.define("ironMonsterPlainsCaveFarmAllowedMobs", new ArrayList<String>(PlainsCave.Hostile));
ironMonsterPlainsCaveFarmAllowedMobs =
builder.comment(SUPPORTED_MOBS_PLAINS_CAVE_FARM).define(
"ironMonsterPlainsCaveFarmAllowedMobs", new ArrayList<String>(PlainsCave.Hostile));
ironMonsterPlainsCaveFarmDeniedMobs = builder.comment(DENIED_MOBS_PLAINS_CAVE_FARM)
.define("ironMonsterPlainsCaveFarmDeniedMobs", new ArrayList<String>());
builder.pop();
Expand Down Expand Up @@ -642,8 +667,9 @@ private static final String getDeniedMobsText(String itemName) {
.defineInRange("goldMonsterPlainsCaveFarmProcessTime", 150, 10, 3600);
goldMonsterPlainsCaveFarmDropSound = builder.comment(DROP_SOUND_TEXT)
.define("goldMonsterPlainsCaveFarmDropSound", "minecraft:block.cave_vines.fall");
goldMonsterPlainsCaveFarmAllowedMobs = builder.comment(SUPPORTED_MOBS_PLAINS_CAVE_FARM)
.define("goldMonsterPlainsCaveFarmAllowedMobs", new ArrayList<String>(PlainsCave.Hostile));
goldMonsterPlainsCaveFarmAllowedMobs =
builder.comment(SUPPORTED_MOBS_PLAINS_CAVE_FARM).define(
"goldMonsterPlainsCaveFarmAllowedMobs", new ArrayList<String>(PlainsCave.Hostile));
goldMonsterPlainsCaveFarmDeniedMobs = builder.comment(DENIED_MOBS_PLAINS_CAVE_FARM)
.define("goldMonsterPlainsCaveFarmDeniedMobs", new ArrayList<String>());
builder.pop();
Expand Down Expand Up @@ -995,6 +1021,12 @@ private static final String getDeniedMobsText(String itemName) {
.define("forceSlimeDropSlime", true);
builder.pop();

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

builder.push("Wither Drop Settings");
forceWitherDropNetherStar =
builder.comment("Enable/Disable forced nether star drops from wither.")
Expand Down
Loading

0 comments on commit f1ce528

Please sign in to comment.