Skip to content

Commit 96362bf

Browse files
committed
bushes should now generate as cotton instead of string if harvestcraft is installed
1 parent 9a658fe commit 96362bf

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/main/java/gregapi/data/CS.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1580,11 +1580,12 @@ public static class PotionsGT {
15801580

15811581
public static class BushesGT {
15821582
public static final ItemStackMap<ItemStackContainer, int[]> MAP = new ItemStackMap<>();
1583-
public static int[] get(ItemStack aStack) {return MAP.containsKey(aStack, F) ? MAP.get(aStack) : MAP.get(new ItemStackContainer(aStack, 1, W));}
1583+
public static int[] get(ItemStack aStack) {return UT.Code.getWithDefault(MAP.containsKey(aStack, F) ? MAP.get(aStack) : MAP.get(new ItemStackContainer(aStack, 1, W)), DEFAULT);}
15841584
/** Bush Color, Stage 1, Stage 2, Stage 3 */
15851585
public static void put(ItemStack aStack, int aBush, int aBloom, int aImmature, int aBerry) {if (!MAP.containsKey(aStack, F)) MAP.put(aStack, new int[] {aBush, aBloom, aImmature, aBerry});}
15861586
public static void override(ItemStack aStack, int... aColors) {MAP.put(aStack, aColors);}
15871587
// Add Cotton as a Default Bush.
1588+
public static int[] DEFAULT = new int[] {0x22cc22, 0x33cc33, 0x44cc44, 0xeeeeee};
15881589
static {put(ST.make(Items.string, 1, 0), 0x22cc22, 0x33cc33, 0x44cc44, 0xeeeeee);}
15891590
}
15901591

src/main/java/gregapi/util/UT.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,10 @@ public static <E> E getFirstNonNull(E... aArray) {
13721372
return null;
13731373
}
13741374

1375+
public static <E> E getWithDefault(E aObject, E aDefault) {
1376+
return aObject != null ? aObject : aDefault;
1377+
}
1378+
13751379
private static final DateFormat sDateFormat = DateFormat.getInstance();
13761380
public static String dateAndTime() {
13771381
return sDateFormat.format(new Date());

src/main/java/gregtech/worldgen/WorldgenBushes.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@
2121

2222
import gregapi.block.multitileentity.MultiTileEntityRegistry;
2323
import gregapi.code.ItemStackContainer;
24-
import gregapi.data.IL;
24+
import gregapi.data.MD;
2525
import gregapi.util.ST;
2626
import gregapi.util.UT;
2727
import gregapi.util.WD;
2828
import gregapi.worldgen.WorldgenObject;
2929
import gregapi.worldgen.WorldgenOnSurface;
3030
import net.minecraft.block.Block;
3131
import net.minecraft.init.Blocks;
32+
import net.minecraft.init.Items;
3233
import net.minecraft.item.ItemStack;
3334
import net.minecraft.world.World;
3435
import net.minecraft.world.biome.BiomeGenBase;
@@ -62,7 +63,10 @@ public boolean tryPlaceStuff(World aWorld, int aX, int aY, int aZ, Random aRando
6263
MultiTileEntityRegistry tRegistry = MultiTileEntityRegistry.getRegistry("gt.multitileentity");
6364
if (tRegistry == null) return F;
6465

65-
ItemStack tBerry = UT.Code.select(new NoiseGenerator(aWorld).get(aX/2, 300, aZ/2, BushesGT.MAP.size()), new ItemStackContainer(IL.Food_Candleberry.get(1)), BushesGT.MAP.keySet().toArray(ZL_ISC)).toStack();
66+
ItemStack tBerry = UT.Code.select(new NoiseGenerator(aWorld).get(aX/2, 300, aZ/2, BushesGT.MAP.size()), new ItemStackContainer(Items.string, 1, 0), BushesGT.MAP.keySet().toArray(ZL_ISC)).toStack();
67+
68+
// Change Minecraft String to Harvestcraft Cotton, because it's in the static initializer as a default.
69+
if (MD.HaC.mLoaded && ST.item(tBerry) == Items.string) tBerry = ST.make(MD.HaC, "cottonItem", 1, 0, tBerry);
6670

6771
if (placeBushCore(aWorld, aX, aY, aZ, tRegistry, tBerry, 3)) {
6872
if (aRandom.nextBoolean() && placeBushCore(aWorld, aX-1, aY, aZ , tRegistry, tBerry, 3)) placeBushSides(aWorld, aX-1, aY, aZ , tRegistry, tBerry, 3);

0 commit comments

Comments
 (0)