mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 03:25:18 +00:00
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:
1 parent
7b0d8f09e9
commit
ae72fa7ceb
4 files changed
+23
-6
No files matched your search
@@ -54,7 +54,7 @@
|
||||
+ {
|
||||
+ List<ItemStack> ret = new java.util.ArrayList<ItemStack>();
|
||||
+ if (RANDOM.nextInt(8) != 0) return ret;
|
||||
+ ItemStack seed = net.minecraftforge.common.ForgeHooks.getGrassSeed(RANDOM);
|
||||
+ ItemStack seed = net.minecraftforge.common.ForgeHooks.getGrassSeed(RANDOM, fortune);
|
||||
+ if (seed != null) ret.add(seed);
|
||||
+ return ret;
|
||||
+ }
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@
|
||||
+ }
|
||||
|
||||
- if (iblockstate.func_185904_a() != Material.field_151579_a && f >= 1.0F)
|
||||
+ if (iblockstate.func_177230_c().isAir(iblockstate, field_73092_a, p_180784_1_) && f >= 1.0F)
|
||||
+ if (!iblockstate.func_177230_c().isAir(iblockstate, field_73092_a, p_180784_1_) && f >= 1.0F)
|
||||
{
|
||||
this.func_180237_b(p_180784_1_);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user