本文整理了Java中net.minecraft.entity.Entity
类的一些代码示例,展示了Entity
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity
类的具体详情如下:
包路径:net.minecraft.entity.Entity
类名称:Entity
暂无
代码示例来源:origin: Vazkii/Botania
public static void particleBeam(EntityPlayer player, Entity e1, Entity e2) {
if(e1 != null && e2 != null && !e1.world.isRemote) {
PacketHandler.sendTo((EntityPlayerMP) player,
new PacketBotaniaEffect(PacketBotaniaEffect.EffectType.SPARK_NET_INDICATOR, e1.posX, e1.posY, e1.posZ,
e1.getEntityId(), e2.getEntityId()));
}
}
代码示例来源:origin: Vazkii/Botania
private static Vector3 getRelativeViewVector(Vector3 pos) {
Entity renderEntity = Minecraft.getMinecraft().getRenderViewEntity();
return new Vector3((float) renderEntity.posX - pos.x, (float) renderEntity.posY + renderEntity.getEyeHeight() - pos.y, (float) renderEntity.posZ - pos.z);
}
代码示例来源:origin: EngineHub/WorldEdit
@Override
public boolean remove() {
net.minecraft.entity.Entity entity = entityRef.get();
if (entity != null) {
entity.setDead();
}
return true;
}
代码示例来源:origin: EngineHub/WorldEdit
@Nullable
@Override
public Entity createEntity(Location location, BaseEntity entity) {
World world = getWorld();
net.minecraft.entity.Entity createdEntity = EntityList.createEntityByIDFromName(new ResourceLocation(entity.getType().getId()), world);
if (createdEntity != null) {
CompoundTag nativeTag = entity.getNbtData();
if (nativeTag != null) {
NBTTagCompound tag = NBTConverter.toNative(entity.getNbtData());
for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) {
tag.removeTag(name);
}
createdEntity.readFromNBT(tag);
}
createdEntity.setLocationAndAngles(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
world.spawnEntity(createdEntity);
return new ForgeEntity(createdEntity);
} else {
return null;
}
}
代码示例来源:origin: Vazkii/Botania
if(!world.isRemote && pos.entityHit != null && pos.entityHit instanceof EntityLivingBase && pos.entityHit != getThrower()) {
EntityLivingBase thrower = getThrower();
pos.entityHit.attackEntityFrom(thrower != null ? thrower instanceof EntityPlayer ? DamageSource.causeThrownDamage(this, thrower) : DamageSource.causeMobDamage(thrower) : DamageSource.GENERIC, 12);
if(isFire())
pos.entityHit.setFire(5);
else if(world.rand.nextInt(3) == 0)
((EntityLivingBase) pos.entityHit).addPotionEffect(new PotionEffect(MobEffects.POISON, 60, 0));
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
if( entity1.isEntityAlive() )
if( entity1.isRidingOrBeingRiddenBy( p ) )
final AxisAlignedBB boundingBox = entity1.getEntityBoundingBox().grow( f1, f1, f1 );
final RayTraceResult RayTraceResult = boundingBox.calculateIntercept( Vec3d, Vec3d1 );
final int id = pos.entityHit.getEntityId();
final PlayerColor marker = new PlayerColor( id, col, 20 * 30 );
TickHandler.INSTANCE.getPlayerColors().put( id, marker );
pos.entityHit.attackEntityFrom( DamageSource.causePlayerDamage( p ), 0 );
NetworkHandler.instance().sendToAll( marker.getPacket() );
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
if( entity1.isEntityAlive() )
if( entity1.isRidingOrBeingRiddenBy( p ) )
final AxisAlignedBB boundingBox = entity1.getEntityBoundingBox().grow( f1, f1, f1 );
final RayTraceResult RayTraceResult = boundingBox.calculateIntercept( Vec3d, Vec3d1 );
pos.entityHit.setDead();
else if( pos.entityHit.attackEntityFrom( dmgSrc, dmg ) )
代码示例来源:origin: Vazkii/Botania
@Override
protected void onImpact(RayTraceResult pos) {
if (world.isRemote)
return;
EntityLivingBase thrower = getThrower();
if(pos.entityHit != null && thrower != null && pos.entityHit != thrower && !pos.entityHit.isDead) {
if(thrower instanceof EntityPlayer)
pos.entityHit.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) thrower), Math.random() < 0.25 ? 10 : 5);
else pos.entityHit.attackEntityFrom(DamageSource.GENERIC, Math.random() < 0.25 ? 10 : 5);
}
if (pos.getBlockPos() != null) {
IBlockState state = world.getBlockState(pos.getBlockPos());
if(ConfigHandler.blockBreakParticles && !state.getBlock().isAir(state, world, pos.getBlockPos()))
world.playEvent(2001, pos.getBlockPos(), Block.getStateId(state));
}
setDead();
}
代码示例来源:origin: Vazkii/Botania
if (entity1.canBeCollidedWith() && (!(entity1 instanceof EntityPlayer) || pickupDelay == 0)) {
float f = 1.0F;
AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().grow(f);
RayTraceResult RayTraceResult1 = axisalignedbb.calculateIntercept(vec3, vec31);
RayTraceResult.entityHit.attackEntityFrom(DamageSource.MAGIC, 2.0F);
if (!world.isRemote) {
Entity item = getItem().getItem().createEntity(world, this, getItem());
代码示例来源:origin: TehNut/HWYLA
public MessageRequestEntity(Entity entity, Set<String> keys) {
this.dim = entity.getEntityWorld().provider.getDimension();
this.entityId = entity.getEntityId();
this.keys = keys;
}
代码示例来源:origin: ldtteam/minecolonies
@Override
public boolean tryMoveToEntityLiving(@NotNull final Entity e, final double speed)
{
return tryMoveToBlockPos(e.getPosition(), speed);
}
代码示例来源:origin: vadis365/TheErebus
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
if (entity instanceof EntityLivingBase) {
int Knockback = 1;
entity.attackEntityFrom(DamageSource.CACTUS, 1);
entity.addVelocity(MathHelper.sin(entity.rotationYaw * 3.141593F / 180.0F) * Knockback * 0.1F, 0.08D, -MathHelper.cos(entity.rotationYaw * 3.141593F / 180.0F) * Knockback * 0.1F);
entity.getEntityWorld().playSound(null, pos, ModSounds.GLOW_WORM_HURT, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
}
代码示例来源:origin: TeamLapen/Vampirism
/**
* @return The nearest village the entity is in or next to.
*/
public static @Nullable
VampirismVillage getNearestVillage(Entity e) {
return getNearestVillage(e.getEntityWorld(), e.getPosition(), 10);
}
代码示例来源:origin: SleepyTrousers/EnderIO
@Override
public void onEntityCollidedWithBlock(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull Entity entity) {
if (!world.isRemote && !entity.isImmuneToFire()) {
entity.attackEntityFrom(DamageSource.LAVA, 4.0F);
entity.setFire(15);
}
super.onEntityCollidedWithBlock(world, pos, state, entity);
}
代码示例来源:origin: Vazkii/Botania
this.lastTickPosY = this.posY;
this.lastTickPosZ = this.posZ;
super.onUpdate();
if (entity1.canBeCollidedWith())
AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().grow(0.30000001192092896D);
RayTraceResult raytraceresult1 = axisalignedbb.calculateIntercept(vec3d, vec3d1);
代码示例来源:origin: SleepyTrousers/EnderIO
public SoundSource(Entity ent, float volume) {
AxisAlignedBB bb = ent.getEntityBoundingBox();
pos = new Vector3d(bb.minX + (bb.maxX - bb.minX) / 2, bb.minY + (bb.maxY - bb.minY) / 2, bb.minZ + (bb.maxZ - bb.minZ) / 2);
this.volume = volume;
isEntity = true;
}
代码示例来源:origin: Vazkii/Botania
if(e == player)
continue;
if(e.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null) && !(e instanceof EntityPlayer)) {
if(scanInventory(e.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null), pstack))
entIdBuilder.add(e.getEntityId());
IInventory inv = (IInventory) e;
if(scanInventory(new InvWrapper(inv), pstack))
entIdBuilder.add(e.getEntityId());
代码示例来源:origin: TehNut/HWYLA
public static RayTraceResult rayTraceServer(Entity entity, double distance) {
double eyeHeight = entity.posY + entity.getEyeHeight();
Vec3d headVec = new Vec3d(entity.posX, eyeHeight, entity.posZ);
Vec3d start = new Vec3d(headVec.x, headVec.y, headVec.z);
Vec3d lookVec = entity.getLook(1.0F);
headVec.add(new Vec3d(lookVec.x * distance, lookVec.y * distance, lookVec.z * distance));
return entity.getEntityWorld().rayTraceBlocks(start, headVec, ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_LIQUID, true));
}
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
@Override
public void placeEntity( World world, Entity entity, float yaw )
{
entity.setLocationAndAngles( this.destination.x, this.destination.y, this.destination.z, yaw, entity.rotationPitch );
entity.motionX = entity.motionY = entity.motionZ = 0.0D;
}
}
代码示例来源:origin: SleepyTrousers/EnderIO
private static boolean isClear(@Nonnull World world, @Nonnull Entity entity, double targetX, double targetY, double targetZ) {
double origX = entity.posX, origY = entity.posY, origZ = entity.posZ;
try {
entity.setPosition(targetX, targetY, targetZ);
boolean result = world.checkNoEntityCollision(entity.getEntityBoundingBox(), entity)
&& world.getCollisionBoxes(entity, entity.getEntityBoundingBox()).isEmpty() && !world.containsAnyLiquid(entity.getEntityBoundingBox());
return result;
} finally {
entity.setPosition(origX, origY, origZ);
}
}
内容来源于网络,如有侵权,请联系作者删除!