mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-28 15:36:18 +00:00
Merge branch 'mc-1.12' of https://github.com/ForestryMC/ForestryMC into mc-1.12
This commit is contained in:
commit
465d32af25
15 files changed
+413
-334
No files matched your search
@@ -15,7 +15,10 @@ import com.google.common.base.Preconditions;
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
|
||||
import forestry.plugins.compat.PluginNatura;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -26,6 +29,7 @@ import net.minecraftforge.fml.common.event.FMLInterModComms.IMCEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
@@ -54,10 +58,11 @@ import forestry.plugins.compat.PluginIC2;
|
||||
name = Constants.MOD_NAME,
|
||||
version = Constants.VERSION,
|
||||
guiFactory = "forestry.core.config.ForestryGuiConfigFactory",
|
||||
acceptedMinecraftVersions = "[1.12]",
|
||||
acceptedMinecraftVersions = "[1.12, 1.12.1]",
|
||||
dependencies = "required-after:forge@[14.21.1.2395,);"
|
||||
+ "after:jei@[4.7.0,);"
|
||||
+ "after:" + PluginIC2.modId + ";"
|
||||
+ "after:" + PluginNatura.modId + ";"
|
||||
+ "after:toughasnails;")
|
||||
public class Forestry {
|
||||
|
||||
@@ -73,6 +78,7 @@ public class Forestry {
|
||||
ForestryAPI.errorStateRegistry = new ErrorStateRegistry();
|
||||
EnumErrorCode.init();
|
||||
FluidRegistry.enableUniversalBucket();
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -105,6 +111,11 @@ public class Forestry {
|
||||
|
||||
PluginManager.runPreInit(event.getSide());
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void registerModels(ModelRegistryEvent event) {
|
||||
PluginManager.runRegisterBackpacksAndCrates();
|
||||
Proxies.render.registerModels();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import net.minecraft.potion.PotionUtils;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.DimensionType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.IChunkGenerator;
|
||||
@@ -897,6 +898,14 @@ public class PluginApiculture extends BlankForestryPlugin {
|
||||
return new SaveEventHandlerApiculture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populateChunk(IChunkGenerator chunkGenerator, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated) {
|
||||
if(!world.provider.getDimensionType().equals(DimensionType.THE_END)) return;
|
||||
if (Config.getBeehivesAmount() > 0.0) {
|
||||
HiveDecorator.decorateHives(world, rand, chunkX, chunkZ);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decorateBiome(World world, Random rand, BlockPos pos) {
|
||||
if (Config.getBeehivesAmount() > 0.0) {
|
||||
|
||||
@@ -142,6 +142,14 @@ public abstract class BlockForestryLog<T extends Enum<T> & IWoodType> extends Bl
|
||||
return woodType.getHardness();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getSilkTouchDrop(IBlockState state) {
|
||||
ItemStack silkTouchDrop = super.getSilkTouchDrop(state);
|
||||
int damage = this.damageDropped(state);
|
||||
silkTouchDrop.setItemDamage(damage);
|
||||
return silkTouchDrop;
|
||||
}
|
||||
|
||||
/* PROPERTIES */
|
||||
@Override
|
||||
public final int getFireSpreadSpeed(IBlockAccess world, BlockPos pos, EnumFacing face) {
|
||||
|
||||
@@ -47,28 +47,35 @@ public class SimpleModel implements IModel {
|
||||
private static final ModelResourceLocation MISSING = new ModelResourceLocation("builtin/missing", "missing");
|
||||
|
||||
private final List<Variant> variants;
|
||||
private final List<ResourceLocation> locations = new ArrayList<>();
|
||||
private final Set<ResourceLocation> textures = Sets.newHashSet();
|
||||
private final List<IModel> models = new ArrayList<>();
|
||||
private final ImmutableList<ResourceLocation> locations;
|
||||
private final ImmutableSet<ResourceLocation> textures;
|
||||
private final ImmutableList<IModel> models;
|
||||
private final IModelState defaultState;
|
||||
|
||||
public SimpleModel(List<ResourceLocation> locations, List<IModel> models, List<Variant> variants,
|
||||
IModelState defaultState) {
|
||||
this.locations.addAll(locations);
|
||||
this.models.addAll(models);
|
||||
this.variants = variants;
|
||||
this.locations = ImmutableList.copyOf(locations);
|
||||
this.models = ImmutableList.copyOf(models);
|
||||
this.defaultState = defaultState;
|
||||
|
||||
ImmutableSet.Builder<ResourceLocation> texturesBuilder = ImmutableSet.builder();
|
||||
for (IModel model : models) {
|
||||
textures.addAll(model.getTextures());
|
||||
texturesBuilder.addAll(model.getTextures());
|
||||
}
|
||||
textures = texturesBuilder.build();
|
||||
}
|
||||
|
||||
public SimpleModel(ResourceLocation parent, VariantList variants) throws Exception {
|
||||
this.variants = variants.getVariantList();
|
||||
ImmutableList.Builder<Pair<IModel, IModelState>> builder = ImmutableList.builder();
|
||||
ImmutableList.Builder<IModel> modelsBuilder = ImmutableList.builder();
|
||||
ImmutableList.Builder<ResourceLocation> locationsBuilder = ImmutableList.builder();
|
||||
ImmutableSet.Builder<ResourceLocation> texturesBuilder = ImmutableSet.builder();
|
||||
|
||||
for (Variant variant : this.variants) {
|
||||
ResourceLocation loc = variant.getModelLocation();
|
||||
locations.add(loc);
|
||||
locationsBuilder.add(loc);
|
||||
|
||||
IModel model;
|
||||
if (loc.equals(MISSING)) {
|
||||
@@ -81,19 +88,23 @@ public class SimpleModel implements IModel {
|
||||
for (ResourceLocation location : model.getDependencies()) {
|
||||
ModelLoaderRegistry.getModelOrMissing(location);
|
||||
}
|
||||
textures.addAll(model.getTextures());
|
||||
texturesBuilder.addAll(model.getTextures());
|
||||
|
||||
models.add(model);
|
||||
modelsBuilder.add(model);
|
||||
builder.add(Pair.of(model, variant.getState()));
|
||||
}
|
||||
|
||||
if (models.size() == 0) {
|
||||
if (this.variants.size() == 0) {
|
||||
IModel missing = ModelLoaderRegistry.getMissingModel();
|
||||
models.add(missing);
|
||||
modelsBuilder.add(missing);
|
||||
builder.add(Pair.of(missing, TRSRTransformation.identity()));
|
||||
}
|
||||
|
||||
defaultState = new MultiModelState(builder.build());
|
||||
|
||||
locations = locationsBuilder.build();
|
||||
models = modelsBuilder.build();
|
||||
textures = texturesBuilder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -129,6 +140,7 @@ public class SimpleModel implements IModel {
|
||||
|
||||
@Override
|
||||
public IModel retexture(ImmutableMap<String, String> textures) {
|
||||
List<ResourceLocation> locations = new ArrayList<>();
|
||||
List<IModel> models = new ArrayList<>();
|
||||
ImmutableList.Builder<Pair<IModel, IModelState>> builder = ImmutableList.builder();
|
||||
for (Variant variant : this.variants) {
|
||||
|
||||
@@ -29,6 +29,7 @@ public class Circuits {
|
||||
public static ICircuit farmOrchardManual;
|
||||
public static ICircuit farmRubberManual;
|
||||
public static ICircuit farmEnderManaged;
|
||||
public static ICircuit farmOrchidManaged;
|
||||
public static ICircuit machineSpeedUpgrade1;
|
||||
public static ICircuit machineSpeedUpgrade2;
|
||||
public static ICircuit machineEfficiencyUpgrade1;
|
||||
|
||||
@@ -99,6 +99,7 @@ public class Config {
|
||||
public static int farmSize = 2;
|
||||
public static boolean squareFarms = false;
|
||||
private static boolean enableExUtilEnderLily = true;
|
||||
private static boolean enableExUtilRedOrchid = true;
|
||||
private static boolean enableMagicalCropsSupport = true;
|
||||
|
||||
// Mail
|
||||
@@ -138,6 +139,8 @@ public class Config {
|
||||
return enableExUtilEnderLily;
|
||||
}
|
||||
|
||||
public static boolean isExUtilRedOrchidEnabled() { return enableExUtilRedOrchid; }
|
||||
|
||||
public static boolean isMagicalCropsSupportEnabled() {
|
||||
return enableMagicalCropsSupport;
|
||||
}
|
||||
@@ -251,6 +254,7 @@ public class Config {
|
||||
farmSize = configCommon.getIntLocalized("tweaks.farms", "size", farmSize, 1, 3);
|
||||
squareFarms = configCommon.getBooleanLocalized("tweaks.farms", "square", squareFarms);
|
||||
enableExUtilEnderLily = configCommon.getBooleanLocalized("tweaks.farms", "enderlily", enableExUtilEnderLily);
|
||||
enableExUtilRedOrchid = configCommon.getBooleanLocalized("tweaks.farms", "redorchid", enableExUtilRedOrchid);
|
||||
enableMagicalCropsSupport = configCommon.getBooleanLocalized("tweaks.farms", "magicalcrops", enableMagicalCropsSupport);
|
||||
|
||||
climateSourceRange = configCommon.getIntLocalized("tweaks.greenhouse", "range", climateSourceRange, 9, 270);
|
||||
|
||||
@@ -26,7 +26,8 @@ public enum EnumElectronTube implements ItemOverlay.IOverlayInfo {
|
||||
EMERALD(new Color(0x00CC41)),
|
||||
APATITE(new Color(0x579CD9)),
|
||||
LAPIS(new Color(0x1c57c6)),
|
||||
ENDER(new Color(0x33adad), new Color(0x255661));
|
||||
ENDER(new Color(0x33adad), new Color(0x255661)),
|
||||
ORCHID(new Color(0x820208), new Color(0xc64f3f));
|
||||
|
||||
public static final EnumElectronTube[] VALUES = values();
|
||||
|
||||
|
||||
@@ -326,6 +326,12 @@ public class PluginFactory extends BlankForestryPlugin {
|
||||
"XXX",
|
||||
'#', new ItemStack(Items.ENDER_EYE, 1, 0),
|
||||
'X', new ItemStack(Blocks.END_STONE, 1, 0)});
|
||||
RecipeManagers.fabricatorManager.addRecipe(ItemStack.EMPTY, Fluids.GLASS.getFluid(500), electronTube.get(EnumElectronTube.ORCHID, 4), new Object[]{
|
||||
" X ",
|
||||
"#X#",
|
||||
"XXX",
|
||||
'#', new ItemStack(Items.REPEATER, 1, 0),
|
||||
'X', new ItemStack(Blocks.REDSTONE_ORE, 1, 0)});
|
||||
|
||||
String[] dyes = {"dyeBlack", "dyeRed", "dyeGreen", "dyeBrown", "dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray", "dyeGray", "dyePink", "dyeLime",
|
||||
"dyeYellow", "dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite"};
|
||||
|
||||
+16
-7
@@ -13,35 +13,44 @@ package forestry.farming.logic;
|
||||
import java.util.Collection;
|
||||
import java.util.Stack;
|
||||
|
||||
import forestry.farming.FarmRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.farming.FarmDirection;
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
|
||||
public class FarmLogicEnder extends FarmLogicHomogeneous {
|
||||
public class FarmLogicExU extends FarmLogicHomogeneous {
|
||||
|
||||
public FarmLogicEnder() {
|
||||
super(new ItemStack(Blocks.END_STONE), Blocks.END_STONE.getDefaultState(), ForestryAPI.farmRegistry.getFarmables("farmEnder"));
|
||||
private final String name;
|
||||
private final Item iconItem;
|
||||
|
||||
public FarmLogicExU(String name, Item iconItem, Block soil, String farmablesKey) {
|
||||
super(new ItemStack(soil), soil.getDefaultState(), FarmRegistry.getInstance().getFarmables(farmablesKey));
|
||||
if (soil.equals(Blocks.REDSTONE_ORE)) {
|
||||
super.addSoil(new ItemStack(Blocks.LIT_REDSTONE_ORE), Blocks.LIT_REDSTONE_ORE.getDefaultState(), false);
|
||||
}
|
||||
this.name = name;
|
||||
this.iconItem = iconItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Managed Ender Farm";
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getIconItemStack() {
|
||||
return new ItemStack(Items.ENDER_EYE);
|
||||
return new ItemStack(iconItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,108 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.farming.logic;
|
||||
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.arboriculture.TreeManager;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.core.blocks.BlockRegistry;
|
||||
import forestry.core.network.packets.PacketFXSignal;
|
||||
import forestry.core.utils.GeneticsUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.NetworkUtil;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
public class FarmableSapling implements IFarmable {
|
||||
protected final ItemStack germling;
|
||||
protected final boolean ignoreMetadata;
|
||||
protected final Block saplingBlock;
|
||||
protected final ItemStack[] windfall;
|
||||
|
||||
public FarmableSapling(final ItemStack germling, final ItemStack[] windfall) {
|
||||
this(germling, windfall, true);
|
||||
}
|
||||
|
||||
public FarmableSapling(final ItemStack germling, final ItemStack[] windfall, boolean addSubItems) {
|
||||
this.germling = germling;
|
||||
this.windfall = windfall;
|
||||
this.saplingBlock = ItemStackUtil.getBlock(germling);
|
||||
this.ignoreMetadata = addSubItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.ARBORICULTURE)) {
|
||||
IIndividual tree = GeneticsUtil.getGeneticEquivalent(germling);
|
||||
if (tree instanceof ITree) {
|
||||
return TreeManager.treeRoot.plantSapling(world, (ITree) tree, player.getGameProfile(), pos);
|
||||
}
|
||||
}
|
||||
ItemStack copy = germling.copy();
|
||||
player.setHeldItem(EnumHand.MAIN_HAND, copy);
|
||||
EnumActionResult actionResult = copy.onItemUse(player, world, pos.down(), EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0);
|
||||
player.setHeldItem(EnumHand.MAIN_HAND, ItemStack.EMPTY);
|
||||
if (actionResult == EnumActionResult.SUCCESS) {
|
||||
PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, pos, Blocks.SAPLING.getDefaultState());
|
||||
NetworkUtil.sendNetworkPacket(packet, pos, world);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSaplingAt(World world, BlockPos pos) {
|
||||
return world.getBlockState(pos).getBlock() == this.saplingBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICrop getCropAt(World world, BlockPos pos, IBlockState blockState) {
|
||||
Block block = blockState.getBlock();
|
||||
if (!block.isWood(world, pos)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new CropDestroy(world, blockState, pos, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGermling(ItemStack itemstack) {
|
||||
if (ignoreMetadata) {
|
||||
return ItemStack.areItemsEqual(germling, new ItemStack((itemstack.getItem())));
|
||||
}
|
||||
return ItemStack.areItemsEqual(germling, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWindfall(ItemStack itemstack) {
|
||||
for (ItemStack drop : windfall) {
|
||||
if (drop.isItemEqual(itemstack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -29,67 +29,13 @@ import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.core.network.packets.PacketFXSignal;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.GeneticsUtil;
|
||||
import forestry.core.utils.NetworkUtil;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
|
||||
public class FarmableVanillaSapling implements IFarmable {
|
||||
|
||||
protected final ItemStack germling;
|
||||
private final ItemStack[] windfall;
|
||||
public class FarmableVanillaSapling extends FarmableSapling {
|
||||
|
||||
public FarmableVanillaSapling() {
|
||||
this.germling = new ItemStack(Blocks.SAPLING);
|
||||
this.windfall = new ItemStack[]{new ItemStack(Items.APPLE), new ItemStack(FarmableCocoa.COCOA_SEED, 1, FarmableCocoa.COCOA_META)};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.ARBORICULTURE)) {
|
||||
IIndividual tree = GeneticsUtil.getGeneticEquivalent(germling);
|
||||
if (!(tree instanceof ITree)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return TreeManager.treeRoot.plantSapling(world, (ITree) tree, player.getGameProfile(), pos);
|
||||
} else {
|
||||
EnumActionResult actionResult = germling.copy().onItemUse(player, world, pos.down(), EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0);
|
||||
if (actionResult == EnumActionResult.SUCCESS) {
|
||||
PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, pos, Blocks.SAPLING.getDefaultState());
|
||||
NetworkUtil.sendNetworkPacket(packet, pos, world);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSaplingAt(World world, BlockPos pos) {
|
||||
return world.getBlockState(pos).getBlock() == Blocks.SAPLING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICrop getCropAt(World world, BlockPos pos, IBlockState blockState) {
|
||||
Block block = blockState.getBlock();
|
||||
if (!block.isWood(world, pos)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new CropDestroy(world, blockState, pos, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGermling(ItemStack itemstack) {
|
||||
return ItemStack.areItemsEqual(germling, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWindfall(ItemStack itemstack) {
|
||||
for (ItemStack drop : windfall) {
|
||||
if (drop.isItemEqual(itemstack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
super(new ItemStack(Blocks.SAPLING), new ItemStack[]{new ItemStack(Items.APPLE), new ItemStack(FarmableCocoa.COCOA_SEED, 1, FarmableCocoa.COCOA_META)});
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,8 @@ public class PluginManager {
|
||||
SETUP, // setup API to make it functional. GameMode Configs are not yet accessible
|
||||
SETUP_DISABLED, // setup fallback API to avoid crashes
|
||||
REGISTER, // register basic blocks and items
|
||||
PRE_INIT, // register handlers, triggers, definitions, backpacks, crates, and anything that depends on basic items
|
||||
PRE_INIT, // register handlers, triggers, definitions, and anything that depends on basic items
|
||||
BACKPACKS_CRATES, // backpacks, crates
|
||||
INIT, // anything that depends on PreInit stages, recipe registration
|
||||
POST_INIT, // stubborn mod integration, dungeon loot, and finalization of things that take input from mods
|
||||
FINISHED
|
||||
@@ -228,11 +229,19 @@ public class PluginManager {
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.BUILDCRAFT_STATEMENTS)) {
|
||||
plugin.registerTriggers();
|
||||
}
|
||||
Log.debug("Pre-Init Complete: {}", plugin);
|
||||
}
|
||||
}
|
||||
|
||||
public static void runRegisterBackpacksAndCrates() {
|
||||
stage = Stage.BACKPACKS_CRATES;
|
||||
for (IForestryPlugin plugin : loadedPlugins) {
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.STORAGE)) {
|
||||
Log.debug("BackpacksAndCrates Start: {}", plugin);
|
||||
plugin.registerBackpackItems();
|
||||
plugin.registerCrates();
|
||||
Log.debug("BackpacksAndCrates Complete: {}", plugin);
|
||||
}
|
||||
Log.debug("Pre-Init Complete: {}", plugin);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,18 +11,10 @@
|
||||
package forestry.plugins.compat;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import forestry.api.circuits.ChipsetManager;
|
||||
import forestry.api.circuits.ICircuit;
|
||||
import forestry.api.circuits.ICircuitLayout;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.PluginCore;
|
||||
@@ -33,12 +25,20 @@ import forestry.core.items.EnumElectronTube;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.ModUtil;
|
||||
import forestry.farming.FarmRegistry;
|
||||
import forestry.farming.circuits.CircuitFarmLogic;
|
||||
import forestry.farming.logic.FarmLogicEnder;
|
||||
import forestry.farming.logic.FarmLogicExU;
|
||||
import forestry.farming.logic.FarmableAgingCrop;
|
||||
import forestry.plugins.BlankForestryPlugin;
|
||||
import forestry.plugins.ForestryPlugin;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
|
||||
@ForestryPlugin(pluginID = ForestryPluginUids.EXTRA_UTILITIES, name = "ExtraUtilities", author = "Nirek", url = Constants.URL, unlocalizedDescription = "for.plugin.extrautilities.description")
|
||||
public class PluginExtraUtilities extends BlankForestryPlugin {
|
||||
@@ -59,33 +59,46 @@ public class PluginExtraUtilities extends BlankForestryPlugin {
|
||||
public void doInit() {
|
||||
super.doInit();
|
||||
|
||||
if (Config.isExUtilRedOrchidEnabled()) {
|
||||
registerExPlant("Orchid", "redorchid", "Red Orchid", Blocks.REDSTONE_ORE, circuit -> Circuits.farmOrchidManaged = circuit);
|
||||
}
|
||||
|
||||
if (Config.isExUtilEnderLilyEnabled()) {
|
||||
Block enderLillyBlock = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(ExU, "enderlilly"));
|
||||
Item enderLillyItem = Item.getItemFromBlock(enderLillyBlock);
|
||||
if (enderLillyBlock == Blocks.AIR) {
|
||||
Log.error("Could not find ender lilly block.");
|
||||
} else if (enderLillyItem == Items.AIR) {
|
||||
Log.error("Could not find ender lilly item.");
|
||||
} else {
|
||||
IProperty<Integer> growthProperty = BlockUtil.getProperty(enderLillyBlock, "growth", Integer.class);
|
||||
if (growthProperty == null) {
|
||||
Log.error("Could not find the growth property of ender lily.");
|
||||
} else {
|
||||
int harvestAge = Collections.max(growthProperty.getAllowedValues());
|
||||
int replantAge = enderLillyBlock.getDefaultState().getValue(growthProperty);
|
||||
ForestryAPI.farmRegistry.registerFarmables("farmEnder", new FarmableAgingCrop(new ItemStack(enderLillyItem), enderLillyBlock, growthProperty, harvestAge, replantAge));
|
||||
Circuits.farmEnderManaged = new CircuitFarmLogic("managedEnder", new FarmLogicEnder());
|
||||
}
|
||||
}
|
||||
registerExPlant("Ender", "enderlilly", "Ender Lily", Blocks.END_STONE, circuit -> Circuits.farmEnderManaged = circuit);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipes() {
|
||||
super.registerRecipes();
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FARMING) && Circuits.farmEnderManaged != null) {
|
||||
if (!ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FARMING)) return;
|
||||
if(Circuits.farmEnderManaged != null) {
|
||||
ICircuitLayout layoutManaged = ChipsetManager.circuitRegistry.getLayout("forestry.farms.managed");
|
||||
ChipsetManager.solderManager.addRecipe(layoutManaged, PluginCore.getItems().tubes.get(EnumElectronTube.ENDER, 1), Circuits.farmEnderManaged);
|
||||
}
|
||||
if(Circuits.farmOrchidManaged != null) {
|
||||
ICircuitLayout layoutManaged = ChipsetManager.circuitRegistry.getLayout("forestry.farms.managed");
|
||||
ChipsetManager.solderManager.addRecipe(layoutManaged, PluginCore.items.tubes.get(EnumElectronTube.ORCHID, 1), Circuits.farmOrchidManaged);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerExPlant(String id, String itemResourceName, String itemName, Block soil, Consumer<ICircuit> assignTo) {
|
||||
Block plantBlock = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(ExU, itemResourceName));
|
||||
Item plantItem = Item.getItemFromBlock(plantBlock);
|
||||
if(plantBlock == Blocks.AIR) {
|
||||
Log.error("Could not find {} block.", itemName);
|
||||
} else if (plantItem == null) {
|
||||
Log.error("Could not find {} item.", itemName);
|
||||
} else {
|
||||
IProperty<Integer> growthProperty = BlockUtil.getProperty(plantBlock, "growth", Integer.class);
|
||||
if (growthProperty == null) {
|
||||
Log.error("Could not find the growth property of {}.", itemName);
|
||||
} else {
|
||||
int harvestAge = Collections.max(growthProperty.getAllowedValues());
|
||||
int replantAge = plantBlock.getDefaultState().getValue(growthProperty);
|
||||
FarmRegistry.getInstance().registerFarmables(itemName, new FarmableAgingCrop(new ItemStack(plantItem), plantBlock, growthProperty, harvestAge, replantAge));
|
||||
assignTo.accept(new CircuitFarmLogic("managed" + id, new FarmLogicExU("Managed " + itemName + " Farm", plantItem, soil, itemName)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,11 +10,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.plugins.compat;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.farming.Farmables;
|
||||
import forestry.api.fuels.FuelManager;
|
||||
import forestry.api.fuels.MoistenerFuel;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
@@ -25,48 +23,57 @@ import forestry.core.config.Constants;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.recipes.RecipeUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.ModUtil;
|
||||
import forestry.farming.FarmRegistry;
|
||||
import forestry.farming.logic.FarmableAgingCrop;
|
||||
import forestry.farming.logic.FarmableSapling;
|
||||
import forestry.plugins.BlankForestryPlugin;
|
||||
import forestry.plugins.ForestryPlugin;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ForestryPlugin(pluginID = ForestryPluginUids.NATURA, name = "Natura", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.plugin.natura.description")
|
||||
public class PluginNatura extends BlankForestryPlugin {
|
||||
|
||||
private static final String NATURA = "Natura";
|
||||
public static final String modId = "natura";
|
||||
|
||||
@Nullable
|
||||
private static Block logNatura;
|
||||
@Nullable
|
||||
private static Block logWillow;
|
||||
@Nullable
|
||||
private static Block leavesNatura;
|
||||
@Nullable
|
||||
private static Block saplingNatura;
|
||||
@Nullable
|
||||
private static Block saplingNaturaRare;
|
||||
private static ArrayList<ItemStack> fruits = new ArrayList<>();
|
||||
private static ArrayList<ItemStack> soups = new ArrayList<>();
|
||||
private static ArrayList<ItemStack> berries = new ArrayList<>();
|
||||
private static ArrayList<ItemStack> edibles = new ArrayList<>();
|
||||
private static ArrayList<ItemStack> seeds = new ArrayList<>();
|
||||
private static ArrayList<ItemStack> logs = new ArrayList<>();
|
||||
private static ArrayList<ItemStack> saplings = new ArrayList<>();
|
||||
private static ArrayList<ItemStack> shrooms = new ArrayList<>();
|
||||
private static ArrayList<ItemStack> materials = new ArrayList<>();
|
||||
private static ArrayList<ItemStack> crops = new ArrayList<>();
|
||||
private static ArrayList<ItemStack> cropBlocks = new ArrayList<>();
|
||||
|
||||
private static ItemStack berryBlight = ItemStack.EMPTY;
|
||||
private static ItemStack berryDusk = ItemStack.EMPTY;
|
||||
private static ItemStack berrySky = ItemStack.EMPTY;
|
||||
private static ItemStack berrySting = ItemStack.EMPTY;
|
||||
private static ItemStack berryRasp = ItemStack.EMPTY;
|
||||
private static ItemStack berryBlue = ItemStack.EMPTY;
|
||||
private static ItemStack berryBlack = ItemStack.EMPTY;
|
||||
private static ItemStack berryMalo = ItemStack.EMPTY;
|
||||
private static ItemStack itemBarley = ItemStack.EMPTY;
|
||||
public PluginNatura() {
|
||||
super();
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return ModUtil.isModLoaded(NATURA);
|
||||
return ModUtil.isModLoaded(modId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,44 +81,103 @@ public class PluginNatura extends BlankForestryPlugin {
|
||||
return "Natura not found";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
super.preInit();
|
||||
@SubscribeEvent
|
||||
public void registerItems(RegistryEvent<Item> itemRegistryEvent) {
|
||||
ForgeRegistries.ITEMS.forEach(item -> {
|
||||
final ResourceLocation registryName = item.getRegistryName();
|
||||
if(!registryName.getResourceDomain().equals(modId)) return;
|
||||
|
||||
logNatura = getBlock("tree");
|
||||
logWillow = getBlock("willow");
|
||||
leavesNatura = getBlock("floraleaves");
|
||||
saplingNatura = getBlock("florasapling");
|
||||
saplingNaturaRare = getBlock("Rare Sapling");
|
||||
final String itemName = registryName.getResourcePath();
|
||||
|
||||
ArrayList<String> saplingItemKeys = new ArrayList<>();
|
||||
if(itemName.matches("^.*_sapling\\d?$")) {
|
||||
consumeSubItems(item, "saplings", saplings);
|
||||
|
||||
if (saplingNatura != null) {
|
||||
saplingItemKeys.add("florasapling");
|
||||
}
|
||||
if (saplingNaturaRare != null) {
|
||||
saplingItemKeys.add("Rare Sapling");
|
||||
}
|
||||
RecipeUtil.addFermenterRecipes(
|
||||
new ItemStack(item, 1, OreDictionary.WILDCARD_VALUE),
|
||||
ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.sapling"),
|
||||
Fluids.BIOMASS
|
||||
);
|
||||
|
||||
for (String key : saplingItemKeys) {
|
||||
ItemStack saplingWild = getItemStack(key, OreDictionary.WILDCARD_VALUE);
|
||||
if (!saplingWild.isEmpty()) {
|
||||
RecipeUtil.addFermenterRecipes(saplingWild, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.sapling"), Fluids.BIOMASS);
|
||||
|
||||
String saplingName = ItemStackUtil.getItemNameFromRegistryAsString(saplingWild.getItem());
|
||||
FMLInterModComms.sendMessage(Constants.MOD_ID, "add-farmable-sapling", String.format("farmArboreal@%s.-1", saplingName));
|
||||
FarmRegistry.getInstance().registerFarmables("farmArboreal", new FarmableSapling(
|
||||
new ItemStack(item),
|
||||
new ItemStack[] {}
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
if(itemName.matches("^edibles|.*fruit_item|soups$")) {
|
||||
complexConsumeSubItems(item, "edibles", subitem -> {
|
||||
final String subItemName = subitem.getUnlocalizedName();
|
||||
if(subItemName.matches("^.*berry$")) {
|
||||
berries.add(subitem);
|
||||
return;
|
||||
}
|
||||
|
||||
if(subItemName.matches("^.*(fruit_item|apple)$")) {
|
||||
fruits.add(subitem);
|
||||
return;
|
||||
}
|
||||
|
||||
if(subItemName.matches("^.*stew$")) {
|
||||
soups.add(subitem);
|
||||
return;
|
||||
}
|
||||
|
||||
edibles.add(subitem);
|
||||
});
|
||||
}
|
||||
|
||||
if(itemName.matches("^.*_seeds$")) {
|
||||
consumeSubItems(item, "seeds", seeds);
|
||||
return;
|
||||
}
|
||||
|
||||
if(itemName.matches("^.*_logs\\d?$")) {
|
||||
consumeSubItems(item, "logs", logs);
|
||||
return;
|
||||
}
|
||||
|
||||
if(itemName.matches("^.*_crop\\d?$")) {
|
||||
consumeSubItems(item, "cropBlocks", cropBlocks);
|
||||
return;
|
||||
}
|
||||
|
||||
if(itemName.matches("^materials$")) {
|
||||
complexConsumeSubItems(item, "materials", subitem -> {
|
||||
final String subItemName = subitem.getUnlocalizedName();
|
||||
|
||||
if (subItemName.matches("^.*(barley|cotton)$")) {
|
||||
crops.add(subitem);
|
||||
return;
|
||||
}
|
||||
materials.add(subitem);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void consumeSubItems(Item item, String groupName, Collection<ItemStack> consumer) {
|
||||
complexConsumeSubItems(item, groupName, subItem -> consumer.add(subItem));
|
||||
}
|
||||
|
||||
private void complexConsumeSubItems(Item item, String groupName, Consumer<ItemStack> consumer) {
|
||||
final NonNullList<ItemStack> subItems = NonNullList.create();
|
||||
item.getSubItems(CreativeTabs.SEARCH, subItems);
|
||||
|
||||
// Fallback if item is not returned in sub items
|
||||
if(subItems.isEmpty()) {
|
||||
final ItemStack itemStack = new ItemStack(item, 1);
|
||||
final String subItemName = itemStack.getUnlocalizedName();
|
||||
Log.info("[PluginNatura] Adding '{}' to list of {}", subItemName, groupName);
|
||||
consumer.accept(itemStack);
|
||||
return;
|
||||
}
|
||||
|
||||
berryBlight = getItemStack("berry.nether", 0);
|
||||
berryDusk = getItemStack("berry.nether", 1);
|
||||
berrySky = getItemStack("berry.nether", 2);
|
||||
berrySting = getItemStack("berry.nether", 3);
|
||||
berryRasp = getItemStack("berry", 0);
|
||||
berryBlue = getItemStack("berry", 1);
|
||||
berryBlack = getItemStack("berry", 2);
|
||||
berryMalo = getItemStack("berry", 3);
|
||||
itemBarley = getItemStack("barleyFood", 0);
|
||||
subItems.forEach(itemStack -> {
|
||||
final String subItemName = itemStack.getUnlocalizedName();
|
||||
Log.info("[PluginNatura] Adding '{}' to list of {}", subItemName, groupName);
|
||||
consumer.accept(itemStack);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -120,196 +186,71 @@ public class PluginNatura extends BlankForestryPlugin {
|
||||
|
||||
ICrateRegistry crateRegistry = StorageManager.crateRegistry;
|
||||
|
||||
if (!berryBlight.isEmpty()) {
|
||||
crateRegistry.registerCrate(berryBlight);
|
||||
}
|
||||
if (!berryDusk.isEmpty()) {
|
||||
crateRegistry.registerCrate(berryDusk);
|
||||
}
|
||||
if (!berrySky.isEmpty()) {
|
||||
crateRegistry.registerCrate(berrySky);
|
||||
}
|
||||
if (!berrySting.isEmpty()) {
|
||||
crateRegistry.registerCrate(berrySting);
|
||||
}
|
||||
if (!berryRasp.isEmpty()) {
|
||||
crateRegistry.registerCrate(berryRasp);
|
||||
}
|
||||
if (!berryBlue.isEmpty()) {
|
||||
crateRegistry.registerCrate(berryBlue);
|
||||
}
|
||||
if (!berryBlack.isEmpty()) {
|
||||
crateRegistry.registerCrate(berryBlack);
|
||||
}
|
||||
if (!berryMalo.isEmpty()) {
|
||||
crateRegistry.registerCrate(berryMalo);
|
||||
}
|
||||
if (!itemBarley.isEmpty()) {
|
||||
crateRegistry.registerCrate(itemBarley);
|
||||
}
|
||||
if (saplingNatura != null) {
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 0));
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 1));
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 2));
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 3));
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 4));
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 5));
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 6));
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNatura, 1, 7));
|
||||
}
|
||||
|
||||
if (saplingNaturaRare != null) {
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNaturaRare, 1, 0));
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNaturaRare, 1, 1));
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNaturaRare, 1, 2));
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNaturaRare, 1, 3));
|
||||
crateRegistry.registerCrate(new ItemStack(saplingNaturaRare, 1, 4));
|
||||
}
|
||||
ItemStack potashApple = getItemStack("Natura.netherfood", 0);
|
||||
if (!potashApple.isEmpty()) {
|
||||
crateRegistry.registerCrate(potashApple);
|
||||
}
|
||||
Item glowShroom = getItem("Glowshroom");
|
||||
if (glowShroom != null) {
|
||||
crateRegistry.registerCrate(new ItemStack(glowShroom, 1, 0));
|
||||
crateRegistry.registerCrate(new ItemStack(glowShroom, 1, 1));
|
||||
crateRegistry.registerCrate(new ItemStack(glowShroom, 1, 2));
|
||||
}
|
||||
if (logNatura != null) {
|
||||
crateRegistry.registerCrate(new ItemStack(logNatura, 1, 0));
|
||||
crateRegistry.registerCrate(new ItemStack(logNatura, 1, 1));
|
||||
crateRegistry.registerCrate(new ItemStack(logNatura, 1, 2));
|
||||
crateRegistry.registerCrate(new ItemStack(logNatura, 1, 3));
|
||||
}
|
||||
if (logWillow != null) {
|
||||
crateRegistry.registerCrate(new ItemStack(logWillow, 1, 0));
|
||||
}
|
||||
|
||||
Item bloodWood = getItem("bloodwood");
|
||||
if (bloodWood != null) {
|
||||
crateRegistry.registerCrate(new ItemStack(bloodWood, 1, 0));
|
||||
}
|
||||
Item darkTree = getItem("Dark Tree");
|
||||
if (darkTree != null) {
|
||||
crateRegistry.registerCrate(new ItemStack(darkTree, 1, 0));
|
||||
crateRegistry.registerCrate(new ItemStack(darkTree, 1, 1));
|
||||
}
|
||||
Item heatSand = getItem("heatsand");
|
||||
if (heatSand != null) {
|
||||
crateRegistry.registerCrate(new ItemStack(heatSand, 1, 0));
|
||||
}
|
||||
Item taintedSoil = getItem("soil.tainted");
|
||||
if (taintedSoil != null) {
|
||||
crateRegistry.registerCrate(new ItemStack(taintedSoil, 1, 0));
|
||||
}
|
||||
Iterables.concat(
|
||||
edibles, logs, saplings, shrooms,
|
||||
materials, seeds, berries, fruits,
|
||||
crops
|
||||
).forEach(item -> crateRegistry.registerCrate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipes() {
|
||||
int amount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.seed");
|
||||
|
||||
Item seed = getItem("barley.seed");
|
||||
if (seed != null) {
|
||||
ItemStack seedBarley = new ItemStack(seed, 1, 0);
|
||||
ItemStack seedCotton = new ItemStack(seed, 1, 1);
|
||||
|
||||
ArrayList<ItemStack> seedList = new ArrayList<>();
|
||||
if (!seedBarley.isEmpty()) {
|
||||
seedList.add(seedBarley);
|
||||
RecipeManagers.moistenerManager.addRecipe(seedBarley, new ItemStack(Blocks.MYCELIUM), 5000);
|
||||
}
|
||||
if (!seedCotton.isEmpty()) {
|
||||
seedList.add(seedCotton);
|
||||
}
|
||||
|
||||
for (ItemStack aSeedList : seedList) {
|
||||
RecipeManagers.squeezerManager.addRecipe(10, aSeedList, Fluids.SEED_OIL.getFluid(amount));
|
||||
}
|
||||
for (ItemStack seed : seeds) {
|
||||
RecipeManagers.squeezerManager.addRecipe(10, NonNullList.from(seed, seed), Fluids.SEED_OIL.getFluid(amount));
|
||||
RecipeManagers.moistenerManager.addRecipe(seed, new ItemStack(Blocks.MYCELIUM), 5000);
|
||||
}
|
||||
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FARMING)) {
|
||||
Block cropBlock = getBlock("N Crops");
|
||||
//TODO: Natura for 1.9
|
||||
// Farmables.farmables.get("farmWheat").add(new FarmableHandPlanted(seedBarley, cropBlock, 3));
|
||||
// Farmables.farmables.get("farmWheat").add(new FarmableHandPlanted(seedCotton, cropBlock, 8));
|
||||
}
|
||||
cropBlocks.forEach(itemStack -> {
|
||||
Block block = ItemStackUtil.getBlock(itemStack);
|
||||
ItemStack seedItem;
|
||||
int maxAge;
|
||||
try {
|
||||
maxAge = (int)block.getClass().getDeclaredMethod("getMaxAge").invoke(block);
|
||||
seedItem = block.getPickBlock(block.getBlockState().getBaseState(), null, null, null, null);
|
||||
} catch (Exception _) {return;} // if this fails just ignore the error.
|
||||
Log.info("[PluginNatura] Addding crop '{}'", itemStack);
|
||||
if(seedItem == null) return;
|
||||
|
||||
List<ItemStack> berries = new ArrayList<>();
|
||||
if (!berryBlight.isEmpty()) {
|
||||
berries.add(berryBlight);
|
||||
FarmRegistry.getInstance().registerFarmables("farmWheat",
|
||||
new FarmableAgingCrop(
|
||||
seedItem,
|
||||
block,
|
||||
(IProperty<Integer>)block.getBlockState().getProperty("age"),
|
||||
maxAge
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
if (!berryDusk.isEmpty()) {
|
||||
berries.add(berryDusk);
|
||||
}
|
||||
if (!berrySky.isEmpty()) {
|
||||
berries.add(berrySky);
|
||||
}
|
||||
if (!berrySting.isEmpty()) {
|
||||
berries.add(berrySting);
|
||||
}
|
||||
if (!berryRasp.isEmpty()) {
|
||||
berries.add(berryRasp);
|
||||
}
|
||||
if (!berryBlue.isEmpty()) {
|
||||
berries.add(berryBlue);
|
||||
}
|
||||
if (!berryBlack.isEmpty()) {
|
||||
berries.add(berryBlack);
|
||||
}
|
||||
if (!berryMalo.isEmpty()) {
|
||||
berries.add(berryMalo);
|
||||
}
|
||||
|
||||
|
||||
amount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.apple") / 2;
|
||||
amount = Math.max(amount, 1); // Produce at least 1 mb of juice.
|
||||
ItemStack netherFood = getItemStack("Natura.netherfood", 0);
|
||||
ItemStack mulch = PluginCore.getItems().mulch.getItemStack();
|
||||
RecipeManagers.squeezerManager.addRecipe(10, netherFood, Fluids.JUICE.getFluid(amount), mulch, ForestryAPI.activeMode.getIntegerSetting("squeezer.mulch.apple"));
|
||||
final int juiceAmount = Math.max(amount, 1); // Produce at least 1 mb of juice.
|
||||
ItemStack mulch = PluginCore.items.mulch.getItemStack();
|
||||
fruits.forEach(fruit -> RecipeManagers.squeezerManager.addRecipe(
|
||||
10, NonNullList.from(fruit, fruit),
|
||||
Fluids.JUICE.getFluid(juiceAmount), mulch,
|
||||
ForestryAPI.activeMode.getIntegerSetting("squeezer.mulch.apple"))
|
||||
);
|
||||
|
||||
amount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.apple") / 25;
|
||||
amount = Math.max(amount, 1); // Produce at least 1 mb of juice.
|
||||
|
||||
for (ItemStack berry : berries) {
|
||||
RecipeManagers.squeezerManager.addRecipe(3, berry, Fluids.JUICE.getFluid(amount));
|
||||
RecipeManagers.squeezerManager.addRecipe(3, NonNullList.from(berry, berry), Fluids.JUICE.getFluid(amount));
|
||||
}
|
||||
|
||||
if (!itemBarley.isEmpty()) {
|
||||
RecipeUtil.addFermenterRecipes(itemBarley, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS);
|
||||
crops.forEach(crop -> {
|
||||
RecipeUtil.addFermenterRecipes(crop, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS);
|
||||
if (crop.getUnlocalizedName().matches("^.*cotton$")) return;
|
||||
|
||||
int compostWheatAmount = ForestryAPI.activeMode.getIntegerSetting("recipe.output.compost.wheat");
|
||||
if (compostWheatAmount > 0) {
|
||||
ItemStack compostWheat = PluginCore.getItems().compost.getItemStack(compostWheatAmount);
|
||||
RecipeUtil.addRecipe("natura_compost_wheat", compostWheat, " X ", "X#X", " X ", '#', Blocks.DIRT, 'X', itemBarley);
|
||||
ItemStack compostWheat = PluginCore.items.fertilizerCompound.getItemStack(compostWheatAmount);
|
||||
RecipeUtil.addRecipe(compostWheat.getUnlocalizedName(), compostWheat, " X ", "X#X", " X ", '#', Blocks.DIRT, 'X', crop);
|
||||
}
|
||||
FuelManager.moistenerResource.put(itemBarley, new MoistenerFuel(itemBarley, PluginCore.getItems().mouldyWheat.getItemStack(), 0, 300));
|
||||
}
|
||||
FuelManager.moistenerResource.put(crop, new MoistenerFuel(crop, PluginCore.items.mouldyWheat.getItemStack(), 0, 300));
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Block getBlock(String blockName) {
|
||||
ResourceLocation key = new ResourceLocation(NATURA, blockName);
|
||||
if (ForgeRegistries.BLOCKS.containsKey(key)) {
|
||||
return ForgeRegistries.BLOCKS.getValue(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Item getItem(String itemName) {
|
||||
ResourceLocation key = new ResourceLocation(NATURA, itemName);
|
||||
if (ForgeRegistries.ITEMS.containsKey(key)) {
|
||||
return ForgeRegistries.ITEMS.getValue(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static ItemStack getItemStack(String itemName, int meta) {
|
||||
ResourceLocation key = new ResourceLocation(NATURA, itemName);
|
||||
if (ForgeRegistries.ITEMS.containsKey(key)) {
|
||||
return new ItemStack(ForgeRegistries.ITEMS.getValue(key), 1, meta);
|
||||
} else {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user