New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup of enchantments #1593
Cleanup of enchantments #1593
Conversation
public String enchantment$getName() { | ||
return shadow$getName(); | ||
return I18n.translateToLocal(shadow$getName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah as the getName method previously returned the translation key of "enchantment." + name. For example "enchantment.waterWalker" or similar.
@@ -436,7 +436,7 @@ public void registerDefaults() { | |||
|
|||
this.fieldMap.put("last_date_played", makeSingleKey(TypeTokens.INSTANT_TOKEN, TypeTokens.INSTANT_VALUE_TOKEN, of("LastTimePlayed"), "sponge:last_time_played", "Last Time Played")); | |||
|
|||
this.fieldMap.put("hide_enchantments", makeSingleKey(TypeTokens.BOOLEAN_TOKEN, TypeTokens.BOOLEAN_VALUE_TOKEN, of("HideEnchantments"), "sponge:hide_enchantments", "Hide Enchantments")); | |||
this.fieldMap.put("hide_enchantments", makeSingleKey(TypeTokens.BOOLEAN_TOKEN, TypeTokens.BOOLEAN_VALUE_TOKEN, of("HideEnchantments"), "sponge:hide_enchantments", "Hide EnchantmentTypes")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is not that much...
@@ -412,7 +412,7 @@ public void registerDefaults() { | |||
|
|||
this.fieldMap.put("persists", makeSingleKey(TypeTokens.BOOLEAN_TOKEN, TypeTokens.BOOLEAN_VALUE_TOKEN, of("Persists"), "sponge:persists", "Persists")); | |||
|
|||
this.fieldMap.put("stored_enchantments", makeListKey(TypeTokens.LIST_ITEM_ENCHANTMENT_TOKEN, TypeTokens.LIST_ITEM_ENCHANTMENT_VALUE_TOKEN, of("StoredEnchantments"), "sponge:stored_enchantments", "Stored Enchantments")); | |||
this.fieldMap.put("stored_enchantments", makeListKey(TypeTokens.LIST_ITEM_ENCHANTMENT_TOKEN, TypeTokens.LIST_ITEM_ENCHANTMENT_VALUE_TOKEN, of("StoredEnchantments"), "sponge:stored_enchantments", "Stored EnchantmentTypes")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should change these names.
this.modifierTypeMap.put("offensive_potion_effect", new SpongeDamageModifierType("Offensive PotionEffect", "offensive_potion_effect")); | ||
this.modifierTypeMap.put("defensive_potion_effect", new SpongeDamageModifierType("Defensive PotionEffect", "defensive_potion_effect")); | ||
this.modifierTypeMap.put("negative_potion_effect", new SpongeDamageModifierType("Negative PotionEffect", "negative_potion_effect")); | ||
this.modifierTypeMap.put("hard_hat", new SpongeDamageModifierType("Hard Hat", "hard_hat")); | ||
this.modifierTypeMap.put("shield", new SpongeDamageModifierType("Shield", "shield")); | ||
this.modifierTypeMap.put("blocking", this.modifierTypeMap.get("shield")); | ||
this.modifierTypeMap.put("armor", new SpongeDamageModifierType("Armor", "armor")); | ||
this.modifierTypeMap.put("armor_enchantment", new SpongeDamageModifierType("Armor Enchantment", "armor_enchantment")); | ||
this.modifierTypeMap.put("armor_enchantment", new SpongeDamageModifierType("Armor EnchantmentType", "armor_enchantment")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not these two
@@ -67,6 +69,20 @@ | |||
public class CustomInventoryTest { | |||
|
|||
@Listener | |||
public void onBlockInteract(InteractBlockEvent event, @Root Player player) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was for some testing, will remove this later.
ba802cc
to
49b67af
Compare
One second, will fix the issue... |
172ac49
to
ba802cc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small ages.
@@ -64,8 +64,8 @@ | |||
public static final DataQuery VELOCITY_Y = of("Y"); | |||
public static final DataQuery VELOCITY_Z = of("Z"); | |||
|
|||
// Enchantments | |||
public static final DataQuery ENCHANTMENT_ID = of("Enchantment"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may need to be deprecated legacy versioned
|
||
@Override | ||
public Enchantment.Builder from(final Enchantment value) { | ||
this.enchantmentType = value.getType(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a null check.
@Override | ||
protected Optional<Enchantment> buildContent(DataView container) throws InvalidDataException { | ||
checkNotNull(container, "The data view cannot be null!"); | ||
if (container.contains(Queries.ENCHANTMENT_ID, Queries.LEVEL)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invert the if block, style change, I know, just preference. Fail fast.
if (container.contains(Queries.ENCHANTMENT_ID, Queries.LEVEL)) { | ||
final String id = DataUtil.getData(container, Queries.ENCHANTMENT_ID, String.class); | ||
final int level = DataUtil.getData(container, Queries.LEVEL, Integer.class); | ||
final Optional<EnchantmentType> enchantmentType = SpongeImpl.getRegistry().getType(EnchantmentType.class, id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SpongeImpl vs Sponge?
@Implements(@Interface(iface = Enchantment.class, prefix = "enchantment$")) | ||
public abstract class MixinEnchantment implements Enchantment, IMixinEnchantment { | ||
@Implements(@Interface(iface = EnchantmentType.class, prefix = "enchantment$")) | ||
public abstract class MixinEnchantment implements IMixinEnchantment { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove it? It'll still perfectly implement just fine normally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMixinEnchantment
extends Enchantment
so I didn't think it was needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about it further, the IMixin
interfaces shouldn't extend the API interfaces for the basic understanding that they are only from implementation, The only reason why there's IMixinEntity
and a few others doing this is because of Java compiler requirements with potentially ambiguous methods.
@@ -20,7 +20,7 @@ public net.minecraft.command.EntitySelector func_82381_h(Ljava/lang/String;)Ljav | |||
public net.minecraft.crash.CrashReport field_71511_b # cause | |||
public net.minecraft.crash.CrashReportCategory field_85078_a # crashReport | |||
|
|||
public net.minecraft.enchantment.Enchantment field_180311_a # enchantmentsList | |||
public net.minecraft.enchantmentType.Enchantment field_180311_a # enchantmentsList |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo?
@Implements(@Interface(iface = Enchantment.class, prefix = "enchantment$")) | ||
public abstract class MixinEnchantment implements Enchantment, IMixinEnchantment { | ||
@Implements(@Interface(iface = EnchantmentType.class, prefix = "enchantment$")) | ||
public abstract class MixinEnchantment implements IMixinEnchantment { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about it further, the IMixin
interfaces shouldn't extend the API interfaces for the basic understanding that they are only from implementation, The only reason why there's IMixinEntity
and a few others doing this is because of Java compiler requirements with potentially ambiguous methods.
9e05be5
to
7aa274b
Compare
7aa274b
to
9e9e94f
Compare
SpongeAPI | SpongeCommon | SpongeVanilla | SpongeForge
Read API PR for more information.