Skip to content

Commit 8e1ec5b

Browse files
committed
Convert wisp config hostile_chance to a percentage instead of 1/x
1 parent 2b0112e commit 8e1ec5b

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/main/java/dev/itsmeow/whisperwoods/entity/EntityWisp.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,14 @@ private static Item getItemForVariant(int variant) {
322322
return null;
323323
}
324324

325+
public boolean getNewHostileChance() {
326+
return getContainer().getCustomConfiguration().getDouble("hostile_chance") / 100D > Math.random();
327+
}
328+
325329
@Override
326330
@Nullable
327331
public ILivingEntityData onInitialSpawn(IServerWorld world, DifficultyInstance difficulty, SpawnReason reason, @Nullable ILivingEntityData livingdata, CompoundNBT compound) {
328-
boolean hostile = this.getRNG().nextInt(getContainer().getCustomConfiguration().getInt("hostile_chance")) == 0;
332+
boolean hostile = this.getNewHostileChance();
329333
int colorVariant = this.getRNG().nextInt(WispColors.values().length) + 1;
330334

331335
if (livingdata instanceof WispData) {

src/main/java/dev/itsmeow/whisperwoods/init/ModEntities.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static void subscribe(IEventBus modBus) {
6565
.spawn(EntityClassification.CREATURE, 13, 1, 3)
6666
.egg(0xc36406, 0xffc008)
6767
.size(0.75F, 0.9F)
68-
.config((holder, builder) -> holder.put(builder.comment("Chance of wisp being hostile (soul stealer). Chance is 1/x, where x is the value specified. 0 is no chance, 1 is 100% chance, 2 is 50% chance, etc").worldRestart().defineInRange("hostile_chance", 8, 0, Integer.MAX_VALUE)))
68+
.config((holder, builder) -> holder.put(builder.comment("Chance of wisp being hostile (soul stealer). Chance is a percentage out of 100. 0 is never, 100 is always").worldRestart().defineInRange("hostile_chance", 12.5D, 0D, 100D)))
6969
.biomes(Type.FOREST, Type.SWAMP));
7070

7171

src/main/java/dev/itsmeow/whisperwoods/tileentity/TileEntityHandOfFate.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public void onRecipeComplete(HOFRecipe recipe, BlockState state, World worldIn,
204204
wisp.setLocationAndAngles((double) pos.getX() + 0.5D, (double) pos.getY() + d0, (double) pos.getZ() + 0.5D, MathHelper.wrapDegrees(world.rand.nextFloat() * 360.0F), 0.0F);
205205
wisp.rotationYawHead = wisp.rotationYaw;
206206
wisp.renderYawOffset = wisp.rotationYaw;
207-
wisp.isHostile = wisp.getRNG().nextInt(ModEntities.WISP.getCustomConfiguration().getInt("hostile_chance")) == 0;
207+
wisp.isHostile = wisp.getNewHostileChance();
208208
wisp.getDataManager().set(EntityWisp.COLOR_VARIANT, wColor.ordinal() + 1);
209209
if (!ForgeEventFactory.doSpecialSpawn(wisp, worldIn, pos.getX(), pos.getY(), pos.getZ(), null, SpawnReason.SPAWN_EGG)) {
210210
worldIn.addEntity(wisp);

0 commit comments

Comments
 (0)