Add config options for disabling specific artefacts
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package electroblob.wizardry;
|
||||
|
||||
import electroblob.wizardry.item.ItemArtefact;
|
||||
import electroblob.wizardry.packet.PacketSyncSettings;
|
||||
import electroblob.wizardry.packet.WizardryPacketHandler;
|
||||
import electroblob.wizardry.spell.Spell;
|
||||
@@ -9,6 +10,7 @@ import electroblob.wizardry.util.MagicDamage.DamageType;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.config.ConfigCategory;
|
||||
@@ -63,6 +65,8 @@ public final class Settings {
|
||||
public static final String TWEAKS_CATEGORY = "tweaks";
|
||||
/** The unlocalised name of the spells config category. */
|
||||
public static final String SPELLS_CATEGORY = "spells";
|
||||
/** The unlocalised name of the artefacts config category. */
|
||||
public static final String ARTEFACTS_CATEGORY = "artefacts";
|
||||
/** The unlocalised name of the resistances config category. */
|
||||
public static final String RESISTANCES_CATEGORY = "resistances";
|
||||
/** The unlocalised name of the client config category. */
|
||||
@@ -406,7 +410,7 @@ public final class Settings {
|
||||
|
||||
Wizardry.logger.info("Setting up main config");
|
||||
|
||||
setupGeneralConfig();
|
||||
setupGameplayConfig();
|
||||
setupDifficultyConfig();
|
||||
setupWorldgenConfig();
|
||||
setupTweaksConfig();
|
||||
@@ -425,11 +429,12 @@ public final class Settings {
|
||||
void initConfigExtras(){
|
||||
|
||||
Wizardry.logger.info("Setting up spells config for " + Spell.getTotalSpellCount() + " spells");
|
||||
|
||||
setupSpellsConfig();
|
||||
|
||||
Wizardry.logger.info("Setting up resistances config");
|
||||
Wizardry.logger.info("Setting up artefacts config");
|
||||
setupArtefactsConfig();
|
||||
|
||||
Wizardry.logger.info("Setting up resistances config");
|
||||
setupResistancesConfig();
|
||||
|
||||
config.save();
|
||||
@@ -440,7 +445,7 @@ public final class Settings {
|
||||
|
||||
Wizardry.logger.info("Saving in-game config changes");
|
||||
|
||||
setupGeneralConfig();
|
||||
setupGameplayConfig();
|
||||
setupDifficultyConfig();
|
||||
setupWorldgenConfig();
|
||||
setupTweaksConfig();
|
||||
@@ -448,6 +453,7 @@ public final class Settings {
|
||||
setupCommandsConfig();
|
||||
setupCompatibilityConfig();
|
||||
setupSpellsConfig();
|
||||
setupArtefactsConfig();
|
||||
setupResistancesConfig();
|
||||
|
||||
config.save();
|
||||
@@ -482,7 +488,27 @@ public final class Settings {
|
||||
|
||||
}
|
||||
|
||||
private void setupGeneralConfig(){
|
||||
private void setupArtefactsConfig(){
|
||||
|
||||
config.addCustomCategoryComment(ARTEFACTS_CATEGORY,
|
||||
"Set an item to false to disable it. Disabled items will still appear in-game but will have no effect when worn. It is also advisable to remove disabled items from wizardry's (and addons') loot tables. Disable an item if it is causing problems, conflicts with another mod or creates an unintended exploit.");
|
||||
|
||||
Property property;
|
||||
|
||||
for(Item item : Item.REGISTRY){
|
||||
if(item instanceof ItemArtefact){
|
||||
property = config.get(ARTEFACTS_CATEGORY, item.getRegistryName().toString(), true,
|
||||
"Set to false to disable this item");
|
||||
// Uses the same config key as the item name, because - well, that's what it's called!
|
||||
property.setLanguageKey(item.getTranslationKey() + ".name");
|
||||
Wizardry.proxy.setToNamedBooleanEntry(property);
|
||||
((ItemArtefact)item).setEnabled(property.getBoolean());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setupGameplayConfig(){
|
||||
|
||||
// This trick is borrowed from forge; it sorts the config options into the order you want them.
|
||||
List<String> propOrder = new ArrayList<>();
|
||||
|
||||
@@ -27,15 +27,16 @@ public class GuiConfigWizardry extends GuiConfig {
|
||||
|
||||
List<IConfigElement> configList = new ArrayList<>(1);
|
||||
|
||||
configList.add(new DummyCategoryElement("gameplayConfig", "config." + Wizardry.MODID + ".category." + Settings.GAMEPLAY_CATEGORY, GameplayCategory.class));
|
||||
configList.add(new DummyCategoryElement("difficultyConfig", "config." + Wizardry.MODID + ".category." + Settings.DIFFICULTY_CATEGORY, DifficultyCategory.class));
|
||||
configList.add(new DummyCategoryElement("worldgenConfig", "config." + Wizardry.MODID + ".category." + Settings.WORLDGEN_CATEGORY, WorldgenCategory.class));
|
||||
configList.add(new DummyCategoryElement("tweaksConfig", "config." + Wizardry.MODID + ".category." + Settings.TWEAKS_CATEGORY, TweaksCategory.class));
|
||||
configList.add(new DummyCategoryElement("commandsConfig", "config." + Wizardry.MODID + ".category." + Settings.COMMANDS_CATEGORY, CommandsCategory.class));
|
||||
configList.add(new DummyCategoryElement("clientConfig", "config." + Wizardry.MODID + ".category." + Settings.CLIENT_CATEGORY, ClientCategory.class));
|
||||
configList.add(new DummyCategoryElement("spellsConfig", "config." + Wizardry.MODID + ".category." + Settings.SPELLS_CATEGORY, SpellsCategory.class));
|
||||
configList.add(new DummyCategoryElement("resistancesConfig", "config." + Wizardry.MODID + ".category." + Settings.RESISTANCES_CATEGORY, ResistancesCategory.class));
|
||||
configList.add(new DummyCategoryElement("compatibilityConfig", "config." + Wizardry.MODID + ".category." + Settings.COMPATIBILITY_CATEGORY, CompatibilityCategory.class));
|
||||
configList.add(new DummyCategoryElement("gameplayConfig", "config." + Wizardry.MODID + ".category." + Settings.GAMEPLAY_CATEGORY, GameplayCategory.class));
|
||||
configList.add(new DummyCategoryElement("difficultyConfig", "config." + Wizardry.MODID + ".category." + Settings.DIFFICULTY_CATEGORY, DifficultyCategory.class));
|
||||
configList.add(new DummyCategoryElement("worldgenConfig", "config." + Wizardry.MODID + ".category." + Settings.WORLDGEN_CATEGORY, WorldgenCategory.class));
|
||||
configList.add(new DummyCategoryElement("tweaksConfig", "config." + Wizardry.MODID + ".category." + Settings.TWEAKS_CATEGORY, TweaksCategory.class));
|
||||
configList.add(new DummyCategoryElement("commandsConfig", "config." + Wizardry.MODID + ".category." + Settings.COMMANDS_CATEGORY, CommandsCategory.class));
|
||||
configList.add(new DummyCategoryElement("clientConfig", "config." + Wizardry.MODID + ".category." + Settings.CLIENT_CATEGORY, ClientCategory.class));
|
||||
configList.add(new DummyCategoryElement("spellsConfig", "config." + Wizardry.MODID + ".category." + Settings.SPELLS_CATEGORY, SpellsCategory.class));
|
||||
configList.add(new DummyCategoryElement("artefactsConfig", "config." + Wizardry.MODID + ".category." + Settings.ARTEFACTS_CATEGORY, ArtefactsCategory.class));
|
||||
configList.add(new DummyCategoryElement("resistancesConfig", "config." + Wizardry.MODID + ".category." + Settings.RESISTANCES_CATEGORY, ResistancesCategory.class));
|
||||
configList.add(new DummyCategoryElement("compatibilityConfig", "config." + Wizardry.MODID + ".category." + Settings.COMPATIBILITY_CATEGORY, CompatibilityCategory.class));
|
||||
|
||||
configList.addAll(new ConfigElement(Wizardry.settings.getConfigCategory(Configuration.CATEGORY_GENERAL)).getChildElements());
|
||||
|
||||
@@ -141,6 +142,16 @@ public class GuiConfigWizardry extends GuiConfig {
|
||||
@Override protected String getCategory() { return Settings.SPELLS_CATEGORY; }
|
||||
}
|
||||
|
||||
/** Artefacts category of the config gui. */
|
||||
public static class ArtefactsCategory extends CategoryBase {
|
||||
|
||||
public ArtefactsCategory(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop){
|
||||
super(owningScreen, owningEntryList, prop);
|
||||
}
|
||||
|
||||
@Override protected String getCategory() { return Settings.ARTEFACTS_CATEGORY; }
|
||||
}
|
||||
|
||||
/** Resistances category of the config gui. */
|
||||
public static class ResistancesCategory extends CategoryBase {
|
||||
|
||||
|
||||
+3
-1
@@ -65,7 +65,9 @@ public final class WizardryBaublesIntegration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of artefact stacks equipped of the given types.
|
||||
* Returns a list of artefact stacks equipped of the given types. <i>This method does not check whether artefacts
|
||||
* have been disabled in the config! {@link ItemArtefact#getActiveArtefacts(EntityPlayer, ItemArtefact.Type...)}
|
||||
* should be used instead of this method in nearly all cases.</i>
|
||||
* @param player The player whose inventory is to be checked.
|
||||
* @param types Zero or more artefact types to check for. If omitted, searches for all types.
|
||||
* @return A list of equipped artefact {@code ItemStacks}.
|
||||
|
||||
@@ -30,6 +30,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.Style;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
@@ -104,6 +106,9 @@ public class ItemArtefact extends Item {
|
||||
private final EnumRarity rarity;
|
||||
private final Type type;
|
||||
|
||||
/** False if this artefact has been disabled in the config, true otherwise. */
|
||||
private boolean enabled = true;
|
||||
|
||||
public ItemArtefact(EnumRarity rarity, Type type){
|
||||
setMaxStackSize(1);
|
||||
setCreativeTab(WizardryTabs.GEAR);
|
||||
@@ -111,6 +116,11 @@ public class ItemArtefact extends Item {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/** Sets whether this artefact is enabled or not. */
|
||||
public void setEnabled(boolean enabled){
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack stack){
|
||||
return rarity;
|
||||
@@ -127,8 +137,9 @@ public class ItemArtefact extends Item {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, net.minecraft.client.util.ITooltipFlag flagIn){
|
||||
public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, net.minecraft.client.util.ITooltipFlag advanced){
|
||||
Wizardry.proxy.addMultiLineDescription(tooltip, "item." + this.getRegistryName() + ".desc");
|
||||
if(!enabled) tooltip.add(Wizardry.proxy.translate("item." + Wizardry.MODID + ":generic.disabled", new Style().setColor(TextFormatting.RED)));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -161,6 +172,8 @@ public class ItemArtefact extends Item {
|
||||
|
||||
if(!(artefact instanceof ItemArtefact)) throw new IllegalArgumentException("Not an artefact!");
|
||||
|
||||
if(!((ItemArtefact)artefact).enabled) return false; // Disabled in the config
|
||||
|
||||
if(WizardryBaublesIntegration.enabled()){
|
||||
return WizardryBaublesIntegration.isBaubleEquipped(player, artefact);
|
||||
}else{
|
||||
@@ -192,7 +205,9 @@ public class ItemArtefact extends Item {
|
||||
if(types.length == 0) types = Type.values();
|
||||
|
||||
if(WizardryBaublesIntegration.enabled()){
|
||||
return WizardryBaublesIntegration.getEquippedArtefacts(player, types);
|
||||
List<ItemArtefact> artefacts = WizardryBaublesIntegration.getEquippedArtefacts(player, types);
|
||||
artefacts.removeIf(i -> !i.enabled); // Remove artefacts that are disabled in the config
|
||||
return artefacts;
|
||||
}else{
|
||||
|
||||
List<ItemArtefact> artefacts = new ArrayList<>();
|
||||
@@ -201,7 +216,7 @@ public class ItemArtefact extends Item {
|
||||
artefacts.addAll(WizardryUtilities.getPrioritisedHotbarAndOffhand(player).stream()
|
||||
.filter(s -> s.getItem() instanceof ItemArtefact)
|
||||
.map(s -> (ItemArtefact)s.getItem())
|
||||
.filter(i -> type == i.type)
|
||||
.filter(i -> type == i.type && i.enabled)
|
||||
.limit(type.maxAtOnce)
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@@ -257,6 +257,8 @@ item.ebwizardry\:spectral_boots.name=Spectral Boots
|
||||
|
||||
item.ebwizardry\:lightning_hammer.name=Lightning Hammer
|
||||
|
||||
item.ebwizardry\:generic.disabled=This item has been disabled in the config
|
||||
|
||||
item.ebwizardry\:ring.generic.desc=Equip this ring in the Baubles inventory or by placing it on your hotbar. Up to 2 rings may be equipped at once.
|
||||
item.ebwizardry\:amulet.generic.desc=Equip this amulet in the Baubles inventory or by placing it on your hotbar. Only one amulet may be equipped at a time.
|
||||
item.ebwizardry\:charm.generic.desc=Equip this charm in the Baubles inventory or by placing it on your hotbar. Only one charm may be equipped at a time.
|
||||
@@ -1146,6 +1148,11 @@ config.ebwizardry.category.spells.tooltip=Select which spells are enabled
|
||||
config.ebwizardry.title.spells=Spell Configuration
|
||||
config.ebwizardry.subtitle.spells=Disabling a spell globally here will override the finer controls in the spell JSON file.
|
||||
|
||||
config.ebwizardry.category.artefacts=Artefact Configuration
|
||||
config.ebwizardry.category.artefacts.tooltip=Select which artefacts are enabled
|
||||
config.ebwizardry.title.artefacts=Artefact Configuration
|
||||
config.ebwizardry.subtitle.artefacts=Disable individual rings, amulets or charms here.
|
||||
|
||||
config.ebwizardry.category.gameplay=Gameplay Settings
|
||||
config.ebwizardry.category.gameplay.tooltip=Configure wizardry's general gameplay
|
||||
config.ebwizardry.title.gameplay=Gameplay Settings
|
||||
|
||||
@@ -257,6 +257,8 @@ item.ebwizardry\:spectral_boots.name=Spectral Boots
|
||||
|
||||
item.ebwizardry\:lightning_hammer.name=Lightning Hammer
|
||||
|
||||
item.ebwizardry\:generic.disabled=This item has been disabled in the config
|
||||
|
||||
item.ebwizardry\:ring.generic.desc=Equip this ring in the Baubles inventory or by placing it on your hotbar. Up to 2 rings may be equipped at once.
|
||||
item.ebwizardry\:amulet.generic.desc=Equip this amulet in the Baubles inventory or by placing it on your hotbar. Only one amulet may be equipped at a time.
|
||||
item.ebwizardry\:charm.generic.desc=Equip this charm in the Baubles inventory or by placing it on your hotbar. Only one charm may be equipped at a time.
|
||||
@@ -1146,6 +1148,11 @@ config.ebwizardry.category.spells.tooltip=Select which spells are enabled
|
||||
config.ebwizardry.title.spells=Spell Configuration
|
||||
config.ebwizardry.subtitle.spells=Disabling a spell globally here will override the finer controls in the spell JSON file.
|
||||
|
||||
config.ebwizardry.category.artefacts=Artifact Configuration
|
||||
config.ebwizardry.category.artefacts.tooltip=Select which artifacts are enabled
|
||||
config.ebwizardry.title.artefacts=Artifact Configuration
|
||||
config.ebwizardry.subtitle.artefacts=Disable individual rings, amulets or charms here.
|
||||
|
||||
config.ebwizardry.category.gameplay=Gameplay Settings
|
||||
config.ebwizardry.category.gameplay.tooltip=Configure wizardry's general gameplay
|
||||
config.ebwizardry.title.gameplay=Gameplay Settings
|
||||
|
||||
Reference in New Issue
Block a user