diff options
| author | BuildTools <james.jenour@protonmail.com> | 2021-05-06 08:03:15 +0800 |
|---|---|---|
| committer | BuildTools <james.jenour@protonmail.com> | 2021-05-06 08:03:15 +0800 |
| commit | 9aa7b49d224bfde055e12bc84f6908ba0a50090d (patch) | |
| tree | 3485af44e6570b143867ec8867c123435244643e /src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemStack.java | |
| parent | 03b9a8dbcc1ebd5f8c39e4733a741a4092ab0a1d (diff) | |
| download | notenoughupdates-9aa7b49d224bfde055e12bc84f6908ba0a50090d.tar.gz notenoughupdates-9aa7b49d224bfde055e12bc84f6908ba0a50090d.tar.bz2 notenoughupdates-9aa7b49d224bfde055e12bc84f6908ba0a50090d.zip | |
fine ironman
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemStack.java')
| -rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemStack.java | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemStack.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemStack.java index 239dbe93..4a7f0f5b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemStack.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemStack.java @@ -1,7 +1,6 @@ package io.github.moulberry.notenoughupdates.mixins; -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.miscfeatures.ItemCooldowns; +import io.github.moulberry.notenoughupdates.miscfeatures.ItemCustomizeManager; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -16,9 +15,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; public class MixinItemStack { @Inject(method="hasEffect", at=@At("HEAD"), cancellable = true) - public void hasEffect(CallbackInfoReturnable cir) { + public void hasEffect(CallbackInfoReturnable<Boolean> cir) { if(Utils.getHasEffectOverride()) { cir.setReturnValue(false); + return; } } @@ -32,28 +32,31 @@ public class MixinItemStack { return; } - String customName = NotEnoughUpdates.INSTANCE.manager.itemRenameJson - .get(stackTagCompound.getCompoundTag("ExtraAttributes").getString("uuid")).getAsString(); - if(customName != null && !customName.equals("")) { - String prefix = EnumChatFormatting.RESET.toString(); - if (stackTagCompound != null && stackTagCompound.hasKey("display", 10)) { - NBTTagCompound nbttagcompound = stackTagCompound.getCompoundTag("display"); - - if (nbttagcompound.hasKey("Name", 8)) { - String name = nbttagcompound.getString("Name"); - char[] chars = name.toCharArray(); - - int i; - for(i=0; i<chars.length; i+=2) { - if(chars[i] != '\u00a7'){ - break; + ItemCustomizeManager.ItemData data = ItemCustomizeManager.getDataForItem((ItemStack)(Object)this); + + if(data != null && data.customName != null) { + String customName = data.customName; + if(customName != null && !customName.equals("")) { + String prefix = EnumChatFormatting.RESET.toString(); + if (stackTagCompound != null && stackTagCompound.hasKey("display", 10)) { + NBTTagCompound nbttagcompound = stackTagCompound.getCompoundTag("display"); + + if (nbttagcompound.hasKey("Name", 8)) { + String name = nbttagcompound.getString("Name"); + char[] chars = name.toCharArray(); + + int i; + for(i=0; i<chars.length; i+=2) { + if(chars[i] != '\u00a7'){ + break; + } } - } - prefix = name.substring(0, i); + prefix = name.substring(0, i); + } } + returnable.setReturnValue(prefix+customName); } - returnable.setReturnValue(prefix+customName); } } catch(Exception e) { } } |
