From ed5e0cd1d0f5d37cb0f67700efbde4f796243b3d Mon Sep 17 00:00:00 2001 From: Calclavia Date: Sat, 4 Jan 2014 00:24:49 +0800 Subject: [PATCH] Fixed redistribute calls --- Calclavia-Core | 2 +- .../battery/TileBattery.java | 65 +++++++++++++++++-- 2 files changed, 60 insertions(+), 7 deletions(-) diff --git a/Calclavia-Core b/Calclavia-Core index 3f91dfa13..9ee405358 160000 --- a/Calclavia-Core +++ b/Calclavia-Core @@ -1 +1 @@ -Subproject commit 3f91dfa13cb0f15c9a5c4fe133364ffa143f98a0 +Subproject commit 9ee40535875746f1f3035e69c43d50bda7b62a82 diff --git a/src/main/java/resonantinduction/battery/TileBattery.java b/src/main/java/resonantinduction/battery/TileBattery.java index 478507ffe..999672aa3 100644 --- a/src/main/java/resonantinduction/battery/TileBattery.java +++ b/src/main/java/resonantinduction/battery/TileBattery.java @@ -1,6 +1,7 @@ package resonantinduction.battery; import java.util.ArrayList; +import java.util.EnumSet; import java.util.HashSet; import java.util.Set; @@ -8,7 +9,9 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; import resonantinduction.ResonantInduction; -import universalelectricity.api.UniversalClass; +import universalelectricity.api.UniversalElectricity; +import universalelectricity.api.electricity.IVoltageInput; +import universalelectricity.api.electricity.IVoltageOutput; import universalelectricity.api.energy.EnergyStorageHandler; import universalelectricity.api.energy.IEnergyContainer; import universalelectricity.api.energy.IEnergyInterface; @@ -27,11 +30,16 @@ import cpw.mods.fml.common.network.PacketDispatcher; * * @author Calclavia */ -@UniversalClass -public class TileBattery extends TileElectrical implements IConnector, IPacketSender, IPacketReceiver, IEnergyInterface, IEnergyContainer +public class TileBattery extends TileElectrical implements IConnector, IVoltageInput, IVoltageOutput, IPacketSender, IPacketReceiver, IEnergyInterface, IEnergyContainer { public static final long STORAGE = 100000000; + /** The transfer rate **/ + public static final long DEFAULT_WATTAGE = 1000000; + + /** Voltage increases as series connection increases */ + public static final long DEFAULT_VOLTAGE = UniversalElectricity.DEFAULT_VOLTAGE; + private BatteryStructure structure; public Set playersUsing = new HashSet(); @@ -65,6 +73,7 @@ public class TileBattery extends TileElectrical implements IConnector 0) { this.getNetwork().redistribute(); } - - this.produce(); } } + @Override + public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive) + { + long returnValue = super.onReceiveEnergy(from, receive, doReceive); + + if (doReceive) + this.getNetwork().redistribute(); + + return returnValue; + } + + @Override + public long onExtractEnergy(ForgeDirection from, long extract, boolean doExtract) + { + long returnValue = super.onExtractEnergy(from, extract, doExtract); + + if (doExtract) + this.getNetwork().redistribute(); + + return returnValue; + } + + @Override + public EnumSet getOutputDirections() + { + return EnumSet.of(ForgeDirection.DOWN); + } + public void updateClient() { PacketDispatcher.sendPacketToAllPlayers(ResonantInduction.PACKET_TILE.getPacket(this, getPacketData(0).toArray())); @@ -150,4 +185,22 @@ public class TileBattery extends TileElectrical implements IConnector