Merge pull request #1642 from MellowArpeggiation/master

Fix Pumpjack sync and ByteBufferize Energy Storage Blocks
This commit is contained in:
HbmMods 2024-08-19 15:06:42 +02:00 committed by GitHub
commit b8eb6586f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 22 deletions

View File

@ -112,12 +112,10 @@ public class TileEntityMachinePumpjack extends TileEntityOilDrillBase {
}
@Override
public void sendUpdate() {
NBTTagCompound data = new NBTTagCompound();
data.setLong("power", power);
data.setInteger("indicator", this.indicator);
data.setFloat("speed", this.indicator == 0 ? (5F + (2F * this.speedLevel)) + (this.overLevel - 1F) * 10: 0F);
this.networkPack(data, 25);
public void networkPack(NBTTagCompound nbt, int range) {
nbt.setFloat("speed", this.indicator == 0 ? (5F + (2F * this.speedLevel)) + (this.overLevel - 1F) * 10: 0F);
super.networkPack(nbt, range);
}
@Override

View File

@ -21,10 +21,10 @@ import com.hbm.util.CompatEnergyControl;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import li.cil.oc.api.network.SimpleComponent;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
@ -35,7 +35,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@Optional.InterfaceList({@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "opencomputers")})
public class TileEntityMachineBattery extends TileEntityMachineBase implements IEnergyConductorMK2, IEnergyProviderMK2, IEnergyReceiverMK2, IPersistentNBT, SimpleComponent, IGUIProvider, IInfoProviderEC, CompatHandler.OCComponent {
public class TileEntityMachineBattery extends TileEntityMachineBase implements IEnergyConductorMK2, IEnergyProviderMK2, IEnergyReceiverMK2, IPersistentNBT, IGUIProvider, IInfoProviderEC, CompatHandler.OCComponent {
public long[] log = new long[20];
public long delta = 0;
@ -214,13 +214,7 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I
prevPowerState = power;
NBTTagCompound nbt = new NBTTagCompound();
nbt.setLong("power", avg);
nbt.setLong("delta", delta);
nbt.setShort("redLow", redLow);
nbt.setShort("redHigh", redHigh);
nbt.setByte("priority", (byte) this.priority.ordinal());
this.networkPack(nbt, 20);
this.networkPackNT(20);
}
}
@ -250,14 +244,25 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I
}
@Override
public void networkUnpack(NBTTagCompound nbt) {
super.networkUnpack(nbt);
public void serialize(ByteBuf buf) {
super.serialize(buf);
this.power = nbt.getLong("power");
this.delta = nbt.getLong("delta");
this.redLow = nbt.getShort("redLow");
this.redHigh = nbt.getShort("redHigh");
this.priority = ConnectionPriority.values()[nbt.getByte("priority")];
buf.writeLong(power);
buf.writeLong(delta);
buf.writeShort(redLow);
buf.writeShort(redHigh);
buf.writeByte(priority.ordinal());
}
@Override
public void deserialize(ByteBuf buf) {
super.deserialize(buf);
power = buf.readLong();
delta = buf.readLong();
redLow = buf.readShort();
redHigh = buf.readShort();
priority = ConnectionPriority.values()[buf.readByte()];
}
@Override