Add support for ExU and AA crops to plantable handler (#1107)
Theoretically. Don't actually know if their stuff is written properly.
This commit is contained in:
parent
c7f644528b
commit
abef1bada7
|
@ -7,9 +7,12 @@ import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.IPlantable;
|
import net.minecraftforge.common.IPlantable;
|
||||||
|
import net.minecraftforge.fml.common.Loader;
|
||||||
|
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -28,6 +31,13 @@ public class HarvestHandlerPlantable implements IHarvestHandler
|
||||||
HarvestRegistry.registerStandardCrop(Blocks.POTATOES, 7);
|
HarvestRegistry.registerStandardCrop(Blocks.POTATOES, 7);
|
||||||
HarvestRegistry.registerStandardCrop(Blocks.BEETROOTS, 3);
|
HarvestRegistry.registerStandardCrop(Blocks.BEETROOTS, 3);
|
||||||
HarvestRegistry.registerStandardCrop(Blocks.NETHER_WART, 3);
|
HarvestRegistry.registerStandardCrop(Blocks.NETHER_WART, 3);
|
||||||
|
|
||||||
|
addThirdPartyCrop("actuallyadditions", "blockFlax", 7);
|
||||||
|
addThirdPartyCrop("actuallyadditions", "blockCanola", 7);
|
||||||
|
addThirdPartyCrop("actuallyadditions", "blockRice", 7);
|
||||||
|
|
||||||
|
addThirdPartyCrop("extrautils2", "redorchid", 6);
|
||||||
|
addThirdPartyCrop("extrautils2", "enderlily", 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -51,11 +61,7 @@ public class HarvestHandlerPlantable implements IHarvestHandler
|
||||||
|
|
||||||
if (stack.getItem() instanceof IPlantable)
|
if (stack.getItem() instanceof IPlantable)
|
||||||
{
|
{
|
||||||
if (stack.getCount() > 1)
|
stack.shrink(1);
|
||||||
stack.shrink(1);
|
|
||||||
else
|
|
||||||
drops.remove(stack);
|
|
||||||
|
|
||||||
foundSeed = true;
|
foundSeed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -67,6 +73,9 @@ public class HarvestHandlerPlantable implements IHarvestHandler
|
||||||
world.playEvent(2001, pos, Block.getStateId(blockStack.getState()));
|
world.playEvent(2001, pos, Block.getStateId(blockStack.getState()));
|
||||||
for (ItemStack stack : drops)
|
for (ItemStack stack : drops)
|
||||||
{
|
{
|
||||||
|
if (stack.isEmpty())
|
||||||
|
continue;
|
||||||
|
|
||||||
if (!world.isRemote)
|
if (!world.isRemote)
|
||||||
{
|
{
|
||||||
EntityItem toDrop = new EntityItem(world, pos.getX(), pos.getY() + 0.5, pos.getZ(), stack);
|
EntityItem toDrop = new EntityItem(world, pos.getX(), pos.getY() + 0.5, pos.getZ(), stack);
|
||||||
|
@ -79,4 +88,14 @@ public class HarvestHandlerPlantable implements IHarvestHandler
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void addThirdPartyCrop(String modid, String regName, int matureMeta)
|
||||||
|
{
|
||||||
|
if (!Loader.isModLoaded(modid))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(modid, regName));
|
||||||
|
if (block != null && block != Blocks.AIR)
|
||||||
|
HarvestRegistry.registerStandardCrop(block, matureMeta);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue