generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use yarn cleanup mod
- Loading branch information
BetterClient
committed
Jul 22, 2024
1 parent
e951570
commit 640e666
Showing
12 changed files
with
122 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
src/main/java/com/nexia/viacombattest/api/CombatTestProtocolVersion.java
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
src/main/java/com/nexia/viacombattest/mixin/MixinAirSwingFix.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.nexia.viacombattest.mixin; | ||
|
||
import com.nexia.viacombattest.mixin_interfaces.Is8CMissPacket; | ||
import net.minecraft.network.PacketByteBuf; | ||
import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(PlayerInteractEntityC2SPacket.class) | ||
public class MixinAirSwingFix implements Is8CMissPacket { | ||
@Unique | ||
public boolean isMiss = false; | ||
|
||
@Redirect(method = "<init>(Lnet/minecraft/network/PacketByteBuf;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketByteBuf;readEnumConstant(Ljava/lang/Class;)Ljava/lang/Enum;")) | ||
public Enum<?> initHook(PacketByteBuf instance, Class<Enum<?>> enumClass) { | ||
int readVar = instance.readVarInt(); | ||
|
||
if(readVar > 2) { | ||
System.out.println("FUCK YOU FUCK YOU FUCK YOU FUCK YOU FUCK YOU FUCK YOU FUCK YOU FUCK YOU FUCK YOU FUCK YOU FUCK YOU"); | ||
//new Exception().printStackTrace(); | ||
this.isMiss = true; //cancel packet | ||
return enumClass.getEnumConstants()[0]; | ||
} | ||
|
||
return enumClass.getEnumConstants()[readVar]; | ||
} | ||
|
||
@Unique | ||
@Override | ||
public boolean viaCombatTest$isMissPacket() { | ||
return isMiss; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/nexia/viacombattest/mixin/MixinViaVersionLateEnable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.nexia.viacombattest.mixin; | ||
|
||
import com.nexia.viacombattest.ViaFabricAddon; | ||
import com.viaversion.viaversion.ViaManagerImpl; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(ViaManagerImpl.class) | ||
public class MixinViaVersionLateEnable { | ||
//https://github.com/ViaVersion/ViaVersion/pull/4038 | ||
@Inject(method = "onServerLoaded", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/protocol/ProtocolManagerImpl;refreshVersions()V", shift = At.Shift.AFTER), remap = false) | ||
public void afterRefreshVersions(CallbackInfo ci) { | ||
ViaFabricAddon.lateEnable(); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/nexia/viacombattest/mixin_interfaces/Is8CMissPacket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.nexia.viacombattest.mixin_interfaces; | ||
|
||
public interface Is8CMissPacket { | ||
boolean viaCombatTest$isMissPacket(); | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/nexia/viacombattest/platform/VCTServerVersionProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.nexia.viacombattest.platform; | ||
|
||
import com.viaversion.viaversion.api.connection.UserConnection; | ||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; | ||
import com.viaversion.viaversion.api.protocol.version.VersionProvider; | ||
import com.viaversion.viaversion.api.protocol.version.VersionType; | ||
|
||
public record VCTServerVersionProvider(VersionProvider old) implements VersionProvider { | ||
@Override | ||
public ProtocolVersion getClientProtocol(UserConnection connection) { | ||
final ProtocolVersion version = connection.getProtocolInfo().protocolVersion(); | ||
if (version.getVersionType() == VersionType.SPECIAL) { | ||
return ProtocolVersion.getProtocol(VersionType.SPECIAL, version.getOriginalVersion()); | ||
} else { | ||
return old.getClientProtocol(connection); | ||
} | ||
} | ||
|
||
@Override | ||
public ProtocolVersion getClosestServerProtocol(UserConnection connection) throws Exception { | ||
return old.getClosestServerProtocol(connection); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"required": true, | ||
"package": "com.nexia.viacombattest.mixin", | ||
"compatibilityLevel": "JAVA_21", | ||
"mixins": [ | ||
"MixinAirSwingFix", | ||
"MixinViaVersionLateEnable" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
} |