diff --git a/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentPotion.java b/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentPotion.java index 2c5dc0e..f6dcacc 100644 --- a/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentPotion.java +++ b/src/main/java/exopandora/worldhandler/builder/component/impl/ComponentPotion.java @@ -48,77 +48,67 @@ public abstract class ComponentPotion implements IBuilderComponent public void setAmplifier(MobEffect potion, byte amplifier) { - this.getMetadata(potion).setAmplifier(amplifier); + this.get(potion).setAmplifier(amplifier); } public byte getAmplifier(MobEffect potion) { - return this.getMetadata(potion).getAmplifier(); + return this.get(potion).getAmplifier(); } public void setSeconds(MobEffect potion, int seconds) { - this.getMetadata(potion).setSeconds(seconds); + this.get(potion).setSeconds(seconds); } public int getSeconds(MobEffect potion) { - return this.getMetadata(potion).getSeconds(); + return this.get(potion).getSeconds(); } public void setMinutes(MobEffect potion, int minutes) { - this.getMetadata(potion).setMinutes(minutes); + this.get(potion).setMinutes(minutes); } public int getMinutes(MobEffect potion) { - return this.getMetadata(potion).getMinutes(); + return this.get(potion).getMinutes(); } public void setHours(MobEffect potion, int hours) { - this.getMetadata(potion).setHours(hours); + this.get(potion).setHours(hours); } public int getHours(MobEffect potion) { - return this.getMetadata(potion).getHours(); + return this.get(potion).getHours(); } public void setShowParticles(MobEffect potion, boolean showParticles) { - this.getMetadata(potion).setShowParticles(showParticles); + this.get(potion).setShowParticles(showParticles); } public boolean getShowParticles(MobEffect potion) { - return this.getMetadata(potion).getShowParticles(); + return this.get(potion).getShowParticles(); } public void setAmbient(MobEffect potion, boolean ambient) { - this.getMetadata(potion).setAmbient(ambient); + this.get(potion).setAmbient(ambient); } public boolean getAmbient(MobEffect potion) { - return this.getMetadata(potion).getAmbient(); + return this.get(potion).getAmbient(); } - private EffectNBT getMetadata(MobEffect potion) + private EffectNBT get(MobEffect potion) { - return this.potions.get(this.validate(potion)); - } - - private MobEffect validate(MobEffect potion) - { - if(!this.potions.containsKey(potion)) - { - this.potions.put(potion, new EffectNBT()); - } - - return potion; + return this.potions.computeIfAbsent(potion, key -> new EffectNBT()); } public Set getMobEffects() diff --git a/src/main/java/exopandora/worldhandler/builder/impl/BuilderPotionEffect.java b/src/main/java/exopandora/worldhandler/builder/impl/BuilderPotionEffect.java index f8a5c25..d9f8847 100644 --- a/src/main/java/exopandora/worldhandler/builder/impl/BuilderPotionEffect.java +++ b/src/main/java/exopandora/worldhandler/builder/impl/BuilderPotionEffect.java @@ -75,7 +75,7 @@ public class BuilderPotionEffect extends CommandBuilder if(location != null) { - return ForgeRegistries.POTIONS.getValue(location); + return ForgeRegistries.MOB_EFFECTS.getValue(location); } return null; diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentPotions.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentPotions.java index e5fd7e0..79a5f3b 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentPotions.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentPotions.java @@ -63,7 +63,7 @@ public class ContentPotions extends ContentChild @Override public void initGui(Container container, int x, int y) { - MenuPageList potions = new MenuPageList(x, y, new ArrayList(ForgeRegistries.POTIONS.getValues()), 114, 20, 3, container, new ILogicPageList() + MenuPageList potions = new MenuPageList(x, y, new ArrayList(ForgeRegistries.MOB_EFFECTS.getValues()), 114, 20, 3, container, new ILogicPageList() { @Override public MutableComponent translate(MobEffect item) diff --git a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentSummon.java b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentSummon.java index f02c551..3cd253b 100644 --- a/src/main/java/exopandora/worldhandler/gui/content/impl/ContentSummon.java +++ b/src/main/java/exopandora/worldhandler/gui/content/impl/ContentSummon.java @@ -316,7 +316,7 @@ public class ContentSummon extends Content for(ResourceLocation location : this.sortedPotions()) { - MobEffect potion = ForgeRegistries.POTIONS.getValue(location); + MobEffect potion = ForgeRegistries.MOB_EFFECTS.getValue(location); if(!potion.equals(MobEffects.HARM) && !potion.equals(MobEffects.HEAL)) { @@ -325,7 +325,7 @@ public class ContentSummon extends Content button1.active = false; } - if(this.potionPage == ForgeRegistries.POTIONS.getKeys().size() - 3) + if(this.potionPage == ForgeRegistries.MOB_EFFECTS.getKeys().size() - 3) { button2.active = false; } @@ -431,7 +431,7 @@ public class ContentSummon extends Content } else if(Page.POTIONS.equals(this.page)) { - Minecraft.getInstance().font.draw(matrix, (this.potionPage + 1) + "/" + (ForgeRegistries.POTIONS.getKeys().size() - 2), x + 118, y - 11, Config.getSkin().getHeadlineColor()); + Minecraft.getInstance().font.draw(matrix, (this.potionPage + 1) + "/" + (ForgeRegistries.MOB_EFFECTS.getKeys().size() - 2), x + 118, y - 11, Config.getSkin().getHeadlineColor()); } else if(Page.EQUIPMENT.equals(this.page)) { @@ -459,8 +459,8 @@ public class ContentSummon extends Content private List sortedPotions() { - return ForgeRegistries.POTIONS.getKeys().stream() - .sorted((a, b) -> I18n.get(ForgeRegistries.POTIONS.getValue(a).getDescriptionId()).compareTo(I18n.get(ForgeRegistries.POTIONS.getValue(b).getDescriptionId()))) + return ForgeRegistries.MOB_EFFECTS.getKeys().stream() + .sorted((a, b) -> I18n.get(ForgeRegistries.MOB_EFFECTS.getValue(a).getDescriptionId()).compareTo(I18n.get(ForgeRegistries.MOB_EFFECTS.getValue(b).getDescriptionId()))) .collect(Collectors.toList()); } diff --git a/src/main/java/exopandora/worldhandler/util/RegistryHelper.java b/src/main/java/exopandora/worldhandler/util/RegistryHelper.java index c9ecca9..4d4e27e 100644 --- a/src/main/java/exopandora/worldhandler/util/RegistryHelper.java +++ b/src/main/java/exopandora/worldhandler/util/RegistryHelper.java @@ -33,7 +33,7 @@ public class RegistryHelper { registerRegistry(ForgeRegistries.BLOCKS, Block::getDescriptionId); registerRegistry(ForgeRegistries.ITEMS, Item::getDescriptionId); - registerRegistry(ForgeRegistries.POTIONS, MobEffect::getDescriptionId); + registerRegistry(ForgeRegistries.MOB_EFFECTS, MobEffect::getDescriptionId); registerRegistry(ForgeRegistries.BIOMES, biome -> { Registry registry = RegistryAccess.builtin().registryOrThrow(Registry.BIOME_REGISTRY);