mirror of
https://github.com/GTNewHorizons/ThaumicTinkerer.git
synced 2026-10-26 14:33:48 +00:00
Implemented the Experience Drain focus.
This commit is contained in:
1 parent
b0b2cd9949
commit
a62ecac0eb
4 files changed
+103
-4
No files matched your search
@@ -0,0 +1,43 @@
|
||||
package vazkii.tinkerer.common.core.helper;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
// From OpenBlocksLib: https://github.com/OpenMods/OpenModsLib
|
||||
public class ExperienceHelper {
|
||||
|
||||
public static int getPlayerXP(EntityPlayer player) {
|
||||
return (int)(getExperienceForLevel(player.experienceLevel) + (player.experience * player.xpBarCap()));
|
||||
}
|
||||
|
||||
public static void drainPlayerXP(EntityPlayer player, int amount) {
|
||||
addPlayerXP(player, -amount);
|
||||
}
|
||||
|
||||
public static void addPlayerXP(EntityPlayer player, int amount) {
|
||||
int experience = getPlayerXP(player) + amount;
|
||||
player.experienceTotal = experience;
|
||||
player.experienceLevel = getLevelForExperience(experience);
|
||||
int expForLevel = getExperienceForLevel(player.experienceLevel);
|
||||
player.experience = (float)(experience - expForLevel) / (float)player.xpBarCap();
|
||||
}
|
||||
|
||||
public static int getExperienceForLevel(int level) {
|
||||
if (level == 0) { return 0; }
|
||||
if (level > 0 && level < 16) {
|
||||
return level * 17;
|
||||
} else if (level > 15 && level < 31) {
|
||||
return (int)(1.5 * Math.pow(level, 2) - 29.5 * level + 360);
|
||||
} else {
|
||||
return (int)(3.5 * Math.pow(level, 2) - 151.5 * level + 2220);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getLevelForExperience(int experience) {
|
||||
int i = 0;
|
||||
while (getExperienceForLevel(i) <= experience) {
|
||||
i++;
|
||||
}
|
||||
return i - 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -70,7 +70,7 @@ public abstract class ItemModFocus extends ItemMod implements IWandFocus {
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
|
||||
AspectList cost = getVisCost();
|
||||
if(cost != null && cost.size() > 0) {
|
||||
if(cost != null) {
|
||||
list.add(StatCollector.translateToLocal(isVisCostPerTick() ? "item.Focus.cost2" : "item.Focus.cost1"));
|
||||
addVisCostTooltip(cost, stack, player, list, par4);
|
||||
}
|
||||
|
||||
@@ -1,25 +1,71 @@
|
||||
package vazkii.tinkerer.common.item.kami.foci;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.common.config.Config;
|
||||
import thaumcraft.common.items.wands.ItemWandCasting;
|
||||
import vazkii.tinkerer.client.core.helper.ClientHelper;
|
||||
import vazkii.tinkerer.client.core.proxy.TTClientProxy;
|
||||
import vazkii.tinkerer.common.core.helper.ExperienceHelper;
|
||||
import vazkii.tinkerer.common.item.foci.ItemModFocus;
|
||||
|
||||
public class ItemFocusXPDrain extends ItemModFocus {
|
||||
|
||||
AspectList cost = new AspectList();
|
||||
final int xpUse = 10;
|
||||
private int lastGiven = 0;
|
||||
|
||||
public ItemFocusXPDrain(int par1) {
|
||||
super(par1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisCostPerTick() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUsingFocusTick(ItemStack paramItemStack, EntityPlayer paramEntityPlayer, int paramInt) {
|
||||
if(paramEntityPlayer.worldObj.isRemote)
|
||||
return;
|
||||
|
||||
ItemWandCasting wand = (ItemWandCasting) paramItemStack.getItem();
|
||||
AspectList aspects = wand.getAllVis(paramItemStack);
|
||||
|
||||
Aspect aspectToAdd = null;
|
||||
int takes = 0;
|
||||
|
||||
while(aspectToAdd == null) {
|
||||
lastGiven = lastGiven == 5 ? 0 : lastGiven + 1;
|
||||
|
||||
Aspect aspect = Aspect.getPrimalAspects().get(lastGiven);
|
||||
|
||||
if(aspects.getAmount(aspect) < wand.getMaxVis(paramItemStack))
|
||||
aspectToAdd = aspect;
|
||||
|
||||
++takes;
|
||||
if(takes == 7)
|
||||
return;
|
||||
}
|
||||
|
||||
int xpUse = getXpUse(paramItemStack);
|
||||
if(paramEntityPlayer.experienceTotal >= xpUse) {
|
||||
ExperienceHelper.drainPlayerXP(paramEntityPlayer, xpUse);
|
||||
wand.storeVis(paramItemStack, aspectToAdd, wand.getVis(paramItemStack, aspectToAdd) + 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int getColorFromItemStack(ItemStack par1ItemStack, int par2) {
|
||||
return getFocusColor();
|
||||
@@ -31,9 +77,13 @@ public class ItemFocusXPDrain extends ItemModFocus {
|
||||
return Color.HSBtoRGB((player.ticksExisted * 2 % 360) / 360F, 1F, 1F);
|
||||
}
|
||||
|
||||
int getXpUse(ItemStack stack) {
|
||||
return 30 - EnchantmentHelper.getEnchantmentLevel(Config.enchFrugal.effectId, stack) * 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addVisCostTooltip(AspectList cost, ItemStack stack, EntityPlayer player, List list, boolean par4) {
|
||||
list.add(String.format(StatCollector.translateToLocal("ttmisc.focusXPDrain.tooltip"), xpUse));
|
||||
list.add(" " + EnumChatFormatting.WHITE + String.format(StatCollector.translateToLocal("ttmisc.focusXPDrain.tooltip"), getXpUse(stack)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -41,6 +91,11 @@ public class ItemFocusXPDrain extends ItemModFocus {
|
||||
return cost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack par1ItemStack) {
|
||||
return TTClientProxy.kamiRarity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsEnchant(int paramInt) {
|
||||
return paramInt == Config.enchFrugal.effectId;
|
||||
|
||||
@@ -46,7 +46,7 @@ ttmisc.mode.axe.2=Tree Mode
|
||||
ttmisc.mode.sword.0=Single Mode
|
||||
ttmisc.mode.sword.1=Area Mode
|
||||
ttmisc.mode.sword.2=Soul Mode
|
||||
ttmisc.focusXPDrain.tooltip=%s XP per tick
|
||||
ttmisc.focusXPDrain.tooltip=Experience x %s
|
||||
|
||||
# ITEM NAMES
|
||||
item.ttinkerer:darkQuartz.name=Smokey Quartz
|
||||
@@ -102,6 +102,7 @@ item.ttinkerer:ichorPouch.name=Bottomless Pouch
|
||||
item.ttinkerer:blockTalisman.name=Black Hole Talisman
|
||||
item.ttinkerer:placementMirror.name=Worldshaper's Looking Glass
|
||||
item.ttinkerer:focusShadowbeam.name=Wand Focus: Shadowbeam
|
||||
item.ttinkerer:focusXpDrain.name=Wand Focus: Experience Drain
|
||||
|
||||
# BLOCK NAMES
|
||||
tile.ttinkerer:darkQuartz.name=Block of Smokey Quartz
|
||||
|
||||
Reference in new issue
Block a user