mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-14 09:04:42 +00:00
Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
448406b81f | ||
|
|
f5e8fcd0a3 | ||
|
|
e78b80e21d | ||
|
|
4e430e718b | ||
|
|
0a2726ac88 | ||
|
|
383b78435d | ||
|
|
c2caa8c0d3 | ||
|
|
cc67010033 | ||
|
|
384336f416 |
No files matched your search
@@ -9,6 +9,7 @@ dependencies {
|
||||
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.57:api')
|
||||
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
|
||||
compileOnly('curse.maven:craftguide-75557:2459320')
|
||||
compileOnly('com.ruling_0:MaterialLib:0.24.0-mu:dev')
|
||||
compileOnly('com.github.GTNewHorizons:Postea:1.4.0-mu:dev')
|
||||
devOnlyNonPublishable('net.xonich.mc:NoHotbarNeeded:0.0.3:dev')
|
||||
}
|
||||
@@ -63,7 +63,8 @@ import forestry.plugins.PluginManager;
|
||||
+ "after:BiomesOPlenty;"
|
||||
+ "after:IC2@[2.0.140,);"
|
||||
+ "after:Natura@[2.2.0,);"
|
||||
+ "after:HardcoreEnderExpansion;")
|
||||
+ "after:HardcoreEnderExpansion;"
|
||||
+ "after:materiallib;")
|
||||
public class Forestry {
|
||||
|
||||
@Mod.Instance(Constants.MOD)
|
||||
|
||||
@@ -230,23 +230,11 @@ public abstract class BlockUtil {
|
||||
return vec != null && (vec.xCoord >= minX && vec.xCoord <= maxX && vec.yCoord >= minY && vec.yCoord <= maxY);
|
||||
}
|
||||
|
||||
private static Class<? extends Block> BW_MetaGenerated_WerkstoffBlocksClass;
|
||||
private static Block BWBlocks;
|
||||
private static Class<? extends Block> GTBlockMachines_Class;
|
||||
private static Block GTBlockMachines;
|
||||
private static final boolean bw = Loader.isModLoaded("bartworks");
|
||||
private static final boolean gt = Loader.isModLoaded("gregtech") && !Loader.isModLoaded("gregapi");
|
||||
|
||||
static {
|
||||
if (bw) try {
|
||||
// noinspection unchecked
|
||||
BW_MetaGenerated_WerkstoffBlocksClass = (Class<? extends Block>) Class
|
||||
.forName("bartworks.system.material.BWMetaGeneratedWerkstoffBlocks");
|
||||
BWBlocks = (Block) Class.forName("bartworks.system.material.WerkstoffLoader").getField("BWBlocks")
|
||||
.get(null);
|
||||
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (gt) try {
|
||||
// noinspection unchecked
|
||||
GTBlockMachines_Class = (Class<? extends Block>) Class.forName("gregtech.common.blocks.BlockMachines");
|
||||
@@ -268,12 +256,6 @@ public abstract class BlockUtil {
|
||||
} while (stillInside.test(tile));
|
||||
block = world.getBlock(x, y - depth, z);
|
||||
|
||||
if (bw && BW_MetaGenerated_WerkstoffBlocksClass != null
|
||||
&& BWBlocks != null
|
||||
&& BW_MetaGenerated_WerkstoffBlocksClass.isInstance(block)) {
|
||||
return new ItemStack(BWBlocks, 1, block.getDamageValue(world, x, y - depth, z));
|
||||
}
|
||||
|
||||
if (gt && GTBlockMachines_Class != null && GTBlockMachines != null && GTBlockMachines_Class.isInstance(block)) {
|
||||
return new ItemStack(GTBlockMachines, 1, block.getDamageValue(world, x, y - depth, z));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package forestry.core.utils;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.ruling_0.materiallib.api.StackResolver;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
|
||||
|
||||
/// Resolves the `ml:<Material>:<shape>` stack string form, which names a MaterialLib item by material and shape.
|
||||
///
|
||||
/// MaterialLib types are named only here, so [Stack] can gate loading this class on `materiallib` being present.
|
||||
public abstract class MaterialLibStacks {
|
||||
|
||||
public static Stack parse(String mlString) {
|
||||
String[] parts = mlString.split(":+");
|
||||
if (parts.length != 3) {
|
||||
Log.warning(
|
||||
"Stack string (" + mlString
|
||||
+ ") isn't formatted properly. The MaterialLib format is ml:<Material>:<shape>, e.g. ml:Aluminium:ore_stone");
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack stack = StackResolver.getStack(parts[1], parts[2], 1);
|
||||
if (stack == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
UniqueIdentifier id = GameRegistry.findUniqueIdentifierFor(stack.getItem());
|
||||
if (id == null) {
|
||||
Log.warning("Stack string (" + mlString + ") resolved to an item with no registry name.");
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Stack(id.toString(), stack.getItemDamage());
|
||||
}
|
||||
|
||||
/// The named material's item in the named shape, or null when MaterialLib serves no such pair.
|
||||
public static ItemStack getStack(String material, String shape) {
|
||||
return StackResolver.getStack(material, shape, 1);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,14 @@
|
||||
package forestry.core.utils;
|
||||
|
||||
import com.gtnewhorizons.postea.api.IVersionedTransformer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.gtnewhorizons.postea.api.CustomDataReplacementManager;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
/// Used to provide custom save data (like mail boxes) to Postea's [IVersionedTransformer]s.
|
||||
///
|
||||
/// These transformers allow other mods to change saved data based on their own version stamps. This compat flags,
|
||||
/// to those transformers, the times they should fire. [#transform] is used before consuming data, so the transformer
|
||||
/// can run, and [#stamp] is used for fresh data to ensure the transformer can add a stamp of its current version.
|
||||
/// Offers Forestry's mail boxes to Postea's custom world data API, so versioned transformers rewrite
|
||||
/// their stacks exactly once per content version change. Safe to call without Postea installed: the Postea types
|
||||
/// live in the inner holder, which only loads when the mod is present.
|
||||
public final class PosteaCompat {
|
||||
|
||||
private static final boolean POSTEA = Loader.isModLoaded("postea");
|
||||
|
||||
@@ -58,12 +58,20 @@ public class Stack {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (stackString.startsWith("ml:")) {
|
||||
if (!ModUtil.isModLoaded("materiallib")) {
|
||||
Log.warning("Stack string (" + stackString + ") needs MaterialLib, which is not loaded. Ignoring it.");
|
||||
return null;
|
||||
}
|
||||
return MaterialLibStacks.parse(stackString);
|
||||
}
|
||||
|
||||
String[] parts = stackString.split(":+");
|
||||
|
||||
if (parts.length != 2 && parts.length != 3) {
|
||||
Log.warning(
|
||||
"Stack string (" + stackString
|
||||
+ ") isn't formatted properly. Suitable formats are <modId>:<name>, <modId>:<name>:<meta> or <modId>:<name>:*, e.g. IC2:blockWall:*");
|
||||
+ ") isn't formatted properly. Suitable formats are <modId>:<name>, <modId>:<name>:<meta>, <modId>:<name>:* or ml:<Material>:<shape>, e.g. IC2:blockWall:*");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,14 +59,25 @@ public class PluginFluids extends ForestryPlugin {
|
||||
public static ItemRegistryFluids items;
|
||||
|
||||
private static void createFluid(Fluids forestryFluid) {
|
||||
if (forestryFluid.getFluid() == null && Config.isFluidEnabled(forestryFluid)) {
|
||||
String fluidName = forestryFluid.getTag();
|
||||
if (!FluidRegistry.isFluidRegistered(fluidName)) {
|
||||
Fluid fluid = new Fluid(fluidName).setDensity(forestryFluid.getDensity())
|
||||
.setViscosity(forestryFluid.getViscosity()).setTemperature(forestryFluid.getTemperature());
|
||||
FluidRegistry.registerFluid(fluid);
|
||||
createBlock(forestryFluid);
|
||||
}
|
||||
if (!Config.isFluidEnabled(forestryFluid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String fluidName = forestryFluid.getTag();
|
||||
boolean preRegistered = FluidRegistry.isFluidRegistered(fluidName);
|
||||
if (!preRegistered) {
|
||||
Fluid fluid = new Fluid(fluidName).setDensity(forestryFluid.getDensity())
|
||||
.setViscosity(forestryFluid.getViscosity()).setTemperature(forestryFluid.getTemperature());
|
||||
FluidRegistry.registerFluid(fluid);
|
||||
}
|
||||
|
||||
// Milk is deliberately left blockless once another mod owns the fluid.
|
||||
if (preRegistered && (forestryFluid == Fluids.MILK || forestryFluid.getBlock() != null)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (forestryFluid.getFluid() != null) {
|
||||
createBlock(forestryFluid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ import forestry.core.items.EnumElectronTube;
|
||||
import forestry.core.recipes.RecipeUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.MaterialLibStacks;
|
||||
import forestry.core.utils.ModUtil;
|
||||
import forestry.energy.blocks.BlockEngineType;
|
||||
import forestry.energy.blocks.BlockRegistryEnergy;
|
||||
@@ -227,7 +228,7 @@ public class PluginIC2 extends ForestryPlugin {
|
||||
}
|
||||
|
||||
if (rubber != null) {
|
||||
crateRegistry.registerCrate(rubber, "cratedRubber");
|
||||
crateRegistry.registerCrate(cratedPart(rubber, "Rubber", "ingot"), "cratedRubber");
|
||||
}
|
||||
|
||||
if (scrap != null) {
|
||||
@@ -239,14 +240,24 @@ public class PluginIC2 extends ForestryPlugin {
|
||||
}
|
||||
|
||||
if (silver != null) {
|
||||
crateRegistry.registerCrateUsingOreDict(silver, "cratedSilver");
|
||||
crateRegistry.registerCrateUsingOreDict(cratedPart(silver, "Silver", "ingot"), "cratedSilver");
|
||||
}
|
||||
|
||||
if (brass != null) {
|
||||
crateRegistry.registerCrateUsingOreDict(brass, "cratedBrass");
|
||||
crateRegistry.registerCrateUsingOreDict(cratedPart(brass, "Bronze", "ingot"), "cratedBrass");
|
||||
}
|
||||
}
|
||||
|
||||
/// GregTech's MaterialLib part in place of IndustrialCraft 2's copy of it, so uncrating hands out the part that
|
||||
/// GregTech's recipes produce.
|
||||
private static ItemStack cratedPart(ItemStack ic2Part, String material, String shape) {
|
||||
if (!ModUtil.isModLoaded("gregtech")) {
|
||||
return ic2Part;
|
||||
}
|
||||
ItemStack part = MaterialLibStacks.getStack(material, shape);
|
||||
return part != null ? part : ic2Part;
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "IC2")
|
||||
protected void registerRecipes() {
|
||||
|
||||
|
||||
Reference in new issue
Block a user