mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-25 14:24:35 +00:00
Fixed Forestry integration
This commit is contained in:
1 parent
333896bcac
commit
ec42d430df
4 files changed
+50
-49
No files matched your search
@@ -128,6 +128,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, IItem
|
||||
name = "Unknown";
|
||||
break;
|
||||
}
|
||||
|
||||
return getUnlocalizedName() + "." + name;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,16 +23,10 @@ public final class MekanismHooks
|
||||
|
||||
private Class BuildCraftEnergy;
|
||||
|
||||
private Class ForestryItem;
|
||||
|
||||
public int ForestryBiofuelID = 5013;
|
||||
public ItemStack ForestryBiofuelBucket;
|
||||
|
||||
public boolean IC2Loaded = false;
|
||||
public boolean RailcraftLoaded = false;
|
||||
public boolean BasicComponentsLoaded = false;
|
||||
public boolean BuildCraftLoaded = false;
|
||||
public boolean ForestryLoaded = false;
|
||||
public boolean TELoaded = false;
|
||||
|
||||
public boolean MetallurgyCoreLoaded = false;
|
||||
@@ -44,8 +38,8 @@ public final class MekanismHooks
|
||||
if(Loader.isModLoaded("Railcraft")) RailcraftLoaded = true;
|
||||
if(Loader.isModLoaded("BasicComponents")) BasicComponentsLoaded = true;
|
||||
if(Loader.isModLoaded("BuildCraft|Energy")) BuildCraftLoaded = true;
|
||||
if(Loader.isModLoaded("Forestry")) ForestryLoaded = true;
|
||||
if(Loader.isModLoaded("ThermalExpansion")) TELoaded = true;
|
||||
|
||||
if(Loader.isModLoaded("Metallurgy3Core"))
|
||||
{
|
||||
MetallurgyCoreLoaded = true;
|
||||
@@ -114,13 +108,6 @@ public final class MekanismHooks
|
||||
System.out.println("[Mekanism] Hooked into BuildCraft successfully.");
|
||||
}
|
||||
|
||||
if(ForestryLoaded)
|
||||
{
|
||||
ForestryBiofuelID = getForestryItem("liquidBiofuel").itemID;
|
||||
ForestryBiofuelBucket = getForestryItem("bucketBiofuel");
|
||||
System.out.println("[Mekanism] Hooked into Forestry successfully.");
|
||||
}
|
||||
|
||||
if(TELoaded)
|
||||
{
|
||||
for(IPulverizerRecipe recipe : CraftingManagers.pulverizerManager.getRecipeList())
|
||||
@@ -170,30 +157,6 @@ public final class MekanismHooks
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getForestryItem(String name)
|
||||
{
|
||||
try {
|
||||
if(ForestryItem == null) ForestryItem = Class.forName("forestry.core.config.ForestryItem");
|
||||
if(ForestryItem == null) ForestryItem = Class.forName("net.minecraft.src.forestry.core.config.ForestryItem");
|
||||
Object ret = ForestryItem.getField(name).get(null);
|
||||
|
||||
if(ret instanceof Item)
|
||||
{
|
||||
return new ItemStack((Item)ret);
|
||||
}
|
||||
else if(ret instanceof Block)
|
||||
{
|
||||
return new ItemStack((Block)ret);
|
||||
}
|
||||
else {
|
||||
throw new Exception("not instanceof ItemStack");
|
||||
}
|
||||
} catch(Exception e) {
|
||||
System.out.println("[Mekanism] Unable to retrieve Forestry item " + name + ".");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getBasicComponentsItem(String name)
|
||||
{
|
||||
try {
|
||||
|
||||
@@ -8,6 +8,8 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
public class ContainerBioGenerator extends Container
|
||||
{
|
||||
@@ -79,7 +81,7 @@ public class ContainerBioGenerator extends Container
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(tileEntity.getFuel(slotStack) > 0 || (Mekanism.hooks.ForestryLoaded && slotStack.itemID == Mekanism.hooks.ForestryBiofuelBucket.itemID))
|
||||
else if(tileEntity.getFuel(slotStack) > 0 || isBiofuel(slotStack))
|
||||
{
|
||||
if(slotID != 0 && slotID != 1)
|
||||
{
|
||||
@@ -136,4 +138,20 @@ public class ContainerBioGenerator extends Container
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
private boolean isBiofuel(ItemStack itemStack)
|
||||
{
|
||||
if(FluidRegistry.isFluidRegistered("bioethanol"))
|
||||
{
|
||||
if(FluidContainerRegistry.getFluidForFilledItem(itemStack) != null)
|
||||
{
|
||||
if(FluidContainerRegistry.getFluidForFilledItem(itemStack).getFluid() == FluidRegistry.getFluid("bioethanol"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
@@ -33,9 +34,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui
|
||||
public float crushMatrix = 0;
|
||||
|
||||
/** The FluidSlot biofuel instance for this generator. */
|
||||
public FluidSlot bioFuelSlot = new FluidSlot(24000, Mekanism.hooks.ForestryBiofuelID);
|
||||
|
||||
public int FLUID_MULTIPLIER = 16;
|
||||
public FluidSlot bioFuelSlot = new FluidSlot(24000, -1);
|
||||
|
||||
public TileEntityBioGenerator()
|
||||
{
|
||||
@@ -78,15 +77,16 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui
|
||||
{
|
||||
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(inventory[0]);
|
||||
|
||||
if(fluid != null)
|
||||
if(fluid != null && FluidRegistry.isFluidRegistered("bioethanol"))
|
||||
{
|
||||
if(fluid.fluidID == Mekanism.hooks.ForestryBiofuelID)
|
||||
if(fluid.getFluid() == FluidRegistry.getFluid("bioethanol"))
|
||||
{
|
||||
int fluidToAdd = fluid.amount*FLUID_MULTIPLIER;
|
||||
int fluidToAdd = fluid.amount;
|
||||
|
||||
if(bioFuelSlot.fluidStored+fluidToAdd <= bioFuelSlot.MAX_FLUID)
|
||||
{
|
||||
bioFuelSlot.setFluid(bioFuelSlot.fluidStored+fluidToAdd);
|
||||
|
||||
if(FluidContainerRegistry.isBucket(inventory[0]))
|
||||
{
|
||||
inventory[0] = new ItemStack(Item.bucketEmpty);
|
||||
@@ -105,6 +105,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui
|
||||
else {
|
||||
int fuel = getFuel(inventory[0]);
|
||||
ItemStack prevStack = inventory[0].copy();
|
||||
|
||||
if(fuel > 0)
|
||||
{
|
||||
int fuelNeeded = bioFuelSlot.MAX_FLUID - bioFuelSlot.fluidStored;
|
||||
@@ -133,6 +134,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui
|
||||
{
|
||||
setActive(true);
|
||||
}
|
||||
|
||||
bioFuelSlot.setFluid(bioFuelSlot.fluidStored - 1);
|
||||
setEnergy(electricityStored + MekanismGenerators.bioGeneration);
|
||||
}
|
||||
@@ -149,7 +151,24 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui
|
||||
{
|
||||
if(slotID == 0)
|
||||
{
|
||||
return getFuel(itemstack) > 0 || (FluidContainerRegistry.getFluidForFilledItem(itemstack) != null && FluidContainerRegistry.getFluidForFilledItem(itemstack).fluidID == Mekanism.hooks.ForestryBiofuelID);
|
||||
if(getFuel(itemstack ) > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if(FluidRegistry.isFluidRegistered("bioethanol"))
|
||||
{
|
||||
if(FluidContainerRegistry.getFluidForFilledItem(itemstack) != null)
|
||||
{
|
||||
if(FluidContainerRegistry.getFluidForFilledItem(itemstack).getFluid() == FluidRegistry.getFluid("bioethanol"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(slotID == 1)
|
||||
{
|
||||
@@ -261,9 +280,9 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
if(from != ForgeDirection.getOrientation(facing))
|
||||
if(FluidRegistry.isFluidRegistered("bioethanol") && from != ForgeDirection.getOrientation(facing))
|
||||
{
|
||||
if(resource.fluidID == Mekanism.hooks.ForestryBiofuelID)
|
||||
if(resource.getFluid() == FluidRegistry.getFluid("bioethanol"))
|
||||
{
|
||||
int fuelTransfer = 0;
|
||||
int fuelNeeded = bioFuelSlot.MAX_FLUID - bioFuelSlot.fluidStored;
|
||||
@@ -304,7 +323,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return fluid.getID() == Mekanism.hooks.ForestryBiofuelID;
|
||||
return FluidRegistry.isFluidRegistered("bioethanol") && fluid == FluidRegistry.getFluid("bioethanol");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user