当前位置: 首页>>代码示例>>Java>>正文


Java TileEntityBanner.removeBannerData方法代码示例

本文整理汇总了Java中net.minecraft.tileentity.TileEntityBanner.removeBannerData方法的典型用法代码示例。如果您正苦于以下问题:Java TileEntityBanner.removeBannerData方法的具体用法?Java TileEntityBanner.removeBannerData怎么用?Java TileEntityBanner.removeBannerData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.tileentity.TileEntityBanner的用法示例。


在下文中一共展示了TileEntityBanner.removeBannerData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeDye

import net.minecraft.tileentity.TileEntityBanner; //导入方法依赖的package包/类
private boolean removeDye(World world, BlockPos pos, EntityPlayer player, EnumHand hand, @Nonnull ItemStack stack, TileFluidTank tank) {
    IFluidHandler handler = FluidUtil.getFluidHandler(world, pos, null);
    if (handler == null) return false;
    if (tank.getFluid() != null && tank.getFluid().getFluid() == FluidRegistry.WATER && tank.getFluidAmount() >= 250) {
        if (stack.getItem() instanceof ItemArmor && ((ItemArmor) stack.getItem()).hasColor(stack)) {
            if (!world.isRemote) {
                ((ItemArmor) stack.getItem()).removeColor(stack);
                player.addStat(StatList.ARMOR_CLEANED);
                handler.drain(250, true);
            }
            player.playSound(SoundEvents.ENTITY_BOBBER_SPLASH, 0.16F, 0.66F);
            return true;
        }
        if (stack.getItem() instanceof ItemBanner) {
            if (TileEntityBanner.getPatterns(stack) > 0) {
                if (!world.isRemote) {
                    ItemStack banner = stack.copy();
                    banner.setCount(1);
                    TileEntityBanner.removeBannerData(banner);
                    player.addStat(StatList.BANNER_CLEANED);

                    if (!player.capabilities.isCreativeMode) {
                        stack.shrink(1);
                        handler.drain(250, true);
                    }
                    InventoryHandlerHelper.giveItem(player, hand, banner);
                }
                player.playSound(SoundEvents.ENTITY_BOBBER_SPLASH, 0.16F, 0.66F);
            }
            return true;
        }
    }
    return false;
}
 
开发者ID:GirafiStudios,项目名称:Culinary-Cultivation,代码行数:35,代码来源:BlockModCauldron.java

示例2: onBlockActivated

import net.minecraft.tileentity.TileEntityBanner; //导入方法依赖的package包/类
@Beta
	@Override
	public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand,
			EnumFacing side, float hitX, float hitY, float hitZ) {
		TileEntityCauldron cauldron = getTileEntityCauldron(world, pos);
		ItemStack heldItem = player.getHeldItem(hand);
		CauldronActivatedEvent event;
		if (MinecraftForge.EVENT_BUS.post(event = new CauldronActivatedEvent(world, pos, state, player, hand, cauldron,
				heldItem, side, hitX, hitY, hitZ)))
			return event.getResult() == Result.DEFAULT;
		
		LinkedList<ItemStack> list = getTileEntityCauldron(world, pos).getContainer();
		if (heldItem == null) {
			if (Always.isServer()) {
				if (list.size() > 0) {
					player.setHeldItem(hand, list.removeLast());
					player.inventory.markDirty();
					cauldron.onContainerChange();
					cauldron.updateTracker();
				}
			}
		} else {
			int i = getWaterLevel(world, pos, state);
			Item item = heldItem.getItem();
			if (item == ModItems.botania$waterRod) {
//				if (i > -1 && i < 3 && ManaItemHandler.requestManaExact(heldItem, player, ItemWaterRod.COST, true))
//					setWaterLevel(world, pos, state, 3);
			} else if (FluidUtil.getFluidHandler(heldItem) != null) {
				FluidUtil.interactWithFluidHandler(player, hand, cauldron.getTank());
			} else if (!list.isEmpty()) {
				if (Always.isServer()) {
					boolean flag = false;
					int limit = heldItem.getMaxStackSize();
					if (heldItem.getCount() >= limit)
						return false;
					for (Iterator<ItemStack> iterator = list.iterator(); iterator.hasNext();) {
						ItemStack citem = iterator.next();
						if (InventoryHelper.canMergeItemStack(heldItem, citem))
							if (heldItem.getCount() < limit) {
								heldItem.setCount(heldItem.getCount() + 1);
								iterator.remove();
								flag = true;
							} else
								break;
					}
					if (flag) {
						player.inventory.markDirty();
						cauldron.onContainerChange();
						cauldron.updateTracker();
					}
				}
			} else {
				if (item instanceof ItemArmor) {
					if (i > 0) {
						ItemArmor armor = (ItemArmor) item;
						if (armor.getArmorMaterial() == ItemArmor.ArmorMaterial.LEATHER && armor.hasColor(heldItem)) {
							armor.removeColor(heldItem);
							player.addStat(StatList.ARMOR_CLEANED);
							setWaterLevel(world, pos, state, i - 1);
						}
					}
				} else if (item instanceof ItemBanner) {
					if (i > 0 && TileEntityBanner.getPatterns(heldItem) > 0) {
						ItemStack banner = heldItem.copy();
						banner.setCount(1);
						TileEntityBanner.removeBannerData(banner);
						InventoryHelper.addItemStackOrSetToHand(player, hand, heldItem, banner);
						player.addStat(StatList.BANNER_CLEANED);
						setWaterLevel(world, pos, state, i - 1);
					}
				}
			}
		}
		return true;
	}
 
开发者ID:NekoCaffeine,项目名称:Alchemy,代码行数:76,代码来源:PBlockCauldron.java


注:本文中的net.minecraft.tileentity.TileEntityBanner.removeBannerData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。