Skip to content

Commit

Permalink
Added BiomeRecipe test class
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Oct 13, 2019
1 parent 31bc36c commit 30c693c
Show file tree
Hide file tree
Showing 2 changed files with 319 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,20 @@ public void addConvBlocks(Material oldMaterial, Material newMaterial, double con
* @param mobType - entity type
* @param mobProbability - reltive probability
* @param mobSpawnOn - material to spawn on
* @return true if add is successful
*/
public void addMobs(EntityType mobType, int mobProbability, Material mobSpawnOn) {
public boolean addMobs(EntityType mobType, int mobProbability, Material mobSpawnOn) {
addon.log(" " + mobProbability + "% chance for " + Util.prettifyText(mobType.toString()) + " to spawn on " + Util.prettifyText(mobSpawnOn.toString())+ ".");
double probability = ((double)mobProbability/100);
double lastProb = mobTree.isEmpty() ? 0D : mobTree.lastKey();
// Add up all the probabilities in the list so far
if ((1D - lastProb) >= probability) {
// Add to probability tree
mobTree.put(lastProb + probability, new GreenhouseMob(mobType, mobSpawnOn));
return true;
} else {
addon.logError("Mob chances add up to > 100% in " + type.toString() + " biome recipe! Skipping " + mobType.toString());
return false;
}
}

Expand All @@ -109,8 +112,9 @@ public void addMobs(EntityType mobType, int mobProbability, Material mobSpawnOn)
* @param plantMaterial - plant type
* @param plantProbability - probability of growing
* @param plantGrowOn - material on which it must grow
* @return true if add is successful
*/
public void addPlants(Material plantMaterial, int plantProbability, Material plantGrowOn) {
public boolean addPlants(Material plantMaterial, int plantProbability, Material plantGrowOn) {
double probability = ((double)plantProbability/100);
// Add up all the probabilities in the list so far
double lastProb = plantTree.isEmpty() ? 0D : plantTree.lastKey();
Expand All @@ -119,8 +123,10 @@ public void addPlants(Material plantMaterial, int plantProbability, Material pla
plantTree.put(lastProb + probability, new GreenhousePlant(plantMaterial, plantGrowOn));
} else {
addon.logError("Plant chances add up to > 100% in " + type.toString() + " biome recipe! Skipping " + plantMaterial.toString());
return false;
}
addon.log(" " + plantProbability + "% chance for " + Util.prettifyText(plantMaterial.toString()) + " to grow on " + Util.prettifyText(plantGrowOn.toString()));
return true;
}

/**
Expand Down Expand Up @@ -275,7 +281,7 @@ public String getPermission() {
/**
* @return the priority
*/
private int getPriority() {
public int getPriority() {
return priority;
}

Expand Down Expand Up @@ -344,6 +350,8 @@ public boolean growPlant(Block bl) {
if (bl.getRelative(BlockFace.UP).getType().equals(Material.AIR)) {
bl.setBlockData(dataBottom, false);
bl.getRelative(BlockFace.UP).setBlockData(dataTop, false);
} else {
return false; // No room
}
} else {
bl.setBlockData(dataBottom, false);
Expand Down

0 comments on commit 30c693c

Please sign in to comment.