Don't use PacketBuffer#readString since it's client-only. (#4489)
Fixes #4488
This commit is contained in:
@@ -32,6 +32,15 @@ import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
|
||||
public abstract class BasePacket {
|
||||
|
||||
/**
|
||||
* Sadly {@link PacketBuffer#readString()} gets inlined by Proguard which means
|
||||
* it's not available on the Server. This field has the default string length
|
||||
* that is used for writeString, which then also should be used for readString
|
||||
* when it has no special length requirements.
|
||||
*/
|
||||
public static final int MAX_STRING_LENGTH = 32767;
|
||||
|
||||
private PacketBuffer p;
|
||||
|
||||
public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) {
|
||||
|
||||
@@ -57,8 +57,8 @@ public class ConfigValuePacket extends BasePacket {
|
||||
private final String Value;
|
||||
|
||||
public ConfigValuePacket(final PacketBuffer stream) {
|
||||
this.Name = stream.readString();
|
||||
this.Value = stream.readString();
|
||||
this.Name = stream.readString(MAX_STRING_LENGTH);
|
||||
this.Value = stream.readString(MAX_STRING_LENGTH);
|
||||
}
|
||||
|
||||
// api
|
||||
|
||||
@@ -21,6 +21,7 @@ import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.BasePacket;
|
||||
|
||||
public class GrinderRecipeSerializer extends ForgeRegistryEntry<IRecipeSerializer<?>>
|
||||
implements IRecipeSerializer<GrinderRecipe> {
|
||||
@@ -70,7 +71,7 @@ public class GrinderRecipeSerializer extends ForgeRegistryEntry<IRecipeSerialize
|
||||
@Override
|
||||
public GrinderRecipe read(ResourceLocation recipeId, PacketBuffer buffer) {
|
||||
|
||||
String group = buffer.readString();
|
||||
String group = buffer.readString(BasePacket.MAX_STRING_LENGTH);
|
||||
Ingredient ingredient = Ingredient.read(buffer);
|
||||
int ingredientCount = buffer.readVarInt();
|
||||
ItemStack result = buffer.readItemStack();
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
|
||||
import appeng.api.features.InscriberProcessType;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.BasePacket;
|
||||
|
||||
public class InscriberRecipeSerializer extends ForgeRegistryEntry<IRecipeSerializer<?>>
|
||||
implements IRecipeSerializer<InscriberRecipe> {
|
||||
@@ -67,7 +68,7 @@ public class InscriberRecipeSerializer extends ForgeRegistryEntry<IRecipeSeriali
|
||||
@Nullable
|
||||
@Override
|
||||
public InscriberRecipe read(ResourceLocation recipeId, PacketBuffer buffer) {
|
||||
String group = buffer.readString();
|
||||
String group = buffer.readString(BasePacket.MAX_STRING_LENGTH);
|
||||
Ingredient middle = Ingredient.read(buffer);
|
||||
ItemStack result = buffer.readItemStack();
|
||||
Ingredient top = Ingredient.read(buffer);
|
||||
|
||||
@@ -65,6 +65,7 @@ import appeng.block.storage.DriveSlotsState;
|
||||
import appeng.client.render.model.DriveModelData;
|
||||
import appeng.container.implementations.DriveContainer;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.sync.BasePacket;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.helpers.MachineSource;
|
||||
@@ -188,7 +189,7 @@ public class DriveTileEntity extends AENetworkInvTileEntity implements IChestOrD
|
||||
int uniqueStrCount = data.readByte();
|
||||
String[] uniqueStrs = new String[uniqueStrCount];
|
||||
for (int i = 0; i < uniqueStrCount; i++) {
|
||||
uniqueStrs[i] = data.readString();
|
||||
uniqueStrs[i] = data.readString(BasePacket.MAX_STRING_LENGTH);
|
||||
}
|
||||
|
||||
boolean changed = false;
|
||||
|
||||
Reference in New Issue
Block a user