Skip to content

Commit

Permalink
Major clean-up and minor bugfix
Browse files Browse the repository at this point in the history
- Fixed a newly introduced bug that prevented magic metal berry from growing
- Cleaned up most if not all crop classes
- Removed a lot of WET implementations
- Organised the crops so you can find you way around stuff
- Abstracted TConstruct ore berries since they were all the same
  • Loading branch information
C0bra5 committed Oct 17, 2023
1 parent 11339dc commit 04af1ca
Show file tree
Hide file tree
Showing 62 changed files with 731 additions and 772 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ public int stat(int n) {
}
}

@Override
public boolean canGrow(ICropTile crop) {
return crop.getSize() < this.maxSize();
}

@Override
public List<String> getCropInformation() {
return Arrays.asList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ public void registerSprites(IIconRegister iconRegister) {
}
}

// be DRY, not WET
@Override
public boolean canGrow(ICropTile crop) {
return this.canGrowBase(crop);
}

protected boolean canGrowBase(ICropTile crop) {
return crop.getSize() < this.maxSize();
}

@Override
public float dropGainChance() {
return (float) ((Math.pow(0.95, (float) tier())) * ConfigValues.BerryGain);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public int maxSize() {

@Override
public boolean canGrow(ICropTile crop) {
return crop.getSize() < this.maxSize() && crop.getLightLevel() >= 9;
return super.canGrow(crop) && crop.getLightLevel() >= 9;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ public int stat(int n) {
}
}

@Override
public boolean canGrow(ICropTile crop) {
return crop.getSize() < this.maxSize();
}

@Override
public List<String> getCropInformation() {
return Arrays
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,15 @@ public int stat(int n) {

@Override
public boolean canGrow(ICropTile crop) {
if (crop.getSize() >= this.maxSize()) return false;
else if (ConfigValues.debug || crop.getSize() < 1) return true;
else if (crop.getSize() < this.maxSize() - 1) return crop.getLightLevel() <= 10;
else if (crop.getSize() == this.maxSize() - 1) return crop.isBlockBelow(hasBlock());
return false;
if (!canGrowBase(crop)) return false;
else if (ConfigValues.debug) return true;
else if (crop.getSize() >= this.maxSize() - 1) return crop.isBlockBelow(hasBlock());
return crop.getLightLevel() <= 10;
}

@Override
public boolean canBeHarvested(ICropTile crop) {
return crop.getSize() >= 3;
return crop.getSize() >= this.maxSize() - 1;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public static void register() {
if (bHasCropObj.get(i) && cropObjs().get(i) != null) Crops.instance.registerCrop(cropObjs().get(i));
}
if (bHasCropObj.get(bHasCropObj.size() - 1)) {
Bonsais.registerAllBonais();
Bonsais.registerAllBonsais();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,28 @@

public class Bamboo extends BasicCrop {

@Override
public int tier() {
return 2;
}

@Override
public String name() {
return "Bamboo";
}

@Override
public String discoveredBy() {
return "Minepolz320";
}

public int tier() {
return 2;
}

@Override
public int weightInfluences(ICropTile crop, float humidity, float nutrients, float air) {
// no documentation on the intended effect, so i'm leaving it as is
return (int) ((double) humidity * 1.3D + (double) nutrients * 1.2D + (double) air * 0.8D);
}

@Override
public int stat(int n) {
switch (n) {
case 0:
Expand All @@ -46,30 +50,32 @@ public int stat(int n) {
}
}

@Override
public String[] attributes() {
return new String[] { "Green", "Pointed", "Edgy" };
}

@Override
public int maxSize() {
return 3;
}

public boolean canGrow(ICropTile crop) {
return crop.getSize() < this.maxSize();
}

@Override
public boolean canBeHarvested(ICropTile crop) {
return crop.getSize() > 1;
}

@Override
public int getOptimalHavestSize(ICropTile crop) {
return this.maxSize();
}

@Override
public ItemStack getGain(ICropTile crop) {
return crop.getSize() > 1 ? new ItemStack(BOPCBlocks.bamboo, crop.getSize() - 1) : null;
}

@Override
public int growthDuration(ICropTile crop) {

// If raining = fast grow
Expand All @@ -79,6 +85,7 @@ public int growthDuration(ICropTile crop) {
return 150;
}

@Override
public boolean onEntityCollision(ICropTile crop, Entity entity) {
if (!entity.isSneaking()) {
CCropUtility.damageEntity(entity, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class EyebulbCrop extends BasicDecorationCrop {

public EyebulbCrop() {
super();
OreDict.BSget("crop" + name(), this);
OreDict.BSget("cropEyebulb", this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@ public int tier() {
return 3;
}

@Override
public boolean canGrow(ICropTile crop) {
return crop.getSize() < this.maxSize();
}

@Override
public int maxSize() {
return 4;
}

@Override
public String name() {
return "Flowering Vines";
Expand All @@ -44,6 +34,11 @@ public String[] attributes() {
return new String[] { "Green", "Tendrilly", "Flower" };
}

@Override
public int maxSize() {
return 4;
}

@Override
public boolean canBeHarvested(ICropTile crop) {
return crop.getSize() >= this.maxSize() - 1;
Expand All @@ -53,8 +48,9 @@ public boolean canBeHarvested(ICropTile crop) {
public ItemStack getGain(ICropTile crop) {
// id 106 = vines
if (crop.getSize() >= this.maxSize()) return new ItemStack(BOPCBlocks.flowerVine, 2, 0);
else if (crop.getSize() == this.maxSize() - 1) return new ItemStack(Item.getItemById(106), 2, 0);
else return null;
// there was a null return if the max side was under maxSize - 1
// in normal operation that doesn't happen, so I removed it
return new ItemStack(Item.getItemById(106), 2, 0);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ public GlowflowerCrop() {
super();
}

@Override
public ItemStack getDisplayItem() {
return new ItemStack(BOPCBlocks.flowers, 1, 3);
}

@Override
public int tier() {
return super.tier() + 2;
Expand All @@ -37,25 +32,25 @@ public String[] attributes() {
return new String[] { "Nether", "Light", "Shiny" };
}

@Override
public boolean canGrow(ICropTile crop) {
return crop.getSize() < this.maxSize();
}

@Override
public int getEmittedLight(ICropTile crop) {
if (crop.getSize() >= this.maxSize()) return 7;
else return 0;
}

@Override
public ItemStack getGain(ICropTile crop) {
// glow stone below doubles the yield
return new ItemStack(BOPCBlocks.flowers, crop.isBlockBelow(Blocks.glowstone) ? 2 : 1, 3);
}

@Override
public List<String> getCropInformation() {
return Arrays.asList("Needs a block of Glowstone below to incrase yield", "Emits light when fully grown.");
return Arrays.asList("Needs a block of Glowstone below to increase yield", "Emits light when fully grown.");
}

@Override
public ItemStack getGain(ICropTile crop) {
// glow stone below doubles the yield
return new ItemStack(BOPCBlocks.flowers, crop.isBlockBelow(Blocks.glowstone) ? 2 : 1, 3);
public ItemStack getDisplayItem() {
return new ItemStack(BOPCBlocks.flowers, 1, 3);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,43 +18,38 @@ public GlowingCoralCrop() {
}

@Override
public ItemStack getDisplayItem() {
return new ItemStack(BOPCBlocks.coral1, 1, 15);
public int tier() {
return super.tier() + 4;
}

@Override
public String name() {
return "Glowing Earth Coral";
}

@Override
public int tier() {
return super.tier() + 4;
}

@Override
public String[] attributes() {
return new String[] { "Water", "Light", "Shiny" };
}

@Override
public List<String> getCropInformation() {
return Arrays.asList("Needs a block of Glowstone below to incrase yield", "Emits light.");
public int getEmittedLight(ICropTile crop) {
return 7;
}

@Override
public int getEmittedLight(ICropTile crop) {
return 7;
public ItemStack getGain(ICropTile crop) {
// glow stone below doubles the yield
return new ItemStack(BOPCBlocks.coral1, crop.isBlockBelow(Blocks.glowstone) ? 2 : 1, 15);
}

@Override
public boolean canGrow(ICropTile crop) {
return crop.getSize() < this.maxSize();
public List<String> getCropInformation() {
return Arrays.asList("Needs a block of Glowstone below to increase yield", "Emits light.");
}

@Override
public ItemStack getGain(ICropTile crop) {
// glow stone below doubles the yield
return new ItemStack(BOPCBlocks.coral1, crop.isBlockBelow(Blocks.glowstone) ? 2 : 1, 15);
public ItemStack getDisplayItem() {
return new ItemStack(BOPCBlocks.coral1, 1, 15);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,13 @@ public int tier() {
}

@Override
public boolean canGrow(ICropTile crop) {
return crop.getSize() < 3;
}

@Override
public int maxSize() {
return 3;
public String name() {
return "Ivy";
}

@Override
public String name() {
return "Ivy";
public String[] attributes() {
return new String[] { "Green", "Tendrilly", "Flower", "Bad", "Poison" };
}

@Override
Expand All @@ -39,13 +34,13 @@ public String discoveredBy() {
}

@Override
public String[] attributes() {
return new String[] { "Green", "Tendrilly", "Flower", "Bad", "Poison" };
public int maxSize() {
return 3;
}

@Override
public boolean canBeHarvested(ICropTile crop) {
return crop.getSize() == this.maxSize();
return crop.getSize() >= this.maxSize();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@

public class TurnipCrop extends BasicFoodCrop {

private static final String cropOreName = "cropTurnip";

public TurnipCrop() {
super();
OreDict.BSget("crop" + this.name(), this);
OreDict.BSget("seed" + this.name(), this);
// this used to register both crop and seed, but it was redundant thanks to the crop loader core code
OreDict.BSget(cropOreName, this);
}

@Override
Expand All @@ -26,13 +28,13 @@ public String name() {
}

@Override
public ItemStack getGain(ICropTile crop) {
return CCropUtility.getCopiedOreStack("cropTurnip");
public String[] attributes() {
return new String[] { "Food", "Purple", "Carrots" };
}

@Override
public String[] attributes() {
return new String[] { "Food", "Purple", "Carrots" };
public ItemStack getGain(ICropTile crop) {
return CCropUtility.getCopiedOreStack(cropOreName);
}

@SideOnly(Side.CLIENT)
Expand All @@ -48,6 +50,6 @@ public void registerSprites(IIconRegister iconRegister) {

@Override
public ItemStack getDisplayItem() {
return OreDict.ISget("crop" + this.name());
return OreDict.ISget(cropOreName);
}
}
Loading

0 comments on commit 04af1ca

Please sign in to comment.