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


Java EntityPlayerMP.getHeldItemOffhand方法代码示例

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


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

示例1: handle

import net.minecraft.entity.player.EntityPlayerMP; //导入方法依赖的package包/类
public static void handle(NBTTagCompound tag)
{
	try
	{
		UUID requesterID = UUID.fromString(tag.getString("uuid"));
		SpecialAttack attack = SpecialAttack.registry.get(tag.getString("attackID"));
		boolean rightClick = tag.getBoolean("rightClick");
		EntityPlayerMP player = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerByUUID(requesterID);
		ItemStack is = !player.getHeldItemMainhand().isEmpty() ? player.getHeldItemMainhand() : player.getHeldItemOffhand();
		if (attack.canExecute(player, WeaponType.getType(is), EnumWeaponWeight.getWeaponWeight(is), rightClick))
		{
			IExPPlayer.of(player).setCurrentSpecialAttack(attack.wrap(), true);
			VoidNetwork.sendDataToClient(ExPPackets.SPECIAL_ATTACK, tag, player);
		}
	}
	catch (Exception ex)
	{
		ExPMisc.modLogger.log(LogLevel.Error, "Malformed client combat packet! %s", ex, tag);
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:21,代码来源:ServerCombatHandler.java

示例2: handle

import net.minecraft.entity.player.EntityPlayerMP; //导入方法依赖的package包/类
@Override
protected void handle(MessagePickBlock message, EntityPlayerMP player) {
    ItemStack held = player.getHeldItemOffhand();
    if (!player.capabilities.isCreativeMode && held.getItem() == RSAddonsItems.NETWORK_PICKER) {
        ItemNetworkPicker picker = (ItemNetworkPicker) held.getItem();

        picker.applyNetwork(held, n -> picker.doPick(n, player, held), e -> {
            // NO OP
        });
    }
}
 
开发者ID:raoulvdberge,项目名称:refinedstorageaddons,代码行数:12,代码来源:MessagePickBlock.java

示例3: execute

import net.minecraft.entity.player.EntityPlayerMP; //导入方法依赖的package包/类
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    EntityPlayerMP player = getCommandSenderAsPlayer(sender);
    ItemStack held = player.getHeldItemMainhand();
    if(held.isEmpty()) {
        held = player.getHeldItemOffhand();
    }
    if(held.isEmpty()) {
        player.sendMessage(new TextComponentTranslation("command.modularmachinery.hand.empty"));
        return;
    }
    Item i = held.getItem();
    StringBuilder sb = new StringBuilder();
    sb.append(i.getRegistryName().toString());
    if(i.getHasSubtypes()) {
        sb.append("@").append(held.getItemDamage());
    }
    NBTTagCompound cmp = held.serializeNBT();
    if(cmp.hasKey("tag")) {
        String json = NBTJsonSerializer.serializeNBT(cmp.getTag("tag"));
        if(!json.isEmpty()) {
            sb.append(" (with nbt: ").append(json).append(" )");
        }
    }

    String str = sb.toString();
    player.sendMessage(new TextComponentString(str));
    ModularMachinery.NET_CHANNEL.sendTo(new PktCopyToClipboard(str), player);

    int burn = TileEntityFurnace.getItemBurnTime(held);
    if(burn > 0) {
        player.sendMessage(new TextComponentString("Fuel BurnTime: " + burn));
    }
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:35,代码来源:CommandHand.java


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