Fix bungee compatibility
This commit is contained in:
parent
54f32cf7d7
commit
7ed1b5d245
|
@ -8,8 +8,11 @@ import net.minecraftforge.network.NetworkConstants;
|
|||
import net.minecraftforge.network.NetworkHooks;
|
||||
import org.spigotmc.SpigotConfig;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
@ -19,6 +22,8 @@ public class CHandshakePacketMixin {
|
|||
private static final String EXTRA_DATA = "extraData";
|
||||
private static final Gson GSON = new Gson();
|
||||
|
||||
@Shadow public String hostName;
|
||||
|
||||
@Redirect(method = "<init>(Lnet/minecraft/network/FriendlyByteBuf;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/FriendlyByteBuf;readUtf(I)Ljava/lang/String;"))
|
||||
private String arclight$bungeeHostname(FriendlyByteBuf packetBuffer, int maxLength) {
|
||||
return packetBuffer.readUtf(Short.MAX_VALUE);
|
||||
|
@ -34,6 +39,7 @@ public class CHandshakePacketMixin {
|
|||
for (Property property : properties) {
|
||||
if (Objects.equals(property.getName(), EXTRA_DATA)) {
|
||||
String extraData = property.getValue().replace("\1", "\0");
|
||||
this.arclight$host = ip;
|
||||
return NetworkHooks.getFMLVersion(split[0] + extraData);
|
||||
}
|
||||
}
|
||||
|
@ -41,4 +47,14 @@ public class CHandshakePacketMixin {
|
|||
}
|
||||
return fmlVersion;
|
||||
}
|
||||
|
||||
private transient String arclight$host;
|
||||
|
||||
@Inject(method = "<init>(Lnet/minecraft/network/FriendlyByteBuf;)V", at = @At("RETURN"))
|
||||
private void arclight$writeBack(FriendlyByteBuf p_179801_, CallbackInfo ci) {
|
||||
if (arclight$host != null) {
|
||||
this.hostName = arclight$host;
|
||||
arclight$host = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"pack": {
|
||||
"description": "Arclight resources",
|
||||
"pack_format": 7
|
||||
"pack_format": 8
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user