本文整理了Java中net.minecraft.entity.Entity.isSneaking()
方法的一些代码示例,展示了Entity.isSneaking()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.isSneaking()
方法的具体详情如下:
包路径:net.minecraft.entity.Entity
类名称:Entity
方法名:isSneaking
暂无
代码示例来源:origin: Vazkii/Botania
@Override
public void addCollisionBoxToList(IBlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull AxisAlignedBB par5AxisAlignedBB, @Nonnull List<AxisAlignedBB> stacks, Entity par7Entity, boolean isActualState) {
PlatformVariant variant = state.getValue(BotaniaStateProps.PLATFORM_VARIANT);
if(variant == PlatformVariant.INFRANGIBLE || variant == PlatformVariant.ABSTRUSE && par7Entity != null && par7Entity.posY > pos.getY() + 0.9 && (!(par7Entity instanceof EntityPlayer) || !par7Entity.isSneaking()))
super.addCollisionBoxToList(state, world, pos, par5AxisAlignedBB, stacks, par7Entity, isActualState);
}
代码示例来源:origin: WayofTime/BloodMagic
@Override
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, IBlockState state, Entity entity) {
if (entity.isSneaking()) {
entity.fallDistance = 0;
} else if (entity.motionY < 0.0D) {
entity.motionY = -entity.motionY;
if (!(entity instanceof EntityLivingBase)) {
entity.motionY *= 0.8D;
}
entity.fallDistance = 0;
}
}
代码示例来源:origin: MightyPirates/TIS-3D
private boolean isObserverSneaking() {
return rendererDispatcher.entity.isSneaking();
}
代码示例来源:origin: Alex-the-666/Ice_and_Fire
@Override
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) {
super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
if (entity.isSneaking()) {
this.cape.rotationPointY = 2.0F;
} else {
this.cape.rotationPointY = 0.0F;
}
}
代码示例来源:origin: MrCrayfish/MrCrayfishFurnitureMod
@Override
public void onLanded(World worldIn, Entity entityIn)
{
if(entityIn.isSneaking())
{
super.onLanded(worldIn, entityIn);
}
else if(entityIn.motionY < 0.0D)
{
entityIn.motionY = -entityIn.motionY * 0.8D;
if(!(entityIn instanceof EntityLivingBase))
{
entityIn.motionY *= 0.8D;
}
}
}
代码示例来源:origin: vadis365/TheErebus
@Override
public void updatePassenger(Entity entity) {
super.updatePassenger(entity);
if (entity instanceof EntityLivingBase) {
double a = Math.toRadians(renderYawOffset);
double offSetX = -Math.sin(a) * -0.6D;
double offSetZ = Math.cos(a) * -0.6D;
entity.setPosition(posX - offSetX, posY - getYOffset(), posZ - offSetZ);
if (entity.isSneaking())
entity.setSneaking(false);
}
}
代码示例来源:origin: GregTechCE/GregTech
@Override
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
entityIn.motionX = MathHelper.clamp(entityIn.motionX, -0.15, 0.15);
entityIn.motionZ = MathHelper.clamp(entityIn.motionZ, -0.15, 0.15);
entityIn.fallDistance = 0.0F;
if (entityIn.motionY < -0.15D) {
entityIn.motionY = -0.15D;
}
if (entityIn.isSneaking() && entityIn.motionY < 0.0D) {
entityIn.motionY = 0.0D;
}
if(entityIn.collidedHorizontally) {
entityIn.motionY = 0.2;
}
}
代码示例来源:origin: vadis365/TheErebus
@Override
public void updatePassenger(Entity entity) {
super.updatePassenger(entity);
if (entity instanceof EntityLivingBase) {
double a = Math.toRadians(renderYawOffset);
double offSetX = -Math.sin(a) * 0.75D;
double offSetZ = Math.cos(a) * 0.75D;
if (captured())
entity.setPosition(posX + offSetX, posY + 0.75D + entity.getYOffset(), posZ + offSetZ);
if (entity.isSneaking())
entity.setSneaking(false);
}
}
代码示例来源:origin: SquidDev-CC/plethora
@Override
public void render(@Nonnull Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entity);
GlStateManager.pushMatrix();
if (entity.isSneaking()) {
GlStateManager.translate(0, 0.2f, 0);
}
bipedHeadwear.render(scale);
GlStateManager.popMatrix();
}
代码示例来源:origin: vadis365/TheErebus
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
if (entity.isSneaking())
return;
if (entity instanceof EntityLiving)
((EntityLiving) entity).enablePersistence();
else if (entity instanceof EntityItem)
((EntityItem) entity).setNoDespawn();
double speed = speed();
int meta = state.getValue(FACING).getIndex() - 2;
int[] factorX = { 0, 0, -1, 1 };
int[] factorZ = { -1, 1, 0, 0 };
if (entity.posY > pos.getY() + 0.5D) {
if (factorX[meta] == 0 && Math.abs(pos.getX() + 0.5D - entity.posX) < 0.5D && Math.abs(pos.getX() + 0.5D - entity.posX) > 0.1D)
entity.motionX += Math.signum(pos.getX() + 0.5D - entity.posX) * Math.min(speed, Math.abs(pos.getX() + 0.5D - entity.posX)) / 1.2D;
if (factorZ[meta] == 0 && Math.abs(pos.getZ() + 0.5D - entity.posZ) < 0.5D && Math.abs(pos.getZ() + 0.5D - entity.posZ) > 0.1D)
entity.motionZ += Math.signum(pos.getZ() + 0.5D - entity.posZ) * Math.min(speed, Math.abs(pos.getZ() + 0.5D - entity.posZ)) / 1.2D;
entity.motionX += factorX[meta] * speed;
entity.motionZ += factorZ[meta] * speed;
}
}
代码示例来源:origin: vadis365/TheErebus
@Override
public void render(Entity entity, float limbSwing, float limbSwingAngle, float entityTickTime, float rotationYaw, float rotationPitch, float unitPixel) {
setRotationAngles(limbSwing, limbSwingAngle, entityTickTime, rotationYaw, rotationPitch, unitPixel, entity);
GlStateManager.pushMatrix();
if (entity.isSneaking()) {
GlStateManager.translate(0.0F, 0.2F, 0F);
capTop.rotationPointY = 1.0F;
}
capTop.render(0.064F);
GlStateManager.popMatrix();
}
代码示例来源:origin: vadis365/TheErebus
@Override
public void render(Entity entity, float limbSwing, float limbSwingAngle, float entityTickTime, float rotationYaw, float rotationPitch, float unitPixel) {
setRotationAngles(limbSwing, limbSwingAngle, entityTickTime, rotationYaw, rotationPitch, unitPixel, entity);
GlStateManager.pushMatrix();
GlStateManager.scale(1.2F, 1F, 1.2F);
if (entity.isSneaking()) {
GlStateManager.translate(0.0F, 0.2F, 0F);
helmFront.rotationPointY = 1.0F;
}
helmFront.render(unitPixel);
GlStateManager.popMatrix();
}
代码示例来源:origin: JurassiCraftTeam/JurassiCraft2
private void updateRiding(Entity riding) {
if (riding.isPassenger(this) && riding instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) riding;
int ridingIndex = riding.getPassengers().indexOf(this);
float radius = (ridingIndex == 2 ? 0.0F : 0.35F) + (player.isElytraFlying() ? 2 : 0);
float renderYawOffset = player.renderYawOffset;
float angle = (float) Math.toRadians(renderYawOffset + (ridingIndex == 1 ? -90 : ridingIndex == 0 ? 90 : 0));
double offsetX = (double) (radius * MathHelper.sin((float) (Math.PI + angle)));
double offsetZ = (double) (radius * MathHelper.cos(angle));
double offsetY = (riding.isSneaking() ? 1.2 : 1.38) + (ridingIndex == 2 ? 0.4 : 0.0);
this.rotationYaw = player.rotationYawHead;
this.rotationYawHead = player.rotationYawHead;
this.prevRotationYaw = player.rotationYawHead;
this.setPosition(riding.posX + offsetX, riding.posY + offsetY, riding.posZ + offsetZ);
this.setAnimation(EntityAnimation.IDLE.get());
if (player.isElytraFlying()) {
this.dismountRidingEntity();
}
}
}
代码示例来源:origin: vadis365/TheErebus
@SuppressWarnings("unchecked")
protected Entity activateBlock() {
List<EntityLivingBase> list = getWorld().getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(getPos().up()).grow(0D, 0.25D, 0D));
for (int i = 0; i < list.size(); i++) {
Entity entity = list.get(i);
if (entity != null) {
if (entity instanceof EntityLivingBase) {
if (entity.isSneaking())
return null;
((EntityLivingBase) entity).setPositionAndUpdate(getTargetX() + 0.5D, getTargetY() + 1D, getTargetZ() + 0.5D);
world.playSound(null, getPos(), SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
}
}
return null;
}
代码示例来源:origin: Alex-the-666/Ice_and_Fire
public void updateRiding(Entity riding) {
if (riding != null && riding.isPassenger(this) && riding instanceof EntityPlayer) {
int i = riding.getPassengers().indexOf(this);
float radius = (i == 2 ? 0F : 0.4F) + (((EntityPlayer) riding).isElytraFlying() ? 2 : 0);
float angle = (0.01745329251F * ((EntityPlayer) riding).renderYawOffset) + (i == 1 ? -90 : i == 0 ? 90 : 0);
double extraX = (double) (radius * MathHelper.sin((float) (Math.PI + angle)));
double extraZ = (double) (radius * MathHelper.cos(angle));
double extraY = (riding.isSneaking() ? 1.2D : 1.4D) + (i == 2 ? 0.4D : 0D);
this.rotationYaw = ((EntityPlayer) riding).rotationYawHead;
this.rotationYawHead = ((EntityPlayer) riding).rotationYawHead;
this.prevRotationYaw = ((EntityPlayer) riding).rotationYawHead;
this.setPosition(riding.posX + extraX, riding.posY + extraY, riding.posZ + extraZ);
if (this.getControlState() == 1 << 4 || ((EntityPlayer) riding).isElytraFlying()) {
this.dismountRidingEntity();
}
}
}
代码示例来源:origin: Vazkii/Quark
@Override
public void onUpdate() {
super.onUpdate();
BlockPos pos = getPosition();
if(pos != null && !(getEntityWorld().getBlockState(pos).getBlock() instanceof BlockStairs) || !canBeAbove(getEntityWorld(), pos)) {
setDead();
return;
}
List<Entity> passangers = getPassengers();
if(passangers.isEmpty())
setDead();
for(Entity e : passangers)
if(e.isSneaking())
setDead();
}
代码示例来源:origin: MrCrayfish/MrCrayfishFurnitureMod
@Override
public void onFallenUpon(World worldIn, BlockPos pos, Entity entityIn, float fallDistance)
{
if(this == FurnitureBlocks.DIVING_BOARD_PLANK && entityIn instanceof EntityLivingBase)
{
float height = entityIn.fallDistance;
if(height > 0 && !entityIn.isSneaking())
{
if(height > MAX_JUMP_HEIGHT) height = MAX_JUMP_HEIGHT;
entityIn.motionY = 0;
entityIn.addVelocity(0, getRequiredVelocity(height + 1), 0);
worldIn.playSound(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, FurnitureSounds.boing, SoundCategory.BLOCKS, 0.75F, 0.75F, false);
if(worldIn.isRemote)
{
for(int i = 0; i < 3; i++)
{
worldIn.spawnParticle(EnumParticleTypes.SPELL_MOB, entityIn.posX, entityIn.posY, entityIn.posZ, 1, 1, 1, 0);
}
}
}
entityIn.fallDistance = 0;
}
}
代码示例来源:origin: Vazkii/Quark
@SubscribeEvent
public void onInteract(PlayerInteractEvent.RightClickBlock event) {
if(event.getUseBlock() == Result.DENY)
return;
TileEntity tile = event.getWorld().getTileEntity(event.getPos());
if(tile instanceof TileEntityNote && (!emptyHand || event.getEntityPlayer().getHeldItemMainhand().isEmpty()) && event.getEntityPlayer().capabilities.allowEdit && !event.getEntity().isSneaking()) {
TileEntityNote noteBlock = (TileEntityNote) tile;
event.getEntityPlayer().openGui(Quark.instance, LibGuiIDs.NOTE_BLOCK, event.getWorld(), event.getPos().getX(), event.getPos().getY(), event.getPos().getZ());
event.setCanceled(true);
}
}
代码示例来源:origin: SquidDev-CC/plethora
public static void load(PlethoraFakePlayer player, Entity entity) {
player.setWorld(entity.getEntityWorld());
player.setPositionAndRotation(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
player.rotationYawHead = player.rotationYaw;
player.setSize(entity.width, entity.height);
player.eyeHeight = entity.height;
player.setSneaking(entity.isSneaking());
player.inventory.currentItem = 0;
if (entity instanceof EntityLivingBase) {
EntityLivingBase living = (EntityLivingBase) entity;
for (EntityEquipmentSlot slot : EntityEquipmentSlot.values()) {
ItemStack stack = living.getItemStackFromSlot(slot);
if (!stack.isEmpty()) {
player.setItemStackToSlot(slot, stack.copy());
player.getAttributeMap().applyAttributeModifiers(stack.getAttributeModifiers(slot));
} else {
player.setItemStackToSlot(slot, ItemStack.EMPTY);
}
}
}
player.inventory.markDirty();
}
代码示例来源:origin: Vazkii/Quark
@SubscribeEvent
public void onInteract(PlayerInteractEvent.RightClickBlock event) {
if(event.getUseBlock() == Result.DENY)
return;
TileEntity tile = event.getWorld().getTileEntity(event.getPos());
if(tile instanceof TileEntitySign && (!emptyHand || event.getEntityPlayer().getHeldItemMainhand().isEmpty()) && event.getEntityPlayer().capabilities.allowEdit && !event.getEntity().isSneaking()) {
IBlockState state = event.getWorld().getBlockState(event.getPos());
if(state.getBlock().getRegistryName().toString().contains("tcguideposts"))
return;
TileEntitySign sign = (TileEntitySign) tile;
sign.setPlayer(event.getEntityPlayer());
ReflectionHelper.setPrivateValue(TileEntitySign.class, sign, true, LibObfuscation.IS_EDITABLE);
event.getEntityPlayer().openGui(Quark.instance, LibGuiIDs.SIGN, event.getWorld(), event.getPos().getX(), event.getPos().getY(), event.getPos().getZ());
}
}
内容来源于网络,如有侵权,请联系作者删除!