本文整理汇总了Java中net.minecraft.entity.Entity类的典型用法代码示例。如果您正苦于以下问题:Java Entity类的具体用法?Java Entity怎么用?Java Entity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Entity类属于net.minecraft.entity包,在下文中一共展示了Entity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeEntity
import net.minecraft.entity.Entity; //导入依赖的package包/类
/**
* Schedule the entity for removal during the next tick. Marks the entity dead in anticipation.
*/
public void removeEntity(Entity entityIn)
{
if (entityIn.riddenByEntity != null)
{
entityIn.riddenByEntity.mountEntity((Entity)null);
}
if (entityIn.ridingEntity != null)
{
entityIn.mountEntity((Entity)null);
}
entityIn.setDead();
if (entityIn instanceof EntityPlayer)
{
this.playerEntities.remove(entityIn);
this.updateAllPlayersSleepingFlag();
this.onEntityRemoved(entityIn);
}
}
示例2: setRotationAngles
import net.minecraft.entity.Entity; //导入依赖的package包/类
/**
* Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
* and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
* "far" arms and legs can swing at most.
*/
public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn)
{
super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
this.head.rotateAngleY = netHeadYaw * 0.017453292F;
this.head.rotateAngleX = headPitch * 0.017453292F;
this.body.rotateAngleY = netHeadYaw * 0.017453292F * 0.25F;
float f = MathHelper.sin(this.body.rotateAngleY);
float f1 = MathHelper.cos(this.body.rotateAngleY);
this.rightHand.rotateAngleZ = 1.0F;
this.leftHand.rotateAngleZ = -1.0F;
this.rightHand.rotateAngleY = 0.0F + this.body.rotateAngleY;
this.leftHand.rotateAngleY = (float)Math.PI + this.body.rotateAngleY;
this.rightHand.rotationPointX = f1 * 5.0F;
this.rightHand.rotationPointZ = -f * 5.0F;
this.leftHand.rotationPointX = -f1 * 5.0F;
this.leftHand.rotationPointZ = f * 5.0F;
}
示例3: collideWithNearbyEntities
import net.minecraft.entity.Entity; //导入依赖的package包/类
protected void collideWithNearbyEntities()
{
List<Entity> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox());
if (list != null && !list.isEmpty())
{
for (int i = 0; i < list.size(); ++i)
{
Entity entity = (Entity)list.get(i);
if (entity instanceof EntityMinecart && ((EntityMinecart)entity).getMinecartType() == EntityMinecart.EnumMinecartType.RIDEABLE && this.getDistanceSqToEntity(entity) <= 0.2D)
{
entity.applyEntityCollision(this);
}
}
}
}
示例4: getViewVector
import net.minecraft.entity.Entity; //导入依赖的package包/类
protected Vector3f getViewVector(Entity entityIn, double partialTicks)
{
float f = (float)((double)entityIn.prevRotationPitch + (double)(entityIn.rotationPitch - entityIn.prevRotationPitch) * partialTicks);
float f1 = (float)((double)entityIn.prevRotationYaw + (double)(entityIn.rotationYaw - entityIn.prevRotationYaw) * partialTicks);
if (Minecraft.getMinecraft().gameSettings.thirdPersonView == 2)
{
f += 180.0F;
}
float f2 = MathHelper.cos(-f1 * 0.017453292F - (float)Math.PI);
float f3 = MathHelper.sin(-f1 * 0.017453292F - (float)Math.PI);
float f4 = -MathHelper.cos(-f * 0.017453292F);
float f5 = MathHelper.sin(-f * 0.017453292F);
return new Vector3f(f3 * f4, f5, f2 * f4);
}
示例5: onUserHurt
import net.minecraft.entity.Entity; //导入依赖的package包/类
/**
* Whenever an entity that has this enchantment on one of its associated items is damaged this method will be
* called.
*/
public void onUserHurt(EntityLivingBase user, Entity attacker, int level)
{
Random random = user.getRNG();
ItemStack itemstack = EnchantmentHelper.getEnchantedItem(Enchantment.thorns, user);
if (func_92094_a(level, random))
{
if (attacker != null)
{
attacker.attackEntityFrom(DamageSource.causeThornsDamage(user), (float)func_92095_b(level, random));
attacker.playSound("damage.thorns", 0.5F, 1.0F);
}
if (itemstack != null)
{
itemstack.damageItem(3, user);
}
}
else if (itemstack != null)
{
itemstack.damageItem(1, user);
}
}
示例6: entityToNBT
import net.minecraft.entity.Entity; //导入依赖的package包/类
protected static NBTTagCompound entityToNBT(Entity theEntity)
{
NBTTagCompound nbttagcompound = theEntity.writeToNBT(new NBTTagCompound());
if (theEntity instanceof EntityPlayer)
{
ItemStack itemstack = ((EntityPlayer)theEntity).inventory.getCurrentItem();
if (!itemstack.func_190926_b())
{
nbttagcompound.setTag("SelectedItem", itemstack.writeToNBT(new NBTTagCompound()));
}
}
return nbttagcompound;
}
示例7: renderParticle
import net.minecraft.entity.Entity; //导入依赖的package包/类
/**
* Renders the particle
*/
public void renderParticle(VertexBuffer worldRendererIn, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ)
{
float f = ((float)this.age + partialTicks) / (float)this.maxAge;
f = f * f;
double d0 = this.item.posX;
double d1 = this.item.posY;
double d2 = this.item.posZ;
double d3 = this.target.lastTickPosX + (this.target.posX - this.target.lastTickPosX) * (double)partialTicks;
double d4 = this.target.lastTickPosY + (this.target.posY - this.target.lastTickPosY) * (double)partialTicks + (double)this.yOffset;
double d5 = this.target.lastTickPosZ + (this.target.posZ - this.target.lastTickPosZ) * (double)partialTicks;
double d6 = d0 + (d3 - d0) * (double)f;
double d7 = d1 + (d4 - d1) * (double)f;
double d8 = d2 + (d5 - d2) * (double)f;
int i = this.getBrightnessForRender(partialTicks);
int j = i % 65536;
int k = i / 65536;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j, (float)k);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
d6 = d6 - interpPosX;
d7 = d7 - interpPosY;
d8 = d8 - interpPosZ;
GlStateManager.enableLighting();
this.renderManager.doRenderEntity(this.item, d6, d7, d8, this.item.rotationYaw, partialTicks, false);
}
示例8: joinEntityInSurroundings
import net.minecraft.entity.Entity; //导入依赖的package包/类
/**
* spwans an entity and loads surrounding chunks
*/
public void joinEntityInSurroundings(Entity entityIn)
{
int i = MathHelper.floor_double(entityIn.posX / 16.0D);
int j = MathHelper.floor_double(entityIn.posZ / 16.0D);
int k = 2;
for (int l = i - k; l <= i + k; ++l)
{
for (int i1 = j - k; i1 <= j + k; ++i1)
{
this.getChunkFromChunkCoords(l, i1);
}
}
if (!this.loadedEntityList.contains(entityIn))
{
this.loadedEntityList.add(entityIn);
}
}
示例9: addCollisionBoxToList
import net.minecraft.entity.Entity; //导入依赖的package包/类
/**
* @reason the overwritten method is only one line, we need to overwrite to mutate the AABB and pass params into the event constructor
* @author Brady
*/
@Overwrite
@Deprecated
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean p_185477_7_) {
Block block = (Block) (Object) (this);
AxisAlignedBB axisalignedbb = block.getCollisionBoundingBox(state, worldIn, pos);
BoundingBoxEvent event = new BoundingBoxEvent(block, pos, axisalignedbb, collidingBoxes, entityIn);
ClientAPI.EVENT_BUS.post(event);
if (event.isCancelled())
return;
axisalignedbb = event.getBoundingBox();
addCollisionBoxToList(pos, entityBox, collidingBoxes, axisalignedbb);
}
示例10: setRotationAngles
import net.minecraft.entity.Entity; //导入依赖的package包/类
public void setRotationAngles(float x, float y, float z, float yaw, float pitch, float tick, Entity entity)
{
super.setRotationAngles(x, y, z, yaw, pitch, tick, entity);
// Looking at things
this.head.rotateAngleY = yaw / (180F / (float) Math.PI);
this.head.rotateAngleX = pitch / (180F / (float) Math.PI);
// Leg movement when wandering around?
this.legC1.rotateAngleX = MathHelper.cos(x * 0.6662F) * 1.4F * y;
this.legC1.rotateAngleY = 0.0F;
this.legC2.rotateAngleX = MathHelper.cos(x * 0.6662F + (float)Math.PI) * 1.4F * y;
this.legC2.rotateAngleY = 0.0F;
this.legC3.rotateAngleX = MathHelper.cos(x * 0.6662F) * 1.4F * y;
this.legC3.rotateAngleY = 0.0F;
this.legC4.rotateAngleX = MathHelper.cos(x * 0.6662F + (float)Math.PI) * 1.4F * y;
this.legC4.rotateAngleY = 0.0F;
}
示例11: newExplosion
import net.minecraft.entity.Entity; //导入依赖的package包/类
/**
* returns a new explosion. Does initiation (at time of writing Explosion is not finished)
*/
public Explosion newExplosion(Entity entityIn, double x, double y, double z, float strength, boolean isFlaming, boolean isSmoking)
{
Explosion explosion = new Explosion(this, entityIn, x, y, z, strength, isFlaming, isSmoking);
explosion.doExplosionA();
explosion.doExplosionB(false);
if (!isSmoking)
{
explosion.func_180342_d();
}
for (EntityPlayer entityplayer : this.playerEntities)
{
if (entityplayer.getDistanceSq(x, y, z) < 4096.0D)
{
((EntityPlayerMP)entityplayer).playerNetServerHandler.sendPacket(new S27PacketExplosion(x, y, z, strength, explosion.getAffectedBlockPositions(), (Vec3)explosion.getPlayerKnockbackMap().get(entityplayer)));
}
}
return explosion;
}
示例12: setRotationAngles
import net.minecraft.entity.Entity; //导入依赖的package包/类
/**
* Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
* and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
* "far" arms and legs can swing at most.
*/
public void setRotationAngles(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity entityIn)
{
super.setRotationAngles(p_78087_1_, p_78087_2_, p_78087_3_, p_78087_4_, p_78087_5_, p_78087_6_, entityIn);
float f = MathHelper.sin(this.swingProgress * (float)Math.PI);
float f1 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * (float)Math.PI);
this.bipedRightArm.rotateAngleZ = 0.0F;
this.bipedLeftArm.rotateAngleZ = 0.0F;
this.bipedRightArm.rotateAngleY = -(0.1F - f * 0.6F);
this.bipedLeftArm.rotateAngleY = 0.1F - f * 0.6F;
this.bipedRightArm.rotateAngleX = -((float)Math.PI / 2F);
this.bipedLeftArm.rotateAngleX = -((float)Math.PI / 2F);
this.bipedRightArm.rotateAngleX -= f * 1.2F - f1 * 0.4F;
this.bipedLeftArm.rotateAngleX -= f * 1.2F - f1 * 0.4F;
this.bipedRightArm.rotateAngleZ += MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F;
this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F;
this.bipedRightArm.rotateAngleX += MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F;
this.bipedLeftArm.rotateAngleX -= MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F;
}
示例13: onImpact
import net.minecraft.entity.Entity; //导入依赖的package包/类
protected void onImpact(RayTraceResult result) {
if (!this.world.isRemote && this.world instanceof WorldServer) {
if (result.typeOfHit == RayTraceResult.Type.ENTITY && result.entityHit != null
&& !result.entityHit.equals(this.caster)) {
Entity entity = result.entityHit;
if (!entity.isImmuneToFire()) {
entity.setFire(7);
}
} else if (result.typeOfHit == RayTraceResult.Type.BLOCK && result.getBlockPos() != null
&& result.sideHit != null) {
BlockPos offsetPos = result.getBlockPos().offset(result.sideHit);
if (this.world.getBlockState(offsetPos).getMaterial() != Material.WATER
&& (this.world.isAirBlock(offsetPos)
|| this.world.getBlockState(offsetPos).getBlock().isReplaceable(this.world, offsetPos))
&& Blocks.FIRE.canPlaceBlockAt(this.world, offsetPos)) {
this.world.setBlockState(offsetPos, Blocks.FIRE.getDefaultState(), 11);
}
}
}
}
示例14: navigateTo
import net.minecraft.entity.Entity; //导入依赖的package包/类
@Override
public boolean navigateTo(Entity dest, Consumer<BlockPos> job, double maxDist) {
if (dest == null || dest.isDead) {
return false;
}
double d = getSquareDist(entity, dest);
if (d > maxDist * maxDist) {
return false;
} else if (d < DISTANCE_TOLERANCE) {
job.accept(dest.getPosition());
} else if (!entity.getNavigator().tryMoveToEntityLiving(dest, 2.0)) {
// We need to teleport
entity.setPositionAndUpdate(dest.posX, dest.posY, dest.posZ);
job.accept(dest.getPosition());
} else {
this.movingToPos = null;
this.movingToEntity = dest;
pathTries = 1;
this.job = job;
}
return true;
}
示例15: onMessage
import net.minecraft.entity.Entity; //导入依赖的package包/类
@Override
public IMessage onMessage(final TeleportMessage message, final MessageContext ctx)
{
// Don't act here - if we cause chunk loading on this thread (netty) then chunks will get
// lost from the server.
IThreadListener mainThread = null;
if (ctx.side == Side.CLIENT)
mainThread = Minecraft.getMinecraft();
else
mainThread = MinecraftServer.getServer();
mainThread.addScheduledTask(new Runnable()
{
@Override
public void run()
{
EnumSet<S08PacketPlayerPosLook.EnumFlags> enumset = EnumSet.noneOf(S08PacketPlayerPosLook.EnumFlags.class);
if (!message.setX)
enumset.add(S08PacketPlayerPosLook.EnumFlags.X);
if (!message.setY)
enumset.add(S08PacketPlayerPosLook.EnumFlags.Y);
if (!message.setZ)
enumset.add(S08PacketPlayerPosLook.EnumFlags.Z);
if (!message.setYaw)
enumset.add(S08PacketPlayerPosLook.EnumFlags.Y_ROT);
if (!message.setPitch)
enumset.add(S08PacketPlayerPosLook.EnumFlags.X_ROT);
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
player.mountEntity((Entity) null);
player.playerNetServerHandler.setPlayerLocation(message.x, message.y, message.z, message.yaw, message.pitch, enumset);
player.setRotationYawHead(message.yaw);
}
});
return null;
}