Skip to content

Commit

Permalink
✨ Added config option to decide if named goblin despawn
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCrayfish committed Jun 7, 2021
1 parent b8a2fc4 commit e372790
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main/java/com/mrcrayfish/goblintraders/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ public static class Common
{
public final Goblin goblinTrader;
public final Goblin veinGoblinTrader;
public final ForgeConfigSpec.BooleanValue preventDespawnIfNamed;

Common(ForgeConfigSpec.Builder builder)
{
builder.comment("Common configuration settings").push("common");
this.goblinTrader = new Goblin(builder, "Goblin Trader", "goblin_trader", 25, 24000, 0, 64);
this.veinGoblinTrader = new Goblin(builder, "Vein Goblin Trader", "vein_goblin_trader", 25, 24000, 0, 128);
this.preventDespawnIfNamed = builder.comment("If true, prevents the trader from despawning if named").define("preventDespawnIfNamed", true);
builder.pop();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mrcrayfish.goblintraders.entity;

import com.mrcrayfish.goblintraders.Config;
import com.mrcrayfish.goblintraders.entity.ai.goal.AttackRevengeTargetGoal;
import com.mrcrayfish.goblintraders.entity.ai.goal.EatFavouriteFoodGoal;
import com.mrcrayfish.goblintraders.entity.ai.goal.FindFavouriteFoodGoal;
Expand Down Expand Up @@ -151,7 +152,7 @@ public void livingTick()
this.world.playSound(null, this.getPosX(), this.getPosY(), this.getPosZ(), ModSounds.ENTITY_GOBLIN_TRADER_ANNOYED_GRUNT.get(), SoundCategory.NEUTRAL, 1.0F, 0.9F + this.getRNG().nextFloat() * 0.2F);
}
}
if(!this.world.isRemote && !this.isNoDespawnRequired())
if(!this.world.isRemote && (!Config.COMMON.preventDespawnIfNamed.get() || !this.isNoDespawnRequired()))
{
this.handleDespawn();
}
Expand Down

0 comments on commit e372790

Please sign in to comment.