mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-21 20:52:42 +00:00
#1311 XP Obelisk keeps taking player XP once max level reached
This commit is contained in:
1 parent
462ddc056f
commit
f7d04bf3c0
2 files changed
+11
-16
No files matched your search
@@ -7,19 +7,13 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.gui.IconButtonEIO;
|
||||
import crazypants.enderio.gui.IconEIO;
|
||||
import crazypants.enderio.machine.GuiMachineBase;
|
||||
import crazypants.enderio.machine.spawner.ContainerPoweredSpawner;
|
||||
import crazypants.enderio.machine.spawner.TilePoweredSpawner;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.xp.ExperienceBarRenderer;
|
||||
import crazypants.enderio.xp.PacketDrainPlayerXP;
|
||||
import crazypants.enderio.xp.PacketGivePlayerXP;
|
||||
import crazypants.enderio.xp.XpUtil;
|
||||
import crazypants.render.RenderUtil;
|
||||
|
||||
public class GuiExperianceObelisk extends GuiMachineBase {
|
||||
@@ -119,7 +113,7 @@ public class GuiExperianceObelisk extends GuiMachineBase {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(levels < 0) {
|
||||
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
@@ -145,7 +139,7 @@ public class GuiExperianceObelisk extends GuiMachineBase {
|
||||
int sx = (width - xSize) / 2;
|
||||
int sy = (height - ySize) / 2;
|
||||
|
||||
drawTexturedModalRect(sx, sy, 0, 0, this.xSize, this.ySize);
|
||||
drawTexturedModalRect(sx, sy, 0, 0, xSize, ySize);
|
||||
|
||||
int width = 110;
|
||||
ExperienceBarRenderer.render(this, getGuiLeft() + xSize/2 - width/2, getGuiTop() + 55, width, te.getContainer());
|
||||
|
||||
@@ -6,10 +6,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.config.Config;
|
||||
|
||||
public class ExperienceContainer {
|
||||
|
||||
@@ -57,7 +55,7 @@ public class ExperienceContainer {
|
||||
experience = xpCon.experience;
|
||||
}
|
||||
|
||||
public void addExperience(int xpToAdd) {
|
||||
public int addExperience(int xpToAdd) {
|
||||
int j = maxXp - experienceTotal;
|
||||
if(xpToAdd > j) {
|
||||
xpToAdd = j;
|
||||
@@ -65,11 +63,12 @@ public class ExperienceContainer {
|
||||
|
||||
experience += (float) xpToAdd / (float) getXpBarCapacity();
|
||||
experienceTotal += xpToAdd;
|
||||
for (; experience >= 1.0F; experience /= (float) getXpBarCapacity()) {
|
||||
experience = (experience - 1.0F) * (float) getXpBarCapacity();
|
||||
for (; experience >= 1.0F; experience /= getXpBarCapacity()) {
|
||||
experience = (experience - 1.0F) * getXpBarCapacity();
|
||||
experienceLevel++;
|
||||
}
|
||||
xpDirty = true;
|
||||
return xpToAdd;
|
||||
}
|
||||
|
||||
private int getXpBarCapacity() {
|
||||
@@ -117,12 +116,14 @@ public class ExperienceContainer {
|
||||
|
||||
public void drainPlayerXpToReachPlayerLevel(EntityPlayer player, int level) {
|
||||
int targetXP = XpUtil.getExperienceForLevel(level);
|
||||
int drainXP = XpUtil.getPlayerXP(player) - targetXP ;
|
||||
int drainXP = XpUtil.getPlayerXP(player) - targetXP;
|
||||
if(drainXP <= 0) {
|
||||
return;
|
||||
}
|
||||
addExperience(drainXP);
|
||||
XpUtil.addPlayerXP(player, -drainXP);
|
||||
drainXP = addExperience(drainXP);
|
||||
if(drainXP > 0) {
|
||||
XpUtil.addPlayerXP(player, -drainXP);
|
||||
}
|
||||
}
|
||||
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
|
||||
Reference in new issue
Block a user