Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import gregtech.api.metatileentity.multiblock.ICleanroomProvider;
import gregtech.api.metatileentity.multiblock.ICleanroomReceiver;
import gregtech.api.metatileentity.multiblock.ParallelLogicType;
import gregtech.api.network.AdvancedPacketBuffer;
import gregtech.api.recipes.Recipe;
import gregtech.api.recipes.RecipeBuilder;
import gregtech.api.recipes.RecipeMap;
Expand All @@ -30,7 +31,6 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.PacketBuffer;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.Constants;
Expand Down Expand Up @@ -1188,7 +1188,7 @@ public void invalidate() {
}

@Override
public void receiveCustomData(int dataId, @NotNull PacketBuffer buf) {
public void receiveCustomData(int dataId, @NotNull AdvancedPacketBuffer buf) {
if (dataId == GregtechDataCodes.WORKABLE_ACTIVE) {
this.isActive = buf.readBoolean();
getMetaTileEntity().scheduleRenderUpdate();
Expand All @@ -1199,13 +1199,13 @@ public void receiveCustomData(int dataId, @NotNull PacketBuffer buf) {
}

@Override
public void writeInitialSyncData(@NotNull PacketBuffer buf) {
public void writeInitialSyncData(@NotNull AdvancedPacketBuffer buf) {
buf.writeBoolean(this.isActive);
buf.writeBoolean(this.workingEnabled);
}

@Override
public void receiveInitialSyncData(@NotNull PacketBuffer buf) {
public void receiveInitialSyncData(@NotNull AdvancedPacketBuffer buf) {
this.isActive = buf.readBoolean();
this.workingEnabled = buf.readBoolean();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import gregtech.api.capability.IEnergyContainer;
import gregtech.api.capability.IMultiblockController;
import gregtech.api.capability.IMultipleTankHandler;
import gregtech.api.network.AdvancedPacketBuffer;
import gregtech.api.recipes.Recipe;
import gregtech.api.recipes.RecipeMap;
import gregtech.api.recipes.RecipeMaps;
Expand All @@ -16,7 +17,6 @@

import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
Expand Down Expand Up @@ -276,21 +276,21 @@ public void deserializeNBT(@NotNull NBTTagCompound compound) {
}

@Override
public void writeInitialSyncData(@NotNull PacketBuffer buf) {
public void writeInitialSyncData(@NotNull AdvancedPacketBuffer buf) {
super.writeInitialSyncData(buf);
buf.writeVarInt(currentHeat);
buf.writeInt(lastTickSteamOutput);
}

@Override
public void receiveInitialSyncData(@NotNull PacketBuffer buf) {
public void receiveInitialSyncData(@NotNull AdvancedPacketBuffer buf) {
super.receiveInitialSyncData(buf);
this.currentHeat = buf.readVarInt();
this.lastTickSteamOutput = buf.readInt();
}

@Override
public void receiveCustomData(int dataId, @NotNull PacketBuffer buf) {
public void receiveCustomData(int dataId, @NotNull AdvancedPacketBuffer buf) {
super.receiveCustomData(dataId, buf);
if (dataId == BOILER_HEAT) {
this.currentHeat = buf.readVarInt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import gregtech.api.capability.GregtechDataCodes;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.interfaces.ISyncedTileEntity;
import gregtech.api.metatileentity.multiblock.ICleanroomProvider;
import gregtech.api.metatileentity.multiblock.IMaintenance;
import gregtech.common.ConfigHolder;
Expand Down Expand Up @@ -205,7 +206,7 @@ public void readFromNBT(@NotNull NBTTagCompound data) {
/**
* writes all needed values to InitialSyncData
* This MUST be called and returned in the MetaTileEntity's
* {@link MetaTileEntity#writeInitialSyncData(PacketBuffer)} method
* {@link ISyncedTileEntity#writeInitialSyncData(gregtech.api.network.AdvancedPacketBuffer)} method
*/
public void writeInitialSyncData(@NotNull PacketBuffer buf) {
buf.writeBoolean(this.isActive);
Expand All @@ -218,7 +219,7 @@ public void writeInitialSyncData(@NotNull PacketBuffer buf) {
/**
* reads all needed values from InitialSyncData
* This MUST be called and returned in the MetaTileEntity's
* {@link MetaTileEntity#receiveInitialSyncData(PacketBuffer)} method
* {@link ISyncedTileEntity#receiveInitialSyncData(gregtech.api.network.AdvancedPacketBuffer)} method
*/
public void receiveInitialSyncData(@NotNull PacketBuffer buf) {
setActive(buf.readBoolean());
Expand All @@ -231,7 +232,7 @@ public void receiveInitialSyncData(@NotNull PacketBuffer buf) {
/**
* reads all needed values from CustomData
* This MUST be called and returned in the MetaTileEntity's
* {@link MetaTileEntity#receiveCustomData(int, PacketBuffer)} method
* {@link ISyncedTileEntity#receiveCustomData(int, gregtech.api.network.AdvancedPacketBuffer)} method
*/
public void receiveCustomData(int dataId, PacketBuffer buf) {
if (dataId == GregtechDataCodes.IS_WORKING) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import gregtech.api.GTValues;
import gregtech.api.capability.GregtechDataCodes;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.interfaces.ISyncedTileEntity;
import gregtech.api.worldgen.bedrockFluids.BedrockFluidVeinHandler;
import gregtech.common.ConfigHolder;
import gregtech.common.metatileentities.multi.electric.MetaTileEntityFluidDrill;
Expand Down Expand Up @@ -281,7 +282,7 @@ public void readFromNBT(@NotNull NBTTagCompound data) {
/**
* writes all needed values to InitialSyncData
* This MUST be called and returned in the MetaTileEntity's
* {@link MetaTileEntity#writeInitialSyncData(PacketBuffer)} method
* {@link ISyncedTileEntity#writeInitialSyncData(gregtech.api.network.AdvancedPacketBuffer)} method
*/
public void writeInitialSyncData(@NotNull PacketBuffer buf) {
buf.writeBoolean(this.isActive);
Expand All @@ -294,7 +295,7 @@ public void writeInitialSyncData(@NotNull PacketBuffer buf) {
/**
* reads all needed values from InitialSyncData
* This MUST be called and returned in the MetaTileEntity's
* {@link MetaTileEntity#receiveInitialSyncData(PacketBuffer)} method
* {@link ISyncedTileEntity#receiveInitialSyncData(gregtech.api.network.AdvancedPacketBuffer)} method
*/
public void receiveInitialSyncData(@NotNull PacketBuffer buf) {
setActive(buf.readBoolean());
Expand All @@ -307,7 +308,7 @@ public void receiveInitialSyncData(@NotNull PacketBuffer buf) {
/**
* reads all needed values from CustomData
* This MUST be called and returned in the MetaTileEntity's
* {@link MetaTileEntity#receiveCustomData(int, PacketBuffer)} method
* {@link ISyncedTileEntity#receiveCustomData(int, gregtech.api.network.AdvancedPacketBuffer)} method
*/
public void receiveCustomData(int dataId, PacketBuffer buf) {
if (dataId == GregtechDataCodes.WORKABLE_ACTIVE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import gregtech.api.capability.IVentable;
import gregtech.api.damagesources.DamageSources;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.network.AdvancedPacketBuffer;
import gregtech.api.recipes.Recipe;
import gregtech.api.recipes.RecipeMap;
import gregtech.api.recipes.logic.OCParams;
Expand All @@ -19,7 +20,6 @@
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.SoundEvents;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.EntitySelectors;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
Expand Down Expand Up @@ -98,7 +98,7 @@ public void setVentingSide(EnumFacing ventingSide) {
}

@Override
public void receiveCustomData(int dataId, @NotNull PacketBuffer buf) {
public void receiveCustomData(int dataId, @NotNull AdvancedPacketBuffer buf) {
super.receiveCustomData(dataId, buf);
if (dataId == GregtechDataCodes.NEEDS_VENTING) {
this.needsVenting = buf.readBoolean();
Expand All @@ -111,15 +111,15 @@ public void receiveCustomData(int dataId, @NotNull PacketBuffer buf) {
}

@Override
public void writeInitialSyncData(@NotNull PacketBuffer buf) {
public void writeInitialSyncData(@NotNull AdvancedPacketBuffer buf) {
super.writeInitialSyncData(buf);
buf.writeByte(getVentingSide().getIndex());
buf.writeBoolean(needsVenting);
buf.writeBoolean(ventingStuck);
}

@Override
public void receiveInitialSyncData(@NotNull PacketBuffer buf) {
public void receiveInitialSyncData(@NotNull AdvancedPacketBuffer buf) {
super.receiveInitialSyncData(buf);
this.ventingSide = EnumFacing.VALUES[buf.readByte()];
this.needsVenting = buf.readBoolean();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import gregtech.api.capability.GregtechDataCodes;
import gregtech.api.capability.IMiner;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.interfaces.ISyncedTileEntity;
import gregtech.api.recipes.Recipe;
import gregtech.api.recipes.RecipeMap;
import gregtech.api.unification.OreDictUnifier;
Expand Down Expand Up @@ -550,7 +551,7 @@ public void readFromNBT(@NotNull NBTTagCompound data) {
/**
* writes all needed values to InitialSyncData
* This MUST be called and returned in the MetaTileEntity's
* {@link MetaTileEntity#writeInitialSyncData(PacketBuffer)} method
* {@link ISyncedTileEntity#writeInitialSyncData(gregtech.api.network.AdvancedPacketBuffer)} method
*/
public void writeInitialSyncData(@NotNull PacketBuffer buf) {
buf.writeInt(pipeLength);
Expand All @@ -562,7 +563,7 @@ public void writeInitialSyncData(@NotNull PacketBuffer buf) {
/**
* reads all needed values from InitialSyncData
* This MUST be called and returned in the MetaTileEntity's
* {@link MetaTileEntity#receiveInitialSyncData(PacketBuffer)} method
* {@link ISyncedTileEntity#receiveInitialSyncData(gregtech.api.network.AdvancedPacketBuffer)} method
*/
public void receiveInitialSyncData(@NotNull PacketBuffer buf) {
this.pipeLength = buf.readInt();
Expand All @@ -574,7 +575,7 @@ public void receiveInitialSyncData(@NotNull PacketBuffer buf) {
/**
* reads all needed values from CustomData
* This MUST be called and returned in the MetaTileEntity's
* {@link MetaTileEntity#receiveCustomData(int, PacketBuffer)} method
* {@link ISyncedTileEntity#receiveCustomData(int, gregtech.api.network.AdvancedPacketBuffer)} method
*/
public void receiveCustomData(int dataId, PacketBuffer buf) {
if (dataId == GregtechDataCodes.PUMP_HEAD_LEVEL) {
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/gregtech/api/cover/Cover.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package gregtech.api.cover;

import gregtech.api.network.AdvancedPacketBuffer;
import gregtech.client.utils.BloomEffectUtil;

import net.minecraft.entity.player.EntityPlayer;
Expand All @@ -19,6 +20,7 @@
import codechicken.lib.render.pipeline.IVertexOperation;
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Matrix4;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability;
Expand Down Expand Up @@ -268,11 +270,19 @@ default void writeToNBT(@NotNull NBTTagCompound nbt) {}

default void readFromNBT(@NotNull NBTTagCompound nbt) {}

@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10")
default void writeInitialSyncData(@NotNull PacketBuffer packetBuffer) {}

@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.10")
default void readInitialSyncData(@NotNull PacketBuffer packetBuffer) {}

default void writeCustomData(int discriminator, @NotNull Consumer<@NotNull PacketBuffer> buf) {
default void writeInitialSyncData(@NotNull AdvancedPacketBuffer packetBuffer) {}

default void readInitialSyncData(@NotNull AdvancedPacketBuffer packetBuffer) {}

default void writeCustomData(int discriminator, @NotNull Consumer<@NotNull AdvancedPacketBuffer> buf) {
getCoverableView().writeCoverData(this, discriminator, buf);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/gregtech/api/cover/CoverHolder.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package gregtech.api.cover;

import gregtech.api.network.AdvancedPacketBuffer;
import gregtech.api.util.GTUtility;
import gregtech.client.utils.RenderUtil;

import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
Expand Down Expand Up @@ -91,7 +91,7 @@ default void updateCovers() {
}
}

void writeCustomData(int discriminator, @NotNull Consumer<@NotNull PacketBuffer> buf);
void writeCustomData(int discriminator, @NotNull Consumer<@NotNull AdvancedPacketBuffer> buf);

/**
* It is used to render cover's baseplate if this CoverHolder is not full block length.
Expand Down
25 changes: 17 additions & 8 deletions src/main/java/gregtech/api/cover/CoverSaveHandler.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package gregtech.api.cover;

import gregtech.api.metatileentity.interfaces.ISyncedTileEntity;
import gregtech.api.network.AdvancedPacketBuffer;
import gregtech.api.util.GTLog;

import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.Constants;
Expand All @@ -23,7 +24,7 @@ private CoverSaveHandler() {}
* @param buf the buf to write to
* @param coverableView the CoverableView containing the covers
*/
public static void writeInitialSyncData(@NotNull PacketBuffer buf, @NotNull CoverableView coverableView) {
public static void writeInitialSyncData(@NotNull AdvancedPacketBuffer buf, @NotNull CoverableView coverableView) {
Cover[] covers = new Cover[EnumFacing.VALUES.length];
int count = 0;
for (EnumFacing facing : EnumFacing.VALUES) {
Expand All @@ -41,7 +42,8 @@ public static void writeInitialSyncData(@NotNull PacketBuffer buf, @NotNull Cove
Cover cover = covers[i];
buf.writeByte(cover.getAttachedSide().ordinal());
buf.writeVarInt(CoverDefinition.getNetworkIdForCover(cover.getDefinition()));
cover.writeInitialSyncData(buf);
cover.writeInitialSyncData(buf.openSubBuffer());
buf.writeSubBuffer();
}
}

Expand All @@ -51,7 +53,7 @@ public static void writeInitialSyncData(@NotNull PacketBuffer buf, @NotNull Cove
* @param buf the buf to read from
* @param coverHolder the CoverHolder containing the covers
*/
public static void receiveInitialSyncData(@NotNull PacketBuffer buf, @NotNull CoverHolder coverHolder) {
public static void receiveInitialSyncData(@NotNull AdvancedPacketBuffer buf, @NotNull CoverHolder coverHolder) {
final int count = buf.readByte();
if (count == 0) return;

Expand All @@ -60,14 +62,17 @@ public static void receiveInitialSyncData(@NotNull PacketBuffer buf, @NotNull Co
int id = buf.readVarInt();
CoverDefinition definition = CoverDefinition.getCoverByNetworkId(id);

AdvancedPacketBuffer b = buf.readSubBuffer();
if (definition == null) {
GTLog.logger.warn("Unable to find CoverDefinition for Network ID {} at position {}", id,
coverHolder.getPos());
} else {
Cover cover = definition.createCover(coverHolder, facing);
cover.readInitialSyncData(buf);
cover.readInitialSyncData(b);
ISyncedTileEntity.checkData(b, cover);
coverHolder.addCover(facing, cover);
}
buf.closeSubBuffer();
}
}

Expand All @@ -84,7 +89,8 @@ public static void writeCoverPlacement(@NotNull CoverHolder coverHolder, int dis
coverHolder.writeCustomData(discriminator, buf -> {
buf.writeByte(side.getIndex());
buf.writeVarInt(CoverDefinition.getNetworkIdForCover(cover.getDefinition()));
cover.writeInitialSyncData(buf);
cover.writeInitialSyncData(buf.openSubBuffer());
buf.writeSubBuffer();
});
}

Expand All @@ -94,20 +100,23 @@ public static void writeCoverPlacement(@NotNull CoverHolder coverHolder, int dis
* @param buf the buffer to read from
* @param coverHolder the CoverHolder the cover is placed on
*/
public static void readCoverPlacement(@NotNull PacketBuffer buf, @NotNull CoverHolder coverHolder) {
public static void readCoverPlacement(@NotNull AdvancedPacketBuffer buf, @NotNull CoverHolder coverHolder) {
// cover placement event
EnumFacing placementSide = EnumFacing.VALUES[buf.readByte()];
int id = buf.readVarInt();
CoverDefinition coverDefinition = CoverDefinition.getCoverByNetworkId(id);
AdvancedPacketBuffer b = buf.readSubBuffer();
if (coverDefinition == null) {
GTLog.logger.warn("Unable to find CoverDefinition for Network ID {} at position {}", id,
coverHolder.getPos());
} else {
Cover cover = coverDefinition.createCover(coverHolder, placementSide);
coverHolder.addCover(placementSide, cover);

cover.readInitialSyncData(buf);
cover.readInitialSyncData(b);
ISyncedTileEntity.checkData(b, cover);
}
buf.closeSubBuffer();
coverHolder.scheduleRenderUpdate();
}

Expand Down
Loading