Fix tall grass not dropping seeds. Closes #5675
This commit is contained in:
parent
c57c6213ea
commit
4b5bf760ec
2 changed files with 26 additions and 4 deletions
|
@ -50,7 +50,6 @@ import net.minecraft.block.state.BlockWorldState;
|
|||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
|
@ -161,8 +160,8 @@ public class ForgeHooks
|
|||
{
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final Marker FORGEHOOKS = MarkerManager.getMarker("FORGEHOOKS");
|
||||
//TODO: Loot tables?
|
||||
static class SeedEntry extends WeightedRandom.Item
|
||||
//TODO: Remove in 1.14 as vanilla uses loot tables
|
||||
public static class SeedEntry extends WeightedRandom.Item
|
||||
{
|
||||
@Nonnull
|
||||
public final ItemStack seed;
|
||||
|
@ -177,6 +176,25 @@ public class ForgeHooks
|
|||
return seed.copy();
|
||||
}
|
||||
}
|
||||
public static class FortuneSeedEntry extends SeedEntry
|
||||
{
|
||||
private int min, factor;
|
||||
public FortuneSeedEntry(@Nonnull ItemStack seed, int weight, int min, int factor)
|
||||
{
|
||||
super(seed, weight);
|
||||
this.min = min;
|
||||
this.factor = factor;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public ItemStack getStack(Random rand, int fortune)
|
||||
{
|
||||
ItemStack ret = seed.copy();
|
||||
ret.setCount(min + rand.nextInt(fortune * factor + 1));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
static final List<SeedEntry> seedList = new ArrayList<SeedEntry>();
|
||||
|
||||
@Nonnull
|
||||
|
|
|
@ -23,8 +23,10 @@ import net.minecraftforge.eventbus.api.BusBuilder;
|
|||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.ForgeHooks.SeedEntry;
|
||||
import net.minecraftforge.common.ForgeHooks.FortuneSeedEntry;
|
||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
@ -81,6 +83,8 @@ public class MinecraftForge
|
|||
|
||||
//For all the normal CrashReport classes to be defined. We're in MC's classloader so this should all be fine
|
||||
new CrashReport("ThisIsFake", new Exception("Not real"));
|
||||
|
||||
addGrassSeed(new FortuneSeedEntry(new ItemStack(Items.WHEAT_SEEDS), 100, 1, 2));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue