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


Java EntityPlayerSP.getHeldItemMainhand方法代码示例

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


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

示例1: renderGhostAngstrom

import net.minecraft.client.entity.EntityPlayerSP; //导入方法依赖的package包/类
@SubscribeEvent
public static void renderGhostAngstrom(RenderWorldLastEvent event) {
	EntityPlayerSP player = Minecraft.getMinecraft().player;
	ItemStack stack = player.getHeldItemMainhand();
	if(stack.isEmpty() || stack.getItem() != ModItems.ANGSTROM) {
		stack = player.getHeldItemOffhand();
	}
	if(!stack.isEmpty() && stack.getItem() == ModItems.ANGSTROM) {
		RayTraceResult result = RayTraceHelper.tracePlayerHighlight(player);
		if(result.typeOfHit != RayTraceResult.Type.BLOCK) {
			Vector3 vec = Vector3.create(player.posX, player.posY + player.getEyeHeight(), player.posZ);
			vec.add(Vector3.create(player.getLookVec()).multiply(2.5D));
			BlockPos pos = new BlockPos(vec.toVec3d());
			IBlockState replaced = player.world.getBlockState(pos);
			if(player.world.isAirBlock(pos) || replaced.getBlock().isReplaceable(player.world, pos)) {
				RenderHelper.renderGhostBlock(pos, ModBlocks.ANGSTROM.getDefaultState());
			}
		}
	}
}
 
开发者ID:ArekkuusuJerii,项目名称:Solar,代码行数:21,代码来源:Events.java

示例2: onMouseEvent

import net.minecraft.client.entity.EntityPlayerSP; //导入方法依赖的package包/类
@SubscribeEvent
public void onMouseEvent(MouseEvent event) {
    EntityPlayerSP player = Minecraft.getMinecraft().player;
    if(event.getDwheel() != 0 && player != null && player.isSneaking()) {
        ItemStack stack = player.getHeldItemMainhand();
        Item item = stack.getItem();
        if(item instanceof ItemTransporter) {
            if(((ItemTransporter) item).getMode(stack) == 1) {

                ItemTransporter.cycleSelected(stack, event.getDwheel());
                PacketWhoosh.sendCycleSelectedPacketToServer(event.getDwheel());
                event.setCanceled(true);
            }
        }
    }
}
 
开发者ID:ImbaKnugel,项目名称:Whoosh,代码行数:17,代码来源:EventHandlerClient.java

示例3: initGui

import net.minecraft.client.entity.EntityPlayerSP; //导入方法依赖的package包/类
@Override
public void initGui() {
    super.initGui();

    guiLeft = (this.width - WIDTH) / 2;
    guiTop = (this.height - HEIGHT) / 2;

    EntityPlayerSP player = MinecraftTools.getPlayer(Minecraft.getMinecraft());
    ItemStack book = player.getHeldItemMainhand();
    if (ItemStackTools.isValid(book) && book.getItem() instanceof IBook) {
        json = ((IBook) book.getItem()).getJson();
        BookParser parser = new BookParser();
        pages = parser.parse(json, WIDTH_FACTOR, HEIGHT_FACTOR);
        pageNumber = 0;
        result = null;
    } else {
        json = null;    // Shouldn't be possible
        pages = new ArrayList<>();
        pages.add(new BookPage());
        RenderSection section = new RenderSection("Error");
        TextElementFormat fmt = new TextElementFormat("red,bold");
        section.addElement(new RenderElementText("Error!", 10, 10, (int) ClientProxy.font.getWidth("Error!"), (int) ClientProxy.font.getHeight(), fmt));
        pages.get(0).addSection(section);
        pageNumber = 0;
        result = null;
    }
}
 
开发者ID:McJty,项目名称:Lector,代码行数:28,代码来源:GuiManual.java

示例4: updateEquippedItem

