feat: HBM compat

This commit is contained in:
Timo Ley 2024-07-21 16:48:38 +02:00
parent a46a2b7801
commit e899355dfb
15 changed files with 342 additions and 17 deletions

View file

@ -25,11 +25,19 @@ defaultTasks 'fullBuild'
repositories { repositories {
maven { maven {
name 'central' url 'https://maven.tilera.xyz'
url 'https://maven.thorfusion.com/artifactory/central/'
} }
maven { maven {
url 'https://maven.tilera.xyz' url = "https://s3.tilera.xyz/cdn/minecraft/libs/"
metadataSources { artifact() }
}
maven {
name "central"
url "https://nexus.covers1624.net/repository/maven-hosted/"
}
maven {
url = "https://gregtech.overminddl1.com/"
metadataSources { artifact() }
} }
} }
@ -55,11 +63,12 @@ dependencies {
compile "codechicken:ForgeMultipart:${config.minecraft_version}-${config.FMP_version}:dev" compile "codechicken:ForgeMultipart:${config.minecraft_version}-${config.FMP_version}:dev"
compile "codechicken:NotEnoughItems:${config.minecraft_version}-${config.NEI_version}:dev" compile "codechicken:NotEnoughItems:${config.minecraft_version}-${config.NEI_version}:dev"
compile "codechicken:CodeChickenCore:${config.minecraft_version}-${config.CCC_version}:dev" compile "codechicken:CodeChickenCore:${config.minecraft_version}-${config.CCC_version}:dev"
compile "inventorytweaks:inventory-tweaks:1.7.10-1.60.0:api" compile "inventorytweaks:InventoryTweaks:1.59-dev:api"
compile "net.industrial-craft:industrialcraft-2:2.2.828-experimental:api" compile "net.industrial-craft:industrialcraft-2:2.2.827-experimental:dev"
compile "mcp.mobius.waila:Waila:1.5.10_1.7.10:dev" compile "mcp.mobius.waila:Waila:1.5.10_1.7.10:dev"
compile "universalelectricity:basiccomponents:2.0.0:deobf" compile "universalelectricity:basiccomponents:2.0.0:deobf"
compile "universalelectricity:universalelectricity:5.1.0:deobf" compile "universalelectricity:universalelectricity:5.1.0:deobf"
compile "com.hbm:HBM-NTM:1.0.27_X5000:deobf"
} }
version = "${config.minecraft_version}-${config.mod_version}" version = "${config.minecraft_version}-${config.mod_version}"

View file

