diff options
| author | ohowe <42757516+carelesshippo@users.noreply.github.com> | 2021-05-05 18:13:28 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-05 18:13:28 -0600 |
| commit | 4d9e538ced80728bca74491698347333f515bfcc (patch) | |
| tree | e272c853cb9ebe7eb8334e405060bc820ee129fd /src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinItemStack.java | |
| parent | 59d3bf67d93d0204d0dc493508d9d9c2a24cd10b (diff) | |
| parent | 9aa7b49d224bfde055e12bc84f6908ba0a50090d (diff) | |
| download | notenoughupdates-4d9e538ced80728bca74491698347333f515bfcc.tar.gz notenoughupdates-4d9e538ced80728bca74491698347333f515bfcc.tar.bz2 notenoughupdates-4d9e538ced80728bca74491698347333f515bfcc.zip | |
Merge pull request #2 from Moulberry/master
x
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) { } } |
