diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java index 5d64915d5..4d3d4063f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java @@ -14,10 +14,15 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.mod.items.InitItems; import de.ellpeck.actuallyadditions.mod.items.ItemSolidifiedExperience; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; +import net.minecraft.entity.item.EntityXPOrb; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.AxisAlignedBB; + +import java.util.ArrayList; +import java.util.List; public class TileEntityXPSolidifier extends TileEntityInventoryBase implements IButtonReactor{ @@ -32,6 +37,7 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I private final int[] buttonAmounts = new int[]{1, 5, 10, 20, 30, 40, 50, 64, -999}; public int amount; private int lastAmount; + private int singlePointAmount; public TileEntityXPSolidifier(){ super(2, "xpSolidifier"); @@ -101,12 +107,14 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ super.writeSyncableNBT(compound, type); compound.setInteger("Amount", this.amount); + compound.setInteger("SinglePointAmount", this.singlePointAmount); } @Override public void readSyncableNBT(NBTTagCompound compound, NBTType type){ super.readSyncableNBT(compound, type); this.amount = compound.getInteger("Amount"); + this.singlePointAmount = compound.getInteger("SinglePointAmount"); } @Override @@ -126,6 +134,24 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I this.amount -= toAdd; } } + + if(!this.isRedstonePowered){ + int range = 5; + List orbs = this.worldObj.getEntitiesWithinAABB(EntityXPOrb.class, new AxisAlignedBB(this.pos.getX()-range, this.pos.getY()-range, this.pos.getZ()-range, this.pos.getX()+1+range, this.pos.getY()+1+range, this.pos.getZ()+1+range)); + if(orbs != null && !orbs.isEmpty()){ + for(EntityXPOrb orb : orbs){ + if(orb != null && !orb.isDead){ + this.singlePointAmount+=orb.getXpValue(); + orb.setDead(); + + if(this.singlePointAmount >= ItemSolidifiedExperience.SOLID_XP_AMOUNT){ + this.amount += this.singlePointAmount/ItemSolidifiedExperience.SOLID_XP_AMOUNT; + this.singlePointAmount = 0; + } + } + } + } + } if(this.slots[1] != null && this.slots[1].getItem() instanceof ItemSolidifiedExperience){ this.amount+=this.slots[1].stackSize; @@ -156,9 +182,10 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I @Override public void onButtonPressed(int buttonID, EntityPlayer player){ if(buttonID < this.buttonAmounts.length){ - if(getPlayerXP(player) > 0){ - int xp = this.buttonAmounts[buttonID] == -999 ? getPlayerXP(player)/ItemSolidifiedExperience.SOLID_XP_AMOUNT : this.buttonAmounts[buttonID]; - if(this.amount < Integer.MAX_VALUE-xp && getPlayerXP(player) >= ItemSolidifiedExperience.SOLID_XP_AMOUNT*xp){ + int playerXP = getPlayerXP(player); + if(playerXP > 0){ + int xp = this.buttonAmounts[buttonID] == -999 ? playerXP/ItemSolidifiedExperience.SOLID_XP_AMOUNT : this.buttonAmounts[buttonID]; + if(this.amount < Integer.MAX_VALUE-xp && playerXP >= ItemSolidifiedExperience.SOLID_XP_AMOUNT*xp){ addPlayerXP(player, -(ItemSolidifiedExperience.SOLID_XP_AMOUNT*xp)); if(!this.worldObj.isRemote){ this.amount += xp; diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index a7fa225b9..f58c0d935 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -793,7 +793,7 @@ booklet.actuallyadditions.chapter.esd.name=ESDs booklet.actuallyadditions.chapter.esd.text.1=The ESD is a block that works similar to a Hopper but has a lot more functionality. You can choose the sides to input and output and you can precisely configure the range of slots to look at! For more precise information about ESDs, craft one and hover over the elements in their GUI! Its actual name is booklet.actuallyadditions.chapter.xpSolidifier.name=Experience Solidifier -booklet.actuallyadditions.chapter.xpSolidifier.text.1=The Experience Solidifer uses the player's experience and turns it into Solidified Experience which can later be used by right-clicking to get the experience you stored into Item form back onto your character. This is a safe and easy way to store your experience so that it isn't getting lost when you die. Solidified Experience also drops from Monsters sometimes as an Extra. +booklet.actuallyadditions.chapter.xpSolidifier.text.1=The Experience Solidifer uses the player's experience and turns it into Solidified Experience which can later be used by right-clicking (or sneak-right-clicking!) to get the experience back. Additionally, you can put Solidified Experience into the solidifier, and, when not powered by redstone, it will pick up any XP Orbs that are on the ground nearby and turn them into Solidified Experience, provided it has enough stored up internally. Solidified Experience is also sometimes dropped from mobs. booklet.actuallyadditions.chapter.greenhouseGlass.name=Greenhouse Glass booklet.actuallyadditions.chapter.greenhouseGlass.text.1=Greenhouse Glass is a very effective way to speed up the growth of your plants! When placed anywhere above the plant, as long as there are no blocks below obstructing the path, and there is sunlight above the glass, it will significantly speed up the growth of the plant! It obviously has to be daytime, too. Thought that was obvious.