當前位置: 首頁>>代碼示例>>Java>>正文


Java FluidContainerRegistry.isFilledContainer方法代碼示例

本文整理匯總了Java中net.minecraftforge.fluids.FluidContainerRegistry.isFilledContainer方法的典型用法代碼示例。如果您正苦於以下問題:Java FluidContainerRegistry.isFilledContainer方法的具體用法?Java FluidContainerRegistry.isFilledContainer怎麽用?Java FluidContainerRegistry.isFilledContainer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraftforge.fluids.FluidContainerRegistry的用法示例。


在下文中一共展示了FluidContainerRegistry.isFilledContainer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getUsedContainer

import net.minecraftforge.fluids.FluidContainerRegistry; //導入方法依賴的package包/類
/**
 * Returns the used (empty) container, for example an empty bucket
 * Used, for example, in isItemValidForSlot() logic
 * @param slotItem
 * @return  True if it is a container; False if it is null or not a container 
 */
public static ItemStack getUsedContainer(ItemStack container)
{
       if (FluidContainerRegistry.isBucket(container) && FluidContainerRegistry.isFilledContainer(container))
       {
           return new ItemStack(Items.bucket, container.stackSize);
       }
       else
       {
           container.stackSize--;

           if (container.stackSize == 0)
           {
               return null;
           }
           
           return container;
       }
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:25,代碼來源:FluidUtil.java

示例2: 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);
    }
}
 
開發者ID:MrSpring,項目名稱:ToggleBlocks,代碼行數:25,代碼來源:BucketToggleAction.java

示例3: isItemValidForSlot

import net.minecraftforge.fluids.FluidContainerRegistry; //導入方法依賴的package包/類
@Override
public boolean isItemValidForSlot(int slotID, ItemStack itemstack)
{
	if(slotID == 1)
	{
		return false;
	}
	else if(slotID == 0)
	{
		return FluidContainerRegistry.isFilledContainer(itemstack);
	}
	else if(slotID == 2)
	{
		return ChargeUtils.canBeDischarged(itemstack);
	}

	return false;
}
 
開發者ID:Microsoft,項目名稱:vsminecraft,代碼行數:19,代碼來源:TileEntityFluidicPlenisher.java

示例4: 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;
}
 
開發者ID:StrayWolfe,項目名稱:Cooking-with-TFC,代碼行數:26,代碼來源:TileCookingPot.java

示例5: 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;
}
 
開發者ID:zmaster587,項目名稱:AdvancedRocketry,代碼行數:22,代碼來源:TileEntityFuelingStation.java

示例6: setInventorySlotContents

import net.minecraftforge.fluids.FluidContainerRegistry; //導入方法依賴的package包/類
@Override
public void setInventorySlotContents(int slot, ItemStack stack)
{
    inventory[slot] = stack;
    if (stack != null && stack.stackSize > getInventoryStackLimit())
    {
        stack.stackSize = getInventoryStackLimit();
    }
    if(FluidContainerRegistry.isFilledContainer(stack) && GeneralReference.isValidFuel(FluidContainerRegistry.getFluidForFilledItem(stack).getFluid()))
    {
        InventoryActions.transferContainerTank(this, fuelTank, 0);
    }else
    if(FluidContainerRegistry.isEmptyContainer(stack) && fuelTank.getFluid()!=null && FluidUtils.isContainerForFluid(stack, fuelTank.getFluid().getFluid()))
    {
        InventoryActions.transferContainerTank(this, fuelTank, 0);
    }
    dirtyTanks();
    dirtyInventory();
}
 
開發者ID:Darkona,項目名稱:AdventureBackpack2,代碼行數:20,代碼來源:InventoryCopterPack.java

示例7: onInventoryChanged

import net.minecraftforge.fluids.FluidContainerRegistry; //導入方法依賴的package包/類
public void onInventoryChanged()
{
    for (int i = 0; i < inventory.length; i++)
    {
        if (i == 0)
        {
            ItemStack container = getStackInSlot(i);
            if(FluidContainerRegistry.isFilledContainer(container) && FluidUtils.isContainerForFluid(container, FluidRegistry.WATER))
            {
                InventoryActions.transferContainerTank(this, waterTank, i);
            }else
            if(FluidContainerRegistry.isEmptyContainer(container) && waterTank.getFluid()!=null && FluidUtils.isContainerForFluid(container, FluidRegistry.WATER))
            {
                InventoryActions.transferContainerTank(this, waterTank, i);
            }
        }
    }
    markDirty();
}
 
