This commit is contained in:
tterrag1098 committed 2015-01-07 00:40:48 -05:00
commit 086c80f79f
3 files changed
+59 -4

No files matched your search

@@ -17,7 +17,9 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.Facing;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
@@ -270,7 +272,7 @@ public class ItemSoulVessel extends Item implements IResourceTooltipProvider {
if(!containsSoul(item)) {
return null;
}
if(item == null || item.stackTagCompound == null || !item.stackTagCompound.hasKey("id")) {
if(item.stackTagCompound == null || !item.stackTagCompound.hasKey("id")) {
return null;
}
return item.stackTagCompound.getString("id");
@@ -281,12 +283,50 @@ public class ItemSoulVessel extends Item implements IResourceTooltipProvider {
if(!containsSoul(item)) {
return null;
}
if(item == null || item.stackTagCompound == null || !item.stackTagCompound.hasKey("FluidName")) {
if(!item.stackTagCompound.hasKey("FluidName")) {
return null;
}
return item.stackTagCompound.getString("FluidName");
}
public float getHealthFromStack(ItemStack item) {
if(!containsSoul(item)) {
return Float.NaN;
}
if(!item.stackTagCompound.hasKey("HealF")) {
return Float.NaN;
}
return item.stackTagCompound.getFloat("HealF");
}
public NBTTagCompound getAttributeFromStack(ItemStack item, String name) {
if(!containsSoul(item)) {
return null;
}
NBTBase tag = item.stackTagCompound.getTag("Attributes");
if(tag instanceof NBTTagList) {
NBTTagList attributes = (NBTTagList)tag;
for(int i=0 ; i<attributes.tagCount() ; i++) {
NBTTagCompound attrib = attributes.getCompoundTagAt(i);
if(attrib.hasKey("Name") && name.equals(attrib.getString("Name"))) {
return attrib;
}
}
}
return null;
}
public float getMaxHealthFromStack(ItemStack item) {
NBTTagCompound maxHealthAttrib = getAttributeFromStack(item, "generic.maxHealth");
if(maxHealthAttrib == null) {
return Float.NaN;
}
if(!maxHealthAttrib.hasKey("Base")) {
return Float.NaN;
}
return maxHealthAttrib.getFloat("Base");
}
private boolean isBlackListed(String entityId) {
for (String str : blackList) {
if(str != null && str.equals(entityId)) {
@@ -312,6 +352,17 @@ public class ItemSoulVessel extends Item implements IResourceTooltipProvider {
par3List.add("Empty");
}
float health = getHealthFromStack(par1ItemStack);
if(health >= 0) {
float maxHealth = getMaxHealthFromStack(par1ItemStack);
String msg = Lang.localize("item.itemSoulVessel.tooltip.health");
if(maxHealth >= 0) {
par3List.add(String.format("%s %3.1f/%3.1f", msg, health, maxHealth));
} else {
par3List.add(String.format("%s %3.1f", msg, health));
}
}
String fluidName = getFluidNameFromStack(par1ItemStack);
if(fluidName != null) {
Fluid fluid = FluidRegistry.getFluid(fluidName);
@@ -123,7 +123,10 @@ public class TileTank extends AbstractMachineEntity implements IFluidHandler {
if(!canFill(from)) {
return 0;
}
return fillInternal(resource, doFill);
}
private int fillInternal(FluidStack resource, boolean doFill) {
int res = tank.fill(resource, doFill);
if(res > 0 && doFill) {
tankDirty = true;
@@ -329,11 +332,11 @@ public class TileTank extends AbstractMachineEntity implements IFluidHandler {
}
}
int filled = fill(ForgeDirection.UP, fluid, false);
int filled = fillInternal(fluid, false);
if(filled < fluid.amount) {
return false; //can't empty the entire thing
}
fill(ForgeDirection.UP, fluid, true);
fillInternal(fluid, true);
fillFrom = fillFrom.copy();
fillFrom.stackSize--;