Improve Tesla integration
This commit is contained in:
@@ -4,7 +4,6 @@ import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||
import net.minecraftforge.fml.common.Mod.Instance;
|
||||
@@ -141,8 +140,4 @@ public final class RefinedStorage {
|
||||
public void postInit(FMLPostInitializationEvent e) {
|
||||
PROXY.postInit(e);
|
||||
}
|
||||
|
||||
public static boolean hasTesla() {
|
||||
return Loader.isModLoaded("tesla");
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ import refinedstorage.gui.Scrollbar;
|
||||
import refinedstorage.gui.grid.sorting.GridSortingName;
|
||||
import refinedstorage.gui.grid.sorting.GridSortingQuantity;
|
||||
import refinedstorage.gui.sidebutton.*;
|
||||
import refinedstorage.integration.jei.JEIIntegration;
|
||||
import refinedstorage.integration.jei.IntegrationJEI;
|
||||
import refinedstorage.network.MessageGridCraftingClear;
|
||||
import refinedstorage.network.MessageGridInsertHeld;
|
||||
import refinedstorage.network.MessageGridPatternCreate;
|
||||
@@ -394,8 +394,8 @@ public class GuiGrid extends GuiBase {
|
||||
}
|
||||
|
||||
private void updateJEI() {
|
||||
if (JEIIntegration.isLoaded() && (grid.getSearchBoxMode() == TileGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED || grid.getSearchBoxMode() == TileGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED)) {
|
||||
JEIIntegration.INSTANCE.getRuntime().getItemListOverlay().setFilterText(searchField.getText());
|
||||
if (IntegrationJEI.isLoaded() && (grid.getSearchBoxMode() == TileGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED || grid.getSearchBoxMode() == TileGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED)) {
|
||||
IntegrationJEI.INSTANCE.getRuntime().getItemListOverlay().setFilterText(searchField.getText());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -3,7 +3,7 @@ package refinedstorage.gui.sidebutton;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import refinedstorage.gui.GuiBase;
|
||||
import refinedstorage.gui.grid.GuiGrid;
|
||||
import refinedstorage.integration.jei.JEIIntegration;
|
||||
import refinedstorage.integration.jei.IntegrationJEI;
|
||||
import refinedstorage.tile.grid.TileGrid;
|
||||
|
||||
public class SideButtonGridSearchBoxMode extends SideButton {
|
||||
@@ -31,7 +31,7 @@ public class SideButtonGridSearchBoxMode extends SideButton {
|
||||
if (mode == TileGrid.SEARCH_BOX_MODE_NORMAL) {
|
||||
mode = TileGrid.SEARCH_BOX_MODE_NORMAL_AUTOSELECTED;
|
||||
} else if (mode == TileGrid.SEARCH_BOX_MODE_NORMAL_AUTOSELECTED) {
|
||||
if (JEIIntegration.isLoaded()) {
|
||||
if (IntegrationJEI.isLoaded()) {
|
||||
mode = TileGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED;
|
||||
} else {
|
||||
mode = TileGrid.SEARCH_BOX_MODE_NORMAL;
|
||||
|
@@ -4,19 +4,19 @@ import ic2.api.energy.prefab.BasicSink;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import refinedstorage.tile.TileController;
|
||||
|
||||
public class IC2EnergyController implements IIC2EnergyController {
|
||||
public class ControllerEnergyIC2 implements IControllerEnergyIC2 {
|
||||
private BasicSink sink;
|
||||
|
||||
public IC2EnergyController(final TileController controller) {
|
||||
this.sink = new BasicSink(controller, (int) IC2Integration.toEU(controller.getEnergy().getMaxEnergyStored()), Integer.MAX_VALUE) {
|
||||
public ControllerEnergyIC2(final TileController controller) {
|
||||
this.sink = new BasicSink(controller, (int) IntegrationIC2.toEU(controller.getEnergy().getMaxEnergyStored()), Integer.MAX_VALUE) {
|
||||
@Override
|
||||
public double getDemandedEnergy() {
|
||||
return Math.max(0.0D, IC2Integration.toEU(controller.getEnergy().getMaxEnergyStored()) - IC2Integration.toEU(controller.getEnergy().getEnergyStored()));
|
||||
return Math.max(0.0D, IntegrationIC2.toEU(controller.getEnergy().getMaxEnergyStored()) - IntegrationIC2.toEU(controller.getEnergy().getEnergyStored()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergy(EnumFacing directionFrom, double amount, double voltage) {
|
||||
controller.getEnergy().setEnergyStored(controller.getEnergy().getEnergyStored() + IC2Integration.toRS(amount));
|
||||
controller.getEnergy().setEnergyStored(controller.getEnergy().getEnergyStored() + IntegrationIC2.toRS(amount));
|
||||
|
||||
return 0.0D;
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
package refinedstorage.integration.ic2;
|
||||
|
||||
public class IC2EnergyControllerNone implements IIC2EnergyController {
|
||||
public class ControllerEnergyIC2None implements IControllerEnergyIC2 {
|
||||
@Override
|
||||
public void invalidate() {
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
package refinedstorage.integration.ic2;
|
||||
|
||||
public interface IIC2EnergyController {
|
||||
public interface IControllerEnergyIC2 {
|
||||
void invalidate();
|
||||
|
||||
void update();
|
@@ -2,7 +2,7 @@ package refinedstorage.integration.ic2;
|
||||
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
|
||||
public final class IC2Integration {
|
||||
public final class IntegrationIC2 {
|
||||
public static boolean isLoaded() {
|
||||
return Loader.isModLoaded("IC2");
|
||||
}
|
@@ -9,8 +9,8 @@ import net.minecraftforge.fml.common.Loader;
|
||||
import refinedstorage.RefinedStorageBlocks;
|
||||
|
||||
@JEIPlugin
|
||||
public class JEIIntegration implements IModPlugin {
|
||||
public static JEIIntegration INSTANCE;
|
||||
public class IntegrationJEI implements IModPlugin {
|
||||
public static IntegrationJEI INSTANCE;
|
||||
|
||||
private IJeiRuntime runtime;
|
||||
|
28
src/main/java/refinedstorage/integration/tesla/ControllerEnergyTesla.java
Executable file
28
src/main/java/refinedstorage/integration/tesla/ControllerEnergyTesla.java
Executable file
@@ -0,0 +1,28 @@
|
||||
package refinedstorage.integration.tesla;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import net.darkhax.tesla.api.ITeslaConsumer;
|
||||
import net.darkhax.tesla.api.ITeslaHolder;
|
||||
|
||||
public class ControllerEnergyTesla implements ITeslaHolder, ITeslaConsumer {
|
||||
private EnergyStorage energy;
|
||||
|
||||
public ControllerEnergyTesla(EnergyStorage energy) {
|
||||
this.energy = energy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long givePower(long power, boolean simulated) {
|
||||
return energy.receiveEnergy((int) power, simulated);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStoredPower() {
|
||||
return energy.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCapacity() {
|
||||
return energy.getMaxEnergyStored();
|
||||
}
|
||||
}
|
9
src/main/java/refinedstorage/integration/tesla/IntegrationTesla.java
Executable file
9
src/main/java/refinedstorage/integration/tesla/IntegrationTesla.java
Executable file
@@ -0,0 +1,9 @@
|
||||
package refinedstorage.integration.tesla;
|
||||
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
|
||||
public final class IntegrationTesla {
|
||||
public static boolean isLoaded() {
|
||||
return Loader.isModLoaded("tesla");
|
||||
}
|
||||
}
|
31
src/main/java/refinedstorage/integration/tesla/WirelessGridEnergyTesla.java
Executable file
31
src/main/java/refinedstorage/integration/tesla/WirelessGridEnergyTesla.java
Executable file
@@ -0,0 +1,31 @@
|
||||
package refinedstorage.integration.tesla;
|
||||
|
||||
import net.darkhax.tesla.api.ITeslaConsumer;
|
||||
import net.darkhax.tesla.api.ITeslaHolder;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.item.ItemWirelessGrid;
|
||||
|
||||
public class WirelessGridEnergyTesla implements ITeslaHolder, ITeslaConsumer {
|
||||
private ItemWirelessGrid wirelessGrid;
|
||||
private ItemStack stack;
|
||||
|
||||
public WirelessGridEnergyTesla(ItemWirelessGrid wirelessGrid, ItemStack stack) {
|
||||
this.wirelessGrid = wirelessGrid;
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStoredPower() {
|
||||
return wirelessGrid.getEnergyStored(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCapacity() {
|
||||
return wirelessGrid.getMaxEnergyStored(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long givePower(long power, boolean simulated) {
|
||||
return wirelessGrid.receiveEnergy(stack, (int) power, simulated);
|
||||
}
|
||||
}
|
@@ -3,8 +3,6 @@ package refinedstorage.item;
|
||||
import cofh.api.energy.ItemEnergyContainer;
|
||||
import ic2.api.item.IElectricItemManager;
|
||||
import ic2.api.item.ISpecialElectricItem;
|
||||
import net.darkhax.tesla.api.ITeslaConsumer;
|
||||
import net.darkhax.tesla.api.ITeslaHolder;
|
||||
import net.darkhax.tesla.capability.TeslaCapabilities;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
@@ -25,7 +23,9 @@ import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.RefinedStorageBlocks;
|
||||
import refinedstorage.integration.ic2.IC2Integration;
|
||||
import refinedstorage.integration.ic2.IntegrationIC2;
|
||||
import refinedstorage.integration.tesla.IntegrationTesla;
|
||||
import refinedstorage.integration.tesla.WirelessGridEnergyTesla;
|
||||
import refinedstorage.tile.TileController;
|
||||
import refinedstorage.tile.grid.TileGrid;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ItemWirelessGrid extends ItemEnergyContainer implements ISpecialEle
|
||||
addPropertyOverride(new ResourceLocation("connected"), new IItemPropertyGetter() {
|
||||
@Override
|
||||
public float apply(ItemStack stack, World world, EntityLivingBase entity) {
|
||||
return (entity != null && hasValidNBT(stack) && getDimensionId(stack) == entity.dimension) ? 1.0f : 0.0f;
|
||||
return (entity != null && isValid(stack) && getDimensionId(stack) == entity.dimension) ? 1.0f : 0.0f;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -79,7 +79,7 @@ public class ItemWirelessGrid extends ItemEnergyContainer implements ISpecialEle
|
||||
|
||||
@Override
|
||||
public double getDurabilityForDisplay(ItemStack stack) {
|
||||
return 1d - ((double) getEnergyStored(stack) / (double) getMaxEnergyStored(stack));
|
||||
return 1D - ((double) getEnergyStored(stack) / (double) getMaxEnergyStored(stack));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -109,7 +109,7 @@ public class ItemWirelessGrid extends ItemEnergyContainer implements ISpecialEle
|
||||
tooltip.add(I18n.format("misc.refinedstorage:energy_stored", getEnergyStored(stack), getMaxEnergyStored(stack)));
|
||||
}
|
||||
|
||||
if (hasValidNBT(stack)) {
|
||||
if (isValid(stack)) {
|
||||
tooltip.add(I18n.format("misc.refinedstorage:wireless_grid.tooltip", getX(stack), getY(stack), getZ(stack)));
|
||||
}
|
||||
}
|
||||
@@ -144,7 +144,7 @@ public class ItemWirelessGrid extends ItemEnergyContainer implements ISpecialEle
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
|
||||
if (!world.isRemote && hasValidNBT(stack) && getDimensionId(stack) == player.dimension) {
|
||||
if (!world.isRemote && isValid(stack) && getDimensionId(stack) == player.dimension) {
|
||||
TileEntity tile = world.getTileEntity(new BlockPos(getX(stack), getY(stack), getZ(stack)));
|
||||
|
||||
if (tile instanceof TileController) {
|
||||
@@ -193,7 +193,7 @@ public class ItemWirelessGrid extends ItemEnergyContainer implements ISpecialEle
|
||||
return stack.getTagCompound().getInteger(TileGrid.NBT_SEARCH_BOX_MODE);
|
||||
}
|
||||
|
||||
private static boolean hasValidNBT(ItemStack stack) {
|
||||
private static boolean isValid(ItemStack stack) {
|
||||
return stack.hasTagCompound()
|
||||
&& stack.getTagCompound().hasKey(NBT_CONTROLLER_X)
|
||||
&& stack.getTagCompound().hasKey(NBT_CONTROLLER_Y)
|
||||
@@ -208,7 +208,7 @@ public class ItemWirelessGrid extends ItemEnergyContainer implements ISpecialEle
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
|
||||
if (oldStack.getItem() == newStack.getItem()) {
|
||||
if (hasValidNBT(oldStack) && hasValidNBT(newStack)) {
|
||||
if (isValid(oldStack) && isValid(newStack)) {
|
||||
if (getX(oldStack) == getX(newStack) && getY(oldStack) == getY(newStack) && getZ(oldStack) == getZ(newStack) && getDimensionId(oldStack) == getDimensionId(newStack)) {
|
||||
return false;
|
||||
}
|
||||
@@ -237,25 +237,25 @@ public class ItemWirelessGrid extends ItemEnergyContainer implements ISpecialEle
|
||||
@Optional.Method(modid = "IC2")
|
||||
@Override
|
||||
public double charge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean simulate) {
|
||||
return IC2Integration.toEU(receiveEnergy(stack, IC2Integration.toRS(amount), simulate));
|
||||
return IntegrationIC2.toEU(receiveEnergy(stack, IntegrationIC2.toRS(amount), simulate));
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "IC2")
|
||||
@Override
|
||||
public double discharge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean externally, boolean simulate) {
|
||||
return IC2Integration.toEU(extractEnergy(stack, IC2Integration.toRS(amount), simulate));
|
||||
return IntegrationIC2.toEU(extractEnergy(stack, IntegrationIC2.toRS(amount), simulate));
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "IC2")
|
||||
@Override
|
||||
public double getCharge(ItemStack stack) {
|
||||
return IC2Integration.toEU(getEnergyStored(stack));
|
||||
return IntegrationIC2.toEU(getEnergyStored(stack));
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "IC2")
|
||||
@Override
|
||||
public double getMaxCharge(ItemStack stack) {
|
||||
return IC2Integration.toEU(getMaxEnergyStored(stack));
|
||||
return IntegrationIC2.toEU(getMaxEnergyStored(stack));
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "IC2")
|
||||
@@ -288,29 +288,6 @@ public class ItemWirelessGrid extends ItemEnergyContainer implements ISpecialEle
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
class TeslaEnergy implements ITeslaHolder, ITeslaConsumer {
|
||||
private ItemStack stack;
|
||||
|
||||
public TeslaEnergy(ItemStack stack) {
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStoredPower() {
|
||||
return getEnergyStored(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCapacity() {
|
||||
return getMaxEnergyStored(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long givePower(long power, boolean simulated) {
|
||||
return receiveEnergy(stack, (int) power, simulated);
|
||||
}
|
||||
}
|
||||
|
||||
class WirelessGridCapabilityProvider implements ICapabilityProvider {
|
||||
private ItemStack stack;
|
||||
|
||||
@@ -320,13 +297,13 @@ public class ItemWirelessGrid extends ItemEnergyContainer implements ISpecialEle
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
return RefinedStorage.hasTesla() && (capability == TeslaCapabilities.CAPABILITY_HOLDER || capability == TeslaCapabilities.CAPABILITY_CONSUMER);
|
||||
return IntegrationTesla.isLoaded() && (capability == TeslaCapabilities.CAPABILITY_HOLDER || capability == TeslaCapabilities.CAPABILITY_CONSUMER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (RefinedStorage.hasTesla() && (capability == TeslaCapabilities.CAPABILITY_HOLDER || capability == TeslaCapabilities.CAPABILITY_CONSUMER)) {
|
||||
return (T) new TeslaEnergy(stack);
|
||||
if (IntegrationTesla.isLoaded() && (capability == TeslaCapabilities.CAPABILITY_HOLDER || capability == TeslaCapabilities.CAPABILITY_CONSUMER)) {
|
||||
return (T) new WirelessGridEnergyTesla(ItemWirelessGrid.this, stack);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@@ -3,8 +3,6 @@ package refinedstorage.tile;
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.darkhax.tesla.api.ITeslaConsumer;
|
||||
import net.darkhax.tesla.api.ITeslaHolder;
|
||||
import net.darkhax.tesla.capability.TeslaCapabilities;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -17,7 +15,6 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import refinedstorage.RefinedStorage;
|
||||
@@ -40,10 +37,12 @@ import refinedstorage.block.BlockController;
|
||||
import refinedstorage.block.EnumControllerType;
|
||||
import refinedstorage.container.ContainerController;
|
||||
import refinedstorage.container.ContainerGrid;
|
||||
import refinedstorage.integration.ic2.IC2EnergyController;
|
||||
import refinedstorage.integration.ic2.IC2EnergyControllerNone;
|
||||
import refinedstorage.integration.ic2.IC2Integration;
|
||||
import refinedstorage.integration.ic2.IIC2EnergyController;
|
||||
import refinedstorage.integration.ic2.ControllerEnergyIC2;
|
||||
import refinedstorage.integration.ic2.ControllerEnergyIC2None;
|
||||
import refinedstorage.integration.ic2.IControllerEnergyIC2;
|
||||
import refinedstorage.integration.ic2.IntegrationIC2;
|
||||
import refinedstorage.integration.tesla.ControllerEnergyTesla;
|
||||
import refinedstorage.integration.tesla.IntegrationTesla;
|
||||
import refinedstorage.item.ItemPattern;
|
||||
import refinedstorage.network.MessageGridDelta;
|
||||
import refinedstorage.network.MessageGridUpdate;
|
||||
@@ -53,11 +52,7 @@ import refinedstorage.tile.externalstorage.ExternalStorage;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(iface = "net.darkhax.tesla.api.ITeslaConsumer", modid = "tesla"),
|
||||
@Optional.Interface(iface = "net.darkhax.tesla.api.ITeslaHolder", modid = "tesla")
|
||||
})
|
||||
public class TileController extends TileBase implements INetworkMaster, IEnergyReceiver, ITeslaHolder, ITeslaConsumer, ISynchronizedContainer, IRedstoneModeConfig {
|
||||
public class TileController extends TileBase implements INetworkMaster, IEnergyReceiver, ISynchronizedContainer, IRedstoneModeConfig {
|
||||
public static final String NBT_ENERGY = "Energy";
|
||||
public static final String NBT_ENERGY_CAPACITY = "EnergyCapacity";
|
||||
|
||||
@@ -99,7 +94,8 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
private List<ICraftingTask> craftingTasksToCancel = new ArrayList<ICraftingTask>();
|
||||
|
||||
private EnergyStorage energy = new EnergyStorage(RefinedStorage.INSTANCE.controllerCapacity);
|
||||
private IIC2EnergyController energyEU;
|
||||
private IControllerEnergyIC2 energyEU;
|
||||
private ControllerEnergyTesla energyTesla;
|
||||
private int energyUsage;
|
||||
|
||||
private int lastEnergyDisplay;
|
||||
@@ -114,10 +110,14 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
private List<ClientNode> clientNodes = new ArrayList<ClientNode>();
|
||||
|
||||
public TileController() {
|
||||
if (IC2Integration.isLoaded()) {
|
||||
this.energyEU = new IC2EnergyController(this);
|
||||
if (IntegrationIC2.isLoaded()) {
|
||||
this.energyEU = new ControllerEnergyIC2(this);
|
||||
} else {
|
||||
this.energyEU = new IC2EnergyControllerNone();
|
||||
this.energyEU = new ControllerEnergyIC2None();
|
||||
}
|
||||
|
||||
if (IntegrationTesla.isLoaded()) {
|
||||
this.energyTesla = new ControllerEnergyTesla(energy);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -554,24 +554,6 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
return energy.getEnergyStored();
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "tesla")
|
||||
@Override
|
||||
public long getStoredPower() {
|
||||
return energy.getEnergyStored();
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "tesla")
|
||||
@Override
|
||||
public long getCapacity() {
|
||||
return energy.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "tesla")
|
||||
@Override
|
||||
public long givePower(long power, boolean simulated) {
|
||||
return energy.receiveEnergy((int) power, simulated);
|
||||
}
|
||||
|
||||
public int getEnergyScaled(int i) {
|
||||
return (int) ((float) energy.getEnergyStored() / (float) energy.getMaxEnergyStored() * (float) i);
|
||||
}
|
||||
@@ -705,8 +687,8 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||
if (RefinedStorage.hasTesla() && (capability == TeslaCapabilities.CAPABILITY_HOLDER || capability == TeslaCapabilities.CAPABILITY_CONSUMER)) {
|
||||
return (T) this;
|
||||
if (energyTesla != null && (capability == TeslaCapabilities.CAPABILITY_HOLDER || capability == TeslaCapabilities.CAPABILITY_CONSUMER)) {
|
||||
return (T) energyTesla;
|
||||
}
|
||||
|
||||
return super.getCapability(capability, facing);
|
||||
@@ -714,7 +696,7 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||
return (RefinedStorage.hasTesla() && (capability == TeslaCapabilities.CAPABILITY_HOLDER || capability == TeslaCapabilities.CAPABILITY_CONSUMER)) || super.hasCapability(capability, facing);
|
||||
return (energyTesla != null && (capability == TeslaCapabilities.CAPABILITY_HOLDER || capability == TeslaCapabilities.CAPABILITY_CONSUMER)) || super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
public class ClientNode {
|
||||
|
Reference in New Issue
Block a user