mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-15 01:24:59 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
448406b81f | ||
|
|
f5e8fcd0a3 | ||
|
|
e78b80e21d | ||
|
|
4e430e718b | ||
|
|
0a2726ac88 | ||
|
|
383b78435d | ||
|
|
c2caa8c0d3 | ||
|
|
cc67010033 | ||
|
|
384336f416 | ||
|
|
96b8f60f87 | ||
|
|
a2a1f8eca9 | ||
|
|
f2e85073d3 | ||
|
|
0bd9a7978a | ||
|
|
e47fc90433 | ||
|
|
452064ef1d | ||
|
|
59c8c36520 |
No files matched your search
@@ -9,5 +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)
|
||||
|
||||
@@ -111,6 +111,14 @@ public class AlvearyController extends RectangularMultiblockControllerBase
|
||||
this.readFromNBT(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detachBlock(IMultiblockComponent part, boolean chunkUnloading) {
|
||||
if (!chunkUnloading) {
|
||||
inventory.dumpInventoryIntoWorld(this.worldObj, part.getCoordinates());
|
||||
}
|
||||
super.detachBlock(part, chunkUnloading);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBlockAdded(IMultiblockComponent newPart) {
|
||||
if (newPart instanceof IAlvearyComponent) {
|
||||
@@ -159,8 +167,6 @@ public class AlvearyController extends RectangularMultiblockControllerBase
|
||||
activeComponents.remove(oldPart);
|
||||
}
|
||||
}
|
||||
|
||||
inventory.dumpInventoryIntoWorld(this.worldObj, oldPart.getCoordinates());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -72,7 +72,7 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return IconProviderWood.getPlankIcon(EnumWoodType.values()[meta]);
|
||||
return IconProviderWood.getPlankIcon(EnumWoodType.VALUES[meta]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -202,7 +202,8 @@ public abstract class Genome implements IGenome {
|
||||
private static IChromosome[] getChromosomes(NBTTagCompound genomeNBT, ISpeciesRoot speciesRoot) {
|
||||
|
||||
NBTTagList chromosomesNBT = genomeNBT.getTagList("Chromosomes", 10);
|
||||
IChromosome[] chromosomes = new IChromosome[speciesRoot.getDefaultTemplate().length];
|
||||
IAllele[] defaultTemplate = speciesRoot.getDefaultTemplate();
|
||||
IChromosome[] chromosomes = new IChromosome[defaultTemplate.length];
|
||||
|
||||
for (int i = 0; i < chromosomesNBT.tagCount(); i++) {
|
||||
NBTTagCompound chromosomeNBT = chromosomesNBT.getCompoundTagAt(i);
|
||||
@@ -213,7 +214,7 @@ public abstract class Genome implements IGenome {
|
||||
chromosomes[chromosomeOrdinal] = chromosome;
|
||||
|
||||
if (Config.clearInvalidChromosomes) {
|
||||
IAllele template = speciesRoot.getDefaultTemplate()[chromosomeOrdinal];
|
||||
IAllele template = defaultTemplate[chromosomeOrdinal];
|
||||
Class<? extends IAllele> chromosomeClass = speciesRoot.getKaryotype()[chromosomeOrdinal]
|
||||
.getAlleleClass();
|
||||
if (chromosome.overrideInvalidAlleles(template, chromosomeClass)) {
|
||||
|
||||
@@ -32,6 +32,10 @@ public class MutationConditionRequiresResource implements IMutationCondition {
|
||||
blockRequired = new ItemStack(block, 1, meta);
|
||||
}
|
||||
|
||||
public ItemStack getBlockRequired() {
|
||||
return blockRequired.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0,
|
||||
IGenome genome1, IClimateProvider climate) {
|
||||
|
||||
+4
@@ -39,6 +39,10 @@ public class MutationConditionRequiresResourceOreDict implements IMutationCondit
|
||||
}
|
||||
}
|
||||
|
||||
public int getOreDictId() {
|
||||
return oreDictId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getChance(World world, int x, int y, int z, IAllele allele0, IAllele allele1, IGenome genome0,
|
||||
IGenome genome1, IClimateProvider climate) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package forestry.core.utils;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.gtnewhorizons.postea.api.CustomDataReplacementManager;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
/// 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");
|
||||
|
||||
private PosteaCompat() {}
|
||||
|
||||
/// Transforms a root read from disk in place; call before consuming it.
|
||||
public static void transform(String storageId, NBTTagCompound root) {
|
||||
if (POSTEA) Impl.transform(storageId, root);
|
||||
}
|
||||
|
||||
/// Stamps a freshly built root about to be written to disk.
|
||||
public static void stamp(NBTTagCompound root) {
|
||||
if (POSTEA) Impl.stamp(root);
|
||||
}
|
||||
|
||||
private static final class Impl {
|
||||
|
||||
static void transform(String storageId, NBTTagCompound root) {
|
||||
CustomDataReplacementManager.transform(storageId, root);
|
||||
}
|
||||
|
||||
static void stamp(NBTTagCompound root) {
|
||||
CustomDataReplacementManager.stamp(root);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,16 +25,22 @@ import forestry.plugins.PluginMail;
|
||||
public class LetterProperties {
|
||||
|
||||
private enum State {
|
||||
|
||||
FRESH,
|
||||
STAMPED,
|
||||
OPENED,
|
||||
EMPTIED
|
||||
EMPTIED;
|
||||
|
||||
public static final State[] VALUES = values();
|
||||
}
|
||||
|
||||
private enum Size {
|
||||
|
||||
EMPTY,
|
||||
SMALL,
|
||||
BIG
|
||||
BIG;
|
||||
|
||||
public static final Size[] VALUES = values();
|
||||
}
|
||||
|
||||
public static ItemStack createStampedLetterStack(ILetter letter) {
|
||||
@@ -98,8 +104,8 @@ public class LetterProperties {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void getSubItems(Item item, CreativeTabs tab, @SuppressWarnings("rawtypes") List list) {
|
||||
for (State state : State.values()) {
|
||||
for (Size size : Size.values()) {
|
||||
for (State state : State.VALUES) {
|
||||
for (Size size : Size.VALUES) {
|
||||
int meta = encodeMeta(state, size);
|
||||
ItemStack letter = new ItemStack(item, 1, meta);
|
||||
list.add(letter);
|
||||
@@ -117,7 +123,7 @@ public class LetterProperties {
|
||||
|
||||
private static State getState(int meta) {
|
||||
int ordinal = meta & 0x0f;
|
||||
State[] values = State.values();
|
||||
State[] values = State.VALUES;
|
||||
if (ordinal >= values.length) {
|
||||
ordinal = 0;
|
||||
}
|
||||
@@ -126,7 +132,7 @@ public class LetterProperties {
|
||||
|
||||
private static Size getSize(int meta) {
|
||||
int ordinal = meta >> 4;
|
||||
Size[] values = Size.values();
|
||||
Size[] values = Size.VALUES;
|
||||
if (ordinal >= values.length) {
|
||||
ordinal = 0;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import forestry.api.mail.IMailAddress;
|
||||
import forestry.api.mail.PostManager;
|
||||
import forestry.core.inventory.InventoryAdapter;
|
||||
import forestry.core.utils.InventoryUtil;
|
||||
import forestry.core.utils.PosteaCompat;
|
||||
|
||||
public class POBox extends WorldSavedData implements IInventory {
|
||||
|
||||
@@ -42,6 +43,7 @@ public class POBox extends WorldSavedData implements IInventory {
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
PosteaCompat.transform("forestry:" + mapName, nbttagcompound);
|
||||
if (nbttagcompound.hasKey("address")) {
|
||||
this.address = MailAddress.loadFromNBT(nbttagcompound.getCompoundTag("address"));
|
||||
}
|
||||
@@ -56,6 +58,7 @@ public class POBox extends WorldSavedData implements IInventory {
|
||||
nbttagcompound.setTag("address", nbt);
|
||||
}
|
||||
letters.writeToNBT(nbttagcompound);
|
||||
PosteaCompat.stamp(nbttagcompound);
|
||||
}
|
||||
|
||||
public boolean storeLetter(ItemStack letterstack) {
|
||||
|
||||
@@ -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