Skip to content

Commit

Permalink
Fix compat problems with Immersive Portals
Browse files Browse the repository at this point in the history
  • Loading branch information
TonimatasDEV committed Sep 19, 2023
1 parent c32ea46 commit 54e1d74
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,16 @@ public String getRefMapperConfig() {

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
if (FabricLoader.getInstance().getAllMods().stream().map(ModContainer::getMetadata).map(ModMetadata::getId).toList().contains("connectivity")) {
return !mixinClassName.equalsIgnoreCase("net.tonimatasdev.packetfixerfabric.mixin.PacketInflaterMixin");
} else {
return !mixinClassName.equalsIgnoreCase("net.tonimatasdev.packetfixerfabric.mixin.compat.connectivity.PacketInflaterMixin");
}
List<String> mods = FabricLoader.getInstance().getAllMods().stream().map(ModContainer::getMetadata).map(ModMetadata::getId).toList();

boolean connectivity = mods.contains("connectivity");
boolean immersivePortals = mods.contains("immersive_portals");

if (mixinClassName.equalsIgnoreCase("net.tonimatasdev.packetfixerfabric.mixin.PacketInflaterMixin")) return !connectivity;
if (mixinClassName.equalsIgnoreCase("net.tonimatasdev.packetfixerfabric.mixin.compat.connectivity.PacketInflaterMixin")) return connectivity;
if (mixinClassName.equalsIgnoreCase("net.tonimatasdev.packetfixerfabric.mixin.CustomPayloadS2CPacket")) return !immersivePortals;

return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ public String getRefMapperConfig() {

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
if (FMLLoader.getLoadingModList().getModFileById("connectivity") != null) {
return !mixinClassName.equalsIgnoreCase("net.tonimatasdev.packetfixerforge.mixin.CompressionDecoderMixin");
} else {
return !mixinClassName.equalsIgnoreCase("net.tonimatasdev.packetfixerforge.mixin.compat.connectivity.CompressionDecoderMixin");
}
boolean connectivity = FMLLoader.getLoadingModList().getModFileById("connectivity") != null;
boolean immersivePortals = FMLLoader.getLoadingModList().getModFileById("immersive_portals") != null;

if (mixinClassName.equalsIgnoreCase("net.tonimatasdev.packetfixerforge.mixin.CompressionDecoderMixin")) return !connectivity;
if (mixinClassName.equalsIgnoreCase("net.tonimatasdev.packetfixerforge.mixin.compat.connectivity.CompressionDecoderMixin")) return connectivity;
if (mixinClassName.equalsIgnoreCase("net.tonimatasdev.packetfixerforge.mixin.ClientboundCustomPayloadPacketMixin")) return !immersivePortals;

return true;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@

@Mixin(value = NbtAccounter.class, priority = 9999)
public abstract class NbtAccounterMixin {
// <= 1.18
//@Redirect(method = "accountBits", at = @At(value = "FIELD", target = "Lnet/minecraft/nbt/NbtAccounter;quota:J", opcode = Opcodes.GETFIELD))
//public long accountBits(NbtAccounter instance) {
// return Long.MAX_VALUE;
//}

// >= 1.19
@Redirect(method = "accountBytes", at = @At(value = "FIELD", target = "Lnet/minecraft/nbt/NbtAccounter;quota:J", opcode = Opcodes.GETFIELD))
public long accountBits(NbtAccounter instance) {
return Long.MAX_VALUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@

@Mixin(value = ServerboundCustomQueryPacket.class, priority = 9999)
public class ServerboundCustomQueryPacketMixin {
// <= 1.18
//@ModifyConstant(method = "<init>(Lnet/minecraft/network/FriendlyByteBuf;)V", constant = @Constant(intValue = 1048576))
//private int newSize(int value) {
// return Integer.MAX_VALUE;
//}

// >= 1.19
@ModifyVariable(method = "<init>(Lnet/minecraft/network/FriendlyByteBuf;)V", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/network/FriendlyByteBuf;readNullable(Lnet/minecraft/network/FriendlyByteBuf$Reader;)Ljava/lang/Object;"), index = 1, argsOnly = true)
private FriendlyByteBuf redirectReadNullable(FriendlyByteBuf value) {
return new FriendlyByteBuf(value.readBytes(value.readableBytes()));
Expand Down

0 comments on commit 54e1d74

Please sign in to comment.