Skip to content

Commit

Permalink
Fix issue when nether mobs did not spawn on nether bricks.
Browse files Browse the repository at this point in the history
Flip chances for easier reading.
Add missing mention about deep ocean biome for guardians in readme.
  • Loading branch information
BONNe committed Jan 14, 2020
1 parent ed632f4 commit cb8fa24
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Addon will replace Enderman with Shulker by chance from config if:
Addon will replace Cod, Salamon or Tropical fish with Guardian by chance from config if:
- given world is generated by GameMode Addon.
- given world is the Overworld
- biome in given location is deep ocean or any its variants
- first block above water where fish is spawned is prismarine, prismarine brick or dark prismarine (blocks, slabs and stairs).

##### For Beehive:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,15 @@ public void onEntitySpawn(CreatureSpawnEvent event)
{
// replace pigmen with blaze or wither



if (this.isSuitableNetherLocation(event.getLocation()))
{
double random = this.spawningRandom.nextDouble();

if (this.addon.getSettings().getWitherSkeletonChance() >= random)
if (this.spawningRandom.nextDouble() < this.addon.getSettings().getWitherSkeletonChance())
{
// oOo wither skeleton got lucky.
this.summonEntity(event.getLocation(), EntityType.WITHER_SKELETON);
event.setCancelled(true);
}
else if (this.addon.getSettings().getWitherSkeletonChance() +
this.addon.getSettings().getBlazeChance() >= random)
else if (this.spawningRandom.nextDouble() < this.addon.getSettings().getBlazeChance())
{
// oOo blaze got lucky.
this.summonEntity(event.getLocation(), EntityType.BLAZE);
Expand All @@ -100,7 +95,7 @@ else if (event.getEntityType() == EntityType.ENDERMAN &&
// replace enderman with shulker
if (this.isSuitableEndLocation(event.getLocation()))
{
if (this.addon.getSettings().getShulkerChance() >= this.spawningRandom.nextDouble())
if (this.spawningRandom.nextDouble() < this.addon.getSettings().getShulkerChance())
{
// oOo shulker got lucky.
this.summonEntity(event.getLocation(), EntityType.SHULKER);
Expand Down Expand Up @@ -129,12 +124,20 @@ else if (world.getEnvironment() == World.Environment.NORMAL &&

if (this.isSuitableGuardianLocation(event.getLocation()))
{
if (this.addon.getSettings().getGuardianChance() >= this.spawningRandom.nextDouble())
if (this.spawningRandom.nextDouble() < this.addon.getSettings().getGuardianChance())
{
// oOo guardian got lucky.
this.summonEntity(event.getLocation(), EntityType.GUARDIAN);
event.setCancelled(true);
}
else
{
System.out.println("unlucky");
}
}
else
{
System.out.println("Not suitable place");
}
}
}
Expand All @@ -151,7 +154,7 @@ private boolean isSuitableNetherLocation(Location location)
{
Material material = location.getBlock().getRelative(BlockFace.DOWN).getType();

return material == Material.NETHER_BRICK ||
return material == Material.NETHER_BRICKS ||
material == Material.NETHER_BRICK_SLAB ||
material == Material.NETHER_BRICK_STAIRS;
}
Expand Down Expand Up @@ -190,6 +193,8 @@ private boolean isSuitableGuardianLocation(Location location)

Material material = block.getType();

System.out.println("Material is " + material);

return material == Material.PRISMARINE ||
material == Material.PRISMARINE_SLAB ||
material == Material.PRISMARINE_STAIRS ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void onTreeGrowth(StructureGrowEvent event)
return;
}

if (this.addon.getSettings().getBeeHiveChance() < this.beeHiveRandom.nextDouble())
if (this.beeHiveRandom.nextDouble() >= this.addon.getSettings().getBeeHiveChance())
{
// Unlucky. BeeHive is not generated.
return;
Expand Down Expand Up @@ -163,7 +163,7 @@ else if (beeLocation.getRelative(BlockFace.NORTH).isEmpty())
// Try to spawn bee 3 times
for (int i = 0; i < 3; i++)
{
if (this.addon.getSettings().getBeeChance() >= this.beeHiveRandom.nextDouble())
if (this.beeHiveRandom.nextDouble() < this.addon.getSettings().getBeeChance())
{
// Spawn Bee :)
event.getWorld().spawnEntity(beeLocation.getLocation(), EntityType.BEE);
Expand Down

0 comments on commit cb8fa24

Please sign in to comment.