Skip to content

Commit 0289379

Browse files
committed
api/cellar/yeast,cellar: Register yeast items
Yeast can be registered, but has no biome mapping, this along with a small change to the Yeast Jar's produce logic allows the multiplication of hard to get yeast types (Origin and Bayanus). I may consider wrapping the Yeast entries in an actual class to keep things organized, but lists and maps work fine for now.
1 parent d396066 commit 0289379

File tree

4 files changed

+49
-1
lines changed

4 files changed

+49
-1
lines changed

src/java/growthcraft/api/cellar/yeast/IYeastRegistry.java

+19
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,26 @@
3333

3434
public interface IYeastRegistry extends ILoggable
3535
{
36+
/**
37+
* Adds the given ItemStack as a possible yeast item
38+
*
39+
* @param yeast - an item
40+
*/
41+
void addYeast(ItemStack yeast);
42+
43+
boolean isYeast(ItemStack yeast);
44+
45+
/**
46+
* Maps the given yeast item to the given biome type, when a Yeast Jar
47+
* is placed into a biome of that type, it MAY produce the yeast item.
48+
* NOTE. This method SHOULD use addYeast to add the given yeast item to the
49+
* known list.
50+
*
51+
* @param yeast - an item
52+
* @param type - the biome type to add
53+
*/
3654
void addYeastToBiomeType(ItemStack yeast, BiomeDictionary.Type type);
55+
3756
List<ItemStack> getYeastListForBiomeType(BiomeDictionary.Type type);
3857
List<BiomeDictionary.Type> getBiomeTypesForYeast(ItemStack yeast);
3958
boolean canYeastFormInBiome(ItemStack yeast, BiomeGenBase biome);

src/java/growthcraft/api/cellar/yeast/YeastRegistry.java

+18
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import java.util.HashMap;
2828
import java.util.List;
2929
import java.util.Map;
30+
import java.util.Set;
31+
import java.util.HashSet;
3032
import javax.annotation.Nonnull;
3133

3234
import growthcraft.api.core.log.ILogger;
@@ -39,6 +41,7 @@
3941

4042
public class YeastRegistry implements IYeastRegistry
4143
{
44+
private Set<ItemKey> yeastList = new HashSet<ItemKey>();
4245
private Map<BiomeDictionary.Type, List<ItemStack>> biomeToYeast = new HashMap<BiomeDictionary.Type, List<ItemStack>>();
4346
private Map<ItemKey, List<BiomeDictionary.Type>> yeastToBiome = new HashMap<ItemKey, List<BiomeDictionary.Type>>();
4447
private ILogger logger = NullLogger.INSTANCE;
@@ -54,9 +57,24 @@ private ItemKey stackToKey(@Nonnull ItemStack stack)
5457
return new ItemKey(stack);
5558
}
5659

60+
@Override
61+
public void addYeast(@Nonnull ItemStack yeast)
62+
{
63+
yeastList.add(stackToKey(yeast));
64+
}
65+
66+
@Override
67+
public boolean isYeast(ItemStack yeast)
68+
{
69+
if (yeast == null) return false;
70+
if (yeast.getItem() == null) return false;
71+
return yeastList.contains(stackToKey(yeast));
72+
}
73+
5774
@Override
5875
public void addYeastToBiomeType(@Nonnull ItemStack yeast, BiomeDictionary.Type type)
5976
{
77+
addYeast(yeast);
6078
if (!biomeToYeast.containsKey(type))
6179
{
6280
biomeToYeast.put(type, new ArrayList<ItemStack>());

src/java/growthcraft/cellar/GrowthCraftCellar.java

+11
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import growthcraft.cellar.stats.GrcCellarAchievements;
4242
import growthcraft.cellar.util.CellarBoozeBuilderFactory;
4343
import growthcraft.cellar.util.GrcCellarUserApis;
44+
import growthcraft.cellar.util.YeastType;
4445
import growthcraft.core.common.definition.BlockDefinition;
4546
import growthcraft.core.common.definition.ItemDefinition;
4647
import growthcraft.core.integration.NEI;
@@ -287,10 +288,20 @@ private void registerOres()
287288
OreDictionary.registerOre("materialYeast", yeast.getItem());
288289
}
289290

291+
private void registerYeast()
292+
{
293+
CellarRegistry.instance().yeast().addYeast(YeastType.BREWERS.asStack());
294+
CellarRegistry.instance().yeast().addYeast(YeastType.LAGER.asStack());
295+
CellarRegistry.instance().yeast().addYeast(YeastType.BAYANUS.asStack());
296+
CellarRegistry.instance().yeast().addYeast(YeastType.ETHEREAL.asStack());
297+
CellarRegistry.instance().yeast().addYeast(YeastType.ORIGIN.asStack());
298+
}
299+
290300
@EventHandler
291301
public void load(FMLInitializationEvent event)
292302
{
293303
registerOres();
304+
registerYeast();
294305

295306
packetPipeline.initialise();
296307
NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandlerCellar());

src/java/growthcraft/cellar/common/tileentity/device/YeastGenerator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void produceYeast()
9696
else
9797
{
9898
final ItemStack contents = getInventory().getStackInSlot(invSlot);
99-
if (CellarRegistry.instance().yeast().canYeastFormInBiome(contents, getCurrentBiome()))
99+
if (CellarRegistry.instance().yeast().isYeast(contents))
100100
{
101101
getInventory().setInventorySlotContents(invSlot, ItemUtils.increaseStack(contents));
102102
consumeFluid();

0 commit comments

Comments
 (0)