@ -42,6 +42,7 @@ public class MekanismConfig {
public static double minerSilkMultiplier = 6; public static double minerSilkMultiplier = 6;
public static boolean blacklistIC2; public static boolean blacklistIC2;
public static boolean blacklistRF; public static boolean blacklistRF;
public static boolean blacklistHBM;
public static boolean destroyDisabledBlocks; public static boolean destroyDisabledBlocks;
public static boolean prefilledFluidTanks; public static boolean prefilledFluidTanks;
public static boolean prefilledGasTanks; public static boolean prefilledGasTanks;

View file

@ -545,6 +545,10 @@ public class CommonProxy implements IGuiProvider {
= Mekanism.configuration = Mekanism.configuration
.get(Configuration.CATEGORY_GENERAL, "BlacklistRFPower", false) .get(Configuration.CATEGORY_GENERAL, "BlacklistRFPower", false)
.getBoolean(); .getBoolean();
general.blacklistHBM
= Mekanism.configuration
.get(Configuration.CATEGORY_GENERAL, "BlacklistHBMPower", false)
.getBoolean();
general.EnableQuartzCompat general.EnableQuartzCompat
= Mekanism.configuration = Mekanism.configuration

View file

@ -1,5 +1,6 @@
package mekanism.common.base; package mekanism.common.base;
import api.hbm.energymk2.IEnergyReceiverMK2;
import cofh.api.energy.IEnergyReceiver; import cofh.api.energy.IEnergyReceiver;
import ic2.api.energy.tile.IEnergySink; import ic2.api.energy.tile.IEnergySink;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
@ -26,6 +27,8 @@ public abstract class EnergyAcceptorWrapper implements IStrictEnergyAcceptor {
wrapper = new RFAcceptor((IEnergyReceiver) tileEntity); wrapper = new RFAcceptor((IEnergyReceiver) tileEntity);
} else if (MekanismUtils.useIC2() && CableUtils.getIC2Tile(tileEntity) instanceof IEnergySink) { } else if (MekanismUtils.useIC2() && CableUtils.getIC2Tile(tileEntity) instanceof IEnergySink) {
wrapper = new IC2Acceptor((IEnergySink) CableUtils.getIC2Tile(tileEntity)); wrapper = new IC2Acceptor((IEnergySink) CableUtils.getIC2Tile(tileEntity));
} else if (MekanismUtils.useHBM() && tileEntity instanceof IEnergyReceiverMK2) {
wrapper = new HBMAcceptor((IEnergyReceiverMK2) tileEntity);
} }
if (wrapper != null) { if (wrapper != null) {
@ -182,4 +185,54 @@ public abstract class EnergyAcceptorWrapper implements IStrictEnergyAcceptor {
return eu * general.FROM_IC2; return eu * general.FROM_IC2;
} }
} }
public static class HBMAcceptor extends EnergyAcceptorWrapper {
private IEnergyReceiverMK2 acceptor;
public HBMAcceptor(IEnergyReceiverMK2 acceptor) {
this.acceptor = acceptor;
}
@Override
public double transferEnergyToAcceptor(ForgeDirection side, double amount) {
if (!canReceiveEnergy(side)) return amount;
long toTransfer = Math.min(Math.min(toHE(amount), acceptor.getReceiverSpeed()), acceptor.getMaxPower() - acceptor.getPower());
long leftover = acceptor.transferPower(toTransfer);
return fromHE(toTransfer - leftover);
}
@Override
public boolean canReceiveEnergy(ForgeDirection side) {
return acceptor.canConnect(side);
}
@Override
public double getEnergy() {
return fromHE(acceptor.getPower());
}
@Override
public void setEnergy(double energy) {
acceptor.setPower(toHE(energy));
}
@Override
public double getMaxEnergy() {
return fromHE(acceptor.getMaxPower());
}
@Override
public boolean needsEnergy(ForgeDirection side) {
return canReceiveEnergy(side) && acceptor.getPower() < acceptor.getMaxPower();
}
public long toHE(double joules) {
return (long)Math.floor(joules * general.TO_IC2);
}
public double fromHE(long he) {
return he * general.FROM_IC2;
}
}
} }

View file