開發者ID:Darkona,項目名稱:AdventureBackpack2,代碼行數:20,代碼來源:InventorySteamJetpack.java

示例8: isItemValidForSlot

import net.minecraftforge.fluids.FluidContainerRegistry; //導入方法依賴的package包/類
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack)
{
	if (gridTE != null)
	{
		ICraftingPattern currentPattern = Util.getAssemblerPattern(itemstack);
		if (currentPattern == null || currentPattern.getRequirements() == null)
			return false;
		if (FluidContainerRegistry.isEmptyContainer(currentPattern.getOutput()))
			return false;

		for (ItemStack entry : currentPattern.getRequirements())
		{
			if (entry != null && entry.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isFilledContainer(entry))
			{
				return doesRecipeExist((ICraftingPatternMAC) currentPattern);
			}
		}
	}
	return false;
}
 
開發者ID:ExtraCells,項目名稱:ExtraCells1,代碼行數:22,代碼來源:ECPrivatePatternInventory.java

示例9: isItemValid

import net.minecraftforge.fluids.FluidContainerRegistry; //導入方法依賴的package包/類
@Override
public boolean isItemValid(ItemStack s) {
    if (s == null)
        return true;

    if (FluidContainerRegistry.isFilledContainer(s))
        return true;

    Block b = Block.getBlockFromItem(s.getItem());

    if (b == Blocks.air)
        return false;

    return true;
}
 
開發者ID:enhancedportals,項目名稱:enhancedportals,代碼行數:16,代碼來源:GuiTexturePortal.java

示例10: loadUsageRecipes

import net.minecraftforge.fluids.FluidContainerRegistry; //導入方法依賴的package包/類
@Override
public void loadUsageRecipes(ItemStack ingredient) {
	for(IRecipe irecipe : RecipesMachine.getInstance().getRecipes(getMachine())) {
		CachedMachineRecipe recipe = new CachedMachineRecipe((((Recipe)irecipe).getRecipeAsAllItemsOnly()));
		boolean match = false;
		
		for(PositionedStack posStack : recipe.getIngredients()) {
			if(posStack.item.isItemEqual(ingredient) || ZUtils.areOresSameTypeOreDict(posStack.item, ingredient)) {
				recipe.setIngredientPermutation(recipe.ingredients, ingredient);
				arecipes.add(recipe);
				match = true;
				break;
			}
		}
		
		if(!match && (FluidContainerRegistry.isFilledContainer(ingredient) || ingredient.getItem() instanceof IFluidContainerItem || 
				(Block.getBlockFromItem(ingredient.getItem()) != Blocks.air && FluidRegistry.lookupFluidForBlock(Block.getBlockFromItem(ingredient.getItem())) != null  ))) {
			
			FluidStack fluidStack = null;
			
			if(ingredient.getItem() instanceof IFluidContainerItem)
				fluidStack  = ((IFluidContainerItem)ingredient.getItem()).getFluid(ingredient);
			else if(FluidContainerRegistry.isFilledContainer(ingredient) && FluidContainerRegistry.isFilledContainer(ingredient))
				fluidStack = FluidContainerRegistry.getFluidForFilledItem(ingredient);
			
			for(FluidStack stack : ((Recipe)irecipe).getFluidIngredients() ) {
				if((fluidStack != null && fluidStack.getFluid() == stack.getFluid()) ||
						(Block.getBlockFromItem(ingredient.getItem()) != Blocks.air && FluidRegistry.lookupFluidForBlock(Block.getBlockFromItem(ingredient.getItem())) == stack.getFluid() )) {
					recipe.setIngredientPermutation(recipe.ingredients, ingredient);
					arecipes.add(recipe);
					break;
				}
			}
		}
	}
}
 
開發者ID:zmaster587,項目名稱:AdvancedRocketry,代碼行數:37,代碼來源:TemplateNEI.java

示例11: interactFirst

