本文整理匯總了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;
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
}
}
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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");
}
}
}
示例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;
}