Add config option to change progression requirements
This commit is contained in:
@@ -310,6 +310,8 @@ public final class Settings {
|
||||
public boolean replaceVanillaFallDamage = true;
|
||||
/** <b>[Synchronised]</b> Chance of 'misreading' an undiscovered spell and triggering a forfeit instead. */
|
||||
public double forfeitChance = 0.2;
|
||||
/** <b>[Synchronised]</b> Progression requirements for upgrading a wand to each tier. */
|
||||
public int[] progressionRequirements = {1500, 3500, 6000};
|
||||
/**
|
||||
* <b>[Synchronised]</b> The maximum number of blocks a bookshelf can be from an arcane workbench or lectern to be
|
||||
* able to link to it.
|
||||
@@ -679,6 +681,13 @@ public final class Settings {
|
||||
forfeitChance = property.getDouble();
|
||||
propOrder.add(property.getName());
|
||||
|
||||
property = config.get(DIFFICULTY_CATEGORY, "progressionRequirements", new int[]{1500, 3500, 6000},
|
||||
"The amount of progression required to upgrade a wand to each tier (apprentice, advanced and master respectively).");
|
||||
property.setLanguageKey("config." + Wizardry.MODID + ".progression_requirements");
|
||||
property.setRequiresWorldRestart(true);
|
||||
progressionRequirements = property.getIntList();
|
||||
propOrder.add(property.getName());
|
||||
|
||||
// These two aren't sliders because using a slider makes it difficult to fine-tune the numbers; the nature of a
|
||||
// scaling factor means that 0.5 is as big a change as 2.0, so whilst a slider is fine for increasing the
|
||||
// damage, it doesn't give fine enough control for values less than 1.
|
||||
|
||||
@@ -718,7 +718,7 @@ public class GuiArcaneWorkbench extends GuiContainer {
|
||||
float progressFraction = 1;
|
||||
|
||||
if(tier != Tier.MASTER){
|
||||
progressFraction = (float)WandHelper.getProgression(stack) / Tier.values()[tier.level + 1].progression;
|
||||
progressFraction = (float)WandHelper.getProgression(stack) / Tier.values()[tier.level + 1].getProgression();
|
||||
}
|
||||
|
||||
DrawingUtils.drawTexturedRect(x, y, MAIN_GUI_WIDTH, ySize + PROGRESSION_BAR_HEIGHT, PROGRESSION_BAR_WIDTH, PROGRESSION_BAR_HEIGHT, TEXTURE_WIDTH, TEXTURE_HEIGHT);
|
||||
@@ -736,7 +736,7 @@ public class GuiArcaneWorkbench extends GuiContainer {
|
||||
if(tier != Tier.MASTER){
|
||||
Tier nextTier = Tier.values()[tier.level + 1];
|
||||
String s = TextFormatting.DARK_GRAY.toString() + nextTier.getDisplayName();
|
||||
if(WandHelper.getProgression(stack) >= nextTier.progression) s = nextTier.getDisplayNameWithFormatting();
|
||||
if(WandHelper.getProgression(stack) >= nextTier.getProgression()) s = nextTier.getDisplayNameWithFormatting();
|
||||
fontRenderer.drawStringWithShadow(s, x + TOOLTIP_WIDTH - TOOLTIP_BORDER * 2 - fontRenderer.getStringWidth(s), y, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,10 +10,10 @@ import java.util.Random;
|
||||
|
||||
public enum Tier {
|
||||
|
||||
NOVICE(700, 3, 12, 0, new Style().setColor(TextFormatting.WHITE), "novice"),
|
||||
APPRENTICE(1000, 5, 5, 1500, new Style().setColor(TextFormatting.AQUA), "apprentice"),
|
||||
ADVANCED(1500, 7, 2, 3500, new Style().setColor(TextFormatting.DARK_BLUE), "advanced"),
|
||||
MASTER(2500, 9, 1, 6000, new Style().setColor(TextFormatting.DARK_PURPLE), "master");
|
||||
NOVICE(700, 3, 12, new Style().setColor(TextFormatting.WHITE), "novice"),
|
||||
APPRENTICE(1000, 5, 5, new Style().setColor(TextFormatting.AQUA), "apprentice"),
|
||||
ADVANCED(1500, 7, 2, new Style().setColor(TextFormatting.DARK_BLUE), "advanced"),
|
||||
MASTER(2500, 9, 1, new Style().setColor(TextFormatting.DARK_PURPLE), "master");
|
||||
|
||||
/** Maximum mana a wand of this tier can store. */
|
||||
public final int maxCharge;
|
||||
@@ -23,20 +23,17 @@ public enum Tier {
|
||||
public final int upgradeLimit;
|
||||
/** The weight given to this tier in the standard weighting. */
|
||||
public final int weight;
|
||||
/** The progression required for a wand to be upgraded to this tier. */
|
||||
public final int progression;
|
||||
/** The colour of text associated with this tier. */
|
||||
// Changed to a Style object for consistency.
|
||||
private final Style colour;
|
||||
|
||||
private final String unlocalisedName;
|
||||
|
||||
Tier(int maxCharge, int upgradeLimit, int weight, int progression, Style colour, String name){
|
||||
Tier(int maxCharge, int upgradeLimit, int weight, Style colour, String name){
|
||||
this.maxCharge = maxCharge;
|
||||
this.level = ordinal();
|
||||
this.upgradeLimit = upgradeLimit;
|
||||
this.weight = weight;
|
||||
this.progression = progression;
|
||||
this.colour = colour;
|
||||
this.unlocalisedName = name;
|
||||
}
|
||||
@@ -96,6 +93,11 @@ public enum Tier {
|
||||
return colour.getFormattingCode();
|
||||
}
|
||||
|
||||
/** The progression required for a wand to be upgraded to this tier. */
|
||||
public int getProgression(){
|
||||
return Wizardry.settings.progressionRequirements[this.ordinal() - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a random tier based on the standard weighting. Currently, the standard weighting is: Basic (Novice) 60%,
|
||||
* Apprentice 25%, Advanced 10%, Master 5%. If an array of tiers is given, it picks a tier from the array, with the
|
||||
@@ -121,4 +123,5 @@ public enum Tier {
|
||||
// This will never happen, but it might as well be a sensible result.
|
||||
return tiers[tiers.length - 1];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ public class ItemWand extends Item implements IWorkbenchItem, ISpellCastingItem,
|
||||
@Override
|
||||
public boolean hasEffect(ItemStack stack){
|
||||
return !Wizardry.settings.legacyWandLevelling && this.tier.level < Tier.MASTER.level
|
||||
&& WandHelper.getProgression(stack) >= tier.next().progression;
|
||||
&& WandHelper.getProgression(stack) >= tier.next().getProgression();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -350,7 +350,7 @@ public class ItemWand extends Item implements IWorkbenchItem, ISpellCastingItem,
|
||||
this.getMana(stack), this.getManaCapacity(stack)));
|
||||
|
||||
text.add(Wizardry.proxy.translate("item." + Wizardry.MODID + ":wand.progression", new Style().setColor(TextFormatting.GRAY),
|
||||
WandHelper.getProgression(stack), this.tier.level < Tier.MASTER.level ? tier.next().progression : 0));
|
||||
WandHelper.getProgression(stack), this.tier.level < Tier.MASTER.level ? tier.next().getProgression() : 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -514,7 +514,7 @@ public class ItemWand extends Item implements IWorkbenchItem, ISpellCastingItem,
|
||||
if(!Wizardry.settings.legacyWandLevelling){ // Don't display the message if legacy wand levelling is enabled
|
||||
// If the wand just gained enough progression to be upgraded...
|
||||
Tier nextTier = tier.next();
|
||||
int excess = WandHelper.getProgression(stack) - nextTier.progression;
|
||||
int excess = WandHelper.getProgression(stack) - nextTier.getProgression();
|
||||
if(excess >= 0 && excess < progression){
|
||||
// ...display a message above the player's hotbar
|
||||
caster.playSound(WizardrySounds.ITEM_WAND_LEVELUP, 1.25f, 1);
|
||||
@@ -694,7 +694,7 @@ public class ItemWand extends Item implements IWorkbenchItem, ISpellCastingItem,
|
||||
// Checks the wand upgrade is for the tier above the wand's tier, and that either the wand has enough
|
||||
// progression or the player is in creative mode.
|
||||
if((player == null || player.isCreative() || Wizardry.settings.legacyWandLevelling
|
||||
|| WandHelper.getProgression(wand) >= tier.progression)
|
||||
|| WandHelper.getProgression(wand) >= tier.getProgression())
|
||||
&& tier == this.tier.next() && this.tier != Tier.MASTER){
|
||||
|
||||
if(Wizardry.settings.legacyWandLevelling){
|
||||
@@ -704,7 +704,7 @@ public class ItemWand extends Item implements IWorkbenchItem, ISpellCastingItem,
|
||||
WandHelper.setProgression(wand, 0);
|
||||
}else{
|
||||
// Carry excess progression over to the new stack
|
||||
WandHelper.setProgression(wand, WandHelper.getProgression(wand) - tier.progression);
|
||||
WandHelper.setProgression(wand, WandHelper.getProgression(wand) - tier.getProgression());
|
||||
}
|
||||
|
||||
if(player != null) WizardData.get(player).setTierReached(tier);
|
||||
|
||||
@@ -2,6 +2,7 @@ package electroblob.wizardry.packet;
|
||||
|
||||
import electroblob.wizardry.Settings;
|
||||
import electroblob.wizardry.Wizardry;
|
||||
import electroblob.wizardry.constants.Tier;
|
||||
import electroblob.wizardry.packet.PacketSyncSettings.Message;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -40,6 +41,7 @@ public class PacketSyncSettings implements IMessageHandler<Message, IMessage> {
|
||||
Wizardry.settings.replaceVanillaFireballs = message.settings.replaceVanillaFireballs;
|
||||
Wizardry.settings.replaceVanillaFallDamage = message.settings.replaceVanillaFallDamage;
|
||||
Wizardry.settings.forfeitChance = message.settings.forfeitChance;
|
||||
Wizardry.settings.progressionRequirements = message.settings.progressionRequirements;
|
||||
Wizardry.settings.bookshelfSearchRadius = message.settings.bookshelfSearchRadius;
|
||||
Wizardry.settings.bookshelfBlocks = message.settings.bookshelfBlocks;
|
||||
Wizardry.settings.bookItems = message.settings.bookItems;
|
||||
@@ -71,6 +73,8 @@ public class PacketSyncSettings implements IMessageHandler<Message, IMessage> {
|
||||
settings.replaceVanillaFireballs = buf.readBoolean();
|
||||
settings.replaceVanillaFallDamage = buf.readBoolean();
|
||||
settings.forfeitChance = buf.readFloat();
|
||||
settings.progressionRequirements = new int[Tier.values().length - 1];
|
||||
for(int i = 0; i < settings.progressionRequirements.length; i++) settings.progressionRequirements[i] = buf.readInt();
|
||||
settings.bookshelfSearchRadius = buf.readInt();
|
||||
settings.bookshelfBlocks = readMetaItems(buf);
|
||||
settings.bookItems = readMetaItems(buf);
|
||||
@@ -85,6 +89,7 @@ public class PacketSyncSettings implements IMessageHandler<Message, IMessage> {
|
||||
buf.writeBoolean(settings.replaceVanillaFireballs);
|
||||
buf.writeBoolean(settings.replaceVanillaFallDamage);
|
||||
buf.writeFloat((float)settings.forfeitChance); // Configs don't have floats but this can only be 0-1 anyway
|
||||
for(int i = 0; i < settings.progressionRequirements.length; i++) buf.writeInt(settings.progressionRequirements[i]);
|
||||
buf.writeInt(settings.bookshelfSearchRadius);
|
||||
writeMetaItems(buf, settings.bookshelfBlocks);
|
||||
writeMetaItems(buf, settings.bookItems);
|
||||
|
||||
Reference in New Issue
Block a user