import net.minecraftforge.fluids.FluidContainerRegistry; //導入方法依賴的package包/類
@Override
public boolean interactFirst(EntityPlayer player)
   {
	if(!player.worldObj.isRemote)
	{
		if(player.getCurrentEquippedItem() != null)
		  {
			  if(FluidContainerRegistry.isFilledContainer(player.getCurrentEquippedItem()))
			  {
					  this.tank.fill(FluidContainerRegistry.getFluidForFilledItem(player.getCurrentEquippedItem()), true);
					  if(!player.capabilities.isCreativeMode)
					  {
						  player.inventory.consumeInventoryItem(player.getCurrentEquippedItem().getItem());
						  player.inventory.addItemStackToInventory(new ItemStack(Items.bucket, 1));
					  }
				  }
			  
			  if(FluidContainerRegistry.isEmptyContainer(player.getCurrentEquippedItem()))
			  {
					  if(this.tank.getFluidAmount() > 0 && this.tank.getFluid().getFluid()!= AdvancedUtilitiesBlocks.fluidSteam)
					  {
						  player.inventory.addItemStackToInventory(FluidContainerRegistry.fillFluidContainer(this.tank.drain(FluidContainerRegistry.BUCKET_VOLUME, true), player.getCurrentEquippedItem()));
						  if(!player.capabilities.isCreativeMode)
						  {
							  player.inventory.getCurrentItem().stackSize-=1;
							  if(player.inventory.getCurrentItem().stackSize <= 0)
							  {
								  player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
							  }
						  }
					  }
				  }
			  }
		if(tank.getFluidAmount() > 0)
			player.addChatComponentMessage(new ChatComponentText("Fluid: "+tank.getFluid().getFluid().getName()+" Amount: "+tank.getFluidAmount()+" mB"));
		else
			player.addChatComponentMessage(new ChatComponentText("Empty"));
	}
	return true;
   }
 
開發者ID:Sudwood,項目名稱:AdvancedUtilities,代碼行數:41,代碼來源:EntitySpeedyChunkTankCart.java

示例12: isFilledContainer

import net.minecraftforge.fluids.FluidContainerRegistry; //導入方法依賴的package包/類
public static boolean isFilledContainer(ItemStack stackInSlot) {
    if (stackInSlot.getItem() instanceof IFluidContainerItem) {
        FluidStack fluidStack = ((IFluidContainerItem) stackInSlot.getItem()).getFluid(stackInSlot);
        if (fluidStack != null) {
            return true;
        }
        else {
            return false;
        }
    }
    else {
        return FluidContainerRegistry.isFilledContainer(stackInSlot);
    }

}
 
開發者ID:TeamDmfMM,項目名稱:Extra-Food,代碼行數:16,代碼來源:FluidContainerRegistryHelper.java

示例13: clickItemStack

