mirror of
https://github.com/GTMEGA/EndlessIDs.git
synced 2026-11-18 19:39:11 +00:00
4 files changed
+25
-41
No files matched your search
+1
-1
@@ -24,5 +24,5 @@
|
||||
package com.falsepattern.endlessids.mixin.helpers;
|
||||
|
||||
public interface IS1DPacketEntityEffectMixin {
|
||||
int getIDExtended();
|
||||
int endlessids$getIDExtended();
|
||||
}
|
||||
+1
-1
@@ -47,7 +47,7 @@ public abstract class NetHandlerPlayClientMixin {
|
||||
at = @At("HEAD"),
|
||||
require = 1)
|
||||
private void grabID(S1DPacketEntityEffect packetIn, CallbackInfo ci) {
|
||||
theID = ((IS1DPacketEntityEffectMixin) packetIn).getIDExtended();
|
||||
theID = ((IS1DPacketEntityEffectMixin) packetIn).endlessids$getIDExtended();
|
||||
}
|
||||
|
||||
@Redirect(method = "handleEntityEffect",
|
||||
|
||||
+21
-20
@@ -26,15 +26,17 @@ package com.falsepattern.endlessids.mixin.mixins.common.potion.vanilla.network;
|
||||
import com.falsepattern.endlessids.mixin.helpers.IS1DPacketEntityEffectMixin;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.val;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.server.S1DPacketEntityEffect;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
|
||||
//Yes, this is wasteful, but other mods also touch these classes, so this is the most robust way to do this unfortunately
|
||||
@Mixin(value = S1DPacketEntityEffect.class)
|
||||
public abstract class S1DPacketEntityEffectMixin implements IS1DPacketEntityEffectMixin {
|
||||
private int idExtended;
|
||||
@@ -44,32 +46,31 @@ public abstract class S1DPacketEntityEffectMixin implements IS1DPacketEntityEffe
|
||||
target = "Lnet/minecraft/potion/PotionEffect;getPotionID()I"),
|
||||
require = 1)
|
||||
private int getPotionID(PotionEffect effect, Operation<Integer> original) {
|
||||
idExtended = original.call(effect);
|
||||
return -1;
|
||||
val id = original.call(effect);
|
||||
idExtended = id;
|
||||
if (id <= 127) {
|
||||
return id;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "readPacketData",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/PacketBuffer;readByte()B",
|
||||
ordinal = 0),
|
||||
require = 1)
|
||||
private byte networkReadPacketData(PacketBuffer instance) {
|
||||
idExtended = instance.readInt();
|
||||
return -1;
|
||||
@Inject(method = "readPacketData",
|
||||
at = @At("RETURN"),
|
||||
require = 1)
|
||||
private void networkReadPacketData(PacketBuffer data, CallbackInfo ci) {
|
||||
idExtended = data.readInt();
|
||||
}
|
||||
|
||||
@Redirect(method = "writePacketData",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/PacketBuffer;writeByte(I)Lio/netty/buffer/ByteBuf;",
|
||||
ordinal = 0),
|
||||
@Inject(method = "writePacketData",
|
||||
at = @At("RETURN"),
|
||||
require = 1)
|
||||
private ByteBuf networkWritePacketData(PacketBuffer instance, int p_writeByte_1_) {
|
||||
instance.writeInt(idExtended);
|
||||
return null;
|
||||
private void networkWritePacketData(PacketBuffer data, CallbackInfo ci) {
|
||||
data.writeInt(idExtended);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIDExtended() {
|
||||
public int endlessids$getIDExtended() {
|
||||
return this.idExtended;
|
||||
}
|
||||
}
|
||||
+2
-19
@@ -23,30 +23,21 @@
|
||||
|
||||
package com.falsepattern.endlessids.mixin.mixins.common.potion.vanilla.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
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 net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.play.server.S1EPacketRemoveEntityEffect;
|
||||
|
||||
//Yes, this is wasteful, but other mods also touch these classes, so this is the most robust way to do this unfortunately
|
||||
@Mixin(S1EPacketRemoveEntityEffect.class)
|
||||
public abstract class S1EPacketRemoveEntityEffectMixin {
|
||||
@Shadow
|
||||
private int field_149078_b;
|
||||
|
||||
@Redirect(method = "readPacketData",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/PacketBuffer;readUnsignedByte()S"),
|
||||
require = 1)
|
||||
private short dontReadByte(PacketBuffer instance) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Inject(method = "readPacketData",
|
||||
at = @At("RETURN"),
|
||||
require = 1)
|
||||
@@ -54,16 +45,8 @@ public abstract class S1EPacketRemoveEntityEffectMixin {
|
||||
field_149078_b = buf.readInt();
|
||||
}
|
||||
|
||||
@Redirect(method = "writePacketData",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/network/PacketBuffer;writeByte(I)Lio/netty/buffer/ByteBuf;"),
|
||||
require = 1)
|
||||
private ByteBuf dontWriteByte(PacketBuffer instance, int p_writeByte_1_) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Inject(method = "writePacketData",
|
||||
at = @At(value = "RETURN"),
|
||||
at = @At("RETURN"),
|
||||
require = 1)
|
||||
private void writeNewData(PacketBuffer buf, CallbackInfo ci) {
|
||||
buf.writeInt(field_149078_b);
|
||||
|
||||
Reference in new issue
Block a user