mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-14 14:34:16 +01:00
Added support of other packet size optimisation mods. (#5362)
* Added support of other packet size optimisation mods. (Connectivity and Packet Fixer) * Added comment why we need min (not max) value. * Finalize changes --------- Co-authored-by: PepperCode1 <44146161+PepperCode1@users.noreply.github.com>
This commit is contained in:
parent
c052807773
commit
8f5031c330
@ -15,9 +15,11 @@ import net.minecraftforge.registries.ForgeRegistries;
|
|||||||
*/
|
*/
|
||||||
public enum Mods {
|
public enum Mods {
|
||||||
COMPUTERCRAFT,
|
COMPUTERCRAFT,
|
||||||
|
CONNECTIVITY,
|
||||||
CURIOS,
|
CURIOS,
|
||||||
DYNAMICTREES,
|
DYNAMICTREES,
|
||||||
OCCULTISM,
|
OCCULTISM,
|
||||||
|
PACKETFIXER,
|
||||||
STORAGEDRAWERS,
|
STORAGEDRAWERS,
|
||||||
TCONSTRUCT,
|
TCONSTRUCT,
|
||||||
XLPACKETS;
|
XLPACKETS;
|
||||||
|
@ -14,17 +14,46 @@ public class ContraptionData {
|
|||||||
/**
|
/**
|
||||||
* A sane, default maximum for contraption data size.
|
* A sane, default maximum for contraption data size.
|
||||||
*/
|
*/
|
||||||
public static final int DEFAULT_MAX = 2_000_000;
|
public static final int DEFAULT_LIMIT = 2_000_000;
|
||||||
|
/**
|
||||||
|
* Connectivity expands the NBT packet limit to 2 GB.
|
||||||
|
*/
|
||||||
|
public static final int CONNECTIVITY_LIMIT = Integer.MAX_VALUE;
|
||||||
|
/**
|
||||||
|
* Packet Fixer expands the NBT packet limit to 200 MB.
|
||||||
|
*/
|
||||||
|
public static final int PACKET_FIXER_LIMIT = 209_715_200;
|
||||||
/**
|
/**
|
||||||
* XL Packets expands the NBT packet limit to 2 GB.
|
* XL Packets expands the NBT packet limit to 2 GB.
|
||||||
*/
|
*/
|
||||||
public static final int EXPANDED_MAX = 2_000_000_000;
|
public static final int XL_PACKETS_LIMIT = 2_000_000_000;
|
||||||
/**
|
/**
|
||||||
* Minecart item sizes are limited by the vanilla slot change packet ({@link ClientboundContainerSetSlotPacket}).
|
* Minecart item sizes are limited by the vanilla slot change packet ({@link ClientboundContainerSetSlotPacket}).
|
||||||
* {@link ContraptionData#DEFAULT_MAX} is used as the default.
|
* {@link #DEFAULT_LIMIT} is used as the default.
|
||||||
* XL Packets expands the size limit to ~2 GB. If the mod is loaded, we take advantage of it and use the higher limit.
|
* Connectivity, PacketFixer, and XL Packets expand the size limit.
|
||||||
|
* If one of these mods is loaded, we take advantage of it and use the higher limit.
|
||||||
*/
|
*/
|
||||||
public static final int PICKUP_MAX = Mods.XLPACKETS.isLoaded() ? EXPANDED_MAX : DEFAULT_MAX;
|
public static final int PICKUP_LIMIT;
|
||||||
|
|
||||||
|
static {
|
||||||
|
int limit = DEFAULT_LIMIT;
|
||||||
|
|
||||||
|
// Check from largest to smallest to use the smallest limit if multiple mods are loaded.
|
||||||
|
// It is necessary to use the smallest limit because even if multiple mods are loaded,
|
||||||
|
// not all of their mixins may be applied. Therefore, it is safest to only assume that
|
||||||
|
// the mod with the smallest limit is actually active.
|
||||||
|
if (Mods.CONNECTIVITY.isLoaded()) {
|
||||||
|
limit = CONNECTIVITY_LIMIT;
|
||||||
|
}
|
||||||
|
if (Mods.XLPACKETS.isLoaded()) {
|
||||||
|
limit = XL_PACKETS_LIMIT;
|
||||||
|
}
|
||||||
|
if (Mods.PACKETFIXER.isLoaded()) {
|
||||||
|
limit = PACKET_FIXER_LIMIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
PICKUP_LIMIT = limit;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if the given NBT is too large for a contraption to be synced to clients.
|
* @return true if the given NBT is too large for a contraption to be synced to clients.
|
||||||
@ -38,7 +67,7 @@ public class ContraptionData {
|
|||||||
* @return true if the given NBT is too large for a contraption to be picked up with a wrench.
|
* @return true if the given NBT is too large for a contraption to be picked up with a wrench.
|
||||||
*/
|
*/
|
||||||
public static boolean isTooLargeForPickup(CompoundTag data) {
|
public static boolean isTooLargeForPickup(CompoundTag data) {
|
||||||
return packetSize(data) > PICKUP_MAX;
|
return packetSize(data) > PICKUP_LIMIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,7 +30,7 @@ public class CKinetics extends ConfigBase {
|
|||||||
public final ConfigGroup contraptions = group(1, "contraptions", "Moving Contraptions");
|
public final ConfigGroup contraptions = group(1, "contraptions", "Moving Contraptions");
|
||||||
public final ConfigInt maxBlocksMoved = i(2048, 1, "maxBlocksMoved", Comments.maxBlocksMoved);
|
public final ConfigInt maxBlocksMoved = i(2048, 1, "maxBlocksMoved", Comments.maxBlocksMoved);
|
||||||
public final ConfigInt maxDataSize =
|
public final ConfigInt maxDataSize =
|
||||||
i(ContraptionData.DEFAULT_MAX, 0, "maxDataSize", Comments.bytes, Comments.maxDataDisable, Comments.maxDataSize, Comments.maxDataSize2);
|
i(ContraptionData.DEFAULT_LIMIT, 0, "maxDataSize", Comments.bytes, Comments.maxDataDisable, Comments.maxDataSize, Comments.maxDataSize2);
|
||||||
public final ConfigInt maxChassisRange = i(16, 1, "maxChassisRange", Comments.maxChassisRange);
|
public final ConfigInt maxChassisRange = i(16, 1, "maxChassisRange", Comments.maxChassisRange);
|
||||||
public final ConfigInt maxPistonPoles = i(64, 1, "maxPistonPoles", Comments.maxPistonPoles);
|
public final ConfigInt maxPistonPoles = i(64, 1, "maxPistonPoles", Comments.maxPistonPoles);
|
||||||
public final ConfigInt maxRopeLength = i(256, 1, "maxRopeLength", Comments.maxRopeLength);
|
public final ConfigInt maxRopeLength = i(256, 1, "maxRopeLength", Comments.maxRopeLength);
|
||||||
|
Loading…
Reference in New Issue
Block a user