@ -2,6 +2,8 @@ package mekanism.common.base;
import java.util.EnumSet; import java.util.EnumSet;
import api.hbm.energymk2.IEnergyProviderMK2;
import api.hbm.energymk2.IEnergyReceiverMK2;
import cofh.api.energy.IEnergyHandler; import cofh.api.energy.IEnergyHandler;
import cpw.mods.fml.common.Optional.Interface; import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.InterfaceList; import cpw.mods.fml.common.Optional.InterfaceList;
@ -17,11 +19,13 @@ import net.minecraftforge.common.util.ForgeDirection;
@InterfaceList({ @InterfaceList({
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2") @Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2")
, @Interface(iface = "ic2.api.energy.tile.IEnergySource", modid = "IC2"), , @Interface(iface = "ic2.api.energy.tile.IEnergySource", modid = "IC2"),
@Interface(iface = "ic2.api.tile.IEnergyStorage", modid = "IC2") @Interface(iface = "ic2.api.tile.IEnergyStorage", modid = "IC2"),
@Interface(iface = "api.hbm.energymk2.IEnergyProviderMK2", modid = "hbm"),
@Interface(iface = "api.hbm.energymk2.IEnergyReceiverMK2", modid = "hbm")
}) })
public interface IEnergyWrapper public interface IEnergyWrapper
extends IStrictEnergyStorage, IEnergyHandler, IEnergySink, IEnergySource, extends IStrictEnergyStorage, IEnergyHandler, IEnergySink, IEnergySource,
IEnergyStorage, IStrictEnergyAcceptor, ICableOutputter, IInventory { IEnergyStorage, IStrictEnergyAcceptor, ICableOutputter, IInventory, IEnergyReceiverMK2, IEnergyProviderMK2 {
public EnumSet<ForgeDirection> getOutputtingSides(); public EnumSet<ForgeDirection> getOutputtingSides();
public EnumSet<ForgeDirection> getConsumingSides(); public EnumSet<ForgeDirection> getConsumingSides();

View file

@ -39,6 +39,7 @@ public final class MekanismHooks {
public boolean TELoaded = false; public boolean TELoaded = false;
public boolean CCLoaded = false; public boolean CCLoaded = false;
public boolean AE2Loaded = false; public boolean AE2Loaded = false;
public boolean HBMLoaded = false;
public void hook() { public void hook() {
if (Loader.isModLoaded("CoFHCore")) if (Loader.isModLoaded("CoFHCore"))
@ -53,6 +54,8 @@ public final class MekanismHooks {
CCLoaded = true; CCLoaded = true;
if (Loader.isModLoaded("appliedenergistics2")) if (Loader.isModLoaded("appliedenergistics2"))
AE2Loaded = true; AE2Loaded = true;
if (Loader.isModLoaded("hbm"))
HBMLoaded = true;
if (IC2Loaded) { if (IC2Loaded) {
hookIC2Recipes(); hookIC2Recipes();

View file

@ -1,6 +1,6 @@
package mekanism.common.inventory.container; package mekanism.common.inventory.container;
import invtweaks.api.container.ChestContainer; //import invtweaks.api.container.ChestContainer;
import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.inventory.slot.SlotPersonalChest; import mekanism.common.inventory.slot.SlotPersonalChest;
import mekanism.common.tile.TileEntityPersonalChest; import mekanism.common.tile.TileEntityPersonalChest;
@ -11,7 +11,7 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ChestContainer(isLargeChest = true) //@ChestContainer(isLargeChest = true)
public class ContainerPersonalChest extends Container { public class ContainerPersonalChest extends Container {
private TileEntityPersonalChest tileEntity; private TileEntityPersonalChest tileEntity;
private IInventory itemInventory; private IInventory itemInventory;

View file

@ -9,10 +9,12 @@ import codechicken.multipart.MultiPartRegistry;
import codechicken.multipart.MultiPartRegistry.IPartFactory; import codechicken.multipart.MultiPartRegistry.IPartFactory;
import codechicken.multipart.MultipartGenerator; import codechicken.multipart.MultipartGenerator;
import codechicken.multipart.TMultiPart; import codechicken.multipart.TMultiPart;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLInterModComms;
import mekanism.common.MekanismBlocks; import mekanism.common.MekanismBlocks;
import mekanism.common.Tier; import mekanism.common.Tier;
import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.util.MekanismUtils;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class MultipartMekanism implements IPartFactory { public class MultipartMekanism implements IPartFactory {
@ -72,6 +74,9 @@ public class MultipartMekanism implements IPartFactory {
"mekanism.common.base.ITileNetwork" "mekanism.common.base.ITileNetwork"
); );
MultipartGenerator.registerPassThroughInterface("cofh.api.energy.IEnergyHandler"); MultipartGenerator.registerPassThroughInterface("cofh.api.energy.IEnergyHandler");
if (Loader.isModLoaded("hbm")) {
MultipartGenerator.registerPassThroughInterface("api.hbm.energymk2.IEnergyReceiverMK2");
}
registerMicroMaterials(); registerMicroMaterials();
} }

View file

@ -3,11 +3,16 @@ package mekanism.common.multipart;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import api.hbm.energymk2.IEnergyProviderMK2;
import api.hbm.energymk2.IEnergyReceiverMK2;
import codechicken.lib.data.MCDataInput; import codechicken.lib.data.MCDataInput;
import codechicken.lib.data.MCDataOutput; import codechicken.lib.data.MCDataOutput;
import codechicken.lib.vec.Vector3; import codechicken.lib.vec.Vector3;
import cofh.api.energy.IEnergyHandler; import cofh.api.energy.IEnergyHandler;
import cofh.api.energy.IEnergyProvider; import cofh.api.energy.IEnergyProvider;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.InterfaceList;
import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import ic2.api.energy.tile.IEnergySource; import ic2.api.energy.tile.IEnergySource;
@ -32,9 +37,12 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon; import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
@InterfaceList({
@Interface(iface = "api.hbm.energymk2.IEnergyReceiverMK2", modid = "hbm")
})
public class PartUniversalCable public class PartUniversalCable
extends PartTransmitter<EnergyAcceptorWrapper, EnergyNetwork> extends PartTransmitter<EnergyAcceptorWrapper, EnergyNetwork>
implements IStrictEnergyAcceptor, IEnergyHandler { implements IStrictEnergyAcceptor, IEnergyHandler, IEnergyReceiverMK2 {
public Tier.CableTier tier; public Tier.CableTier tier;
public static TransmitterIcons cableIcons = new TransmitterIcons(4, 8); public static TransmitterIcons cableIcons = new TransmitterIcons(4, 8);
@ -44,6 +52,8 @@ public class PartUniversalCable
public EnergyStack buffer = new EnergyStack(0); public EnergyStack buffer = new EnergyStack(0);
public boolean isLoaded = false;
public PartUniversalCable(Tier.CableTier cableTier) { public PartUniversalCable(Tier.CableTier cableTier) {
super(); super();
tier = cableTier; tier = cableTier;
@ -61,6 +71,10 @@ public class PartUniversalCable
} }
} else { } else {
updateShare(); updateShare();
isLoaded = true;
if (MekanismUtils.useHBM()) {
receiveHe();
}
List<ForgeDirection> sides = getConnections(ConnectionType.PULL); List<ForgeDirection> sides = getConnections(ConnectionType.PULL);
@ -72,7 +86,6 @@ public class PartUniversalCable
for (ForgeDirection side : sides) { for (ForgeDirection side : sides) {
if (connectedOutputters[side.ordinal()] != null) { if (connectedOutputters[side.ordinal()] != null) {
TileEntity outputter = connectedOutputters[side.ordinal()]; TileEntity outputter = connectedOutputters[side.ordinal()];
if (outputter instanceof ICableOutputter if (outputter instanceof ICableOutputter
&& outputter instanceof IStrictEnergyStorage) { && outputter instanceof IStrictEnergyStorage) {
if (((ICableOutputter) outputter) if (((ICableOutputter) outputter)
@ -128,6 +141,14 @@ public class PartUniversalCable
((IEnergySource) CableUtils.getIC2Tile(outputter)) ((IEnergySource) CableUtils.getIC2Tile(outputter))
.drawEnergy(toDraw * general.TO_IC2); .drawEnergy(toDraw * general.TO_IC2);
} else if (MekanismUtils.useHBM() && outputter instanceof IEnergyProviderMK2) {
IEnergyProviderMK2 tile = (IEnergyProviderMK2) outputter;
double received = Math.min(Math.min(tile.getPower(), tile.getProviderSpeed()) * general.FROM_IC2, canDraw);
double toDraw = received;
if (received > 0) {
toDraw -= takeEnergy(received, true);
}
tile.usePower((long)(toDraw * general.TO_IC2));
} }
} }
} }
@ -256,9 +277,16 @@ public class PartUniversalCable
@Override @Override
public void onChunkUnload() { public void onChunkUnload() {
takeShare(); takeShare();
isLoaded = false;
super.onChunkUnload(); super.onChunkUnload();
} }
@Override
public void onRemoved() {
isLoaded = false;
super.onRemoved();
}
@Override @Override
public Object getBuffer() { public Object getBuffer() {
return buffer; return buffer;
@ -408,4 +436,41 @@ public class PartUniversalCable
super.writeDesc(packet); super.writeDesc(packet);
} }
@Override
@Method(modid = "hbm")
public long getPower() {
return Math.round(getEnergy() * general.TO_IC2);
}
@Override
@Method(modid = "hbm")
public void setPower(long power) {
setEnergy(power * general.FROM_IC2);
}
@Override
@Method(modid = "hbm")
public long getMaxPower() {
return Math.round(getMaxEnergy() * general.TO_IC2);
}
@Method(modid = "hbm")
public void receiveHe() {
for (ForgeDirection dir : getConnections(ConnectionType.NORMAL))
this.trySubscribe(
world(),
x() + dir.offsetX,
y() + dir.offsetY,
z() + dir.offsetZ,
dir
);
}
@Override
@Method(modid = "hbm")
public boolean isLoaded() {
return isLoaded;
}
} }

View file

@ -49,6 +49,7 @@ public class PacketConfigSync implements IMessageHandler<ConfigSyncMessage, IMes
dataStream.writeDouble(general.minerSilkMultiplier); dataStream.writeDouble(general.minerSilkMultiplier);
dataStream.writeBoolean(general.blacklistIC2); dataStream.writeBoolean(general.blacklistIC2);
dataStream.writeBoolean(general.blacklistRF); dataStream.writeBoolean(general.blacklistRF);
dataStream.writeBoolean(general.blacklistHBM);
dataStream.writeDouble(general.armoredJetpackDamageRatio); dataStream.writeDouble(general.armoredJetpackDamageRatio);
dataStream.writeInt(general.armoredJetpackDamageMax); dataStream.writeInt(general.armoredJetpackDamageMax);
dataStream.writeBoolean(general.aestheticWorldDamage); dataStream.writeBoolean(general.aestheticWorldDamage);
@ -141,6 +142,7 @@ public class PacketConfigSync implements IMessageHandler<ConfigSyncMessage, IMes
general.minerSilkMultiplier = dataStream.readDouble(); general.minerSilkMultiplier = dataStream.readDouble();
general.blacklistIC2 = dataStream.readBoolean(); general.blacklistIC2 = dataStream.readBoolean();
general.blacklistRF = dataStream.readBoolean(); general.blacklistRF = dataStream.readBoolean();
general.blacklistHBM = dataStream.readBoolean();
general.armoredJetpackDamageRatio = dataStream.readDouble(); general.armoredJetpackDamageRatio = dataStream.readDouble();
general.armoredJetpackDamageMax = dataStream.readInt(); general.armoredJetpackDamageMax = dataStream.readInt();
general.aestheticWorldDamage = dataStream.readBoolean(); general.aestheticWorldDamage = dataStream.readBoolean();

View file

@ -34,6 +34,8 @@ public abstract class TileEntityElectricBlock
/** Is this registered with IC2 */ /** Is this registered with IC2 */
public boolean ic2Registered = false; public boolean ic2Registered = false;
public boolean isLoaded = false;
/** /**
* The base of all blocks that deal with electricity. It has a facing state, * The base of all blocks that deal with electricity. It has a facing state,
* initialized state, and a current amount of stored energy. * initialized state, and a current amount of stored energy.
@ -82,6 +84,10 @@ public abstract class TileEntityElectricBlock
if (!ic2Registered && MekanismUtils.useIC2()) { if (!ic2Registered && MekanismUtils.useIC2()) {
register(); register();
} }
if (MekanismUtils.useHBM()) {
receiveHe();
}
isLoaded = true;
} }
@Override @Override
@ -147,12 +153,14 @@ public abstract class TileEntityElectricBlock
if (MekanismUtils.useIC2()) { if (MekanismUtils.useIC2()) {
deregister(); deregister();
} }
isLoaded = false;
super.onChunkUnload(); super.onChunkUnload();
} }
@Override @Override
public void invalidate() { public void invalidate() {
super.invalidate(); super.invalidate();
isLoaded = false;
if (MekanismUtils.useIC2()) { if (MekanismUtils.useIC2()) {
deregister(); deregister();
} }
@ -349,4 +357,55 @@ public abstract class TileEntityElectricBlock
return toUse; return toUse;
} }
@Override
@Method(modid = "hbm")
public long getPower() {
return Math.round(getEnergy() * general.TO_IC2);
}
@Override
@Method(modid = "hbm")
public void setPower(long power) {
setEnergy(power * general.FROM_IC2);
}
@Override
@Method(modid = "hbm")
public long getMaxPower() {
return Math.round(getMaxEnergy() * general.TO_IC2);
}
@Override
@Method(modid = "hbm")
public long getProviderSpeed() {
return Math.round(getMaxOutput() * general.TO_IC2);
}
@Method(modid = "hbm")
public void receiveHe() {
if (!worldObj.isRemote) {
for (ForgeDirection dir : getConsumingSides())
this.trySubscribe(
worldObj,
xCoord + dir.offsetX,
yCoord + dir.offsetY,
zCoord + dir.offsetZ,
dir
);
}
}
@Override
@Method(modid = "hbm")
public boolean isLoaded() {
return isLoaded;
}
@Override
@Method(modid = "hbm")
public boolean canConnect(ForgeDirection from) {
return getConsumingSides().contains(from) || getOutputtingSides().contains(from);
}
} }

View file

@ -31,7 +31,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import universalelectricity.core.electricity.ElectricityPack;
@InterfaceList({ @InterfaceList({
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2") @Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2")
@ -41,6 +40,7 @@ import universalelectricity.core.electricity.ElectricityPack;
public class TileEntityInductionPort extends TileEntityInductionCasing public class TileEntityInductionPort extends TileEntityInductionCasing
implements IEnergyWrapper, IConfigurable, IActiveState { implements IEnergyWrapper, IConfigurable, IActiveState {
public boolean ic2Registered = false; public boolean ic2Registered = false;
public boolean isLoaded = false;
/** false = input, true = output */ /** false = input, true = output */
public boolean mode; public boolean mode;
@ -56,6 +56,10 @@ public class TileEntityInductionPort extends TileEntityInductionCasing
if (!ic2Registered && MekanismUtils.useIC2()) { if (!ic2Registered && MekanismUtils.useIC2()) {
register(); register();
} }
if (MekanismUtils.useHBM()) {
receiveHe();
}
isLoaded = true;
if (!worldObj.isRemote) { if (!worldObj.isRemote) {
if (structure != null && mode == true) { if (structure != null && mode == true) {
@ -169,14 +173,14 @@ public class TileEntityInductionPort extends TileEntityInductionCasing
if (MekanismUtils.useIC2()) { if (MekanismUtils.useIC2()) {
deregister(); deregister();
} }
isLoaded = false;
super.onChunkUnload(); super.onChunkUnload();
} }
@Override @Override
public void invalidate() { public void invalidate() {
super.invalidate(); super.invalidate();
isLoaded = false;
if (MekanismUtils.useIC2()) { if (MekanismUtils.useIC2()) {
deregister(); deregister();
} }
@ -428,4 +432,48 @@ public class TileEntityInductionPort extends TileEntityInductionCasing
public boolean lightUpdate() { public boolean lightUpdate() {
return false; return false;
} }
@Override
@Method(modid = "hbm")
public long getPower() {
return Math.round(getEnergy() * general.TO_IC2);
}
@Override
@Method(modid = "hbm")
public void setPower(long power) {
setEnergy(power * general.FROM_IC2);
}
@Override
@Method(modid = "hbm")
public long getMaxPower() {
return Math.round(getMaxEnergy() * general.TO_IC2);
}
@Override
@Method(modid = "hbm")
public long getProviderSpeed() {
return Math.round(getMaxOutput() * general.TO_IC2);
}
@Method(modid = "hbm")
public void receiveHe() {
if (!worldObj.isRemote) {
for (ForgeDirection dir : getConsumingSides())
this.trySubscribe(
worldObj,
xCoord + dir.offsetX,
yCoord + dir.offsetY,
zCoord + dir.offsetZ,
dir
);
}
}
@Override
@Method(modid = "hbm")
public boolean isLoaded() {
return isLoaded;
}
} }

View file

@ -4,6 +4,9 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import api.hbm.energymk2.IEnergyConnectorMK2;
import api.hbm.energymk2.IEnergyProviderMK2;
import api.hbm.energymk2.IEnergyReceiverMK2;
import cofh.api.energy.IEnergyConnection; import cofh.api.energy.IEnergyConnection;
import cofh.api.energy.IEnergyProvider; import cofh.api.energy.IEnergyProvider;
import cofh.api.energy.IEnergyReceiver; import cofh.api.energy.IEnergyReceiver;
@ -27,6 +30,7 @@ public final class CableUtils {
tileEntity instanceof IStrictEnergyAcceptor tileEntity instanceof IStrictEnergyAcceptor
|| (MekanismUtils.useIC2() && getIC2Tile(tileEntity) instanceof IEnergySink) || (MekanismUtils.useIC2() && getIC2Tile(tileEntity) instanceof IEnergySink)
|| (MekanismUtils.useRF() && tileEntity instanceof IEnergyReceiver) || (MekanismUtils.useRF() && tileEntity instanceof IEnergyReceiver)
|| (MekanismUtils.useHBM() && tileEntity instanceof IEnergyReceiverMK2)
); );
} }
@ -112,7 +116,9 @@ public final class CableUtils {
&& ((IEnergySource) getIC2Tile(tileEntity)) && ((IEnergySource) getIC2Tile(tileEntity))
.emitsEnergyTo(null, side.getOpposite())) .emitsEnergyTo(null, side.getOpposite()))
|| (MekanismUtils.useRF() && tileEntity instanceof IEnergyProvider || (MekanismUtils.useRF() && tileEntity instanceof IEnergyProvider
&& ((IEnergyConnection) tileEntity).canConnectEnergy(side.getOpposite())); && ((IEnergyConnection) tileEntity).canConnectEnergy(side.getOpposite()))
|| (MekanismUtils.useHBM() && tileEntity instanceof IEnergyProviderMK2
&& ((IEnergyConnectorMK2) tileEntity).canConnect(side.getOpposite()));
} }
public static boolean public static boolean
@ -139,6 +145,10 @@ public final class CableUtils {
if (((IEnergyConnection) tileEntity).canConnectEnergy(side.getOpposite())) { if (((IEnergyConnection) tileEntity).canConnectEnergy(side.getOpposite())) {
return true; return true;
} }
} else if (MekanismUtils.useHBM() && tileEntity instanceof IEnergyConnectorMK2) {
if (((IEnergyConnectorMK2) tileEntity).canConnect(side.getOpposite())) {
return true;
}
} }
return false; return false;
@ -158,6 +168,15 @@ public final class CableUtils {
if (connectable[side.ordinal()]) { if (connectable[side.ordinal()]) {
outputtingSides.add(side); outputtingSides.add(side);
} }
if (MekanismUtils.useHBM()) {
emitter.tryProvide(
((TileEntity)emitter).getWorldObj(),
((TileEntity)emitter).xCoord + side.offsetX,
((TileEntity)emitter).yCoord + side.offsetY,
((TileEntity)emitter).zCoord + side.offsetZ,
side
);
}
} }
if (outputtingSides.size() > 0) { if (outputtingSides.size() > 0) {

View file

@ -1208,6 +1208,10 @@ public final class MekanismUtils {
return !general.blacklistRF; return !general.blacklistRF;
} }
public static boolean useHBM() {
return Mekanism.hooks.HBMLoaded && !general.blacklistHBM;
}
/** /**
* Gets a clean view of a coordinate value without the dimension ID. * Gets a clean view of a coordinate value without the dimension ID.
* @param obj - coordinate to check * @param obj - coordinate to check

View file

@ -36,6 +36,7 @@ import net.minecraftforge.fluids.IFluidHandler;
public class TileEntityTurbineValve public class TileEntityTurbineValve
extends TileEntityTurbineCasing implements IFluidHandler, IEnergyWrapper { extends TileEntityTurbineCasing implements IFluidHandler, IEnergyWrapper {
public boolean ic2Registered = false; public boolean ic2Registered = false;
public boolean isLoaded = false;
public TurbineFluidTank fluidTank; public TurbineFluidTank fluidTank;
@ -51,6 +52,10 @@ public class TileEntityTurbineValve
if (!ic2Registered && MekanismUtils.useIC2()) { if (!ic2Registered && MekanismUtils.useIC2()) {
register(); register();
} }
if (MekanismUtils.useHBM()) {
receiveHe();
}
isLoaded = true;
if (!worldObj.isRemote) { if (!worldObj.isRemote) {
if (structure != null) { if (structure != null) {
@ -138,14 +143,14 @@ public class TileEntityTurbineValve
if (MekanismUtils.useIC2()) { if (MekanismUtils.useIC2()) {
deregister(); deregister();
} }
isLoaded = false;
super.onChunkUnload(); super.onChunkUnload();
} }
@Override @Override
public void invalidate() { public void invalidate() {
super.invalidate(); super.invalidate();
isLoaded = false;
if (MekanismUtils.useIC2()) { if (MekanismUtils.useIC2()) {
deregister(); deregister();
} }
@ -356,4 +361,48 @@ public class TileEntityTurbineValve
public String getInventoryName() { public String getInventoryName() {
return LangUtils.localize("gui.industrialTurbine"); return LangUtils.localize("gui.industrialTurbine");
} }
@Override
@Method(modid = "hbm")
public long getPower() {
return Math.round(getEnergy() * general.TO_IC2);
}
@Override
@Method(modid = "hbm")
public void setPower(long power) {
setEnergy(power * general.FROM_IC2);
}
@Override
@Method(modid = "hbm")
public long getMaxPower() {
return Math.round(getMaxEnergy() * general.TO_IC2);
}
@Override
@Method(modid = "hbm")
public long getProviderSpeed() {
return Math.round(getMaxOutput() * general.TO_IC2);
}
@Method(modid = "hbm")
public void receiveHe() {
if (!worldObj.isRemote) {
for (ForgeDirection dir : getConsumingSides())
this.trySubscribe(
worldObj,
xCoord + dir.offsetX,
yCoord + dir.offsetY,
zCoord + dir.offsetZ,
dir
);
}
}
@Override
@Method(modid = "hbm")
public boolean isLoaded() {
return isLoaded;
}
} }