Made the XP solidifier pick up any XP orbs nearby

This commit is contained in:
Ellpeck 2016-08-12 22:02:20 +02:00
parent 7ca7ce6949
commit 80ad0c9543
2 changed files with 31 additions and 4 deletions

View file

@ -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<EntityXPOrb> 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;

View file

@ -793,7 +793,7 @@ booklet.actuallyadditions.chapter.esd.name=ESDs
booklet.actuallyadditions.chapter.esd.text.1=The <item>ESD<r> is a block that works <imp>similar to a Hopper<r> but has <imp>a lot more functionality<r>. <n>You can choose the sides to input and output and you can <imp>precisely configure<r> the range of slots to look at! <n>For more precise information about <item>ESDs<r>, craft one and <imp>hover over the elements in their GUI<r>! <n><n><i>Its actual name is
booklet.actuallyadditions.chapter.xpSolidifier.name=Experience Solidifier
booklet.actuallyadditions.chapter.xpSolidifier.text.1=The <item>Experience Solidifer<r> uses the player's experience and turns it into <item>Solidified Experience<r> which can later be used by <imp>right-clicking<r> to get the experience you stored into Item form back onto your character. <n>This is a safe and easy way to store your experience so that it isn't getting lost when you die. <n><item>Solidified Experience<r> also drops from Monsters sometimes as an Extra.
booklet.actuallyadditions.chapter.xpSolidifier.text.1=The <item>Experience Solidifer<r> uses the player's experience and turns it into <item>Solidified Experience<r> which can later be used by <imp>right-clicking<r> (or sneak-right-clicking!) to get the experience back. <n>Additionally, you can put <item>Solidified Experience<r> into the solidifier, and, when not powered by redstone, it will <imp>pick up any XP Orbs<r> that are on the ground nearby and turn them into <item>Solidified Experience<r>, provided it has enough stored up internally. <n><item>Solidified Experience<r> is also sometimes dropped from mobs.
booklet.actuallyadditions.chapter.greenhouseGlass.name=Greenhouse Glass
booklet.actuallyadditions.chapter.greenhouseGlass.text.1=<item>Greenhouse Glass<r> is a very effective way to <imp>speed up the growth of your plants<r>! 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 <imp>significantly speed up the growth of the plant<r>! <n>It obviously has to be daytime, too. Thought that was obvious.