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