Add Rustic Integration

This commit is contained in:
Nedelosk committed 2017-07-23 20:37:56 +02:00
1 parent 353fcb1ba7
commit e391d06f32
10 files changed
+372 -206

No files matched your search

@@ -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));
}
}
}
}
}