mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-11-25 12:25:22 +01:00
Updated Via* API usages
This commit is contained in:
parent
ea72120ff7
commit
751090cdfd
@ -19,31 +19,29 @@
|
|||||||
|
|
||||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion;
|
package de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14_4to1_14_3.ClientboundPackets1_14_4;
|
import com.viaversion.viaversion.protocols.protocol1_14_4to1_14_3.ClientboundPackets1_14_4;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
|
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.metadata.MetadataRewriter1_15To1_14_4;
|
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.metadata.MetadataRewriter1_15To1_14_4;
|
||||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||||
|
import com.viaversion.viaversion.rewriter.meta.MetaFilter;
|
||||||
import de.florianmichael.viafabricplus.fixes.tracker.WolfHealthTracker;
|
import de.florianmichael.viafabricplus.fixes.tracker.WolfHealthTracker;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
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.List;
|
@Mixin(value = MetadataRewriter1_15To1_14_4.class, remap = false)
|
||||||
|
|
||||||
@Mixin(MetadataRewriter1_15To1_14_4.class)
|
|
||||||
public abstract class MixinMetadataRewriter1_15To1_14_4 extends EntityRewriter<ClientboundPackets1_14_4, Protocol1_15To1_14_4> {
|
public abstract class MixinMetadataRewriter1_15To1_14_4 extends EntityRewriter<ClientboundPackets1_14_4, Protocol1_15To1_14_4> {
|
||||||
|
|
||||||
public MixinMetadataRewriter1_15To1_14_4(Protocol1_15To1_14_4 protocol) {
|
public MixinMetadataRewriter1_15To1_14_4(Protocol1_15To1_14_4 protocol) {
|
||||||
super(protocol);
|
super(protocol);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "handleMetadata", at = @At(value = "INVOKE", target = "Ljava/util/List;remove(Ljava/lang/Object;)Z", shift = At.Shift.BEFORE), remap = false)
|
@Redirect(method = "registerRewrites", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/rewriter/meta/MetaFilter$Builder;removeIndex(I)V"))
|
||||||
private void trackHealth(int entityId, EntityType type, Metadata metadata, List<Metadata> metadatas, UserConnection connection, CallbackInfo ci) {
|
private void trackHealth(MetaFilter.Builder instance, int index) {
|
||||||
WolfHealthTracker.get(connection).setWolfHealth(entityId, metadata.value());
|
instance.index(18).handler((event, meta) -> {
|
||||||
|
WolfHealthTracker.get(event.user()).setWolfHealth(event.entityId(), meta.value());
|
||||||
|
event.cancel();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,24 +19,21 @@
|
|||||||
|
|
||||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion;
|
package de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
|
||||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.metadata.MetadataRewriter1_9To1_8;
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.metadata.MetadataRewriter1_9To1_8;
|
||||||
|
import com.viaversion.viaversion.rewriter.meta.MetaHandlerEvent;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Mixin(value = MetadataRewriter1_9To1_8.class, remap = false)
|
@Mixin(value = MetadataRewriter1_9To1_8.class, remap = false)
|
||||||
public abstract class MixinMetadataRewriter1_9To1_8 {
|
public abstract class MixinMetadataRewriter1_9To1_8 {
|
||||||
|
|
||||||
@Inject(method = "handleMetadata", at = @At(value = "FIELD", target = "Lcom/viaversion/viaversion/protocols/protocol1_9to1_8/metadata/MetaIndex;PLAYER_HAND:Lcom/viaversion/viaversion/protocols/protocol1_9to1_8/metadata/MetaIndex;", ordinal = 0, shift = At.Shift.BEFORE), cancellable = true)
|
@Inject(method = "handleMetadata", at = @At(value = "FIELD", target = "Lcom/viaversion/viaversion/protocols/protocol1_9to1_8/metadata/MetaIndex;PLAYER_HAND:Lcom/viaversion/viaversion/protocols/protocol1_9to1_8/metadata/MetaIndex;", ordinal = 0, shift = At.Shift.BEFORE), cancellable = true)
|
||||||
private void preventMetadataForClientPlayer(int entityId, EntityType type, Metadata metadata, List<Metadata> metadatas, UserConnection connection, CallbackInfo ci) {
|
private void preventMetadataForClientPlayer(MetaHandlerEvent event, Metadata metadata, CallbackInfo ci) {
|
||||||
if (connection.getEntityTracker(Protocol1_9To1_8.class).clientEntityId() == entityId) {
|
if (event.user().getEntityTracker(Protocol1_9To1_8.class).clientEntityId() == event.entityId()) {
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,21 +33,21 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
|||||||
@Mixin(value = JoinPackets.class, remap = false)
|
@Mixin(value = JoinPackets.class, remap = false)
|
||||||
public abstract class MixinJoinPackets {
|
public abstract class MixinJoinPackets {
|
||||||
|
|
||||||
@Redirect(method = "lambda$register$2", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/protocol/packet/PacketWrapper;read(Lcom/viaversion/viaversion/api/type/Type;)Ljava/lang/Object;", ordinal = 5))
|
@Redirect(method = "lambda$register$8", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/protocol/packet/PacketWrapper;read(Lcom/viaversion/viaversion/api/type/Type;)Ljava/lang/Object;", ordinal = 5))
|
||||||
private static Object trackWorldSeed(PacketWrapper instance, Type<LongLEType> tType) throws Exception {
|
private static Object trackWorldSeed(PacketWrapper instance, Type<LongLEType> tType) throws Exception {
|
||||||
final Object seed = instance.read(tType);
|
final Object seed = instance.read(tType);
|
||||||
instance.user().get(JoinGameDataTracker.class).setSeed((long) seed);
|
instance.user().get(JoinGameDataTracker.class).setSeed((long) seed);
|
||||||
return seed;
|
return seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(method = "lambda$register$2", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/protocol/packet/PacketWrapper;read(Lcom/viaversion/viaversion/api/type/Type;)Ljava/lang/Object;", ordinal = 55))
|
@Redirect(method = "lambda$register$8", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/protocol/packet/PacketWrapper;read(Lcom/viaversion/viaversion/api/type/Type;)Ljava/lang/Object;", ordinal = 55))
|
||||||
private static Object trackLevelId(PacketWrapper instance, Type<StringType> tType) throws Exception {
|
private static Object trackLevelId(PacketWrapper instance, Type<StringType> tType) throws Exception {
|
||||||
final Object levelId = instance.read(tType);
|
final Object levelId = instance.read(tType);
|
||||||
instance.user().get(JoinGameDataTracker.class).setLevelId((String) levelId);
|
instance.user().get(JoinGameDataTracker.class).setLevelId((String) levelId);
|
||||||
return levelId;
|
return levelId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(method = "lambda$register$2", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/protocol/packet/PacketWrapper;read(Lcom/viaversion/viaversion/api/type/Type;)Ljava/lang/Object;", ordinal = 63))
|
@Redirect(method = "lambda$register$8", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/protocol/packet/PacketWrapper;read(Lcom/viaversion/viaversion/api/type/Type;)Ljava/lang/Object;", ordinal = 63))
|
||||||
private static Object trackEnchantmentSeed(PacketWrapper instance, Type<VarIntType> tType) throws Exception {
|
private static Object trackEnchantmentSeed(PacketWrapper instance, Type<VarIntType> tType) throws Exception {
|
||||||
final Object enchantmentSeed = instance.read(tType);
|
final Object enchantmentSeed = instance.read(tType);
|
||||||
instance.user().get(JoinGameDataTracker.class).setEnchantmentSeed((Integer) enchantmentSeed);
|
instance.user().get(JoinGameDataTracker.class).setEnchantmentSeed((Integer) enchantmentSeed);
|
||||||
|
Loading…
Reference in New Issue
Block a user