本文整理匯總了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);
}
}
示例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
});
}
}
示例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));
}
}