Fixed breaking of tall grass. It now uses fortune. Expanded grass seed hooks to allow Fortune. Potentially removing in future in favor of LootTables.

This commit is contained in:
LexManos committed 2016-03-15 01:17:38 -07:00
1 parent 7b0d8f09e9
commit ae72fa7ceb
4 files changed
+23 -6

No files matched your search

@@ -111,6 +111,7 @@ import net.minecraftforge.fml.relauncher.ReflectionHelper;
public class ForgeHooks
{
//TODO: Loot tables?
static class SeedEntry extends WeightedRandom.Item
{
public final ItemStack seed;
@@ -119,17 +120,21 @@ public class ForgeHooks
super(weight);
this.seed = seed;
}
public ItemStack getStack(Random rand, int fortune)
{
return seed.copy();
}
}
static final List<SeedEntry> seedList = new ArrayList<SeedEntry>();
public static ItemStack getGrassSeed(Random rand)
public static ItemStack getGrassSeed(Random rand, int fortune)
{
SeedEntry entry = (SeedEntry)WeightedRandom.getRandomItem(rand, seedList);
if (entry == null || entry.seed == null)
{
return null;
}
return entry.seed.copy();
return entry.getStack(rand, fortune);
}
private static boolean toolInit = false;
@@ -257,7 +262,13 @@ public class ForgeHooks
static
{
seedList.add(new SeedEntry(new ItemStack(Items.wheat_seeds), 10));
seedList.add(new SeedEntry(new ItemStack(Items.wheat_seeds), 10)
{
public ItemStack getStack(Random rand, int fortune)
{
return new ItemStack(Items.wheat_seeds, 1 + rand.nextInt(fortune * 2 + 1));
}
});
initTools();
}
@@ -38,10 +38,16 @@ public class MinecraftForge
* @param seed The item to drop as a seed.
* @param weight The relative probability of the seeds,
* where wheat seeds are 10.
*
* Note: These functions may be going away soon, we're looking into loot tables....
*/
public static void addGrassSeed(ItemStack seed, int weight)
{
ForgeHooks.seedList.add(new SeedEntry(seed, weight));
addGrassSeed(new SeedEntry(seed, weight));
}
public static void addGrassSeed(SeedEntry seed)
{
ForgeHooks.seedList.add(seed);
}
/**