本文整理汇总了Java中net.minecraftforge.fluids.FluidContainerRegistry.isContainer方法的典型用法代码示例。如果您正苦于以下问题:Java FluidContainerRegistry.isContainer方法的具体用法?Java FluidContainerRegistry.isContainer怎么用?Java FluidContainerRegistry.isContainer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.fluids.FluidContainerRegistry
的用法示例。
在下文中一共展示了FluidContainerRegistry.isContainer方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyPlayerContainerInteraction
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
public static boolean applyPlayerContainerInteraction(final World world, final TileEntity entity, final EntityPlayer player) {
final ItemStack stack = player.getCurrentEquippedItem();
if(stack == null || !FluidContainerRegistry.isContainer(stack))
return false;
boolean update = false;
final IFluidHandler handler = (IFluidHandler)entity;
// Get the fluid from the item. If there is one they are trying
// to fill. Otherwise they are trying to remove.
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack);
if(liquid != null) {
update = FluidHelper.fillHandlerWithContainer(world, handler, player);
}
else {
liquid = handler.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid;
update = FluidHelper.fillContainerFromHandler(world, handler, player, liquid);
}
if(update)
world.markBlockForUpdate(entity.xCoord, entity.yCoord, entity.zCoord);
return update;
}
示例2: onBlockActivated
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
TileEntity tileEntity = worldIn.getTileEntity(pos);
if (tileEntity == null || playerIn.isSneaking()) {
return false;
}
if (worldIn.isRemote) {
return true;
}
ItemStack item = playerIn.getHeldItemMainhand();
if (item != null && FluidContainerRegistry.isContainer(item)) {
IFluidTankBlock te = (IFluidTankBlock) tileEntity;
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(item);
if (fluid != null && fluid.getFluid() == FluidRegistry.WATER) {
if (te.getTank().getFluidAmount() <= 0 && te.getTank().getCapacity() >= fluid.amount) {
// В пустой танк
te.getTank().setFluid(fluid);
FluidHelper.bucktDrain(playerIn, item, worldIn);
return true;
} else if (te.getTank().getFluid().getFluid().equals(fluid.getFluid())
&& (te.getTank().getFluidAmount() + fluid.amount) <= te.getTank().getCapacity()) {
//В не пустой танк
te.getTank().fill(fluid, true);
FluidHelper.bucktDrain(playerIn, item, worldIn);
tileEntity.markDirty();
return true;
} else {
return false;
}
}
}
playerIn.openGui(Nord.instance, 2, worldIn, pos.getX(), pos.getY(), pos.getZ());
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, heldItem, side, hitX, hitY, hitZ);
}
示例3: isItemValidForSlot
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
@Override
public boolean isItemValidForSlot(int slotID, ItemStack itemstack)
{
if(slotID == 0)
{
return FluidContainerRegistry.isContainer(itemstack);
}
return false;
}
示例4: isItemValidForSlot
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
@Override
public boolean isItemValidForSlot(int slot, ItemStack stack)
{
if (stack.getItem() instanceof ItemAdventureBackpack || Block.getBlockFromItem(stack.getItem()) instanceof BlockAdventureBackpack)
{
return false;
}
if (slot == 6 || slot == 8)
{
return FluidContainerRegistry.isContainer(stack);
}
return !(slot == 0 || slot == 3) || SlotTool.isValidTool(stack);
}
示例5: isItemValidForSlot
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
@Override
public boolean isItemValidForSlot(int slot, ItemStack stack)
{
if (stack.getItem() instanceof ItemAdventureBackpack || Block.getBlockFromItem(stack.getItem()) instanceof BlockAdventureBackpack)
{
return false;
}
if (slot == Constants.bucketInRight || slot == Constants.bucketInLeft)
{
return FluidContainerRegistry.isContainer(stack);
}
return !(slot == Constants.upperTool || slot == Constants.lowerTool) || SlotTool.isValidTool(stack);
}
示例6: canSmelt
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
/**
* Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't full, etc.
*/
private boolean canSmelt()
{
if (this.getFurnaceItemStack(0) == null)
{
return false;
}
else
{
ItemStack cur0 = this.getFurnaceItemStack(0);
ItemStack cur = this.getFurnaceItemStack(2);
FluidStack fluidstack = FluidHeatRecipes.heating().getHeatingResultF(cur0);
if (fluidstack == null) return false;
if (cur == null) return false;
if (FluidContainerRegistry.isContainer(cur) && (FluidContainerRegistry.isEmptyContainer(cur) || FluidContainerRegistry.containsFluid(cur, fluidstack))) return true;
if (cur0.getItem() instanceof IFluidContainerItem && cur.getItem() instanceof IFluidContainerItem)
{
FluidStack stack = ((IFluidContainerItem)cur0.getItem()).drain(cur0, 100, false);
if(stack != null && stack.amount == 100)
return true;
return false;
}
else if(cur.getItem() instanceof IFluidContainerItem)
{
return ((IFluidContainerItem)cur.getItem()).fill(cur0, fluidstack, false) != 0;
}
return false;
}
}
示例7: valid
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
public static boolean valid(ItemStack stack)
{
return ((stack != null) && (FluidContainerRegistry.isContainer(stack)));
}
示例8: isItemValid
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
@Override
public boolean isItemValid(ItemStack stack)
{
return ((stack != null) && (FluidContainerRegistry.isContainer(stack)));
}
示例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));
}
}
示例10: isPlayerHoldingFluidContainer
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
/**
* Determine if a player is holding a registered Fluid Container.
*/
public static final boolean isPlayerHoldingFluidContainer(EntityPlayer player) {
return FluidContainerRegistry.isContainer(player.getCurrentEquippedItem());
}
示例11: isItemValidForSlot
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
@Override
public boolean isItemValidForSlot(int slot, ItemStack item) {
if (slot == 3) return FluidContainerRegistry.isContainer(item);
return slot == 2 ? false : (slot == 1 ? getItemFreezeTime(item) > 0 : true);
}
示例12: canInsertItem
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
@Override
public boolean canInsertItem(int slot, ItemStack item, int side) {
return FluidContainerRegistry.isContainer(item) ? slot == 3 : slot == 1;
}
示例13: isItemValidForSlot
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack)
{
return FluidContainerRegistry.isContainer(itemstack) || (itemstack != null && itemstack.getItem() instanceof IFluidContainerItem && ((IFluidContainerItem) itemstack.getItem()).getFluid(itemstack) != null);
}
示例14: isValidContainer
import net.minecraftforge.fluids.FluidContainerRegistry; //导入方法依赖的package包/类
/**
* Test for any container type at all
* 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 boolean isValidContainer(ItemStack slotItem)
{
return slotItem != null && slotItem.stackSize == 1 && (slotItem.getItem() instanceof ItemCanisterGeneric || FluidContainerRegistry.isContainer(slotItem));
}