mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-28 15:36:18 +00:00
Add Rustic Integration
This commit is contained in:
1 parent
353fcb1ba7
commit
e391d06f32
10 files changed
+372
-206
No files matched your search
@@ -5,6 +5,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.climate.IClimateManager;
|
||||
@@ -52,6 +53,7 @@ public class ForestryAPI {
|
||||
/**
|
||||
* A registry for register fertilizers, {@link IFarmabeles}s and {@link ISimpleFarmLogic}s
|
||||
*/
|
||||
@Nullable
|
||||
public static IFarmRegistry farmRegistry;
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,10 +11,31 @@
|
||||
package forestry.farming;
|
||||
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.block.BlockBeetroot;
|
||||
import net.minecraft.block.BlockCrops;
|
||||
import net.minecraft.block.BlockNetherWart;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import net.minecraftforge.fml.common.SidedProxy;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.Forestry;
|
||||
import forestry.api.circuits.ChipsetManager;
|
||||
import forestry.api.circuits.CircuitSocketType;
|
||||
@@ -63,22 +84,6 @@ import forestry.farming.triggers.FarmingTriggers;
|
||||
import forestry.plugins.BlankForestryPlugin;
|
||||
import forestry.plugins.ForestryPlugin;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
import net.minecraft.block.BlockBeetroot;
|
||||
import net.minecraft.block.BlockCrops;
|
||||
import net.minecraft.block.BlockNetherWart;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.SidedProxy;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
@ForestryPlugin(pluginID = ForestryPluginUids.FARMING, name = "Farming", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.plugin.farming.description")
|
||||
public class PluginFarming extends BlankForestryPlugin {
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package forestry.farming.logic;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmable;
|
||||
|
||||
public class FarmableRusticGrape implements IFarmable {
|
||||
public static final PropertyBool GRAPES = PropertyBool.create("grapes");
|
||||
|
||||
private final Block cropBlock;
|
||||
|
||||
public FarmableRusticGrape(Block cropBlock) {
|
||||
Preconditions.checkNotNull(cropBlock);
|
||||
|
||||
this.cropBlock = cropBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSaplingAt(World world, BlockPos pos) {
|
||||
IBlockState blockState = world.getBlockState(pos);
|
||||
return blockState.getBlock() == cropBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ICrop getCropAt(World world, BlockPos pos, IBlockState blockState) {
|
||||
if (blockState.getBlock() != cropBlock) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!blockState.getValue(GRAPES)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IBlockState replantState = getReplantState(blockState);
|
||||
return new CropDestroy(world, blockState, pos, replantState);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected IBlockState getReplantState(IBlockState blockState) {
|
||||
return blockState.withProperty(GRAPES, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGermling(ItemStack itemstack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWindfall(ItemStack itemstack) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package forestry.farming.logic;
|
||||
|
||||
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.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.farming.IFarmable;
|
||||
import forestry.core.network.packets.PacketFXSignal;
|
||||
import forestry.core.utils.NetworkUtil;
|
||||
|
||||
public class FarmableRusticSapling implements IFarmable {
|
||||
|
||||
protected final Item germling;
|
||||
protected final Block germlingBlock;
|
||||
private final ItemStack[] windfall;
|
||||
|
||||
public FarmableRusticSapling(Item germling, ItemStack[] windfall) {
|
||||
this.germling = germling;
|
||||
this.germlingBlock = Block.getBlockFromItem(germling);
|
||||
this.windfall = windfall;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) {
|
||||
if (world.setBlockState(pos, germlingBlock.getStateFromMeta(germling.getItemDamage()))) {
|
||||
PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, pos, germlingBlock.getStateFromMeta(germling.getItemDamage()));
|
||||
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 germling == itemstack.getItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWindfall(ItemStack itemstack) {
|
||||
for (ItemStack drop : windfall) {
|
||||
if (drop.isItemEqual(itemstack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package forestry.plugins.compat;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.ModUtil;
|
||||
import forestry.plugins.BlankForestryPlugin;
|
||||
|
||||
public abstract class CompatPlugin extends BlankForestryPlugin {
|
||||
|
||||
protected final String modName;
|
||||
protected final String modID;
|
||||
|
||||
public CompatPlugin(String modName, String modID) {
|
||||
this.modName = modName;
|
||||
this.modID = modID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isAvailable() {
|
||||
return ModUtil.isModLoaded(modID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getFailMessage() {
|
||||
return modName + " not found";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected ItemStack getItemStack(@Nonnull String itemName) {
|
||||
return getItemStack(itemName, 0);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected ItemStack getItemStack(@Nonnull String itemName, int meta) {
|
||||
Item item = getItem(itemName);
|
||||
if (item == null) {
|
||||
return null;
|
||||
}
|
||||
return new ItemStack(item,1, meta);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected Block getBlock(@Nonnull String blockName) {
|
||||
ResourceLocation key = new ResourceLocation(modID, blockName);
|
||||
if (ForgeRegistries.BLOCKS.containsKey(key)) {
|
||||
return ForgeRegistries.BLOCKS.getValue(key);
|
||||
}
|
||||
Log.error("Could not find block {}", key);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected Item getItem(String itemName) {
|
||||
ResourceLocation key = new ResourceLocation(modID, itemName);
|
||||
if (ForgeRegistries.ITEMS.containsKey(key)) {
|
||||
return ForgeRegistries.ITEMS.getValue(key);
|
||||
}
|
||||
Log.error("Could not find item {}", key);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected Fluid getFluid(String fluidName) {
|
||||
Fluid fluid = FluidRegistry.getFluid(fluidName);
|
||||
if (fluid == null) {
|
||||
Log.error("Could not find fluid {}", fluidName);
|
||||
}
|
||||
return fluid;
|
||||
}
|
||||
}
|
||||
@@ -3,39 +3,29 @@ package forestry.plugins.compat;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.ModUtil;
|
||||
import forestry.farming.FarmRegistry;
|
||||
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.BlockCrops;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.farming.FarmRegistry;
|
||||
import forestry.farming.logic.FarmableAgingCrop;
|
||||
import forestry.plugins.ForestryPlugin;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
|
||||
@ForestryPlugin(pluginID = ForestryPluginUids.ACT_ADD, name = "Actually Additions", author = "Ellpeck", url = "http://ellpeck.de/actadd", unlocalizedDescription = "for.plugin.actuallyadditions.description")
|
||||
public class PluginActuallyAdditions extends BlankForestryPlugin {
|
||||
public class PluginActuallyAdditions extends CompatPlugin {
|
||||
|
||||
private static final String ACT_ADD = "actuallyadditions";
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return ModUtil.isModLoaded(ACT_ADD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFailMessage() {
|
||||
return "Actually Additions not found!";
|
||||
public PluginActuallyAdditions() {
|
||||
super("Actually Additions", ACT_ADD);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,7 +69,7 @@ public class PluginActuallyAdditions extends BlankForestryPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
private static void registerSeedPlant(@Nullable Item seedItem, String blockName) {
|
||||
private void registerSeedPlant(@Nullable Item seedItem, String blockName) {
|
||||
if (seedItem != null) {
|
||||
Block plantBlock = getBlock(blockName);
|
||||
if (plantBlock != null) {
|
||||
@@ -90,35 +80,4 @@ public class PluginActuallyAdditions extends BlankForestryPlugin {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Fluid getFluid(String fluidName) {
|
||||
Fluid fluid = FluidRegistry.getFluid(fluidName);
|
||||
if (fluid == null) {
|
||||
Log.error("Could not find fluid {}", fluidName);
|
||||
}
|
||||
return fluid;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Block getBlock(String blockName) {
|
||||
ResourceLocation key = new ResourceLocation(ACT_ADD, blockName);
|
||||
if (ForgeRegistries.BLOCKS.containsKey(key)) {
|
||||
return ForgeRegistries.BLOCKS.getValue(key);
|
||||
} else {
|
||||
Log.error("Could not find {}", key);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Item getItem(String itemName) {
|
||||
ResourceLocation key = new ResourceLocation(ACT_ADD, itemName);
|
||||
if (ForgeRegistries.ITEMS.containsKey(key)) {
|
||||
return ForgeRegistries.ITEMS.getValue(key);
|
||||
} else {
|
||||
Log.error("Could not find {}", key);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,13 @@
|
||||
******************************************************************************/
|
||||
package forestry.plugins.compat;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.farming.IFarmRegistry;
|
||||
import forestry.api.fuels.FuelManager;
|
||||
@@ -24,52 +28,18 @@ import forestry.core.config.Constants;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.items.ItemRegistryCore;
|
||||
import forestry.core.recipes.RecipeUtil;
|
||||
import forestry.core.utils.ModUtil;
|
||||
import forestry.farming.FarmRegistry;
|
||||
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.PropertyInteger;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
|
||||
@ForestryPlugin(pluginID = ForestryPluginUids.HARVESTCRAFT, name = "HarvestCraft", author = "Nirek", url = Constants.URL, unlocalizedDescription = "for.plugin.harvestcraft.description")
|
||||
public class PluginHarvestCraft extends BlankForestryPlugin {
|
||||
public class PluginHarvestCraft extends CompatPlugin {
|
||||
|
||||
private static final String HC = "harvestcraft";
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return ModUtil.isModLoaded(HC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFailMessage() {
|
||||
return "HarvestCraft not found";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static ItemStack getItemStack(String itemName) {
|
||||
ResourceLocation key = new ResourceLocation(HC, itemName);
|
||||
if (ForgeRegistries.ITEMS.containsKey(key)) {
|
||||
return new ItemStack(ForgeRegistries.ITEMS.getValue(key), 1);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Block getBlock(String blockName) {
|
||||
ResourceLocation key = new ResourceLocation(HC, blockName);
|
||||
if (ForgeRegistries.BLOCKS.containsKey(key)) {
|
||||
return ForgeRegistries.BLOCKS.getValue(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
public PluginHarvestCraft() {
|
||||
super("HarvestCraft", HC);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,8 +1,19 @@
|
||||
package forestry.plugins.compat;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.farming.ICrop;
|
||||
import forestry.api.fuels.FuelManager;
|
||||
@@ -10,38 +21,18 @@ import forestry.api.fuels.GeneratorFuel;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.utils.ModUtil;
|
||||
import forestry.farming.FarmRegistry;
|
||||
import forestry.farming.logic.CropDestroy;
|
||||
import forestry.farming.logic.FarmableBase;
|
||||
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.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
|
||||
@ForestryPlugin(pluginID = ForestryPluginUids.IMMERSIVE_ENGINEERING, name = "ImmersiveEngineering", author = "marcin212", url = Constants.URL, unlocalizedDescription = "for.plugin.immersiveengineering.description")
|
||||
public class PluginImmersiveEngineering extends BlankForestryPlugin {
|
||||
public class PluginImmersiveEngineering extends CompatPlugin {
|
||||
private static final String IE = "immersiveengineering";
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return ModUtil.isModLoaded(IE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFailMessage() {
|
||||
return "ImmersiveEngineering not found";
|
||||
public PluginImmersiveEngineering() {
|
||||
super("ImmersiveEngineering", IE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,29 +71,4 @@ public class PluginImmersiveEngineering extends BlankForestryPlugin {
|
||||
FuelManager.generatorFuel.put(ethanol, ethanolFuel);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Block getBlock(String blockName) {
|
||||
ResourceLocation key = new ResourceLocation(IE, blockName);
|
||||
if (ForgeRegistries.BLOCKS.containsKey(key)) {
|
||||
return ForgeRegistries.BLOCKS.getValue(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static ItemStack getItemStack(String itemName, int meta) {
|
||||
ResourceLocation key = new ResourceLocation(IE, itemName);
|
||||
if (ForgeRegistries.ITEMS.containsKey(key)) {
|
||||
return new ItemStack(ForgeRegistries.ITEMS.getValue(key), 1, meta);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static ItemStack getItemStack(String itemName) {
|
||||
return getItemStack(itemName, 0);
|
||||
}
|
||||
}
|
||||
@@ -2,62 +2,25 @@ package forestry.plugins.compat;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockCrops;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.farming.Farmables;
|
||||
import forestry.api.farming.IFarmRegistry;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.utils.ModUtil;
|
||||
import forestry.farming.logic.FarmableAgingCrop;
|
||||
import forestry.plugins.BlankForestryPlugin;
|
||||
import forestry.plugins.ForestryPlugin;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
|
||||
@ForestryPlugin(pluginID = ForestryPluginUids.MAGICAL_AGRICULTURE, name = "mysticalagriculture", author = "Nedelosk", url = Constants.URL, unlocalizedDescription = "for.plugin.mysticalagriculture.description")
|
||||
public class PluginMysticalAgriculture extends BlankForestryPlugin {
|
||||
public class PluginMysticalAgriculture extends CompatPlugin {
|
||||
private static final String MAGICAL_AGRICULTURE = "mysticalagriculture";
|
||||
|
||||
public PluginMysticalAgriculture() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return ModUtil.isModLoaded(MAGICAL_AGRICULTURE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFailMessage() {
|
||||
return "Mystical Agriculture not found";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static ItemStack getItemStack(@Nonnull String itemName) {
|
||||
ResourceLocation key = new ResourceLocation(MAGICAL_AGRICULTURE, itemName);
|
||||
if (ForgeRegistries.ITEMS.containsKey(key)) {
|
||||
return new ItemStack(ForgeRegistries.ITEMS.getValue(key),1);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Block getBlock(@Nonnull String blockName) {
|
||||
ResourceLocation key = new ResourceLocation(MAGICAL_AGRICULTURE, blockName);
|
||||
if (ForgeRegistries.BLOCKS.containsKey(key)) {
|
||||
return ForgeRegistries.BLOCKS.getValue(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
super("Mystical Agriculture", MAGICAL_AGRICULTURE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -177,17 +140,18 @@ public class PluginMysticalAgriculture extends BlankForestryPlugin {
|
||||
"quartz_enriched_iron"
|
||||
);
|
||||
|
||||
IFarmRegistry farmRegistry = ForestryAPI.farmRegistry;
|
||||
int seedAmount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.seed");
|
||||
|
||||
for(String cropName : crops){
|
||||
ItemStack seed = getItemStack( cropName + "_seeds");
|
||||
ItemStack seeds = getItemStack( cropName + "_seeds");
|
||||
Block block = getBlock(cropName + "_crop");
|
||||
if (seed != null) {
|
||||
RecipeManagers.squeezerManager.addRecipe(10, seed, Fluids.SEED_OIL.getFluid(seedAmount));
|
||||
if (seeds != null) {
|
||||
RecipeManagers.squeezerManager.addRecipe(10, seeds, Fluids.SEED_OIL.getFluid(seedAmount));
|
||||
}
|
||||
if (seed != null && block != null) {
|
||||
Farmables.farmables.get("farmWheat").add(new FarmableAgingCrop(seed, block, BlockCrops.AGE, 7));
|
||||
Farmables.farmables.get("farmOrchard").add(new FarmableAgingCrop(seed, block, BlockCrops.AGE, 7, 0));
|
||||
if (seeds != null && block != null) {
|
||||
farmRegistry.registerFarmables("farmWheat", new FarmableAgingCrop(seeds, block, BlockCrops.AGE, 7));
|
||||
farmRegistry.registerFarmables("farmOrchard", new FarmableAgingCrop(seeds, block, BlockCrops.AGE, 7, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
package forestry.plugins.compat;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.farming.IFarmRegistry;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.farming.logic.FarmableAgingCrop;
|
||||
import forestry.farming.logic.FarmableRusticGrape;
|
||||
import forestry.farming.logic.FarmableRusticSapling;
|
||||
import forestry.plugins.ForestryPlugin;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
|
||||
@ForestryPlugin(pluginID = ForestryPluginUids.RUSTIC, name = "rustic", author = "Nedelosk", url = Constants.URL, unlocalizedDescription = "for.plugin.rustic.description")
|
||||
public class PluginRustic extends CompatPlugin {
|
||||
private static final String RUSTIC = "rustic";
|
||||
|
||||
public PluginRustic() {
|
||||
super("Rustic", RUSTIC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipes() {
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FARMING)) {
|
||||
ImmutableList<String> fruits = ImmutableList.of(
|
||||
"tomato",
|
||||
"chili_pepper"
|
||||
);
|
||||
ImmutableList<String> crops = ImmutableList.of(
|
||||
"tomato",
|
||||
"chili"
|
||||
);
|
||||
PropertyInteger cropAge = PropertyInteger.create("age", 0, 3);
|
||||
int seedAmount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.seed");
|
||||
int juiceAmount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.apple");
|
||||
IFarmRegistry farmRegistry = ForestryAPI.farmRegistry;
|
||||
|
||||
ItemStack grapes = getItemStack( "grapes");
|
||||
ItemStack grapeSeeds = getItemStack( "grape_stem");
|
||||
Block grapeLeaves = getBlock("grape_leaves");
|
||||
if (grapeSeeds != null) {
|
||||
RecipeManagers.squeezerManager.addRecipe(10, grapeSeeds, Fluids.SEED_OIL.getFluid(seedAmount));
|
||||
}
|
||||
if (grapes != null) {
|
||||
RecipeManagers.squeezerManager.addRecipe(10, grapes, Fluids.JUICE.getFluid(juiceAmount / 12));
|
||||
}
|
||||
if(grapeLeaves != null){
|
||||
farmRegistry.registerFarmables("farmOrchard", new FarmableRusticGrape(grapeLeaves));
|
||||
}
|
||||
|
||||
ItemStack sapling = getItemStack("sapling");
|
||||
ItemStack ironBerries = getItemStack("ironberries");
|
||||
ItemStack olives = getItemStack("olives");
|
||||
if(sapling != null && ironBerries != null && olives != null){
|
||||
farmRegistry.registerFarmables("farmArboreal", new FarmableRusticSapling(sapling.getItem(), new ItemStack[]{ironBerries, olives}));
|
||||
}
|
||||
|
||||
for(int i = 0;i <fruits.size();i++){
|
||||
String fruitName = fruits.get(i);
|
||||
ItemStack seeds = getItemStack( fruitName + "_seeds");
|
||||
Block block = getBlock(crops.get(i) + "_crop");
|
||||
ItemStack fruit = getItemStack(fruitName);
|
||||
if (seeds != null) {
|
||||
RecipeManagers.squeezerManager.addRecipe(10, seeds, Fluids.SEED_OIL.getFluid(seedAmount));
|
||||
}
|
||||
if(fruit != null){
|
||||
RecipeManagers.squeezerManager.addRecipe(10, fruit, Fluids.JUICE.getFluid(juiceAmount / 25));
|
||||
}
|
||||
if (seeds != null && block != null) {
|
||||
farmRegistry.registerFarmables("farmOrchard", new FarmableAgingCrop(seeds, block, cropAge, 3, 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user