Skip to content

Commit

Permalink
Implemented ability to change how large cactus and sugarcane can grow.
Browse files Browse the repository at this point in the history
  • Loading branch information
BONNe committed Apr 4, 2024
1 parent 9af2084 commit a51037d
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 2 deletions.
56 changes: 56 additions & 0 deletions src/main/java/world/bentobox/farmersdance/configs/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,50 @@ public void setGrowBerries(boolean growBerries)
}


/**
* Gets maximal cactus size.
*
* @return the maximal cactus size
*/
public int getMaximalCactusSize()
{
return this.maximalCactusSize;
}


/**
* Sets maximal cactus size.
*
* @param maximalCactusSize the maximal cactus size
*/
public void setMaximalCactusSize(int maximalCactusSize)
{
this.maximalCactusSize = maximalCactusSize;
}


/**
* Gets maximal sugar cane size.
*
* @return the maximal sugar cane size
*/
public int getMaximalSugarCaneSize()
{
return this.maximalSugarCaneSize;
}


/**
* Sets maximal sugar cane size.
*
* @param maximalSugarCaneSize the maximal sugar cane size
*/
public void setMaximalSugarCaneSize(int maximalSugarCaneSize)
{
this.maximalSugarCaneSize = maximalSugarCaneSize;
}


// ---------------------------------------------------------------------
// Section: Variables
// ---------------------------------------------------------------------
Expand Down Expand Up @@ -602,4 +646,16 @@ public void setGrowBerries(boolean growBerries)
@ConfigComment("Default value = true.")
@ConfigEntry(path = "groups.grow-berries")
private boolean growBerries = true;

@ConfigComment("")
@ConfigComment("The maximal cactus size that it can grow to.")
@ConfigComment("Default value = 3.")
@ConfigEntry(path = "size.cactus-size")
private int maximalCactusSize = 3;

@ConfigComment("")
@ConfigComment("The maximal sugar cane size that it can grow to.")
@ConfigComment("Default value = 3.")
@ConfigEntry(path = "size.sugar-cane-size")
private int maximalSugarCaneSize;
}
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,18 @@ else if (Material.CACTUS.equals(block.getType()) || Material.SUGAR_CANE.equals(b

int height = 1;

while (block.getType().equals(rootBlock.getType()) && height < 4)
// Get max height based on block data.
int maxHeight = Material.CACTUS.equals(block.getType()) ?
this.addon.getSettings().getMaximalCactusSize() :
this.addon.getSettings().getMaximalSugarCaneSize();

while (block.getType().equals(rootBlock.getType()) && height < maxHeight)
{
rootBlock = rootBlock.getRelative(BlockFace.UP);
height++;
}

if (height < 4 && Material.AIR.equals(rootBlock.getType()))
if (height < maxHeight && Material.AIR.equals(rootBlock.getType()))
{
rootBlock.setBlockData(block.getType().createBlockData(), true);
this.spawnParticle(rootBlock.getLocation());
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,10 @@ groups:
# Dancing near berries will produce berries.
# Default value = true.
grow-berries: true
size:
# The maximal cactus size that it can grow to.
# Default value = 3.
cactus-size: 3
# The maximal sugar cane size that it can grow to.
# Default value = 3.
sugar-cane-size: 3

0 comments on commit a51037d

Please sign in to comment.