import net.minecraftforge.fluids.FluidContainerRegistry; //導入方法依賴的package包/類
public ItemStack clickItemStack(final int par1, ItemStack item) {
    if (item != null) {
        item = item.copy();
        item.stackSize = 1;
    }
    final String keyname = "items_" + par1;
    final ItemStack filter = this.player.inventory.getStackInSlot(this.currentFilter);
    if (filter == null) {
        return item;
    }
    NBTTagCompound tags = filter.getTagCompound();
    if (item != null) {
        if (tags == null) {
            tags = new NBTTagCompound();
        }
        if (tags.hasKey(keyname)) {
            if (FluidContainerRegistry.isFilledContainer(item) && ItemStack.areItemStacksEqual(ItemStack.loadItemStackFromNBT(tags.getCompoundTag(keyname)), item)) {
                final NBTTagCompound fluidTags = new NBTTagCompound();
                if (tags.hasKey("isLiquid_" + par1)) {
                    tags.removeTag("isLiquid_" + par1);
                }
                else {
                    tags.setBoolean("isLiquid_" + par1, true);
                }
                return item;
            }
            if (tags.hasKey("isLiquid_" + par1)) {
                tags.removeTag("isLiquid_" + par1);
            }
            tags.removeTag(keyname);
        }
        else if (tags.hasKey("isLiquid_" + par1)) {
            tags.removeTag("isLiquid_" + par1);
        }
        final NBTTagCompound itemTags = new NBTTagCompound();
        item.writeToNBT(itemTags);
        tags.setTag(keyname, (NBTBase)itemTags);
        filter.setTagCompound(tags);
    }
    else if (tags != null) {
        if (tags.hasKey("isLiquid_" + par1)) {
            tags.removeTag("isLiquid_" + par1);
        }
        tags.removeTag(keyname);
        if (tags.hasNoTags()) {
            filter.setTagCompound((NBTTagCompound)null);
        }
        else {
            filter.setTagCompound(tags);
        }
    }
    return item;
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:54,代碼來源:ContainerFilter.java

示例14: onTooltip

import net.minecraftforge.fluids.FluidContainerRegistry; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onTooltip(ItemTooltipEvent event){
    if((ConfigHandler.requiresF3plusH && event.showAdvancedItemTooltips) || !ConfigHandler.requiresF3plusH){
        if((ConfigHandler.requiresCtrl && MiscUtil.isCtrlPressed()) || !ConfigHandler.requiresCtrl){
            event.toolTip.add(EnumChatFormatting.GOLD.toString() + "Unlocalized name: " + EnumChatFormatting.GRAY.toString() + event.itemStack.getItem().getUnlocalizedName());

            //GameRegistry stuff
            if(ConfigHandler.showGameRegistryNames) {
                if (GameRegistry.findUniqueIdentifierFor(event.itemStack.getItem()) != null) {
                    event.toolTip.add(EnumChatFormatting.DARK_AQUA.toString() + "GameRegistry name: " + EnumChatFormatting.GRAY.toString() + GameRegistry.findUniqueIdentifierFor(event.itemStack.getItem()).name);
                    event.toolTip.add(EnumChatFormatting.DARK_AQUA.toString() + "Mod ID: " + EnumChatFormatting.GRAY.toString() + GameRegistry.findUniqueIdentifierFor(event.itemStack.getItem()).modId);
                } else {
                    event.toolTip.add(EnumChatFormatting.RED.toString() + "Uh oh. It looks like this item has not");
                    event.toolTip.add(EnumChatFormatting.RED.toString() + "been registered. This is a bug!");
                }
            }

            //FluidRegistry stuff
            if(ConfigHandler.showFluidRegistryNames) {
                if (FluidContainerRegistry.isFilledContainer(event.itemStack)) {
                    event.toolTip.add(EnumChatFormatting.AQUA.toString() + "FluidRegistry name: " + EnumChatFormatting.GRAY.toString() + FluidRegistry.getFluidName(FluidContainerRegistry.getFluidForFilledItem(event.itemStack)));
                } else if (event.itemStack.getItem() instanceof ItemBlock) {
                    if (FluidRegistry.lookupFluidForBlock(Block.getBlockFromItem(event.itemStack.getItem())) != null)
                        event.toolTip.add(EnumChatFormatting.AQUA.toString() + "FluidRegistry name: " + EnumChatFormatting.GRAY.toString() + FluidRegistry.lookupFluidForBlock(Block.getBlockFromItem(event.itemStack.getItem())).getName());
                }
            }

            //Classes
            if(ConfigHandler.showClassNames) {
                event.toolTip.add(EnumChatFormatting.DARK_PURPLE.toString() + "Item class name: " + EnumChatFormatting.GRAY.toString() + event.itemStack.getItem().getClass().getCanonicalName());
                if (event.itemStack.getItem() instanceof ItemBlock) {
                    event.toolTip.add(EnumChatFormatting.DARK_PURPLE.toString() + "Block class name: " + EnumChatFormatting.GRAY.toString() + Block.getBlockFromItem(event.itemStack.getItem()).getClass().getCanonicalName());
                }
            }

            //OreDictionary stuff
            if(ConfigHandler.showOreDictNames) {
                if (OreDictionary.getOreIDs(event.itemStack).length != 0) {
                    event.toolTip.add(EnumChatFormatting.DARK_GREEN.toString() + "OreDictionary names:");
                    for (int id : OreDictionary.getOreIDs(event.itemStack)) {
                        event.toolTip.add("  " + OreDictionary.getOreName(id));
                    }
                }
            }
        }else{
            event.toolTip.add(EnumChatFormatting.DARK_GRAY.toString() + event.itemStack.getItem().getUnlocalizedName());
            event.toolTip.add("Hold Ctrl for more info");
        }
    }
}
 
開發者ID:goldenapple3,項目名稱:DevTooltips,代碼行數:51,代碼來源:TooltipHandler.java

示例15: canPlaceBlock

import net.minecraftforge.fluids.FluidContainerRegistry; //導入方法依賴的package包/類
@Override
    public boolean canPlaceBlock(World world, int x, int y, int z, ItemStack placing, IToggleController controller)
    {
        return FluidContainerRegistry.isFilledContainer(placing) || placing.getItem() instanceof ItemBucket;
//        return placing.getItem() instanceof ItemBucket && placing.getItem() != Items.bucket;
    }
 
開發者ID:MrSpring,項目名稱:ToggleBlocks,代碼行數:7,代碼來源:BucketToggleAction.java


注:本文中的net.minecraftforge.fluids.FluidContainerRegistry.isFilledContainer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。