Fixed namings in MixinItemStack and updated Classic4J

This commit is contained in:
FlorianMichael 2024-01-20 23:15:00 +01:00
parent 549fce8b55
commit 610ae09d69
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
5 changed files with 17 additions and 15 deletions

View File

@ -32,4 +32,4 @@ mcping_version=1.4.0
# Misc Libraries
mod_menu_version=9.0.0
classic4j_version=2.0.1
classic4j_version=2.0.2

View File

@ -21,7 +21,7 @@ package de.florianmichael.viafabricplus.injection.access;
public interface IItemStack {
boolean viaFabricPlus$has1_10ViaFabricPlusTag();
boolean viaFabricPlus$has1_10Tag();
int viaFabricPlus$get1_10Count();

View File

@ -31,7 +31,7 @@ public abstract class MixinDrawContext {
@Redirect(method = "drawItemInSlot(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/item/ItemStack;IILjava/lang/String;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getCount()I"))
private int handleNegativeItemCount(ItemStack instance) {
if (((IItemStack) (Object) instance).viaFabricPlus$has1_10ViaFabricPlusTag()) {
if (((IItemStack) (Object) instance).viaFabricPlus$has1_10Tag()) {
return ((IItemStack) (Object) instance).viaFabricPlus$get1_10Count();
}
return instance.getCount();

View File

@ -45,10 +45,10 @@ public abstract class MixinItemStack implements IItemStack {
public abstract Item getItem();
@Unique
private boolean viaFabricPlus$has1_10ProtocolHackTag;
private boolean viaFabricPlus$has1_10Tag;
@Unique
private int viaFabricPlus$1_10_count;
private int viaFabricPlus$1_10Count;
@Redirect(method = "getTooltip",
slice = @Slice(from = @At(value = "FIELD", target = "Lnet/minecraft/entity/attribute/EntityAttributes;GENERIC_ATTACK_DAMAGE:Lnet/minecraft/entity/attribute/EntityAttribute;", ordinal = 0)),
@ -64,7 +64,9 @@ public abstract class MixinItemStack implements IItemStack {
@SuppressWarnings({"InvalidInjectorMethodSignature", "MixinAnnotationTarget"})
@ModifyVariable(method = "getAttributeModifiers", ordinal = 0, at = @At(value = "STORE", ordinal = 1))
private Multimap<EntityAttribute, EntityAttributeModifier> modifyVariableGetAttributeModifiers(Multimap<EntityAttribute, EntityAttributeModifier> modifiers) {
if (!DebugSettings.global().replaceAttributeModifiers.isEnabled() || modifiers.isEmpty()) return modifiers;
if (!DebugSettings.global().replaceAttributeModifiers.isEnabled() || modifiers.isEmpty()) {
return modifiers;
}
modifiers = HashMultimap.create(modifiers);
modifiers.removeAll(EntityAttributes.GENERIC_ATTACK_DAMAGE);
@ -79,10 +81,10 @@ public abstract class MixinItemStack implements IItemStack {
}
@Inject(method = "copy", at = @At("RETURN"))
private void copyProtocolHackData(CallbackInfoReturnable<ItemStack> cir) {
private void copyViaFabricPlusData(CallbackInfoReturnable<ItemStack> cir) {
final IItemStack mixinItemStack = (IItemStack) (Object) cir.getReturnValue();
if (this.viaFabricPlus$has1_10ProtocolHackTag) {
mixinItemStack.viaFabricPlus$set1_10Count(this.viaFabricPlus$1_10_count);
if (this.viaFabricPlus$has1_10Tag) {
mixinItemStack.viaFabricPlus$set1_10Count(this.viaFabricPlus$1_10Count);
}
}
@ -105,19 +107,19 @@ public abstract class MixinItemStack implements IItemStack {
}
@Override
public boolean viaFabricPlus$has1_10ViaFabricPlusTag() {
return this.viaFabricPlus$has1_10ProtocolHackTag;
public boolean viaFabricPlus$has1_10Tag() {
return this.viaFabricPlus$has1_10Tag;
}
@Override
public int viaFabricPlus$get1_10Count() {
return this.viaFabricPlus$1_10_count;
return this.viaFabricPlus$1_10Count;
}
@Override
public void viaFabricPlus$set1_10Count(final int count) {
this.viaFabricPlus$has1_10ProtocolHackTag = true;
this.viaFabricPlus$1_10_count = count;
this.viaFabricPlus$has1_10Tag = true;
this.viaFabricPlus$1_10Count = count;
}
}

View File

@ -51,7 +51,7 @@ public abstract class MixinPacketByteBuf {
NbtCompound tag = instance.getNbt();
final IItemStack mixinItemStack = ((IItemStack) (Object) instance);
if (mixinItemStack.viaFabricPlus$has1_10ViaFabricPlusTag()) {
if (mixinItemStack.viaFabricPlus$has1_10Tag()) {
if (tag == null) tag = new NbtCompound();
tag.putByte(ClientsideFixes.ITEM_COUNT_NBT_TAG, (byte) mixinItemStack.viaFabricPlus$get1_10Count());
}