use of net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData in project ArsMagica2 by Mithion.
the class AMCore method postInit.
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
//Register Flicker Operators
registerFlickerOperators();
proxy.setCompendiumSaveBase(compendiumBase);
proxy.postinit();
if (config.retroactiveWorldgen()) {
LogHelper.info("Retroactive Worldgen is enabled");
}
FluidContainerRegistry.registerFluidContainer(new FluidContainerData(FluidRegistry.getFluidStack(BlockLiquidEssence.liquidEssenceFluid.getName(), FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(ItemsCommonProxy.itemAMBucket), FluidContainerRegistry.EMPTY_BUCKET));
SeventhSanctum.instance.init();
/*if (Loader.isModLoaded("BetterDungeons"))
BetterDungeons.init();*/
if (Loader.isModLoaded("Thaumcraft"))
TC4Interop.initialize();
/*if (Loader.isModLoaded("MineFactoryReloaded"))
MFRInterop.init();*/
}
use of net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData in project PneumaticCraft by MineMaarten.
the class TileEntityBase method processFluidItem.
protected void processFluidItem(int inputSlot, int outputSlot) {
IInventory inv = (IInventory) this;
IFluidHandler fluidHandler = (IFluidHandler) this;
FluidTankInfo tankInfo = fluidHandler.getTankInfo(ForgeDirection.UNKNOWN)[0];
if (inv.getStackInSlot(inputSlot) != null) {
ItemStack fluidContainer = inv.getStackInSlot(inputSlot);
if (tankInfo.fluid == null || tankInfo.fluid.isFluidEqual(fluidContainer)) {
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(fluidContainer);
int amount = FluidContainerRegistry.BUCKET_VOLUME;
if (fluid == null) {
if (fluidContainer.getItem() instanceof IFluidContainerItem) {
IFluidContainerItem containerItem = (IFluidContainerItem) fluidContainer.getItem();
fluid = containerItem.getFluid(fluidContainer);
if (fluid != null && fluidHandler.canFill(ForgeDirection.UNKNOWN, fluid.getFluid())) {
amount = fluid != null ? fluid.amount : 0;
int availableSpace = tankInfo.capacity - (tankInfo.fluid != null ? tankInfo.fluid.amount : 0);
if (availableSpace >= amount) {
ItemStack singleFuelItem = fluidContainer.copy();
singleFuelItem.stackSize = 1;
FluidStack drainedStack = containerItem.drain(singleFuelItem, availableSpace, true);
if (fluidContainer.stackSize == 1 || inv.getStackInSlot(outputSlot) == null || canStack(singleFuelItem, inv.getStackInSlot(outputSlot))) {
fluidHandler.fill(ForgeDirection.UNKNOWN, drainedStack, true);
if (fluidContainer.stackSize == 1) {
inv.setInventorySlotContents(inputSlot, singleFuelItem);
} else {
inv.getStackInSlot(inputSlot).stackSize--;
if (inv.getStackInSlot(outputSlot) == null) {
inv.setInventorySlotContents(outputSlot, singleFuelItem);
} else {
inv.getStackInSlot(outputSlot).stackSize++;
}
}
}
}
}
}
} else if (fluidHandler.canFill(ForgeDirection.UNKNOWN, fluid.getFluid())) {
if (tankInfo.capacity - (tankInfo.fluid != null ? tankInfo.fluid.amount : 0) >= amount) {
ItemStack returnedItem = null;
FluidContainerData[] allFluidData = FluidContainerRegistry.getRegisteredFluidContainerData();
for (FluidContainerData fluidData : allFluidData) {
if (fluidData.filledContainer.isItemEqual(fluidContainer)) {
returnedItem = fluidData.emptyContainer;
break;
}
}
if (returnedItem == null || inv.getStackInSlot(outputSlot) == null || canStack(returnedItem, inv.getStackInSlot(outputSlot))) {
if (returnedItem != null) {
if (inv.getStackInSlot(outputSlot) == null) {
inv.setInventorySlotContents(outputSlot, returnedItem.copy());
} else {
inv.getStackInSlot(outputSlot).stackSize += returnedItem.stackSize;
}
}
fluidHandler.fill(ForgeDirection.UNKNOWN, new FluidStack(fluid.getFluid(), amount, fluid.tag), true);
inv.getStackInSlot(inputSlot).stackSize--;
if (inv.getStackInSlot(inputSlot).stackSize <= 0)
inv.setInventorySlotContents(inputSlot, null);
}
}
}
}
if (fluidContainer.getItem() instanceof IFluidContainerItem) {
if (((IFluidContainerItem) fluidContainer.getItem()).getFluid(fluidContainer) == null && (inv.getStackInSlot(outputSlot) == null || canStack(fluidContainer, inv.getStackInSlot(outputSlot)))) {
if (inv.getStackInSlot(outputSlot) == null) {
inv.setInventorySlotContents(outputSlot, fluidContainer);
} else {
inv.getStackInSlot(outputSlot).stackSize += fluidContainer.stackSize;
}
inv.setInventorySlotContents(inputSlot, null);
}
}
}
}
use of net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData in project PneumaticCraft by MineMaarten.
the class FluidUtils method tryInsertingLiquid.
public static boolean tryInsertingLiquid(TileEntity te, ItemStack liquidContainer, boolean creative, List<ItemStack> returnedItems) {
if (te instanceof IFluidHandler) {
IFluidHandler fluidHandler = (IFluidHandler) te;
if (liquidContainer != null) {
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(liquidContainer);
if (fluid != null) {
fluid.amount = 1000;
if (fluidHandler.canFill(ForgeDirection.UNKNOWN, fluid.getFluid()) && fluidHandler.fill(ForgeDirection.UNKNOWN, fluid, false) == 1000) {
fluidHandler.fill(ForgeDirection.UNKNOWN, fluid, true);
if (!creative) {
liquidContainer.stackSize--;
ItemStack returnedItem = null;
FluidContainerData[] allFluidData = FluidContainerRegistry.getRegisteredFluidContainerData();
for (FluidContainerData fluidData : allFluidData) {
if (fluidData.filledContainer.isItemEqual(liquidContainer)) {
returnedItem = fluidData.emptyContainer;
break;
}
}
if (returnedItem != null) {
returnedItems.add(returnedItem.copy());
}
}
return true;
}
} else if (liquidContainer.getItem() instanceof IFluidContainerItem) {
IFluidContainerItem container = (IFluidContainerItem) liquidContainer.getItem();
fluid = container.getFluid(liquidContainer);
if (fluid != null) {
fluid = fluid.copy();
if (fluidHandler.canFill(ForgeDirection.UNKNOWN, fluid.getFluid()) && fluidHandler.fill(ForgeDirection.UNKNOWN, fluid, false) == fluid.amount) {
ItemStack returnedItem = liquidContainer.copy();
returnedItem.stackSize = 1;
container.drain(returnedItem, fluid.amount, true);
fluidHandler.fill(ForgeDirection.UNKNOWN, fluid, true);
if (!creative) {
liquidContainer.stackSize--;
returnedItems.add(returnedItem.copy());
}
return true;
}
}
}
}
}
return false;
}
use of net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData in project Railcraft by Railcraft.
the class FluidTools method registerContainer.
public static boolean registerContainer(FluidStack fluidStack, ItemStack filled, @Nullable ItemStack empty) {
if (!InvTools.isEmpty(empty)) {
FluidContainerData container = new FluidContainerData(fluidStack, filled, empty);
registerContainer(container);
return true;
}
return false;
}
Aggregations