Skip to content

Commit

Permalink
Convert wisp config hostile_chance to a percentage instead of 1/x
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmeow committed Apr 25, 2021
1 parent 128099a commit 295f3e9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,14 @@ private static Item getItemForVariant(int variant) {
return null;
}

public boolean getNewHostileChance() {
return getContainer().getCustomConfiguration().getDouble("hostile_chance") / 100D > Math.random();
}

@Override
@Nullable
public ILivingEntityData onInitialSpawn(IWorld world, DifficultyInstance difficulty, SpawnReason reason, @Nullable ILivingEntityData livingdata, CompoundNBT compound) {
boolean hostile = this.getRNG().nextInt(getContainer().getCustomConfiguration().getInt("hostile_chance")) == 0;
boolean hostile = this.getNewHostileChance();
int colorVariant = this.getRNG().nextInt(WispColors.values().length) + 1;

if (livingdata instanceof WispData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static void subscribe(IEventBus modBus) {
.spawn(EntityClassification.CREATURE, 13, 1, 3)
.egg(0xc36406, 0xffc008)
.size(0.75F, 0.9F)
.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)))
.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)))
.biomes(Type.FOREST, Type.SWAMP));

public static final EntityTypeContainer<EntityHirschgeist> HIRSCHGEIST = H.add(EntityHirschgeist.class, EntityHirschgeist::new, "hirschgeist", b -> b
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public void onRecipeComplete(HOFRecipe recipe, BlockState state, World worldIn,
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);
wisp.rotationYawHead = wisp.rotationYaw;
wisp.renderYawOffset = wisp.rotationYaw;
wisp.isHostile = wisp.getRNG().nextInt(ModEntities.WISP.getCustomConfiguration().getInt("hostile_chance")) == 0;
wisp.isHostile = wisp.getNewHostileChance();
wisp.getDataManager().set(EntityWisp.COLOR_VARIANT, wColor.ordinal() + 1);
if (!ForgeEventFactory.doSpecialSpawn(wisp, worldIn, pos.getX(), pos.getY(), pos.getZ(), null, SpawnReason.SPAWN_EGG)) {
worldIn.addEntity(wisp);
Expand Down

0 comments on commit 295f3e9

Please sign in to comment.