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


Java EntityPlayer.isRiding方法代码示例

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


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

示例1: onItemRightClick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    if (playerIn.isRiding() && playerIn.ridingEntity instanceof EntityPig)
    {
        EntityPig entitypig = (EntityPig)playerIn.ridingEntity;

        if (entitypig.getAIControlledByPlayer().isControlledByPlayer() && itemStackIn.getMaxDamage() - itemStackIn.getMetadata() >= 7)
        {
            entitypig.getAIControlledByPlayer().boostSpeed();
            itemStackIn.damageItem(7, playerIn);

            if (itemStackIn.stackSize == 0)
            {
                ItemStack itemstack = new ItemStack(Items.fishing_rod);
                itemstack.setTagCompound(itemStackIn.getTagCompound());
                return itemstack;
            }
        }
    }

    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    return itemStackIn;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:27,代码来源:ItemCarrotOnAStick.java

示例2: emulateSendMotion

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
private static void emulateSendMotion(EntityPlayer player) {
    // emulate client player's sendMotion
    Vec3d newPosition = null;
    if (player.isRiding()) {
        // needs improvement
        newPosition = getPosition(player);
        emulateHandleMotion(player, newPosition, getOnGround(player));
    } else if (getView() == player) {
        double dx = getX(sentPosition) - getX(player);
        double dy = getY(sentPosition) - getY(player);
        double dz = getZ(sentPosition) - getZ(player);
        boolean sync = (dx*dx + dy*dy + dz*dz > 9.0E-4D
            || ticksForForceSync >= 20);
        ++ticksForForceSync;
        if (sync) {
            newPosition = sentPosition = getPosition(player);
            ticksForForceSync = 0;
        }
        emulateHandleMotion(player, newPosition, getOnGround(player));
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:22,代码来源:Motion.java

示例3: onItemRightClick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    if (playerIn.isRiding() && playerIn.getRidingEntity() instanceof EntityPig)
    {
        EntityPig entitypig = (EntityPig)playerIn.getRidingEntity();

        if (itemStackIn.getMaxDamage() - itemStackIn.getMetadata() >= 7 && entitypig.boost())
        {
            itemStackIn.damageItem(7, playerIn);

            if (itemStackIn.stackSize == 0)
            {
                ItemStack itemstack = new ItemStack(Items.FISHING_ROD);
                itemstack.setTagCompound(itemStackIn.getTagCompound());
                return new ActionResult(EnumActionResult.SUCCESS, itemstack);
            }

            return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
        }
    }

    playerIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.PASS, itemStackIn);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:25,代码来源:ItemCarrotOnAStick.java

示例4: afterMove

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
private static void afterMove(EntityPlayer ent, Vec3d move) {
    if (isSleeping(ent) || ent.isRiding()) return;
    if (ent == flyPlayer) {
        playerClassActive = true;
        playerOnGround = getOnGround(ent);

        if (modFlyAllowed) {
            if (getMotionX(ent) != 0) setMotionX(ent, motionX);
            if (getMotionY(ent) != 0) setMotionY(ent, motionY);
            if (getMotionZ(ent) != 0) setMotionZ(ent, motionZ);
            if (playerFly) {
                flyPlayer.movementInput.sneak = false;
                setFall(ent, 0f); setOnGround(ent, true);
                setSteps(ent, flySteps);
                setFlying(ent, true);
                if (ent.capabilities.allowFlying)
                ent.sendPlayerAbilities();
            } else if (flew && !getOnGround(ent)) {
                setFall(ent, 0f); setOnGround(ent, true);
                if (ent.capabilities.allowFlying)
                ent.sendPlayerAbilities();
            }
            else flew = false;
        }
    }
    if (ent == flyDummy) {
        dummyOnGround = getOnGround(ent);
        if (getMotionX(ent) != 0) setMotionX(ent, motionX);
        if (getMotionY(ent) != 0) setMotionY(ent, motionY);
        if (getMotionZ(ent) != 0) setMotionZ(ent, motionZ);
        if (dummyFly) {
            flyDummy.movementInput.sneak = false;
            setSteps(ent, flySteps);
            setFlying(ent, true);
        }
        setFall(ent, 0f);
        setOnGround(ent, true);
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:40,代码来源:Fly.java

示例5: onItemRightClick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
    ItemStack itemstack = worldIn.getHeldItem(playerIn);

    if (itemStackIn.isRemote)
    {
        return new ActionResult(EnumActionResult.PASS, itemstack);
    }
    else
    {
        if (worldIn.isRiding() && worldIn.getRidingEntity() instanceof EntityPig)
        {
            EntityPig entitypig = (EntityPig)worldIn.getRidingEntity();

            if (itemstack.getMaxDamage() - itemstack.getMetadata() >= 7 && entitypig.boost())
            {
                itemstack.damageItem(7, worldIn);

                if (itemstack.func_190926_b())
                {
                    ItemStack itemstack1 = new ItemStack(Items.FISHING_ROD);
                    itemstack1.setTagCompound(itemstack.getTagCompound());
                    return new ActionResult(EnumActionResult.SUCCESS, itemstack1);
                }

                return new ActionResult(EnumActionResult.SUCCESS, itemstack);
            }
        }

        worldIn.addStat(StatList.getObjectUseStats(this));
        return new ActionResult(EnumActionResult.PASS, itemstack);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:34,代码来源:ItemCarrotOnAStick.java

示例6: emulateHandleMotion

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
private static void emulateHandleMotion(EntityPlayer player, Vec3d newPosition, boolean packetOnGround) {
    // emulate server handling of C03PacketPlayer
    Vec3d oldPosition = serverPosition;
    if (newPosition == null) newPosition = oldPosition;
    if (player.isRiding()) {
        // needs improvement
        serverPosition = serverNextPosition = newPosition;
        serverMotion   = serverNextMotion;
        return;
    }
    if (isSleeping(player)) {
        // needs improvement
        serverPosition = serverNextPosition = oldPosition;
        serverMotion   = serverNextMotion;
        return;
    }
    // server update part
    if (!anticipated) {
        setPosition(serverDummy, serverPosition);
        setMotion(serverDummy,   serverMotion);
        serverDummy.onUpdate();
        serverNextPosition = getPosition(serverDummy);
        serverNextMotion   = getMotion(serverDummy);
    }
    serverPosition = serverNextPosition;
    serverMotion   = serverNextMotion;
    anticipated = false;
    // moved too quickly check
    if (isMultiplayer() && isMoveTooQuick(newPosition)) {
        serverNextPosition = serverPosition = oldPosition;
        // note: motion is kept as is and a position packet is sent
        return;
    }
    // server movement attempt
    setPosition(serverDummy, oldPosition);
    double spacing = 0.0625;
    boolean wasFree = getWorld(player).getCollisionBoxes(player, getAABB(serverDummy).contract(spacing)).isEmpty();
    if (getOnGround(serverDummy) && !packetOnGround
     && getX(player) > getX(oldPosition)) {
        serverDummy.jump();
    }
    Vec3d move = newPosition.subtract(oldPosition);
    serverDummy.moveEntity(MoverType.SELF, getX(move), getY(move), getZ(move));
    setOnGround(serverDummy, packetOnGround);
    // moved wrongly check
    boolean moveWrong = false;
    if (!isSleeping(player) && !isCreative(player)
     && wasMoveWrong(serverDummy, newPosition)) {
        moveWrong = true;
    }
    setPosition(serverDummy, newPosition);
    if (!getNoclip(player)) {
        boolean isFree = getWorld(player).getCollisionBoxes(player, getAABB(serverDummy).contract(spacing)).isEmpty();
        if (wasFree && (moveWrong || !isFree) && !isSleeping(player)) {
            serverNextPosition = serverPosition = oldPosition;
            // note: motion is kept as is and a position packet is sent
            return;
        }
    }
    setOnGround(serverDummy, packetOnGround);
    // serverUpdateMountedMovingPlayer(serverDummy)
    // serverDummy.handleFalling(getY(serverDummy) - getY(oldPosition), packetOnGround);
    serverNextPosition = serverPosition = getPosition(serverDummy);
    serverNextMotion   = serverMotion   = getMotion(serverDummy);
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:66,代码来源:Motion.java

示例7: beforeMove

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
private static Vec3d beforeMove(EntityPlayer ent, Vec3d move) {
    if (isSleeping(ent) || ent.isRiding()) return move;
    double mx = motionX = getX(move),
           my = motionY = getY(move),
           mz = motionZ = getZ(move);
    flySteps = 0;
    if (modFlyAllowed && ent == flyPlayer || ent == flyDummy) {
        flySteps = getSteps(ent);
        if (ent == flyPlayer && playerFly || ent == flyDummy && dummyFly) {
            if (ent == flyPlayer) flyPlayer.movementInput.sneak = false;
            else                  flyDummy .movementInput.sneak = false;
            my = 0d;
            if (optNoInertia || ent != controlledEntity) {
                mx = my = mz = 0;
            }
            if (ent == controlledEntity) {
                if (flyUp)   my += optSpeedVertical;
                if (flyDown) my -= optSpeedVertical;
                if (flyFree) {
                    double siny = Math.sin(getYaw(ent) * TO_RADIANS);
                    double cosy = Math.cos(getYaw(ent) * TO_RADIANS);
                    double sinp = Math.sin(getPitch(ent) * TO_RADIANS);
                    double cosp = Math.cos(getPitch(ent) * TO_RADIANS);
                    double mf = -mx * siny + mz * cosy;
                    double mv = -mf * sinp;
                    mf *=  1-cosp;
                    mx -= -mf * siny;
                    mz -=  mf * cosy;
                    my += mv;
                }
                if (flyForward) {
                    double moves = optSpeedForward;
                    double movef = -moves * Math.cos(getPitch(ent) * TO_RADIANS);
                    double movev = -moves * Math.sin(getPitch(ent) * TO_RADIANS);
                    mx += movef * Math.sin(getYaw(ent) * TO_RADIANS);
                    mz += -movef * Math.cos(getYaw(ent) * TO_RADIANS);
                    my += movev;
                }
                double mul = flySpeed ? optSpeedMulModifier : optSpeedMulNormal;
                if (optNoInertia) mul *= 2;
                mx *= mul; my *= mul; mz *= mul;
            }
            setFall(ent, 0f);
            if (ent == flyPlayer) flew = true;
        } else if (ent == controlledEntity && flyRun) {
            mx *= optRunSpeedMul;
            mz *= optRunSpeedMul;
            int id = getIdAt(getWorld(), fix(getX(ent)), fix(getY(ent)), fix(getZ(ent)));
            // if in ladders, water or lava
            if (id == 65 || id >= 8 && id <= 11) my *= optRunSpeedVMul;
        }
    }
    setMotion(ent, mx,my,mz);
    return new Vec3d(mx,my,mz);
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:56,代码来源:Fly.java


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