Fix CatalogTypes#1792
Conversation
|
~wip |
fb84287 to
fb1cab5
Compare
|
Does this fix the spam from the catalog type tests? |
|
All inconsistencies with mojang's translations should be fixed. There are still a few things I don't like, I'll see if I can come up with something better. Suggestions are welcomed. EDIT:
Yes. After this PR: This also adds a test to make sure name and id are not the same and another one to find inconsistencies with mojang's translation |
|
Also, the old test had a few problems. If the translation was equal to the id, then it'd be classified as a missing translation. However minecraft is using the id as a fallback for a missing translation, thus that's not something we should fix. Here's the situation before this PR with the new test: |
|
|
||
| @Override | ||
| public Translation getTranslation() { | ||
| return translation; |
|
|
||
| @Override | ||
| public Translation getTranslation() { | ||
| EnumDyeColor enumdyecolor = ItemBanner.getBaseColor(new ItemStack((Item) (IMixinItem) this)); |
|
|
||
| @Override | ||
| public Translation getTranslation() { | ||
| return new SpongeTranslation(PotionUtils.getPotionFromItem(new ItemStack((Item) (IMixinItem) this)).getNamePrefixed("lingering_potion.effect.")); |
|
|
||
| @Override | ||
| public Translation getTranslation() { | ||
| return new SpongeTranslation(PotionUtils.getPotionFromItem(new ItemStack((Item) (IMixinItem) this)).getNamePrefixed("potion.effect.")); |
| public SpongeItemStatistic(String statId, String itemName, ITextComponent statName, Item item) { | ||
| super(statId, itemName, statName, item); | ||
| String args = new ItemStack(item).getDisplayName(); | ||
| translation = new SpongeTranslation(statId.substring(0, statId.length() - 1), args); |
| public abstract class MixinItemTippedArrow extends MixinItem implements ItemType { | ||
|
|
||
| @Override | ||
| public Translation getTranslation() { |
|
|
||
| public Translation itemstack$getTranslation() { | ||
| return new SpongeTranslation(shadow$getItem().getUnlocalizedName((net.minecraft.item.ItemStack) (Object) this) + ".name"); | ||
| String id; |
| public abstract class MixinItemSplashPotion extends MixinItem implements ItemType { | ||
|
|
||
| @Override | ||
| public Translation getTranslation() { |
| public abstract class MixinItemSkull extends MixinItem implements ItemType { | ||
|
|
||
| @Override | ||
| public Translation getTranslation() { |
|
|
||
| @Override | ||
| public Translation getTranslation() { | ||
| return translation; |
|
Nice improvements. |
I don't know what's going on here. Everything else works as expected. |
|
~qa |
gabizou
left a comment
There was a problem hiding this comment.
Some changes, clarifications.
| LOG.warn("Catalog Type: {} Id : {} has broken Method: {} ({}): {}", this.name, this.catalogId, this.methodName, | ||
| this.implementationClass, t); | ||
| return; | ||
| testResult(checkNotNull(this.method.invoke(this.catalogType), "return value")); |
There was a problem hiding this comment.
How is this changing how it used to work previously?
There was a problem hiding this comment.
Previously, everything inside ignoredFailureswould be ignored (it would just log "x has broken method: etc.") but it was a workaround (see the TODO above). I've just removed the if and unwrapped the exception.
|
|
||
| if (object instanceof IStringSerializable || object instanceof Fish || object instanceof CookedFish) { | ||
| if (verbose) { | ||
| LOG.info("This is probably a blockstate. Mojang doesn't directly provide translations for blockstates. Ignoring {}", translation.getId()); |
There was a problem hiding this comment.
Why is fish considered untranslatable but you're saying it's probably a block state?
There was a problem hiding this comment.
AFAICT there are translations for fish!?
item.fish.cod.raw.name=Raw Fish
item.fish.salmon.raw.name=Raw Salmon
item.fish.pufferfish.raw.name=Pufferfish
item.fish.clownfish.raw.name=Clownfish
item.fish.cod.cooked.name=Cooked Fish
item.fish.salmon.cooked.name=Cooked SalmonThere was a problem hiding this comment.
Indeed. However that's net.minecraft.item.ItemFishFood.
This check should avoid net.minecraft.item.ItemFishFood.FishType
| @Shadow private String unlocalizedName; | ||
|
|
||
| @Shadow public abstract int getItemStackLimit(); | ||
| @Shadow public abstract String getUnlocalizedName(); |
| ItemStack is = ItemStackUtil.fromNative(new net.minecraft.item.ItemStack((Item) (IMixinItem) this)); | ||
| Optional<GameProfile> owner = is.get(Keys.REPRESENTED_PLAYER); | ||
|
|
||
| if (owner.isPresent()) { |
There was a problem hiding this comment.
This cannot be present, since you just created the item or am I missing something?
| @Override | ||
| public Translation getTranslation() { | ||
| return new SpongeTranslation(this.statId); | ||
| return this.translation; |
There was a problem hiding this comment.
Instead of statId.equals("stat.mineBlock.") you could use StatBase#statId.startsWith("stat.mineBlock.").
and instead of item you could use StatCrafting#Item
| */ | ||
| package org.spongepowered.common.interfaces; | ||
|
|
||
| public interface MojangTranslatable { |
There was a problem hiding this comment.
Need javadocs that explain the purpose of this interface.
|
|
||
| if (object instanceof IStringSerializable || object instanceof Fish || object instanceof CookedFish) { | ||
| if (verbose) { | ||
| LOG.info("This is probably a blockstate. Mojang doesn't directly provide translations for blockstates. Ignoring {}", translation.getId()); |
There was a problem hiding this comment.
AFAICT there are translations for fish!?
item.fish.cod.raw.name=Raw Fish
item.fish.salmon.raw.name=Raw Salmon
item.fish.pufferfish.raw.name=Pufferfish
item.fish.clownfish.raw.name=Clownfish
item.fish.cod.cooked.name=Cooked Fish
item.fish.salmon.cooked.name=Cooked Salmon5ab9b63 to
4187f41
Compare
|
Sounds like it's almost ready, so with these changes the warnings are pretty much gone from all the catalog type tests? (I know I may have introduced one or two printouts with the recent PhaseTracker changes, but that I'll get to once I figure out how to beat a testing environment check without making those checks fail in production). |
Correct, but as you can see from the travis log https://travis-ci.org/SpongePowered/SpongeCommon/jobs/403996687, it's still complaining about NotePitch having the same id and name. I think it's safe to ignore them (unless someone comes up with different names). |
|
Ids shouldn't be uppercase, I noticed |
|
That's probably a breaking change. Is it something I can do in this PR ? Input wanted |
I'd say it's a fix, but best to check with some plugin developers for input. @clienthax for your note block music plugin, do the catalog id's changing from previously unprefixed to correctly prefixed note pitches change anything for you? (first example I could think of at this moment). |
|
There is a solution to it though. The associated registry could still return the right entries for old ids, so after the entries get loaded and saved once, you have completed the note pitch migration. Or does the config loader only use the ids for the mapping. IIRC they use GameRegistry#get(type, id). |
|
The thing is, NotePitch is not the only one having unprefixed ids. |
Something is not right. EDIT: Ok, something is horribly wrong. Looks like the catalogtest was not testing every catalog type. |
87beb6d to
bbe521d
Compare
|
Updated to reflect the CatalogKey PR. |
165b6f4 to
2d2b3eb
Compare
2ba45aa to
3828654
Compare
SpongeAPI | SpongeCommon
Missing translations:
entity.MinecartSpawner.name
entity.MinecartTNT.name
entity.ThrownEnderpearl.name
entity.EyeOfEnderSignal.name
entity.FireworksRocketEntity.name
entity.MinecartCommandBlock.name
entity.MinecartFurnace.name
entity.LlamaSpit.name
entity.ThrownExpBottle.name
entity.ItemFrame.name
entity.SpectralArrow.name
entity.EvocationFangs.name
entity.ShulkerBullet.name
entity.MinecartRideable.name
entity.AreaEffectCloud.name
entity.LeashKnot.name
entity.WitherSkull.name
entity.EnderCrystal.name