本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.getHeldItemOffhand方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.getHeldItemOffhand方法的具体用法?Java EntityPlayer.getHeldItemOffhand怎么用?Java EntityPlayer.getHeldItemOffhand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.player.EntityPlayer
的用法示例。
在下文中一共展示了EntityPlayer.getHeldItemOffhand方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isUsingShears
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
private static boolean isUsingShears(EntityPlayer player)
{
ItemStack stack = player.getHeldItemMainhand();
if (!stack.isEmpty() && stack.getItem() instanceof ItemShears)
{
return true;
}
stack = player.getHeldItemOffhand();
if (!stack.isEmpty() && stack.getItem() instanceof ItemShears)
{
return true;
}
return false;
}
示例2: getClientGuiElement
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (ID == 0) {
return new GuiATM(player);
} else if (ID == 1) {
return new GuiWallet(new ContainerItem(player, player.inventory, new InventoryItem(player.getHeldItemMainhand())));
} else if (ID == 2) {
return new GuiWallet(new ContainerItem(player, player.inventory, new InventoryItem(player.getHeldItemOffhand())));
} else if (ID == 3) {
return new GuiShopController(new BlockPos(x, y, z), world);
} else if (ID == 4) {
return new GuiStockCrate(player, new BlockPos(x, y, z), player.inventory, (TileEntityStockCrate) world.getTileEntity(new BlockPos(x, y, z)));
} else if (ID == 5) {
return new GuiShoppingList(player);
}
return null;
}
示例3: playerAndHandToItemStack
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static ItemStack playerAndHandToItemStack(EntityPlayer player, EnumHand hand)
{
ItemStack stack = null;
// okay, find the itemstack
if (hand == EnumHand.MAIN_HAND) {
stack = player.getHeldItemMainhand();
} else if (hand == EnumHand.OFF_HAND) {
stack = player.getHeldItemOffhand();
} else {
// uhh... what?
Util.logger.error("Found invalid EnumHand value!");
}
return stack;
}
示例4: canAdvance
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public boolean canAdvance(World world, BlockPos pos, IBlockState state) {
if (getTile(world, pos) == null)
return false;
List<EntityPlayer> players = world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(pos.add(-range, -range, -range), pos.add(range, range, range)));
for (EntityPlayer player : players) {
if (player.getUniqueID().equals(getTile(world, pos).getOwner())) {
ItemStack hand = player.getHeldItemMainhand();
ItemStack offhand = player.getHeldItemOffhand();
if ((hand != null && hand.getItem() == Item.getItemFromBlock(Blocks.TORCH)) || (offhand != null && offhand.getItem() == Item.getItemFromBlock(Blocks.TORCH)))
return true;
}
}
return false;
}
示例5: searchForWatches
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static Tuple<Integer, ItemStack> searchForWatches(EntityLivingBase living) {
if (living instanceof EntitySpy)
return new Tuple<>(3, ((EntitySpy)living).loadout.getStackInSlot(3));
if (living instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) living;
if (!player.getHeldItemOffhand().isEmpty() && player.getHeldItemOffhand().getItem() instanceof ItemCloak
&& player.getHeldItemOffhand().getTagCompound().getBoolean("Active"))
// System.out.println("Found offhand");
return new Tuple<>(40,player.getHeldItemOffhand());
for (int i=0;i<player.inventory.mainInventory.size();i++) {
ItemStack stack=player.inventory.mainInventory.get(i);
if (!stack.isEmpty() && stack.getItem() instanceof ItemCloak
&& stack.getTagCompound().getBoolean("Active"))
// System.out.println("Found hand");
return new Tuple<>(i,stack);
}
}
return new Tuple<>(-1, ItemStack.EMPTY);
}
示例6: canBeSteered
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* returns true if all the conditions for steering the entity are met. For pigs, this is true if it is being ridden
* by a player and the player is holding a carrot-on-a-stick
*/
public boolean canBeSteered()
{
Entity entity = this.getControllingPassenger();
if (!(entity instanceof EntityPlayer))
{
return false;
}
else
{
EntityPlayer entityplayer = (EntityPlayer)entity;
ItemStack itemstack = entityplayer.getHeldItemMainhand();
if (itemstack != null && itemstack.getItem() == Items.CARROT_ON_A_STICK)
{
return true;
}
else
{
itemstack = entityplayer.getHeldItemOffhand();
return itemstack != null && itemstack.getItem() == Items.CARROT_ON_A_STICK;
}
}
}
示例7: onExecutionTick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onExecutionTick(EntityPlayer player, int progress)
{
player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_NODAMAGE, SoundCategory.PLAYERS, 1, 2F);
Vec3d look = player.getLookVec().scale(3);
Vec3d pos = player.getPositionVector();
List<EntityLivingBase> targets = Helpers.rayTraceEntities(player.world, pos.addVector(0, player.getEyeHeight(), 0), look, Optional.of(e -> e != player), EntityLivingBase.class);
EntityLivingBase assumedToBeLookedAt = Helpers.getClosest(targets, player);
if (assumedToBeLookedAt != null)
{
assumedToBeLookedAt.hurtResistantTime = 0;
assumedToBeLookedAt.attackEntityFrom(DamageSource.causePlayerDamage(player), Math.max(1, (float) player.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue() / 10));
player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_NODAMAGE, SoundCategory.PLAYERS, 1, 0.1F);
Vec3d targetPos = assumedToBeLookedAt.getPositionVector();
player.world.spawnParticle(EnumParticleTypes.CRIT, targetPos.x + player.world.rand.nextDouble() / 2 - player.world.rand.nextDouble() / 2, targetPos.y + assumedToBeLookedAt.getEyeHeight() + player.world.rand.nextDouble() / 2 - player.world.rand.nextDouble() / 2, targetPos.z + player.world.rand.nextDouble() / 2 - player.world.rand.nextDouble() / 2, 0, 0, 0);
if (!player.world.isRemote)
{
ItemStack is = player.getHeldItemMainhand().isEmpty() ? player.getHeldItemOffhand() : player.getHeldItemMainhand();
is.damageItem(1, player);
}
}
}
示例8: onExecutionStart
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onExecutionStart(EntityPlayer player)
{
ItemStack is = player.getHeldItemMainhand().isEmpty() ? player.getHeldItemOffhand() : player.getHeldItemMainhand();
EnumWeaponWeight weight = EnumWeaponWeight.getWeaponWeight(is);
player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_NODAMAGE, SoundCategory.PLAYERS, 1, 1F);
Vec3d look = player.getLookVec().scale(5);
Vec3d pos = player.getPositionVector();
List<EntityLivingBase> targets = Helpers.rayTraceEntities(player.world, pos.addVector(0, player.getEyeHeight(), 0), look, Optional.of(e -> e != player), EntityLivingBase.class);
EntityLivingBase assumedToBeLookedAt = Helpers.getClosest(targets, player);
if (assumedToBeLookedAt != null)
{
if (!player.world.isRemote)
{
assumedToBeLookedAt.addPotionEffect(new PotionEffect(ExPPotions.stunned, weight == EnumWeaponWeight.NORMAL ? 20 : 30, 0, false, false));
}
player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_KNOCKBACK, SoundCategory.PLAYERS, 1, 1F);
Vec3d targetPos = assumedToBeLookedAt.getPositionVector();
assumedToBeLookedAt.knockBack(player, 1, pos.x - targetPos.x, pos.z - targetPos.z);
for (int i = 0; i < 50; ++i)
{
player.world.spawnParticle(EnumParticleTypes.CRIT_MAGIC, targetPos.x + player.world.rand.nextDouble() - player.world.rand.nextDouble(), targetPos.z + assumedToBeLookedAt.getEyeHeight() + player.world.rand.nextDouble() - player.world.rand.nextDouble(), targetPos.z + player.world.rand.nextDouble() - player.world.rand.nextDouble(), 0, -0.1, 0);
}
}
}
示例9: onStarted
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onStarted(EntityPlayer player, IRitualHandler tile, World world, BlockPos pos, NBTTagCompound data) {
ItemStack chalk = player.getHeldItemOffhand();
data.setInteger("chalkType", chalk.getMetadata());
if (!player.isCreative()) {
int usesLeft = chalk.getTagCompound().getInteger("usesLeft") - coords.size();
chalk.getTagCompound().setInteger("usesLeft", usesLeft);
if (usesLeft < 1)
chalk.setCount(0);
}
player.setHeldItem(EnumHand.OFF_HAND, chalk);
}
示例10: isStackInHand
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
private boolean isStackInHand(ItemStack itemStackIn) {
EntityPlayer player = EasyMappings.player();
if ((player.getHeldItemMainhand() == itemStackIn) || (player.getHeldItemOffhand() == itemStackIn)) {
return true;
}
return false;
}
示例11: getClientGuiElement
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (ID == GuiLearnSpell.MAIN_ID){
return new GuiLearnSpell(player, EnumHand.MAIN_HAND, player.getHeldItemMainhand());
}
if (ID == GuiLearnSpell.OFF_ID){
return new GuiLearnSpell(player, EnumHand.OFF_HAND, player.getHeldItemOffhand());
}
return null;
}
示例12: getClientGuiElement
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
@SideOnly(Side.CLIENT)
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
BlockPos pos = new BlockPos(x, y, z);
if (ID == RandoresGuiType.FORGE.ordinal()) {
TileEntity entity = world.getTileEntity(pos);
if (entity instanceof CraftiniumForgeTileEntity) {
return new CraftiniumForgeGui((CraftiniumForgeTileEntity) entity, player.inventory);
}
} else if (ID == RandoresGuiType.TABLE.ordinal()) {
return new CraftiniumTableGui(player.inventory, world, pos);
} else if (ID == RandoresGuiType.TOME.ordinal()) {
ItemStack[] stacks = new ItemStack[] {player.getHeldItemMainhand(), player.getHeldItemOffhand()};
for(ItemStack stack : stacks) {
if(stack.getItem() instanceof TomeItem && RandoresItemData.hasData(stack)) {
RandoresItemData data = new RandoresItemData(stack);
if(RandoresWorldData.contains(data)) {
return new TomeGui(RandoresWorldData.get(data).buildPages());
}
}
}
return new TomeGui(Arrays.asList(new TomeGui.StringElement("An example text page: \n" + TextFormatting.RED + "This tome has no data associated with it, so it instead displays examples of the different kinds of pages in a tome.", "Example"),
new TomeGui.CraftingElement("An example crafting recipe page: ", new ItemStack[][]{
{new ItemStack(Items.IRON_INGOT), new ItemStack(Items.IRON_INGOT), new ItemStack(Items.IRON_INGOT)},
{null, new ItemStack(Items.STICK), null},
{null, new ItemStack(Items.STICK), null}
}, new ItemStack(Items.IRON_PICKAXE), "Example"),
new TomeGui.FurnaceElement("An example furnace recipe page: ", new ItemStack(Items.STICK), new ItemStack(Blocks.IRON_ORE), new ItemStack(Items.IRON_INGOT), "Example")));
} else if (ID == RandoresGuiType.CONVERTER.ordinal()) {
return new CraftiniumConverterGui(player.inventory, world, pos);
}
return null;
}
示例13: getServerGuiElement
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (ID == 1) {
return new ContainerItem(player, player.inventory, new InventoryItem(player.getHeldItemMainhand()));
} else if (ID == 2) {
return new ContainerItem(player, player.inventory, new InventoryItem(player.getHeldItemOffhand()));
} else if (ID == 4) {
return new ContainerStockCrate(player.inventory, (TileEntityStockCrate) world.getTileEntity(new BlockPos(x, y, z)));
}
return null;
}
示例14: processClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static void processClick(EntityPlayer player, boolean rightClick)
{
if (!player.getHeldItemMainhand().isEmpty() || (!player.getHeldItemOffhand().isEmpty() && rightClick))
{
ItemStack is = !player.getHeldItemMainhand().isEmpty() ? player.getHeldItemMainhand() : player.getHeldItemOffhand();
for (SpecialAttack attack : SpecialAttack.sortedData)
{
if (attack.canExecute(player, WeaponType.getType(is), EnumWeaponWeight.getWeaponWeight(is), rightClick))
{
boolean b = true;
for (IExecuteCondition condition : attack.executeConditions)
{
if (!condition.isMet())
{
b = false;
break;
}
}
if (!b)
{
continue;
}
NBTTagCompound tag = NBTChain.startChain().withString("uuid", player.getPersistentID().toString()).withString("attackID", attack.id).withBool("rightClick", rightClick).endChain();
VoidNetwork.sendDataToServer(ExPPackets.SPECIAL_ATTACK, tag);
return;
}
}
}
}
示例15: onExecutionStart
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onExecutionStart(EntityPlayer player)
{
ItemStack is = player.getHeldItemMainhand().isEmpty() ? player.getHeldItemOffhand() : player.getHeldItemMainhand();
EnumWeaponWeight weight = EnumWeaponWeight.getWeaponWeight(is);
player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, SoundCategory.PLAYERS, 1, 1F);
Vec3d playerLook = player.getLookVec();
Vec3d playerPos = player.getPositionVector();
player.world.spawnParticle(EnumParticleTypes.SWEEP_ATTACK, playerPos.x + playerLook.x, playerPos.y + player.getEyeHeight() * 0.5F, playerPos.z + playerLook.z, 0, 0, 0);
AxisAlignedBB aabb = new AxisAlignedBB(playerPos.addVector(-3, -1, -3), playerPos.addVector(3, 3, 3));
List<EntityLivingBase> lst = player.world.getEntitiesWithinAABB(EntityLivingBase.class, aabb, e -> e != player);
for (EntityLivingBase ent : lst)
{
if (ent instanceof EntityTameable && ((EntityTameable)ent).getOwner() == player)
{
continue;
}
Vec3d ePos = ent.getPositionVector();
Vec3d player2ent = ePos.subtract(playerPos).normalize();
float angle = (float) Math.toDegrees(Math.acos(player2ent.dotProduct(playerLook)));
if (angle > 60)
{
continue;
}
ent.attackEntityFrom(DamageSource.causePlayerDamage(player), (float) (player.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue() * 0.85F));
player.world.playSound(player, ent.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, SoundCategory.PLAYERS, 1, 2F);
if (!player.world.isRemote && weight == EnumWeaponWeight.HEAVY && player.world.rand.nextBoolean())
{
ent.addPotionEffect(new PotionEffect(ExPPotions.stunned, 100, 0, false, false));
}
}
}