Skip to content

Commit d5a01b1

Browse files
committed
fix: 🐛 Fixed unsafe network packet handling
1 parent 3deccb6 commit d5a01b1

5 files changed

Lines changed: 15 additions & 14 deletions

File tree

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ loader_version_range=[4,)
1515
mod_id=sophisticatedcore
1616
mod_name=Sophisticated Core
1717
mod_license=All Rights Reserved
18-
mod_version=1.4.92
18+
mod_version=1.4.93
1919
mod_group_id=net.p3pp3rf1y
2020
mod_authors=P3pp3rF1y
2121
mod_description=A library / shared functionality mod for Sophisticated Storage and Backpacks
@@ -45,7 +45,7 @@ curios_version=14.0.0+1.21.11
4545
sawmill_cf_file_id=6119477
4646
moonlightlib_cf_file_id=6224057
4747
trashslot_version=21.11.2
48-
reliquary_version=[1.21.11-2.0.70,1.21.12)
48+
reliquary_version=[1.21.11-2.0.83,1.21.12)
4949
ftb_chunks_version=2101.1.11
5050
ftb_library_version=2101.1.21
5151
accessories_version=1.4.3-beta+1.21.10

src/disabledcompats/main/java/net/p3pp3rf1y/sophisticatedcore/compat/recipeviewers/emi/EmiTransferRecipePayload.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ public record EmiTransferRecipePayload(ResourceKey<Recipe<?>> recipeId, Identifi
3131
EmiTransferRecipePayload::recipeTypeId,
3232
ByteBufCodecs.INT,
3333
EmiTransferRecipePayload::action,
34-
ByteBufCodecs.INT.apply(ByteBufCodecs.list()),
34+
ByteBufCodecs.INT.apply(ByteBufCodecs.list(512)),
3535
EmiTransferRecipePayload::slots,
36-
ByteBufCodecs.INT.apply(ByteBufCodecs.list()),
36+
ByteBufCodecs.INT.apply(ByteBufCodecs.list(9)),
3737
EmiTransferRecipePayload::crafting,
3838
ByteBufCodecs.INT,
3939
EmiTransferRecipePayload::output,
40-
ItemStack.OPTIONAL_LIST_STREAM_CODEC,
40+
ItemStack.OPTIONAL_STREAM_CODEC.apply(ByteBufCodecs.list(9)),
4141
EmiTransferRecipePayload::stacks,
4242
ByteBufCodecs.BOOL,
4343
EmiTransferRecipePayload::maxTransfer,
@@ -75,4 +75,4 @@ public static void handlePayload(EmiTransferRecipePayload payload, IPayloadConte
7575
}
7676
}
7777
}
78-
}
78+
}

src/main/java/net/p3pp3rf1y/sophisticatedcore/compat/recipeviewers/jei/JeiTransferRecipePayload.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ public record JeiTransferRecipePayload(ResourceKey<Recipe<?>> recipeId, Identifi
2222
public static final Type<JeiTransferRecipePayload> TYPE = new Type<>(SophisticatedCore.getIdentifier("jei_transfer_recipe"));
2323
public static final StreamCodec<ByteBuf, JeiTransferRecipePayload> STREAM_CODEC = StreamCodec.composite(ResourceKey.streamCodec(Registries.RECIPE),
2424
JeiTransferRecipePayload::recipeId, Identifier.STREAM_CODEC, JeiTransferRecipePayload::recipeTypeId,
25-
SlotTransfer.STREAM_CODEC.apply(ByteBufCodecs.list()), JeiTransferRecipePayload::transferOperations, ByteBufCodecs.INT.apply(ByteBufCodecs.list()),
26-
JeiTransferRecipePayload::craftingSlotIndexes, ByteBufCodecs.INT.apply(ByteBufCodecs.list()), JeiTransferRecipePayload::inventorySlotIndexes,
27-
ByteBufCodecs.BOOL, JeiTransferRecipePayload::maxTransfer, JeiTransferRecipePayload::new);
25+
SlotTransfer.STREAM_CODEC.apply(ByteBufCodecs.list(512)), JeiTransferRecipePayload::transferOperations,
26+
ByteBufCodecs.INT.apply(ByteBufCodecs.list(9)), JeiTransferRecipePayload::craftingSlotIndexes, ByteBufCodecs.INT.apply(ByteBufCodecs.list(512)),
27+
JeiTransferRecipePayload::inventorySlotIndexes, ByteBufCodecs.BOOL, JeiTransferRecipePayload::maxTransfer, JeiTransferRecipePayload::new);
2828

