use of net.minecraftforge.liquids.LiquidStack in project MineFactoryReloaded by powercrystals.
the class MFRLiquidMover method manuallyFillTank.
/**
* Attempts to fill tank with the player's current item.
* @param itcb the tank the liquid is going into
* @param entityplayer the player trying to fill the tank
* @return True if liquid was transferred to the tank.
*/
public static boolean manuallyFillTank(ITankContainerBucketable itcb, EntityPlayer entityplayer) {
ItemStack ci = entityplayer.inventory.getCurrentItem();
LiquidStack liquid = LiquidContainerRegistry.getLiquidForFilledItem(ci);
if (liquid != null) {
if (itcb.fill(ForgeDirection.UNKNOWN, liquid, false) == liquid.amount) {
itcb.fill(ForgeDirection.UNKNOWN, liquid, true);
if (!entityplayer.capabilities.isCreativeMode) {
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, UtilInventory.consumeItem(ci));
}
return true;
}
}
return false;
}
use of net.minecraftforge.liquids.LiquidStack in project MineFactoryReloaded by powercrystals.
the class MFRLiquidMover method manuallyDrainTank.
/**
* Attempts to drain tank into the player's current item.
* @param itcb the tank the liquid is coming from
* @param entityplayer the player trying to take liquid from the tank
* @return True if liquid was transferred from the tank.
*/
public static boolean manuallyDrainTank(ITankContainerBucketable itcb, EntityPlayer entityplayer) {
ItemStack ci = entityplayer.inventory.getCurrentItem();
if (LiquidContainerRegistry.isEmptyContainer(ci)) {
for (ILiquidTank tank : itcb.getTanks(ForgeDirection.UNKNOWN)) {
LiquidStack tankLiquid = tank.getLiquid();
ItemStack filledBucket = LiquidContainerRegistry.fillLiquidContainer(tankLiquid, ci);
if (LiquidContainerRegistry.isFilledContainer(filledBucket)) {
LiquidStack bucketLiquid = LiquidContainerRegistry.getLiquidForFilledItem(filledBucket);
if (entityplayer.capabilities.isCreativeMode) {
tank.drain(bucketLiquid.amount, true);
return true;
} else if (ci.stackSize == 1) {
tank.drain(bucketLiquid.amount, true);
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, filledBucket);
return true;
} else if (entityplayer.inventory.addItemStackToInventory(filledBucket)) {
tank.drain(bucketLiquid.amount, true);
ci.stackSize -= 1;
return true;
}
}
}
}
return false;
}
use of net.minecraftforge.liquids.LiquidStack in project MineFactoryReloaded by powercrystals.
the class GuiLiquiCrafter method drawGuiContainerForegroundLayer.
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
fontRenderer.drawString("Template", 67, 27, 4210752);
fontRenderer.drawString("Output", 128, 26, 4210752);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
for (int i = 0; i < 9; i++) {
LiquidStack l = _crafter.getTanks(ForgeDirection.UNKNOWN)[i].getLiquid();
if (l != null) {
drawTank(-50 + (i % 3 * 18), 43 + (i / 3 * 35), l.itemID, l.itemMeta, l.amount * 33 / _crafter.getTanks(ForgeDirection.UNKNOWN)[i].getCapacity());
}
}
this.mc.renderEngine.bindTexture(MineFactoryReloadedCore.guiFolder + "liquicrafter.png");
for (int i = 0; i < 8; i++) {
this.drawTexturedModalRect(-50 + (i % 3 * 18), 10 + (i / 3 * 35), 232, 0, 16, 33);
}
}
use of net.minecraftforge.liquids.LiquidStack in project MineFactoryReloaded by powercrystals.
the class ContainerLiquiCrafter method detectAndSendChanges.
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
int tankIndex = (int) (_crafter.worldObj.getWorldTime() % 9);
ILiquidTank tank = _crafter.getTanks(ForgeDirection.UNKNOWN)[tankIndex];
LiquidStack l = tank.getLiquid();
for (int i = 0; i < crafters.size(); i++) {
((ICrafting) crafters.get(i)).sendProgressBarUpdate(this, 0, tankIndex);
if (l != null) {
((ICrafting) crafters.get(i)).sendProgressBarUpdate(this, 1, l.itemID);
((ICrafting) crafters.get(i)).sendProgressBarUpdate(this, 2, l.itemMeta);
((ICrafting) crafters.get(i)).sendProgressBarUpdate(this, 3, l.amount);
} else {
((ICrafting) crafters.get(i)).sendProgressBarUpdate(this, 1, 0);
((ICrafting) crafters.get(i)).sendProgressBarUpdate(this, 2, 0);
((ICrafting) crafters.get(i)).sendProgressBarUpdate(this, 3, 0);
}
}
}
use of net.minecraftforge.liquids.LiquidStack in project MineFactoryReloaded by powercrystals.
the class ItemFactoryCup method getItemDisplayName.
@Override
public String getItemDisplayName(ItemStack item) {
int id = item.getItemDamage();
if (id != 0) {
String ret = getFluidName(item), t = getLocalizedName(ret);
if (t != null && !t.isEmpty())
return EnumChatFormatting.RESET + t + EnumChatFormatting.RESET;
if (ret == null) {
item.setItemDamage(0);
return super.getItemDisplayName(item);
}
LiquidStack liquid = LiquidDictionary.getLiquid(ret, 0);
if (liquid != null) {
ItemStack q = liquid.asItemStack();
Item temp = Item.itemsList[q.itemID];
if (temp != null)
ret = temp.getItemDisplayName(q);
}
_prefix = true;
t = super.getItemDisplayName(item);
_prefix = false;
t = t != null ? t.trim() : "";
ret = (t.isEmpty() ? "" : t + " ") + ret;
t = super.getItemDisplayName(item);
t = t != null ? t.trim() : "";
ret += t.isEmpty() ? " Cup" : " " + t;
return ret;
}
return super.getItemDisplayName(item);
}
Aggregations