mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-26 06:43:05 +00:00
#561 refactor networking
Use more DataStreams and less NBT Add packet for error states changing Reduce network use by Clockwork Engine
This commit is contained in:
1 parent
ce00a33593
commit
9fccfd1198
115 files changed
+1850
-1855
No files matched your search
@@ -1,18 +1,23 @@
|
||||
package forestry.energy;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import forestry.core.GameMode;
|
||||
import forestry.core.network.IStreamable;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
|
||||
public class EnergyManager implements IEnergyHandler {
|
||||
public class EnergyManager implements IEnergyHandler, IStreamable {
|
||||
private enum EnergyTransferMode {
|
||||
EXTRACT, RECEIVE, BOTH
|
||||
}
|
||||
@@ -79,11 +84,23 @@ public class EnergyManager implements IEnergyHandler {
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
public int toPacketInt() {
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
int energyStored = energyStorage.getEnergyStored();
|
||||
data.writeInt(energyStored);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
int energyStored = data.readInt();
|
||||
energyStorage.setEnergyStored(energyStored);
|
||||
}
|
||||
|
||||
public int toGuiInt() {
|
||||
return energyStorage.getEnergyStored();
|
||||
}
|
||||
|
||||
public void fromPacketInt(int packetInt) {
|
||||
public void fromGuiInt(int packetInt) {
|
||||
energyStorage.setEnergyStored(packetInt);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user