import net.minecraft.client.entity.EntityPlayerSP; //导入方法依赖的package包/类
public void updateEquippedItem()
{
    this.prevEquippedProgressMainHand = this.equippedProgressMainHand;
    this.prevEquippedProgressOffHand = this.equippedProgressOffHand;
    EntityPlayerSP entityplayersp = this.mc.thePlayer;
    ItemStack itemstack = entityplayersp.getHeldItemMainhand();
    ItemStack itemstack1 = entityplayersp.getHeldItemOffhand();

    if (entityplayersp.isRowingBoat())
    {
        this.equippedProgressMainHand = MathHelper.clamp_float(this.equippedProgressMainHand - 0.4F, 0.0F, 1.0F);
        this.equippedProgressOffHand = MathHelper.clamp_float(this.equippedProgressOffHand - 0.4F, 0.0F, 1.0F);
    }
    else
    {
        float f = entityplayersp.getCooledAttackStrength(1.0F);
        this.equippedProgressMainHand += MathHelper.clamp_float((!net.minecraftforge.client.ForgeHooksClient.shouldCauseReequipAnimation(this.itemStackMainHand, itemstack, entityplayersp.inventory.currentItem) ? f * f * f : 0.0F) - this.equippedProgressMainHand, -0.4F, 0.4F);
        this.equippedProgressOffHand += MathHelper.clamp_float((float)(!net.minecraftforge.client.ForgeHooksClient.shouldCauseReequipAnimation(this.itemStackOffHand, itemstack1, -1) ? 1 : 0) - this.equippedProgressOffHand, -0.4F, 0.4F);
    }

    if (this.equippedProgressMainHand < 0.1F)
    {
        this.itemStackMainHand = itemstack;
    }

    if (this.equippedProgressOffHand < 0.1F)
    {
        this.itemStackOffHand = itemstack1;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:31,代码来源:ItemRenderer.java

示例5: onRender

import net.minecraft.client.entity.EntityPlayerSP; //导入方法依赖的package包/类
@SubscribeEvent
public void onRender(RenderGameOverlayEvent.Post event) {
    if(event.getType() != RenderGameOverlayEvent.ElementType.EXPERIENCE) {
        return;
    }

    Minecraft mc = Minecraft.getMinecraft();
    EntityPlayerSP player = mc.player;
    ItemStack stack = player.getHeldItemMainhand();
    if(stack == null || !(stack.getItem() instanceof ItemTransporter))
        return;

    if(!ItemTransporter.canPlayerAccess(stack, player))
        return;

    if(stack.getTagCompound().getInteger("Mode") == 0)
        return;

    int selected = ItemTransporter.getSelected(stack);
    List<TeleportPosition> positions = ItemTransporter.getPositions(stack);
    if(selected != -1 && positions.size() > 0) {
        if(selected >= positions.size()) {
            ItemTransporter.setSelected(stack, positions.size() - 1);
            return;
        }

        int h = event.getResolution().getScaledHeight();
        int w = event.getResolution().getScaledWidth();
        String name = positions.get(selected).name;

        int width = mc.fontRenderer.getStringWidth(name);
        int height = player.capabilities.isCreativeMode ? 33 : 70;
        mc.fontRenderer.drawStringWithShadow(name, (w - width) / 2, h - height, 0xFFFFFF);
    }
}
 
开发者ID:ImbaKnugel,项目名称:Whoosh,代码行数:36,代码来源:EventHandlerClient.java

示例6: updateEquippedItem

import net.minecraft.client.entity.EntityPlayerSP; //导入方法依赖的package包/类
public void updateEquippedItem()
{
    this.prevEquippedProgressMainHand = this.equippedProgressMainHand;
    this.prevEquippedProgressOffHand = this.equippedProgressOffHand;
    EntityPlayerSP entityplayersp = this.mc.player;
    ItemStack itemstack = entityplayersp.getHeldItemMainhand();
    ItemStack itemstack1 = entityplayersp.getHeldItemOffhand();

    if (entityplayersp.isRowingBoat())
    {
        this.equippedProgressMainHand = MathHelper.clamp(this.equippedProgressMainHand - 0.4F, 0.0F, 1.0F);
        this.equippedProgressOffHand = MathHelper.clamp(this.equippedProgressOffHand - 0.4F, 0.0F, 1.0F);
    }
    else
    {
        float f = entityplayersp.getCooledAttackStrength(1.0F);

        if (Reflector.ForgeHooksClient_shouldCauseReequipAnimation.exists())
        {
            boolean flag = Reflector.callBoolean(Reflector.ForgeHooksClient_shouldCauseReequipAnimation, new Object[] {this.itemStackMainHand, itemstack, Integer.valueOf(entityplayersp.inventory.currentItem)});
            this.equippedProgressMainHand += MathHelper.clamp((!flag ? f * f * f : 0.0F) - this.equippedProgressMainHand, -0.4F, 0.4F);
            boolean flag1 = Reflector.callBoolean(Reflector.ForgeHooksClient_shouldCauseReequipAnimation, new Object[] {this.itemStackOffHand, itemstack1, Integer.valueOf(-1)});
            this.equippedProgressOffHand += MathHelper.clamp((float)(!flag1 ? 1 : 0) - this.equippedProgressOffHand, -0.4F, 0.4F);
        }
        else
        {
            this.equippedProgressMainHand += MathHelper.clamp((Objects.equal(this.itemStackMainHand, itemstack) ? f * f * f : 0.0F) - this.equippedProgressMainHand, -0.4F, 0.4F);
            this.equippedProgressOffHand += MathHelper.clamp((float)(Objects.equal(this.itemStackOffHand, itemstack1) ? 1 : 0) - this.equippedProgressOffHand, -0.4F, 0.4F);
        }
    }

    if (this.equippedProgressMainHand < 0.1F)
    {
        this.itemStackMainHand = itemstack;

        if (Config.isShaders())
        {
            Shaders.setItemToRenderMain(this.itemStackMainHand);
        }
    }

    if (this.equippedProgressOffHand < 0.1F)
    {
        this.itemStackOffHand = itemstack1;

        if (Config.isShaders())
        {
            Shaders.setItemToRenderOff(this.itemStackOffHand);
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:52,代码来源:ItemRenderer.java


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