本文整理匯總了Java中net.minecraftforge.fluids.FluidContainerRegistry.drainFluidContainer方法的典型用法代碼示例。如果您正苦於以下問題:Java FluidContainerRegistry.drainFluidContainer方法的具體用法?Java FluidContainerRegistry.drainFluidContainer怎麽用?Java FluidContainerRegistry.drainFluidContainer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraftforge.fluids.FluidContainerRegistry
的用法示例。
在下文中一共展示了FluidContainerRegistry.drainFluidContainer方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: placeBlock
import net.minecraftforge.fluids.FluidContainerRegistry; //導入方法依賴的package包/類
@Override
public void placeBlock(World world, int x, int y, int z, ForgeDirection direction, EntityPlayer player,
ItemStack placing, IToggleController controller) // TODO: Add storage item index as parameter?
{
if (FluidContainerRegistry.isFilledContainer(placing))
{
FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(placing);
Fluid fluid = fluidStack.getFluid();
if (fluidStack.getFluid().canBePlacedInWorld())
{
Block fluidBlock = fluid.getBlock();
world.setBlock(x, y, z, fluidBlock);
world.notifyBlockChange(x, y, z, fluidBlock);
fluidBlock.onBlockAdded(world, x, y, z);
ItemStack drainedContainer = FluidContainerRegistry.drainFluidContainer(placing);
placing.stackSize--;
controller.getStorageHandler().addItemStackToStorage(drainedContainer);
}
} else if (placing.getItem() instanceof ItemBucket)
{
ItemBucket item = (ItemBucket) placing.getItem();
item.tryPlaceContainedLiquid(world, x, y, z);
}
}
示例2: addLiquid
import net.minecraftforge.fluids.FluidContainerRegistry; //導入方法依賴的package包/類
public ItemStack addLiquid(ItemStack is)
{
if(is == null || is.stackSize > 1)
return is;
if(FluidContainerRegistry.isFilledContainer(is))
{
FluidStack fs = FluidContainerRegistry.getFluidForFilledItem(is);
if(addLiquid(fs))
{
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
return FluidContainerRegistry.drainFluidContainer(is);
}
}
else if(is.getItem() instanceof IFluidContainerItem)
{
FluidStack isfs = ((IFluidContainerItem) is.getItem()).getFluid(is);
if(isfs != null && addLiquid(isfs))
{
((IFluidContainerItem) is.getItem()).drain(is, is.getMaxDamage(), true);
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
return is;
}
示例3: useBucket
import net.minecraftforge.fluids.FluidContainerRegistry; //導入方法依賴的package包/類
private boolean useBucket( int slot, ItemStack stack) {
if(slot == 0 && FluidContainerRegistry.isFilledContainer(stack) && FuelRegistry.instance.isFuel(FuelType.LIQUID,FluidContainerRegistry.getFluidForFilledItem(stack).getFluid()) && tank.getFluidAmount() + FluidContainerRegistry.getContainerCapacity(stack) <= tank.getCapacity()) {
ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(stack);
if(emptyContainer != null && inventory.getStackInSlot(1) == null || (emptyContainer.isItemEqual(inventory.getStackInSlot(1)) && inventory.getStackInSlot(1).stackSize < inventory.getStackInSlot(1).getMaxStackSize())) {
tank.fill(FluidContainerRegistry.getFluidForFilledItem(stack), true);
if(inventory.getStackInSlot(1) == null)
super.setInventorySlotContents(1, emptyContainer);
else
inventory.getStackInSlot(1).stackSize++;
decrStackSize(0, 1);
}
else
return false;
}
else
return false;
return true;
}
示例4: drain
import net.minecraftforge.fluids.FluidContainerRegistry; //導入方法依賴的package包/類
@Nullable
@Override
public FluidStack drain(int maxDrain, boolean doDrain)
{
if (container.stackSize != 1)
{
return null;
}
FluidStack contained = FluidContainerRegistry.getFluidForFilledItem(container);
if (contained != null)
{
if (contained.amount <= maxDrain)
{
ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(container);
if (emptyContainer != null)
{
if (doDrain)
{
if (FluidContainerRegistry.hasNullEmptyContainer(container))
{
emptyContainer.stackSize = 0;
}
container.deserializeNBT(emptyContainer.serializeNBT());
}
return contained;
}
}
}
return null;
}
示例5: bucktDrain
import net.minecraftforge.fluids.FluidContainerRegistry; //導入方法依賴的package包/類
public static void bucktDrain(EntityPlayer playerIn, ItemStack item, World worldIn){
if (!playerIn.capabilities.isCreativeMode){
ItemStack newBucket = FluidContainerRegistry.drainFluidContainer(item);
if (item.stackSize == 1) {
playerIn.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, (ItemStack)newBucket);
} else {
item.stackSize--;
SpawnEntityHelper.spawnItemStack(worldIn,playerIn.getPosition(),newBucket);
}
}
}
示例6: drainFluidContainer
import net.minecraftforge.fluids.FluidContainerRegistry; //導入方法依賴的package包/類
public static ItemStack drainFluidContainer(ItemStack stackInSlot) {
if (stackInSlot.getItem() instanceof IFluidContainerItem) {
ItemStack working = stackInSlot.copy();
((IFluidContainerItem) stackInSlot.getItem()).drain(working, ((IFluidContainerItem) stackInSlot.getItem()).getCapacity(stackInSlot), true);
return working;
}
else {
return FluidContainerRegistry.drainFluidContainer(stackInSlot);
}
}
示例7: onBlockActivated
import net.minecraftforge.fluids.FluidContainerRegistry; //導入方法依賴的package包/類
@Override
public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState blockState, EntityPlayer player, EnumHand hand,
ItemStack stack, EnumFacing side, float hitX, float hitY, float hitZ) {
if (world.isRemote) return true;
else {
TileEntityLavaGenerator te = (TileEntityLavaGenerator) world.getTileEntity(blockPos);
if (te != null && player != null) {
// empty item fluid into fluid tank
FluidStack containerFluid = getFluidForItem(stack);
if (containerFluid == null || containerFluid.getFluid() == null || containerFluid.getFluid() != FluidRegistry.LAVA) {
return openGui(world, player, stack, blockPos.getX(), blockPos.getY(), blockPos.getZ());
}
if (te.fill(null, containerFluid, true) > 0 && !player.capabilities.isCreativeMode) {
ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(stack);
if (stack.stackSize-- <= 0) player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
if (player instanceof FakePlayer || !player.inventory.addItemStackToInventory(emptyContainer))
world.spawnEntityInWorld(new EntityItem(world, player.posX + 0.5D, player.posY + 1.5D, player.posZ + 0.5D, emptyContainer));
else if (player instanceof EntityPlayerMP) ((EntityPlayerMP) player).sendContainerToPlayer(player.inventoryContainer);
}
// ProjectZed.logHelper.info("Stored: " + ((TileEntityIndustrialCentrifuge) te).getTank().getFluidAmount());
}
}
return true;
}
示例8: onBlockActivated
import net.minecraftforge.fluids.FluidContainerRegistry; //導入方法依賴的package包/類
@Override
public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState blockState, EntityPlayer player, EnumHand hand, ItemStack stack,
EnumFacing side, float hitX, float hitY, float hitZ) {
// TODO: read through and clean-up this code!
if (world.isRemote) return true;
else {
TileEntityIndustrialCentrifuge te = (TileEntityIndustrialCentrifuge) world.getTileEntity(blockPos);
if (te != null && player != null) {
// empty item fluid into fluid tank
FluidStack containerFluid = getFluidForItem(stack);
if (containerFluid == null || containerFluid.getFluid() == null || containerFluid.getFluid() != FluidRegistry.WATER) {
return openGui(world, player, stack, blockPos.getX(), blockPos.getY(), blockPos.getZ());
}
if (te.fill(null, containerFluid, true) > 0 && !player.capabilities.isCreativeMode) {
ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(stack);
if (stack.stackSize-- <= 0) player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
if (player instanceof FakePlayer || !player.inventory.addItemStackToInventory(emptyContainer))
world.spawnEntityInWorld(new EntityItem(world, player.posX + 0.5D, player.posY + 1.5D, player.posZ + 0.5D, emptyContainer));
else if (player instanceof EntityPlayerMP) ((EntityPlayerMP) player).sendContainerToPlayer(player.inventoryContainer);
}
// ProjectZed.logHelper.info("Stored: " + ((TileEntityIndustrialCentrifuge) te).getTank().getFluidAmount());
}
}
return true;
}
示例9: addFinalValues
import net.minecraftforge.fluids.FluidContainerRegistry; //導入方法依賴的package包/類
private static void addFinalValues() {
// Fluid handling
for (Item item : GameData.getItemRegistry().typeSafeIterable()) {
LinkedList<ItemStack> subItems = Lists.newLinkedList();
try {
item.getSubItems(item, item.getCreativeTab(), subItems);
} catch (Exception ignore) {}
for (ItemStack itemStack : subItems) {
if (FluidContainerRegistry.isContainer(itemStack)) {
FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(itemStack);
ItemStack empty = FluidContainerRegistry.drainFluidContainer(itemStack);
if (fluidStack != null && empty != null) {
setEMC(itemStack, getEMC(empty) + getEMC(fluidStack.getFluid()));
}
}
}
}
// Stone brick handling
double stoneBrickEmc = getEMC(Blocks.stonebrick);
for (int i = 1; i < BlockStoneBrick.field_150141_b.length; i++) {
setEMC(new ItemStack(Blocks.stonebrick, 1, i), stoneBrickEmc);
}
// Anvil handling
double anvilEmc = getEMC(new ItemStack(Blocks.anvil, 1, 0));
setEMC(new ItemStack(Blocks.anvil, 1, 1), anvilEmc * 0.66D);
setEMC(new ItemStack(Blocks.anvil, 1, 2), anvilEmc * 0.33D);
// Name tag
double string = getEMC(Items.string);
double paper = getEMC(Items.paper);
setEMC(Items.name_tag, string + paper);
if (Loader.isModLoaded("Thaumcraft")) {
setEMC(GameRegistry.findItem("Thaumcraft", "ItemThaumonomicon"), getEMC(Blocks.bookshelf));
}
}