2929
@Override
3030
public Type<? extends CustomPacketPayload> type() {

src/main/java/net/p3pp3rf1y/sophisticatedcore/compat/recipeviewers/rei/ReiTransferRecipePayload.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ public record ReiTransferRecipePayload(Identifier recipeId, Identifier recipeTyp
3434
public static final Type<ReiTransferRecipePayload> TYPE = new Type<>(SophisticatedCore.getIdentifier("rei_move_items"));
3535
public static final StreamCodec<RegistryFriendlyByteBuf, ReiTransferRecipePayload> STREAM_CODEC = StreamCodec.composite(Identifier.STREAM_CODEC,
3636
ReiTransferRecipePayload::recipeId, Identifier.STREAM_CODEC, ReiTransferRecipePayload::recipeTypeId, ByteBufCodecs.COMPOUND_TAG,
37-
ReiTransferRecipePayload::tag, ByteBufCodecs.INT.apply(ByteBufCodecs.list()), ReiTransferRecipePayload::inputSlots,
38-
ByteBufCodecs.INT.apply(ByteBufCodecs.list()), ReiTransferRecipePayload::inventorySlots, ByteBufCodecs.BOOL, ReiTransferRecipePayload::maxTransfer,
39-
ReiTransferRecipePayload::new);
37+
ReiTransferRecipePayload::tag, ByteBufCodecs.INT.apply(ByteBufCodecs.list(9)), ReiTransferRecipePayload::inputSlots,
38+
ByteBufCodecs.INT.apply(ByteBufCodecs.list(512)), ReiTransferRecipePayload::inventorySlots, ByteBufCodecs.BOOL,
39+
ReiTransferRecipePayload::maxTransfer, ReiTransferRecipePayload::new);
4040

4141
@Override
4242
public Type<? extends CustomPacketPayload> type() {

src/main/java/net/p3pp3rf1y/sophisticatedcore/upgrades/cooking/CookingLogic.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import net.p3pp3rf1y.sophisticatedcore.util.WorldHelper;
3535
import org.jspecify.annotations.Nullable;
3636

37+
import java.util.HashMap;
3738
import java.util.List;
3839
import java.util.Map;
3940
import java.util.Optional;
@@ -68,8 +69,8 @@ public class CookingLogic<T extends AbstractCookingRecipe> {
6869
ExtraCodecs.NON_NEGATIVE_INT);
6970

7071
public static final StreamCodec<ByteBuf, ResourceKey<Recipe<?>>> RECIPE_KEY_STREAM_CODEC = ResourceKey.streamCodec(Registries.RECIPE);
71-
public static final StreamCodec<FriendlyByteBuf, Map<ResourceKey<Recipe<?>>, Integer>> RECIPES_USED_STREAM_CODEC = StreamCodec
72-
.of((buf, map) -> buf.writeMap(map, RECIPE_KEY_STREAM_CODEC, ByteBufCodecs.INT), buf -> buf.readMap(RECIPE_KEY_STREAM_CODEC, ByteBufCodecs.INT));
72+
public static final StreamCodec<FriendlyByteBuf, Map<ResourceKey<Recipe<?>>, Integer>> RECIPES_USED_STREAM_CODEC = ByteBufCodecs.map(HashMap::new,
73+
RECIPE_KEY_STREAM_CODEC, ByteBufCodecs.INT, 256);
7374

7475
public CookingLogic(ItemStack upgrade, Consumer<ItemStack> saveHandler, CookingUpgradeConfig cookingUpgradeConfig, RecipeType<T> recipeType,
7576
Predicate<ItemStack> isInput, float burnTimeModifier) {

0 commit comments

Comments
 (0)