本文整理汇总了Java中net.minecraft.entity.Entity.canBeCollidedWith方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.canBeCollidedWith方法的具体用法?Java Entity.canBeCollidedWith怎么用?Java Entity.canBeCollidedWith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.Entity
的用法示例。
在下文中一共展示了Entity.canBeCollidedWith方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import net.minecraft.entity.Entity; //导入方法依赖的package包/类
public boolean apply(Entity p_apply_1_)
{
return p_apply_1_.canBeCollidedWith();
}
示例2: canBeHooked
import net.minecraft.entity.Entity; //导入方法依赖的package包/类
protected boolean canBeHooked(Entity p_189739_1_)
{
return p_189739_1_.canBeCollidedWith() || p_189739_1_ instanceof EntityItem;
}
示例3: onItemRightClick
import net.minecraft.entity.Entity; //导入方法依赖的package包/类
@Override
@Nonnull
public ActionResult<ItemStack> onItemRightClick(@Nonnull ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
float f1 = playerIn.prevRotationPitch + (playerIn.rotationPitch - playerIn.prevRotationPitch) * 1.0F;
float f2 = playerIn.prevRotationYaw + (playerIn.rotationYaw - playerIn.prevRotationYaw) * 1.0F;
double d0 = playerIn.prevPosX + (playerIn.posX - playerIn.prevPosX) * 1.0D;
double d1 = playerIn.prevPosY + (playerIn.posY - playerIn.prevPosY) * 1.0D + (double)playerIn.getEyeHeight();
double d2 = playerIn.prevPosZ + (playerIn.posZ - playerIn.prevPosZ) * 1.0D;
Vec3d vec3d = new Vec3d(d0, d1, d2);
float f3 = MathHelper.cos(-f2 * 0.017453292F - (float)Math.PI);
float f4 = MathHelper.sin(-f2 * 0.017453292F - (float)Math.PI);
float f5 = -MathHelper.cos(-f1 * 0.017453292F);
float f6 = MathHelper.sin(-f1 * 0.017453292F);
float f7 = f4 * f5;
float f8 = f3 * f5;
Vec3d vec3d1 = vec3d.addVector((double)f7 * 5.0D, (double)f6 * 5.0D, (double)f8 * 5.0D);
RayTraceResult raytraceresult = worldIn.rayTraceBlocks(vec3d, vec3d1, false);
if (raytraceresult == null)
{
return new ActionResult<>(EnumActionResult.PASS, itemStackIn);
}
else
{
Vec3d vec3d2 = playerIn.getLook(1.0F);
boolean flag = false;
List<Entity> list = worldIn.getEntitiesWithinAABBExcludingEntity(playerIn, playerIn.getEntityBoundingBox().addCoord(vec3d2.xCoord * 5.0D, vec3d2.yCoord * 5.0D, vec3d2.zCoord * 5.0D).expandXyz(1.0D));
for (int i = 0; i < list.size(); ++i)
{
Entity entity = list.get(i);
if (entity.canBeCollidedWith())
{
AxisAlignedBB axisalignedbb = entity.getEntityBoundingBox().expandXyz((double)entity.getCollisionBorderSize());
if (axisalignedbb.isVecInside(vec3d))
{
flag = true;
}
}
}
if (flag)
{
return new ActionResult<>(EnumActionResult.PASS, itemStackIn);
}
else if (raytraceresult.typeOfHit != RayTraceResult.Type.BLOCK)
{
return new ActionResult<>(EnumActionResult.PASS, itemStackIn);
}
else
{
EntityTractor entityTractor = new EntityTractor(worldIn, raytraceresult.hitVec.xCoord, raytraceresult.hitVec.yCoord, raytraceresult.hitVec.zCoord);
entityTractor.rotationYaw = playerIn.rotationYaw;
if (!worldIn.getCollisionBoxes(entityTractor, entityTractor.getEntityBoundingBox().expandXyz(-0.1D)).isEmpty())
{
return new ActionResult<>(EnumActionResult.FAIL, itemStackIn);
}
else
{
if (!worldIn.isRemote)
{
worldIn.spawnEntity(entityTractor);
}
if (!playerIn.capabilities.isCreativeMode)
{
--itemStackIn.stackSize;
}
playerIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult<>(EnumActionResult.SUCCESS, itemStackIn);
}
}
}
}
示例4: getMouseOverServer
import net.minecraft.entity.Entity; //导入方法依赖的package包/类
public static RayTraceResult getMouseOverServer(EntityLivingBase lookingEntity, double range) {
RayTraceResult mop = raytraceEntityBlocks(lookingEntity, range);
double d1 = range;
Pair<Vec3d, Vec3d> startAndEnd = getStartAndEndLookVec(lookingEntity, (float) range);
Vec3d vec3 = startAndEnd.getLeft();
if (mop != null) {
d1 = mop.hitVec.distanceTo(vec3);
}
Vec3d vec31 = lookingEntity.getLookVec();
Vec3d vec32 = startAndEnd.getRight();
Entity pointedEntity = null;
Vec3d vec33 = null;
float f1 = 1.0F;
List<Entity> list = lookingEntity.world.getEntitiesWithinAABBExcludingEntity(lookingEntity, lookingEntity.getEntityBoundingBox()
.grow(vec31.x * range, vec31.y * range, vec31.z * range).grow(f1, f1, f1));
double d2 = d1;
for (Entity entity : list) {
if (entity.canBeCollidedWith()) {
float f2 = entity.getCollisionBorderSize();
AxisAlignedBB axisalignedbb = entity.getEntityBoundingBox().grow(f2, f2, f2);
RayTraceResult movingobjectposition = axisalignedbb.calculateIntercept(vec3, vec32);
if (axisalignedbb.contains(vec3)) {
if (0.0D < d2 || d2 == 0.0D) {
pointedEntity = entity;
vec33 = movingobjectposition == null ? vec3 : movingobjectposition.hitVec;
d2 = 0.0D;
}
} else if (movingobjectposition != null) {
double d3 = vec3.distanceTo(movingobjectposition.hitVec);
if (d3 < d2 || d2 == 0.0D) {
if (entity == entity.getRidingEntity() && !entity.canRiderInteract()) {
if (d2 == 0.0D) {
pointedEntity = entity;
vec33 = movingobjectposition.hitVec;
}
} else {
pointedEntity = entity;
vec33 = movingobjectposition.hitVec;
d2 = d3;
}
}
}
}
}
if (pointedEntity != null && (d2 < d1 || mop == null)) {
mop = new RayTraceResult(pointedEntity, vec33);
}
return mop;
}