本文整理汇总了Java中net.minecraftforge.fluids.FluidContainerRegistry.getFluidForFilledItem方法的典型用法代码示例。如果您正苦于以下问题:Java FluidContainerRegistry.getFluidForFilledItem方法的具体用法?Java FluidContainerRegistry.getFluidForFilledItem怎么用?Java FluidContainerRegistry.getFluidForFilledItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.fluids.FluidContainerRegistry
的用法示例。
在下文中一共展示了FluidContainerRegistry.getFluidForFilledItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drain
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
@Nullable
@Override
public FluidStack drain(FluidStack resource, boolean doDrain)
{
if (container.stackSize != 1 || resource == null)
{
return null;
}
FluidStack contained = FluidContainerRegistry.getFluidForFilledItem(container);
if (contained != null && contained.isFluidEqual(resource))
{
return drain(resource.amount, doDrain);
}
return null;
}
示例2: getFuelBurn
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
@Override
public double getFuelBurn(final ItemStack item) {
if (item != null) {
if (item.getItem() == Items.ender_pearl) {
return 750.0;
}
if (item.getItem() == Items.ender_eye) {
return 3000.0;
}
if (item.getItem() == Item.getItemFromBlock((Block)ExtraUtils.enderLily)) {
return 12000.0;
}
final FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(item);
if (fluid != null && "ender".equals(fluid.getFluid().getName())) {
return fluid.amount * 6;
}
}
return 0.0;
}
示例3: onBlockActivated
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
public boolean onBlockActivated(final World worldObj, final int x, final int y, final int z, final EntityPlayer player, final int side, final float dx, final float dy, final float dz) {
if (worldObj.isRemote) {
return true;
}
final TileEntity tile = worldObj.getTileEntity(x, y, z);
if (player.getCurrentEquippedItem() != null && tile instanceof IFluidHandler) {
final ItemStack item = player.getCurrentEquippedItem();
final FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(item);
if (fluid != null && ((IFluidHandler)tile).fill(ForgeDirection.getOrientation(side), fluid, false) == fluid.amount) {
((IFluidHandler)tile).fill(ForgeDirection.getOrientation(side), fluid, true);
if (!player.capabilities.isCreativeMode) {
player.setCurrentItemOrArmor(0, item.getItem().getContainerItem(item));
}
return true;
}
}
player.openGui((Object)ExtraUtilsMod.instance, 0, worldObj, x, y, z);
return true;
}
示例4: getOveride
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
public List<String> getOveride(final ItemStack par1ItemStack, final int par2, final int par3) {
int j1 = 0;
while (j1 < this.inventorySlots.inventorySlots.size()) {
final Slot slot = (Slot) this.inventorySlots.inventorySlots.get(j1);
if (slot instanceof SlotGhostItemContainer && slot.getHasStack()) {
if (!this.func_146978_c(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, par2, par3) || !slot.func_111238_b()) {
return null;
}
final ItemStack filter = this.player.inventory.getStackInSlot(this.currentFilter);
if (filter != null && filter.hasTagCompound() && filter.getTagCompound().hasKey("isLiquid_" + slot.slotNumber)) {
final FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(slot.getStack());
final List t = new ArrayList();
t.add(XUHelper.getFluidName(liquid));
return (List<String>)t;
}
return null;
}
else {
++j1;
}
}
return null;
}
示例5: fillTankWithContainer
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
public static boolean fillTankWithContainer(IFluidHandler tank, EntityPlayer player)
{
ItemStack stack = player.getCurrentEquippedItem();
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack);
if(liquid == null)
return false;
if(tank.fill(ForgeDirection.UNKNOWN, liquid, false) != liquid.amount && !player.capabilities.isCreativeMode)
return false;
tank.fill(ForgeDirection.UNKNOWN, liquid, true);
if(!player.capabilities.isCreativeMode)
InventoryUtils.consumeItem(player.inventory, player.inventory.currentItem);
player.inventoryContainer.detectAndSendChanges();
return true;
}
示例6: isMachineItemValidForSlot
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
@Override
protected boolean isMachineItemValidForSlot(int i, @Nullable ItemStack item) {
if (i == 0 && item != null) {
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(item);
if (fluid != null) {
return isValidFluid(fluid);
}
if (item.getItem() == Items.water_bucket) {
return true;
}
if (item.getItem() == Items.lava_bucket) {
return true;
}
if (item.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem) item.getItem()).getFluid(item) != null) {
return isValidFluid(((IFluidContainerItem) item.getItem()).getFluid(item));
}
return false;
}
return false;
}
示例7: 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);
}
}
示例8: renderItem
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
// ====================== Render item texture ======================
FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(item);
int color = fluidStack.getFluid().getColor();
IIcon fluidIcon = item.getIconIndex();
IIcon bucketIcon = Items.bucket.getIconIndex(new ItemStack(Items.bucket));
if(type == ItemRenderType.INVENTORY) {
GL11.glEnable(GL11.GL_ALPHA_TEST);
RenderItem.getInstance().renderIcon(0, 0, bucketIcon, 16, 16);
GL11.glColor3ub((byte)((color >>> 16) & 0xFF), (byte)((color >>> 8) & 0xFF), (byte)(color & 0xFF));
RenderItem.getInstance().renderIcon(0, 0, fluidIcon, 16, 16);
GL11.glColor3f(1f, 1f, 1f);
}
else {
ItemRenderer.renderItemIn2D(Tessellator.instance, ((IIcon)bucketIcon).getMinU(), ((IIcon)bucketIcon).getMinV(), ((IIcon)bucketIcon).getMaxU(), ((IIcon)bucketIcon).getMaxV(), ((IIcon)bucketIcon).getIconWidth(), ((IIcon)bucketIcon).getIconHeight(), 0.1f);
GL11.glColor3ub((byte)((color >>> 16) & 0xFF), (byte)((color >>> 8) & 0xFF), (byte)(color & 0xFF));
ItemRenderer.renderItemIn2D(Tessellator.instance, ((IIcon)fluidIcon).getMinU(), ((IIcon)fluidIcon).getMinV(), ((IIcon)fluidIcon).getMaxU(), ((IIcon)fluidIcon).getMaxV(), ((IIcon)fluidIcon).getIconWidth(), ((IIcon)fluidIcon).getIconHeight(), 0.1f);
GL11.glColor3f(1f, 1f, 1f);
}
}
示例9: isItemFuel
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
@Override
protected boolean isItemFuel(ItemStack itemstack) {
FluidStack containedFluid = null;
if(itemstack.getItem() instanceof IFluidContainerItem) {
containedFluid = ((IFluidContainerItem)itemstack.getItem()).getFluid(itemstack);
}
if(containedFluid == null) {
containedFluid = FluidContainerRegistry.getFluidForFilledItem(itemstack);
}
if(containedFluid != null) {
if(containedFluid.getFluid() == fuel) {
return true;
}
return FluidUtil.testFuel(FluidRegistry.getFluidName(containedFluid));
}
return false;
}
示例10: isItemValidForSlot
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
@Override
public boolean isItemValidForSlot(int slotID, ItemStack itemstack) {
if(itemstack == null) return false;
switch(slotID) {
case 0:
FluidStack containedFluid = FluidContainerRegistry.getFluidForFilledItem(itemstack);
if(containedFluid != null && containedFluid.getFluid() == fuel) {
return true;
}
break;
case 1:
return ItemElectricBase.isElectricItem(itemstack.getItem());
}
return false;
// return (slotID == 0 && itemstack != null && itemstack.getItem() == GCItems.fuelCanister);
}
示例11: getResultFluid
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
@Override
public FluidStack getResultFluid(ItemStack inIS, FluidStack inFS, int sealedTime)
{
if(recipeOutFluid != null)
{
FluidStack fs = recipeOutFluid.copy();
FluidStack itemLiquid = FluidContainerRegistry.getFluidForFilledItem(inIS);
if(!removesLiquid)
{
fs.amount = inFS.amount+itemLiquid.amount;
}
else
{
fs.amount = ( fs.amount * inFS.amount ) / recipeFluid.amount;
}
return fs;
}
return null;
}
示例12: 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;
}
示例13: loadUsageRecipes
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
@Override
public void loadUsageRecipes(ItemStack ingredient)
{
for (CookingPotRecipe recipe : recipeList)
{
if(recipe != null)
{
CachedCookingPotRecipe crecipe = new CachedCookingPotRecipe(recipe);
if(crecipe.contains(crecipe.Ingredients, ingredient))
arecipes.add(crecipe);
FluidStack inputFluid = recipe.getInputFluid();
FluidStack fluidstack = FluidContainerRegistry.getFluidForFilledItem(ingredient);
if (inputFluid != null && inputFluid.isFluidEqual(fluidstack))
arecipes.add(crecipe);
}
}
}
示例14: fillHandlerWithContainer
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
public static boolean fillHandlerWithContainer(World world, IFluidHandler handler, EntityPlayer player) {
ItemStack container = player.getCurrentEquippedItem();
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(container);
if (fluid != null) {
if (handler.fill(ForgeDirection.UNKNOWN, fluid, false) == fluid.amount || player.capabilities.isCreativeMode) {
if (ServerHelper.isClientWorld(world)) {
return true;
}
handler.fill(ForgeDirection.UNKNOWN, fluid, true);
if (!player.capabilities.isCreativeMode) {
player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemHelper.consumeItem(container));
}
return true;
}
}
return false;
}
示例15: matches
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
@Override
public boolean matches(ItemStack subject) {
FluidStack fs = FluidContainerRegistry.getFluidForFilledItem(subject);
if (fs == null && subject.getItem() instanceof IFluidContainerItem) {
IFluidContainerItem item = (IFluidContainerItem)subject.getItem();
fs = item.getFluid(subject);
}
// match amount precisely to avoid having to deal with leftover
return fs == null && fluid == null ||
fs != null && fs.getFluid() == fluid && fs.amount >= amount;
}