本文整理匯總了Java中net.minecraft.util.EnumHand.OFF_HAND屬性的典型用法代碼示例。如果您正苦於以下問題:Java EnumHand.OFF_HAND屬性的具體用法?Java EnumHand.OFF_HAND怎麽用?Java EnumHand.OFF_HAND使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類net.minecraft.util.EnumHand
的用法示例。
在下文中一共展示了EnumHand.OFF_HAND屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onBlockActivated
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if(!(worldIn.getTileEntity(pos) instanceof TileEntityPot) || hand == EnumHand.OFF_HAND)
return false;
ItemStack stack = playerIn.getHeldItem(hand);
if(!stack.isEmpty() && stack.getItem().equals(Items.WATER_BUCKET))
{
((TileEntityPot)worldIn.getTileEntity(pos)).replenishWater();
worldIn.notifyBlockUpdate(pos, state, getDefaultState(), 3);
if(!playerIn.capabilities.isCreativeMode)
playerIn.setHeldItem(hand, stack.getItem().getContainerItem(stack));
return true;
}
playerIn.openGui(ExSartagine.instance, 2, worldIn, pos.getX(), pos.getY(), pos.getZ());
return true;
}
示例2: fromBytes
@Override
public void fromBytes(ByteBuf buf) {
slot = buf.readByte();
this.hand = buf.readBoolean() ? EnumHand.MAIN_HAND : EnumHand.OFF_HAND;
this.readData = new ArrayList<Object[]>();
while (buf.readableBytes() > 0) {
Object[] obj = new Object[3];
obj[0] = buf.readInt();
// obj[1]=buf.readFloat();
// obj[2]=buf.readFloat();
// obj[3]=buf.readFloat();
obj[1] = buf.readBoolean();
obj[2] = buf.readFloat();
this.readData.add(obj);
}
}
示例3: notifyDataManagerChange
public void notifyDataManagerChange(DataParameter<?> key)
{
super.notifyDataManagerChange(key);
if (HAND_STATES.equals(key))
{
boolean flag = (((Byte)this.dataManager.get(HAND_STATES)).byteValue() & 1) > 0;
EnumHand enumhand = (((Byte)this.dataManager.get(HAND_STATES)).byteValue() & 2) > 0 ? EnumHand.OFF_HAND : EnumHand.MAIN_HAND;
if (flag && !this.handActive)
{
this.setActiveHand(enumhand);
}
else if (!flag && this.handActive)
{
this.resetActiveHand();
}
}
if (FLAGS.equals(key) && this.isElytraFlying() && !this.wasFallFlying)
{
this.mc.getSoundHandler().playSound(new ElytraSound(this));
}
}
示例4: setActiveHand
public void setActiveHand(EnumHand hand)
{
ItemStack itemstack = this.getHeldItem(hand);
if (!itemstack.func_190926_b() && !this.isHandActive())
{
this.activeItemStack = itemstack;
this.activeItemStackUseCount = itemstack.getMaxItemUseDuration();
if (!this.world.isRemote)
{
int i = 1;
if (hand == EnumHand.OFF_HAND)
{
i |= 2;
}
this.dataManager.set(HAND_STATES, Byte.valueOf((byte)i));
}
}
}
示例5: onItemRightClick
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn)
{
ItemStack glove = playerIn.getHeldItem(handIn);
if (handIn == EnumHand.OFF_HAND)
{
ItemStack shard = playerIn.getHeldItem(EnumHand.MAIN_HAND);
if (shard.getItem() == ItemRegistry.crystal_shard)
{
int shrink = playerIn.isSneaking() ? shard.getCount() : 1;
playerIn.playSound(SoundRegistry.GLASS, 1, 1);
if (ItemSipAmulet.checkForAmulet(playerIn))
{
ItemStack amulet = ItemUtils.getBauble(playerIn, BaubleType.AMULET.getValidSlots()[0]);
amulet.getCapability(CapabilityRegistry.SIP_STORE_CAP, null).add(SipUtils.getSipInStack(shard), shrink);
ItemUtils.setBauble(playerIn, BaubleType.AMULET.getValidSlots()[0], amulet);
}
playerIn.getHeldItem(EnumHand.MAIN_HAND).shrink(shrink);
return new ActionResult<>(EnumActionResult.SUCCESS, glove);
}
}
return new ActionResult<>(EnumActionResult.PASS, glove);
}
示例6: setActiveHand
public void setActiveHand(EnumHand hand)
{
ItemStack itemstack = this.getHeldItem(hand);
if (itemstack != null && !this.isHandActive())
{
int duration = net.minecraftforge.event.ForgeEventFactory.onItemUseStart(this, itemstack, itemstack.getMaxItemUseDuration());
if (duration <= 0) return;
this.activeItemStack = itemstack;
this.activeItemStackUseCount = duration;
if (!this.worldObj.isRemote)
{
int i = 1;
if (hand == EnumHand.OFF_HAND)
{
i |= 2;
}
this.dataManager.set(HAND_STATES, Byte.valueOf((byte)i));
}
}
}
示例7: setHeldItem
public void setHeldItem(EnumHand hand, @Nullable ItemStack stack)
{
if (hand == EnumHand.MAIN_HAND)
{
this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, stack);
}
else
{
if (hand != EnumHand.OFF_HAND)
{
throw new IllegalArgumentException("Invalid hand " + hand);
}
this.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, stack);
}
}
示例8: onBlockActivated
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if(!(worldIn.getTileEntity(pos) instanceof TileEntitySmelter) || hand == EnumHand.OFF_HAND)
return false;
playerIn.openGui(ExSartagine.instance, 1, worldIn, pos.getX(), pos.getY(), pos.getZ());
return true;
}
示例9: onBlockActivated
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (hand == EnumHand.OFF_HAND) return false;
if (worldIn.isRemote) return true;
TileEntityCrystalBall te = (TileEntityCrystalBall) worldIn.getTileEntity(pos);
return te.fortune(playerIn);
}
示例10: onBlockActivated
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
TileEntityChalkBase te = (TileEntityChalkBase)worldIn.getTileEntity(pos);
if(te == null)return false;
if(hand == EnumHand.OFF_HAND)return false;
if(heldItem==null&&te.hasItem())
{
if(worldIn.isRemote)
{
te.markDirty();
te.removeStackFromSlot(0);
return true;
}
InventoryHelper.dropInventoryItems(worldIn,playerIn,te);
te.setInventorySlotContents(0,null);
return true;
}
else if(!worldIn.isRemote&&heldItem!=null&&heldItem.getItem()!= ModItems.defaultChalkItem &&!te.hasItem()&&te.isItemValidForSlot(0,heldItem))
{
ItemStack newItem = heldItem.copy();
newItem.stackSize = 1;
heldItem.stackSize--;
if(heldItem.stackSize<1)heldItem=null;
te.setInventorySlotContents(0,newItem);
te.updateRendering();
return true;
}
return false;
}
示例11: getClientGuiElement
@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: getHeldItem
public ItemStack getHeldItem(EnumHand hand)
{
if (hand == EnumHand.MAIN_HAND)
{
return this.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND);
}
else if (hand == EnumHand.OFF_HAND)
{
return this.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND);
}
else
{
throw new IllegalArgumentException("Invalid hand " + hand);
}
}
示例13: renderItemInFirstPerson
/**
* Renders the active item in the player's hand when in first person mode.
*/
public void renderItemInFirstPerson(float partialTicks)
{
AbstractClientPlayer abstractclientplayer = this.mc.thePlayer;
float f = abstractclientplayer.getSwingProgress(partialTicks);
EnumHand enumhand = (EnumHand)Objects.firstNonNull(abstractclientplayer.swingingHand, EnumHand.MAIN_HAND);
float f1 = abstractclientplayer.prevRotationPitch + (abstractclientplayer.rotationPitch - abstractclientplayer.prevRotationPitch) * partialTicks;
float f2 = abstractclientplayer.prevRotationYaw + (abstractclientplayer.rotationYaw - abstractclientplayer.prevRotationYaw) * partialTicks;
boolean flag = true;
boolean flag1 = true;
if (abstractclientplayer.isHandActive())
{
ItemStack itemstack = abstractclientplayer.getActiveItemStack();
if (itemstack != null && itemstack.getItem() == Items.BOW) //Forge: Data watcher can desync and cause this to NPE...
{
EnumHand enumhand1 = abstractclientplayer.getActiveHand();
flag = enumhand1 == EnumHand.MAIN_HAND;
flag1 = !flag;
}
}
this.rotateArroundXAndY(f1, f2);
this.setLightmap();
this.rotateArm(partialTicks);
GlStateManager.enableRescaleNormal();
if (flag)
{
float f3 = enumhand == EnumHand.MAIN_HAND ? f : 0.0F;
float f5 = 1.0F - (this.prevEquippedProgressMainHand + (this.equippedProgressMainHand - this.prevEquippedProgressMainHand) * partialTicks);
if(!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(EnumHand.MAIN_HAND, partialTicks, f1, f3, f5, this.itemStackMainHand))
this.renderItemInFirstPerson(abstractclientplayer, partialTicks, f1, EnumHand.MAIN_HAND, f3, this.itemStackMainHand, f5);
}
if (flag1)
{
float f4 = enumhand == EnumHand.OFF_HAND ? f : 0.0F;
float f6 = 1.0F - (this.prevEquippedProgressOffHand + (this.equippedProgressOffHand - this.prevEquippedProgressOffHand) * partialTicks);
if(!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(EnumHand.OFF_HAND, partialTicks, f1, f4, f6, this.itemStackOffHand))
this.renderItemInFirstPerson(abstractclientplayer, partialTicks, f1, EnumHand.OFF_HAND, f4, this.itemStackOffHand, f6);
}
GlStateManager.disableRescaleNormal();
RenderHelper.disableStandardItemLighting();
}
示例14: fromBytes
@Override
public void fromBytes(ByteBuf buf) {
part = EnumPlayerPart.fromID(buf.readByte());
hand = buf.readBoolean() ? EnumHand.MAIN_HAND : EnumHand.OFF_HAND;
}
示例15: renderItemInFirstPerson
/**
* Renders the active item in the player's hand when in first person mode.
*/
public void renderItemInFirstPerson(float partialTicks)
{
AbstractClientPlayer abstractclientplayer = this.mc.player;
float f = abstractclientplayer.getSwingProgress(partialTicks);
EnumHand enumhand = (EnumHand)Objects.firstNonNull(abstractclientplayer.swingingHand, EnumHand.MAIN_HAND);
float f1 = abstractclientplayer.prevRotationPitch + (abstractclientplayer.rotationPitch - abstractclientplayer.prevRotationPitch) * partialTicks;
float f2 = abstractclientplayer.prevRotationYaw + (abstractclientplayer.rotationYaw - abstractclientplayer.prevRotationYaw) * partialTicks;
boolean flag = true;
boolean flag1 = true;
if (abstractclientplayer.isHandActive())
{
ItemStack itemstack = abstractclientplayer.getActiveItemStack();
if (itemstack != null && itemstack.getItem() == Items.BOW)
{
EnumHand enumhand1 = abstractclientplayer.getActiveHand();
flag = enumhand1 == EnumHand.MAIN_HAND;
flag1 = !flag;
}
}
this.rotateArroundXAndY(f1, f2);
this.setLightmap();
this.rotateArm(partialTicks);
GlStateManager.enableRescaleNormal();
if (flag)
{
float f3 = enumhand == EnumHand.MAIN_HAND ? f : 0.0F;
float f5 = 1.0F - (this.prevEquippedProgressMainHand + (this.equippedProgressMainHand - this.prevEquippedProgressMainHand) * partialTicks);
if (!Reflector.ForgeHooksClient_renderSpecificFirstPersonHand.exists() || !Reflector.callBoolean(Reflector.ForgeHooksClient_renderSpecificFirstPersonHand, new Object[] {EnumHand.MAIN_HAND, Float.valueOf(partialTicks), Float.valueOf(f1), Float.valueOf(f3), Float.valueOf(f5), this.itemStackMainHand}))
{
this.renderItemInFirstPerson(abstractclientplayer, partialTicks, f1, EnumHand.MAIN_HAND, f3, this.itemStackMainHand, f5);
}
}
if (flag1)
{
float f4 = enumhand == EnumHand.OFF_HAND ? f : 0.0F;
float f6 = 1.0F - (this.prevEquippedProgressOffHand + (this.equippedProgressOffHand - this.prevEquippedProgressOffHand) * partialTicks);
if (!Reflector.ForgeHooksClient_renderSpecificFirstPersonHand.exists() || !Reflector.callBoolean(Reflector.ForgeHooksClient_renderSpecificFirstPersonHand, new Object[] {EnumHand.OFF_HAND, Float.valueOf(partialTicks), Float.valueOf(f1), Float.valueOf(f4), Float.valueOf(f6), this.itemStackOffHand}))
{
this.renderItemInFirstPerson(abstractclientplayer, partialTicks, f1, EnumHand.OFF_HAND, f4, this.itemStackOffHand, f6);
}
}
GlStateManager.disableRescaleNormal();
RenderHelper.disableStandardItemLighting();
}