mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 17:44:55 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f6b45abcf | ||
|
|
7297a6a5d3 |
No files matched your search
+1
-1
@@ -7,4 +7,4 @@ ic2_version=2.5.5-ex19
|
||||
|
||||
version_major=5
|
||||
version_minor=0
|
||||
version_patch=21
|
||||
version_patch=22
|
||||
@@ -14,11 +14,17 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
import cofh.api.energy.IEnergyConnection;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import forestry.core.network.packets.PacketFXSignal;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.TileEngine;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockHorizontal;
|
||||
import net.minecraft.block.BlockOldLog;
|
||||
import net.minecraft.block.BlockPlanks;
|
||||
import net.minecraft.block.BlockStaticLiquid;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -31,16 +37,8 @@ import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import forestry.core.network.packets.PacketFXSignal;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.TileEngine;
|
||||
|
||||
import cofh.api.energy.IEnergyConnection;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
|
||||
public abstract class BlockUtil {
|
||||
|
||||
private static final int slabWoodId = OreDictionary.getOreID("slabWood");
|
||||
@@ -343,4 +341,17 @@ public abstract class BlockUtil {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static <T extends Comparable<T>> IProperty<T> getProperty(Block block, String propertyName, Class<T> valueClass) {
|
||||
for (IProperty<?> property : block.getDefaultState().getPropertyNames()) {
|
||||
if (property.getName().equals(propertyName)) {
|
||||
if (property.getValueClass().isAssignableFrom(valueClass)) {
|
||||
//noinspection unchecked
|
||||
return (IProperty<T>) property;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,8 @@ public class ForestryPluginUids {
|
||||
public static final String BUILDCRAFT_STATEMENTS = "forestry.buildcraft.statements";
|
||||
public static final String BUILDCRAFT_TRANSPORT = "forestry.buildcraft.transport";
|
||||
public static final String CHISEL = "forestry.chisel";
|
||||
public static final String ENDER_IO = "forestry.ender.io";
|
||||
public static final String EXTRA_UTILITIES = "forestry.extra.utilities";
|
||||
public static final String NATURA = "forestry.natura";
|
||||
public static final String INDUSTRIALCRAFT2 = "forestry.industrialcraft2";
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package forestry.plugins.compat;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.utils.ModUtil;
|
||||
import forestry.plugins.BlankForestryPlugin;
|
||||
import forestry.plugins.ForestryPlugin;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms;
|
||||
|
||||
@ForestryPlugin(pluginID = ForestryPluginUids.ENDER_IO, name = "EnderIO", author = "mezz", url = Constants.URL, unlocalizedDescription = "for.plugin.enderIO.description")
|
||||
public class PluginEnderIO extends BlankForestryPlugin {
|
||||
|
||||
private static final String EnderIO = "EnderIO";
|
||||
|
||||
private static final String FLUID_FUEL_ADD = "fluidFuel:add";
|
||||
private static final String FLUID_COOLANT_ADD = "fluidCoolant:add";
|
||||
|
||||
private static final String KEY_FLUID_NAME = "fluidName";
|
||||
private static final String KEY_POWER_PER_CYCLE = "powerPerCycle";
|
||||
private static final String KEY_TOTAL_BURN_TIME = "totalBurnTime";
|
||||
private static final String KEY_COOLING_PER_MB = "coolingPerMb";
|
||||
|
||||
private static final float WATER_COOLING_PER_MB = 0.0023f;
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return ModUtil.isModLoaded(EnderIO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFailMessage() {
|
||||
return "EnderIO not found";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doInit() {
|
||||
Fluid ethanol = Fluids.BIO_ETHANOL.getFluid();
|
||||
if (ethanol != null) {
|
||||
int ethanolBurnTime = Math.round(Constants.ENGINE_CYCLE_DURATION_ETHANOL * ForestryAPI.activeMode.getFloatSetting("fuel.ethanol.combustion"));
|
||||
addFuel(ethanol, 40, ethanolBurnTime);
|
||||
}
|
||||
|
||||
Fluid crushedIce = Fluids.ICE.getFluid();
|
||||
if (crushedIce != null) {
|
||||
addCoolant(crushedIce, Constants.ICE_COOLING_MULTIPLIER);
|
||||
}
|
||||
}
|
||||
|
||||
private static void addFuel(Fluid fluid, int powerPerCycle, int totalBurnTime) {
|
||||
NBTTagCompound fuelTag = new NBTTagCompound();
|
||||
fuelTag.setString(KEY_FLUID_NAME, fluid.getName());
|
||||
fuelTag.setInteger(KEY_POWER_PER_CYCLE, powerPerCycle);
|
||||
fuelTag.setInteger(KEY_TOTAL_BURN_TIME, totalBurnTime);
|
||||
|
||||
FMLInterModComms.sendMessage(EnderIO, FLUID_FUEL_ADD, fuelTag);
|
||||
}
|
||||
|
||||
private static void addCoolant(Fluid fluid, float coolingMultiplier) {
|
||||
float coolingPerMb = coolingMultiplier * WATER_COOLING_PER_MB;
|
||||
NBTTagCompound coolantTag = new NBTTagCompound();
|
||||
coolantTag.setString(KEY_FLUID_NAME, fluid.getName());
|
||||
coolantTag.setFloat(KEY_COOLING_PER_MB, coolingPerMb);
|
||||
|
||||
FMLInterModComms.sendMessage(EnderIO, FLUID_COOLANT_ADD, coolantTag);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*******************************************************************************
|
||||
* 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.plugins.compat;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import forestry.api.circuits.ChipsetManager;
|
||||
import forestry.api.circuits.ICircuitLayout;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.farming.Farmables;
|
||||
import forestry.core.PluginCore;
|
||||
import forestry.core.circuits.Circuit;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.items.EnumElectronTube;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.ModUtil;
|
||||
import forestry.farming.circuits.CircuitFarmLogic;
|
||||
import forestry.farming.logic.FarmLogicEnder;
|
||||
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 {
|
||||
|
||||
private static final String ExU = "ExtraUtils2";
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return ModUtil.isModLoaded(ExU);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFailMessage() {
|
||||
return "ExtraUtilities not found";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doInit() {
|
||||
super.doInit();
|
||||
|
||||
if (Config.isExUtilEnderLilyEnabled()) {
|
||||
Block enderLillyBlock = ForgeRegistries.BLOCKS.getValue(new ResourceLocation("extrautils2", "EnderLilly"));
|
||||
Item enderLillyItem = Item.getItemFromBlock(enderLillyBlock);
|
||||
if (enderLillyBlock == Blocks.AIR) {
|
||||
Log.error("Could not find ender lilly block.");
|
||||
} else if (enderLillyItem == null) {
|
||||
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);
|
||||
Farmables.farmables.put("farmEnder", new FarmableAgingCrop(new ItemStack(enderLillyItem), enderLillyBlock, growthProperty, harvestAge, replantAge));
|
||||
Circuit.farmEnderManaged = new CircuitFarmLogic("managedEnder", new FarmLogicEnder());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipes() {
|
||||
super.registerRecipes();
|
||||
if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FARMING) && Circuit.farmEnderManaged != null) {
|
||||
ICircuitLayout layoutManaged = ChipsetManager.circuitRegistry.getLayout("forestry.farms.managed");
|
||||
ChipsetManager.solderManager.addRecipe(layoutManaged, PluginCore.items.tubes.get(EnumElectronTube.ENDER, 1), Circuit.farmEnderManaged);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user