本文整理匯總了Java中net.minecraftforge.fluids.FluidContainerRegistry.isBucket方法的典型用法代碼示例。如果您正苦於以下問題:Java FluidContainerRegistry.isBucket方法的具體用法?Java FluidContainerRegistry.isBucket怎麽用?Java FluidContainerRegistry.isBucket使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraftforge.fluids.FluidContainerRegistry
的用法示例。
在下文中一共展示了FluidContainerRegistry.isBucket方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: onBlockActivated
import net.minecraftforge.fluids.FluidContainerRegistry; //導入方法依賴的package包/類
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
if (world.isRemote)
{
return true;
}
int meta = world.getBlockMetadata(x,y,z);
switch (meta) {
default:
ItemStack held = player.getHeldItem();
FluidStack fluidHeld = FluidContainerRegistry.getFluidForFilledItem(held);
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (fluidHeld != null && fluidHeld.getFluid() == ModFluids.fluidSolarWater && tileEntity instanceof TileSolarGenerator) {
TileSolarGenerator tank = (TileSolarGenerator) tileEntity;
if (tank.canReceiveBucket()) {
tank.addBucket();
if (FluidContainerRegistry.isBucket(held) && !(((EntityPlayerMP) player).theItemInWorldManager.isCreative())) {
int heldLocation = player.inventory.currentItem;
player.inventory.decrStackSize(heldLocation, 1);
world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, new ItemStack(Items.bucket, 1)));
// player.inventory.setInventorySlotContents(heldLocation, new ItemStack(Items.bucket, 1));
}
}
return true;
}
}
return false;
}
示例3: onBlockActivated
import net.minecraftforge.fluids.FluidContainerRegistry; //導入方法依賴的package包/類
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
ItemStack stack = player.inventory.getCurrentItem();
if (stack != null) {
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack);
TileGlassFluidTank tank = (TileGlassFluidTank) world.getTileEntity(x, y, z);
if (liquid != null) {
int amount = tank.fill(ForgeDirection.UNKNOWN, liquid, false);
if (amount == liquid.amount) {
tank.fill(ForgeDirection.UNKNOWN, liquid, true);
if (!player.capabilities.isCreativeMode)
player.inventory.setInventorySlotContents(player.inventory.currentItem, Utils.useItemSafely(stack));
if(tank.tank.getFluid().getFluid().getBlock() != null){
}
return true;
}
else
return true;
}
else if (FluidContainerRegistry.isBucket(stack)) {
FluidTankInfo[] tanks = tank.getTankInfo(ForgeDirection.UNKNOWN);
if (tanks[0] != null) {
FluidStack fillFluid = tanks[0].fluid;
ItemStack fillStack = FluidContainerRegistry.fillFluidContainer(fillFluid, stack);
if (fillStack != null) {
tank.drain(ForgeDirection.UNKNOWN, FluidContainerRegistry.getFluidForFilledItem(fillStack).amount, true);
if (!player.capabilities.isCreativeMode) {
if (stack.stackSize == 1)
player.inventory.setInventorySlotContents(player.inventory.currentItem, fillStack);
else {
player.inventory.setInventorySlotContents(player.inventory.currentItem, Utils.useItemSafely(stack));
if (!player.inventory.addItemStackToInventory(fillStack))
player.dropPlayerItemWithRandomChoice(fillStack, false);
}
}
return true;
}
else
return true;
}
}
}
return false;
}
示例4: onBlockActivated
import net.minecraftforge.fluids.FluidContainerRegistry; //導入方法依賴的package包/類
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float clickX, float clickY, float clickZ) {
world.scheduleBlockUpdate(x, y, z, 0, 1);
ItemStack playerItem = player.inventory.getCurrentItem();
if(playerItem != null){
TileEntityLiquidStorageTank tank = (TileEntityLiquidStorageTank)world.getBlockTileEntity(x, y, z);
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(player.getCurrentEquippedItem());
if(liquid != null){
int amount = tank.fill(ForgeDirection.UNKNOWN, liquid, false);
if(amount == liquid.amount){
tank.fill(ForgeDirection.UNKNOWN, liquid, true);
if(!player.capabilities.isCreativeMode){
player.inventory.setInventorySlotContents(player.inventory.currentItem, removeItem(playerItem));
return true;
}
return true;
}
else{
return true;
}
}
else if (FluidContainerRegistry.isBucket(playerItem)){
FluidTankInfo[] tankInfo = tank.getTankInfo(ForgeDirection.UNKNOWN);
FluidStack fillFluid = tankInfo[0].fluid;
ItemStack stack = FluidContainerRegistry.fillFluidContainer(fillFluid, playerItem);
if(stack != null){
tank.drain(ForgeDirection.UNKNOWN, FluidContainerRegistry.getFluidForFilledItem(stack).amount, true);
if(!player.capabilities.isCreativeMode){
if(playerItem.stackSize == 1){
player.inventory.setInventorySlotContents(player.inventory.currentItem, stack);
}
else
{
player.inventory.setInventorySlotContents(player.inventory.currentItem, removeItem(playerItem));
if(!player.inventory.addItemStackToInventory(stack)){
player.dropPlayerItem(stack);
}
}
}
return true;
}
else
{
return true;
}
}
}
return false;
}