Java Code Examples for net.minecraft.entity.Entity

The following are top voted examples for showing how to use net.minecraft.entity.Entity. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: CustomWorldGen   File: ModelSnowMan.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
}
 
Example 2
Project: BaseClient   File: EntityArmorStand.java   Source Code and License 6 votes vote down vote up
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);
            }
        }
    }
}
 
Example 3
Project: CustomWorldGen   File: RenderGlobal.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 4
Project: Backmemed   File: CommandBase.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 5
Project: CustomWorldGen   File: ParticleItemPickup.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
}
 
Example 6
Project: BaseClient   File: World.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 7
Project: ClientAPI   File: MixinBlock.java   Source Code and License 6 votes vote down vote up
/**
 * @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);
}
 
Example 8
Project: minecraft-quiverbow   File: Model_AA.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 9
Project: Infernum   File: EntityFireBreath.java   Source Code and License 6 votes vote down vote up
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);
			}
		}
	}
}
 
Example 10
Project: MeeCreeps   File: WorkerHelper.java   Source Code and License 6 votes vote down vote up
@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;
}
 
Example 11
Project: Proyecto-DASI   File: AbsoluteMovementCommandsImplementation.java   Source Code and License 5 votes vote down vote up
@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;
}
 
Example 12
Project: BaseClient   File: EnchantmentHelper.java   Source Code and License 5 votes vote down vote up
public static void applyArthropodEnchantments(EntityLivingBase p_151385_0_, Entity p_151385_1_)
{
    ENCHANTMENT_ITERATOR_DAMAGE.user = p_151385_0_;
    ENCHANTMENT_ITERATOR_DAMAGE.target = p_151385_1_;

    if (p_151385_0_ != null)
    {
        applyEnchantmentModifierArray(ENCHANTMENT_ITERATOR_DAMAGE, p_151385_0_.getInventory());
    }

    if (p_151385_0_ instanceof EntityPlayer)
    {
        applyEnchantmentModifier(ENCHANTMENT_ITERATOR_DAMAGE, p_151385_0_.getHeldItem());
    }
}
 
Example 13
Project: harshencastle   File: HarshenTemplate.java   Source Code and License 5 votes vote down vote up
private void addEntitiesToWorld(World worldIn, BlockPos pos, Mirror mirrorIn, Rotation rotationIn, @Nullable StructureBoundingBox aabb)
{
    for (Template.EntityInfo template$entityinfo : this.entities)
    {
        BlockPos blockpos = transformedBlockPos(template$entityinfo.blockPos, mirrorIn, rotationIn).add(pos);

        if (aabb == null || aabb.isVecInside(blockpos))
        {
            NBTTagCompound nbttagcompound = template$entityinfo.entityData;
            Vec3d vec3d = transformedVec3d(template$entityinfo.pos, mirrorIn, rotationIn);
            Vec3d vec3d1 = vec3d.addVector((double)pos.getX(), (double)pos.getY(), (double)pos.getZ());
            NBTTagList nbttaglist = new NBTTagList();
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.x));
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.y));
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.z));
            nbttagcompound.setTag("Pos", nbttaglist);
            nbttagcompound.setUniqueId("UUID", UUID.randomUUID());
            Entity entity;

            try
            {
                entity = EntityList.createEntityFromNBT(nbttagcompound, worldIn);
            }
            catch (Exception var15)
            {
                entity = null;
            }

            if (entity != null)
            {
                float f = entity.getMirroredYaw(mirrorIn);
                f = f + (entity.rotationYaw - entity.getRotatedYaw(rotationIn));
                entity.setLocationAndAngles(vec3d1.x, vec3d1.y, vec3d1.z, f, entity.rotationPitch);
                worldIn.spawnEntity(entity);
            }
        }
    }
}
 
Example 14
Project: Backmemed   File: ModelGhast.java   Source Code and License 5 votes vote down vote up
/**
 * 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)
{
    for (int i = 0; i < this.tentacles.length; ++i)
    {
        this.tentacles[i].rotateAngleX = 0.2F * MathHelper.sin(ageInTicks * 0.3F + (float)i) + 0.4F;
    }
}
 
Example 15
Project: CustomWorldGen   File: Teleporter.java   Source Code and License 5 votes vote down vote up
public void placeInPortal(Entity entityIn, float rotationYaw)
{
    if (this.worldServerInstance.provider.getDimensionType().getId() != 1)
    {
        if (!this.placeInExistingPortal(entityIn, rotationYaw))
        {
            this.makePortal(entityIn);
            this.placeInExistingPortal(entityIn, rotationYaw);
        }
    }
    else
    {
        int i = MathHelper.floor_double(entityIn.posX);
        int j = MathHelper.floor_double(entityIn.posY) - 1;
        int k = MathHelper.floor_double(entityIn.posZ);
        int l = 1;
        int i1 = 0;

        for (int j1 = -2; j1 <= 2; ++j1)
        {
            for (int k1 = -2; k1 <= 2; ++k1)
            {
                for (int l1 = -1; l1 < 3; ++l1)
                {
                    int i2 = i + k1 * 1 + j1 * 0;
                    int j2 = j + l1;
                    int k2 = k + k1 * 0 - j1 * 1;
                    boolean flag = l1 < 0;
                    this.worldServerInstance.setBlockState(new BlockPos(i2, j2, k2), flag ? Blocks.OBSIDIAN.getDefaultState() : Blocks.AIR.getDefaultState());
                }
            }
        }

        entityIn.setLocationAndAngles((double)i, (double)j, (double)k, entityIn.rotationYaw, 0.0F);
        entityIn.motionX = 0.0D;
        entityIn.motionY = 0.0D;
        entityIn.motionZ = 0.0D;
    }
}
 
Example 16
Project: CraftingParadiseMod   File: EntityHandler.java   Source Code and License 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOW)
public void onEntityConstruction(EntityEvent.EntityConstructing event)
{
    Entity entity = event.getEntity();
    if(entity instanceof EntityPlayer)
    {
        if(entity.world != null)
        {
            if(event.getEntity().world.isRemote)
            {
                CraftingParadise.proxy.registerCustomSky();
            }
        }
    }
}
 
Example 17
Project: BaseClient   File: EntityPlayer.java   Source Code and License 5 votes vote down vote up
private Collection<ScoreObjective> func_175137_e(Entity p_175137_1_)
{
    ScorePlayerTeam scoreplayerteam = this.getWorldScoreboard().getPlayersTeam(this.getName());

    if (scoreplayerteam != null)
    {
        int i = scoreplayerteam.getChatFormat().getColorIndex();

        if (i >= 0 && i < IScoreObjectiveCriteria.field_178793_i.length)
        {
            for (ScoreObjective scoreobjective : this.getWorldScoreboard().getObjectivesFromCriteria(IScoreObjectiveCriteria.field_178793_i[i]))
            {
                Score score = this.getWorldScoreboard().getValueFromObjective(p_175137_1_.getName(), scoreobjective);
                score.func_96648_a();
            }
        }
    }

    ScorePlayerTeam scoreplayerteam1 = this.getWorldScoreboard().getPlayersTeam(p_175137_1_.getName());

    if (scoreplayerteam1 != null)
    {
        int j = scoreplayerteam1.getChatFormat().getColorIndex();

        if (j >= 0 && j < IScoreObjectiveCriteria.field_178792_h.length)
        {
            return this.getWorldScoreboard().getObjectivesFromCriteria(IScoreObjectiveCriteria.field_178792_h[j]);
        }
    }

    return Lists.<ScoreObjective>newArrayList();
}
 
Example 18
Project: BaseClient   File: CommandTestFor.java   Source Code and License 5 votes vote down vote up
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length < 1)
    {
        throw new WrongUsageException("commands.testfor.usage", new Object[0]);
    }
    else
    {
        Entity entity = func_175768_b(sender, args[0]);
        NBTTagCompound nbttagcompound = null;

        if (args.length >= 2)
        {
            try
            {
                nbttagcompound = JsonToNBT.getTagFromJson(buildString(args, 1));
            }
            catch (NBTException nbtexception)
            {
                throw new CommandException("commands.testfor.tagError", new Object[] {nbtexception.getMessage()});
            }
        }

        if (nbttagcompound != null)
        {
            NBTTagCompound nbttagcompound1 = new NBTTagCompound();
            entity.writeToNBT(nbttagcompound1);

            if (!NBTUtil.func_181123_a(nbttagcompound, nbttagcompound1, true))
            {
                throw new CommandException("commands.testfor.failure", new Object[] {entity.getName()});
            }
        }

        notifyOperators(sender, this, "commands.testfor.success", new Object[] {entity.getName()});
    }
}
 
Example 19
Project: interactionwheel   File: RenderHelper.java   Source Code and License 5 votes vote down vote up
public static boolean renderObject(Minecraft mc, int x, int y, Object itm, boolean highlight) {
    if (itm instanceof Entity) {
        renderEntity((Entity) itm, x, y, 10);
        return true;
    }
    RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
    return renderObject(mc, itemRender, x, y, itm, highlight, 200);
}
 
Example 20
Project: BaseClient   File: BlockTripWire.java   Source Code and License 5 votes vote down vote up
/**
 * Called When an Entity Collided with the Block
 */
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
{
    if (!worldIn.isRemote)
    {
        if (!((Boolean)state.getValue(POWERED)).booleanValue())
        {
            this.updateState(worldIn, pos);
        }
    }
}
 
Example 21
Project: Mods   File: TF2Message.java   Source Code and License 5 votes vote down vote up
public CapabilityMessage(Entity entity,boolean sendAll) {
	WeaponsCapability cap = entity.getCapability(TF2weapons.WEAPONS_CAP, null);
	this.entityID = entity.getEntityId();
	this.healTarget = cap.getHealTarget();
	//this.critTime = cap.critTime;
	//this.heads = cap.collectedHeads;
	if(sendAll) {
		this.entries=cap.dataManager.getAll();
	}
	else {
		this.entries=cap.dataManager.getDirty();
	}
	// new Exception().printStackTrace();
}
 
Example 22
Project: RunicArcana   File: AirStrikeFX.java   Source Code and License 5 votes vote down vote up
@Override
public void renderParticle(VertexBuffer vertexBuffer, Entity entity, float partialTick,
                           float edgeLRdirectionX, float edgeUDdirectionY, float edgeLRdirectionZ,
                           float edgeUDdirectionX, float edgeUDdirectionZ)
{
    double minU = this.particleTexture.getMinU();
    double maxU = this.particleTexture.getMaxU();
    double minV = this.particleTexture.getMinV();
    double maxV = this.particleTexture.getMaxV();

    double scale = 0.1F * this.particleScale;  // vanilla scaling factor
    final double scaleLR = scale;
    final double scaleUD = scale;
    double x = this.prevPosX + (this.posX - this.prevPosX) * partialTick - interpPosX;
    double y = this.prevPosY + (this.posY - this.prevPosY) * partialTick - interpPosY;
    double z = this.prevPosZ + (this.posZ - this.prevPosZ) * partialTick - interpPosZ;

    int combinedBrightness = this.getBrightnessForRender(partialTick);
    int skyLightTimes16 = combinedBrightness >> 16 & 65535;
    int blockLightTimes16 = combinedBrightness & 65535;

    vertexBuffer.pos(x - edgeLRdirectionX * scaleLR - edgeUDdirectionX * scaleUD, y - edgeUDdirectionY * scaleUD, z - edgeLRdirectionZ * scaleLR - edgeUDdirectionZ * scaleUD).tex(maxU, maxV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(skyLightTimes16, blockLightTimes16).endVertex();
    vertexBuffer.pos(x - edgeLRdirectionX * scaleLR + edgeUDdirectionX * scaleUD, y + edgeUDdirectionY * scaleUD, z - edgeLRdirectionZ * scaleLR + edgeUDdirectionZ * scaleUD).tex(maxU, minV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(skyLightTimes16, blockLightTimes16).endVertex();
    vertexBuffer.pos(x + edgeLRdirectionX * scaleLR + edgeUDdirectionX * scaleUD, y + edgeUDdirectionY * scaleUD, z + edgeLRdirectionZ * scaleLR + edgeUDdirectionZ * scaleUD).tex(minU, minV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(skyLightTimes16, blockLightTimes16).endVertex();
    vertexBuffer.pos(x + edgeLRdirectionX * scaleLR - edgeUDdirectionX * scaleUD, y - edgeUDdirectionY * scaleUD, z + edgeLRdirectionZ * scaleLR - edgeUDdirectionZ * scaleUD).tex(minU, maxV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(skyLightTimes16, blockLightTimes16).endVertex();

}
 
Example 23
Project: Backmemed   File: Chunk.java   Source Code and License 5 votes vote down vote up
/**
 * Called when this Chunk is unloaded by the ChunkProvider
 */
public void onChunkUnload()
{
    this.isChunkLoaded = false;

    for (TileEntity tileentity : this.chunkTileEntityMap.values())
    {
        this.worldObj.markTileEntityForRemoval(tileentity);
    }

    for (ClassInheritanceMultiMap<Entity> classinheritancemultimap : this.entityLists)
    {
        this.worldObj.unloadEntities(classinheritancemultimap);
    }
}
 
Example 24
Project: CustomWorldGen   File: FMLMessage.java   Source Code and License 5 votes vote down vote up
@Override
void toBytes(ByteBuf buf)
{
    super.toBytes(buf);
    ByteBufUtils.writeUTF8String(buf, modId);
    buf.writeInt(modEntityTypeId);
    buf.writeLong(entity.getUniqueID().getMostSignificantBits());
    buf.writeLong(entity.getUniqueID().getLeastSignificantBits());
    // posX, posY, posZ
    buf.writeDouble(entity.posX);
    buf.writeDouble(entity.posY);
    buf.writeDouble(entity.posZ);
    // yaw, pitch
    buf.writeByte((byte)(entity.rotationYaw * 256.0F / 360.0F));
    buf.writeByte((byte) (entity.rotationPitch * 256.0F / 360.0F));
    // head yaw
    if (entity instanceof EntityLivingBase)
    {
        buf.writeByte((byte) (((EntityLivingBase)entity).rotationYawHead * 256.0F / 360.0F));
    }
    else
    {
        buf.writeByte(0);
    }
    ByteBuf tmpBuf = Unpooled.buffer();
    PacketBuffer pb = new PacketBuffer(tmpBuf);
    try
    {
        entity.getDataManager().writeEntries(pb);
    } catch (IOException e)
    {
        FMLLog.log(Level.FATAL,e,"Encountered fatal exception trying to send entity spawn data watchers");
        throw Throwables.propagate(e);
    }
    buf.writeBytes(tmpBuf);

    if (entity instanceof IThrowableEntity)
    {
        Entity owner = ((IThrowableEntity)entity).getThrower();
        buf.writeInt(owner == null ? entity.getEntityId() : owner.getEntityId());
        double maxVel = 3.9D;
        double mX = entity.motionX;
        double mY = entity.motionY;
        double mZ = entity.motionZ;
        if (mX < -maxVel) mX = -maxVel;
        if (mY < -maxVel) mY = -maxVel;
        if (mZ < -maxVel) mZ = -maxVel;
        if (mX >  maxVel) mX =  maxVel;
        if (mY >  maxVel) mY =  maxVel;
        if (mZ >  maxVel) mZ =  maxVel;
        buf.writeInt((int)(mX * 8000D));
        buf.writeInt((int)(mY * 8000D));
        buf.writeInt((int)(mZ * 8000D));
    }
    else
    {
        buf.writeInt(0);
    }
    if (entity instanceof IEntityAdditionalSpawnData)
    {
        tmpBuf = Unpooled.buffer();
        ((IEntityAdditionalSpawnData)entity).writeSpawnData(tmpBuf);
        buf.writeBytes(tmpBuf);
    }
}
 
Example 25
Project: CustomWorldGen   File: ParticleLava.java   Source Code and License 5 votes vote down vote up
/**
 * 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.particleAge + partialTicks) / (float)this.particleMaxAge;
    this.particleScale = this.lavaParticleScale * (1.0F - f * f);
    super.renderParticle(worldRendererIn, entityIn, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ);
}
 
Example 26
Project: pnc-repressurized   File: PneumaticCraftUtils.java   Source Code and License 5 votes vote down vote up
private static boolean isEntityValidForName(String filter, Entity entity) throws IllegalArgumentException {
    if (filter.equals("")) {
        return true;
    } else if (filter.startsWith("@")) {//entity type selection
        filter = filter.substring(1); //cut off the '@'.
        Class typeClass = null;
        if (filter.equals("mob")) {
            typeClass = EntityMob.class;
        } else if (filter.equals("animal")) {
            typeClass = EntityAnimal.class;
        } else if (filter.equals("living")) {
            typeClass = EntityLivingBase.class;
        } else if (filter.equals("player")) {
            typeClass = EntityPlayer.class;
        } else if (filter.equals("item")) {
            typeClass = EntityItem.class;
        } else if (filter.equals("minecart")) {
            typeClass = EntityMinecart.class;
        } else if (filter.equals("drone")) {
            typeClass = EntityDrone.class;
        }
        if (typeClass != null) {
            return typeClass.isAssignableFrom(entity.getClass());
        } else {
            throw new IllegalArgumentException(filter + " is not a valid entity type.");
        }
    } else {
        try {
            String regex = filter.toLowerCase().replaceAll(".", "[$0]").replace("[*]", ".*");//Wildcard regex
            return entity.getName().toLowerCase().matches(regex);//TODO when player, check if entity is tamed by the player (see EntityAIAvoidEntity for example)
        } catch (PatternSyntaxException e) {
            return entity.getName().toLowerCase().equals(filter.toLowerCase());
        }
    }
}
 
Example 27
Project: CustomWorldGen   File: EntityThrowable.java   Source Code and License 5 votes vote down vote up
@Nullable
public EntityLivingBase getThrower()
{
    if (this.thrower == null && this.throwerName != null && !this.throwerName.isEmpty())
    {
        this.thrower = this.worldObj.getPlayerEntityByName(this.throwerName);

        if (this.thrower == null && this.worldObj instanceof WorldServer)
        {
            try
            {
                Entity entity = ((WorldServer)this.worldObj).getEntityFromUuid(UUID.fromString(this.throwerName));

                if (entity instanceof EntityLivingBase)
                {
                    this.thrower = (EntityLivingBase)entity;
                }
            }
            catch (Throwable var2)
            {
                this.thrower = null;
            }
        }
    }

    return this.thrower;
}
 
Example 28
Project: BaseClient   File: ModelSilverfish.java   Source Code and License 5 votes vote down vote up
/**
 * 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)
{
    for (int i = 0; i < this.silverfishBodyParts.length; ++i)
    {
        this.silverfishBodyParts[i].rotateAngleY = MathHelper.cos(p_78087_3_ * 0.9F + (float)i * 0.15F * (float)Math.PI) * (float)Math.PI * 0.05F * (float)(1 + Math.abs(i - 2));
        this.silverfishBodyParts[i].rotationPointX = MathHelper.sin(p_78087_3_ * 0.9F + (float)i * 0.15F * (float)Math.PI) * (float)Math.PI * 0.2F * (float)Math.abs(i - 2);
    }

    this.silverfishWings[0].rotateAngleY = this.silverfishBodyParts[2].rotateAngleY;
    this.silverfishWings[1].rotateAngleY = this.silverfishBodyParts[4].rotateAngleY;
    this.silverfishWings[1].rotationPointX = this.silverfishBodyParts[4].rotationPointX;
    this.silverfishWings[2].rotateAngleY = this.silverfishBodyParts[1].rotateAngleY;
    this.silverfishWings[2].rotationPointX = this.silverfishBodyParts[1].rotationPointX;
}
 
Example 29
Project: CustomWorldGen   File: EntityEvent.java   Source Code and License 5 votes vote down vote up
public EnteringChunk(Entity entity, int newChunkX, int newChunkZ, int oldChunkX, int oldChunkZ)
{
    super(entity);
    this.setNewChunkX(newChunkX);
    this.setNewChunkZ(newChunkZ);
    this.setOldChunkX(oldChunkX);
    this.setOldChunkZ(oldChunkZ);
}
 
Example 30
Project: Backmemed   File: CrystalLog.java   Source Code and License 5 votes vote down vote up
public void onUpdate(EntityPlayerSP player) {
	if(isEnabled()) {
		for (Entity e : Wrapper.getWorld().loadedEntityList) {
			if (e instanceof EntityEnderCrystal) {
				if (player.getDistanceToEntity(e) > distance.getValue() && player.getPosition().getY() >= e.getPosition().getY()) {
					Wrapper.getWorld().sendQuittingDisconnectingPacket();
					Hacks.findMod(CrystalLog.class).toggle();
				}
			}
		}
	}
}
 
Example 31
Project: Backmemed   File: WorldClient.java   Source Code and License 5 votes vote down vote up
/**
 * Runs a single tick for the world
 */
public void tick()
{
    super.tick();
    this.setTotalWorldTime(this.getTotalWorldTime() + 1L);

    if (this.getGameRules().getBoolean("doDaylightCycle"))
    {
        this.setWorldTime(this.getWorldTime() + 1L);
    }

    this.theProfiler.startSection("reEntryProcessing");

    for (int i = 0; i < 10 && !this.entitySpawnQueue.isEmpty(); ++i)
    {
        Entity entity = (Entity)this.entitySpawnQueue.iterator().next();
        this.entitySpawnQueue.remove(entity);

        if (!this.loadedEntityList.contains(entity))
        {
            this.spawnEntityInWorld(entity);
        }
    }

    this.theProfiler.endStartSection("chunkCache");
    this.clientChunkProvider.unloadQueuedChunks();
    this.theProfiler.endStartSection("blocks");
    this.updateBlocks();
    this.theProfiler.endSection();
}
 
Example 32
Project: Backmemed   File: ParticleFootStep.java   Source Code and License 5 votes vote down vote up
/**
 * 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.footstepAge + partialTicks) / (float)this.footstepMaxAge;
    f = f * f;
    float f1 = 2.0F - f * 2.0F;

    if (f1 > 1.0F)
    {
        f1 = 1.0F;
    }

    f1 = f1 * 0.2F;
    GlStateManager.disableLighting();
    float f2 = 0.125F;
    float f3 = (float)(this.posX - interpPosX);
    float f4 = (float)(this.posY - interpPosY);
    float f5 = (float)(this.posZ - interpPosZ);
    float f6 = this.worldObj.getLightBrightness(new BlockPos(this.posX, this.posY, this.posZ));
    this.currentFootSteps.bindTexture(FOOTPRINT_TEXTURE);
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
    worldRendererIn.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
    worldRendererIn.pos((double)(f3 - 0.125F), (double)f4, (double)(f5 + 0.125F)).tex(0.0D, 1.0D).color(f6, f6, f6, f1).endVertex();
    worldRendererIn.pos((double)(f3 + 0.125F), (double)f4, (double)(f5 + 0.125F)).tex(1.0D, 1.0D).color(f6, f6, f6, f1).endVertex();
    worldRendererIn.pos((double)(f3 + 0.125F), (double)f4, (double)(f5 - 0.125F)).tex(1.0D, 0.0D).color(f6, f6, f6, f1).endVertex();
    worldRendererIn.pos((double)(f3 - 0.125F), (double)f4, (double)(f5 - 0.125F)).tex(0.0D, 0.0D).color(f6, f6, f6, f1).endVertex();
    Tessellator.getInstance().draw();
    GlStateManager.disableBlend();
    GlStateManager.enableLighting();
}
 
Example 33
Project: BaseClient   File: ItemMonsterPlacer.java   Source Code and License 5 votes vote down vote up
/**
 * Spawns the creature specified by the egg's type in the location specified by the last three parameters.
 * Parameters: world, entityID, x, y, z.
 */
public static Entity spawnCreature(World worldIn, int entityID, double x, double y, double z)
{
    if (!EntityList.entityEggs.containsKey(Integer.valueOf(entityID)))
    {
        return null;
    }
    else
    {
        Entity entity = null;

        for (int i = 0; i < 1; ++i)
        {
            entity = EntityList.createEntityByID(entityID, worldIn);

            if (entity instanceof EntityLivingBase)
            {
                EntityLiving entityliving = (EntityLiving)entity;
                entity.setLocationAndAngles(x, y, z, MathHelper.wrapAngleTo180_float(worldIn.rand.nextFloat() * 360.0F), 0.0F);
                entityliving.rotationYawHead = entityliving.rotationYaw;
                entityliving.renderYawOffset = entityliving.rotationYaw;
                entityliving.onInitialSpawn(worldIn.getDifficultyForLocation(new BlockPos(entityliving)), (IEntityLivingData)null);
                worldIn.spawnEntityInWorld(entity);
                entityliving.playLivingSound();
            }
        }

        return entity;
    }
}
 
Example 34
Project: Backmemed   File: TileEntityEndGateway.java   Source Code and License 5 votes vote down vote up
/**
 * Like the old updateEntity(), except more generic.
 */
public void update()
{
    boolean flag = this.isSpawning();
    boolean flag1 = this.isCoolingDown();
    ++this.age;

    if (flag1)
    {
        --this.teleportCooldown;
    }
    else if (!this.world.isRemote)
    {
        List<Entity> list = this.world.<Entity>getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(this.getPos()));

        if (!list.isEmpty())
        {
            this.teleportEntity((Entity)list.get(0));
        }

        if (this.age % 2400L == 0L)
        {
            this.triggerCooldown();
        }
    }

    if (flag != this.isSpawning() || flag1 != this.isCoolingDown())
    {
        this.markDirty();
    }
}
 
Example 35
Project: BaseClient   File: ModelPlayer.java   Source Code and License 5 votes vote down vote up
/**
 * Sets the models various rotation angles then renders the model.
 */
public void render(Entity entityIn, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float scale)
{
    super.render(entityIn, p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, scale);
    GlStateManager.pushMatrix();

    if (this.isChild)
    {
        float f = 2.0F;
        GlStateManager.scale(1.0F / f, 1.0F / f, 1.0F / f);
        GlStateManager.translate(0.0F, 24.0F * scale, 0.0F);
        this.bipedLeftLegwear.render(scale);
        this.bipedRightLegwear.render(scale);
        this.bipedLeftArmwear.render(scale);
        this.bipedRightArmwear.render(scale);
        this.bipedBodyWear.render(scale);
    }
    else
    {
        if (entityIn.isSneaking())
        {
            GlStateManager.translate(0.0F, 0.2F, 0.0F);
        }

        this.bipedLeftLegwear.render(scale);
        this.bipedRightLegwear.render(scale);
        this.bipedLeftArmwear.render(scale);
        this.bipedRightArmwear.render(scale);
        this.bipedBodyWear.render(scale);
    }

    GlStateManager.popMatrix();
}
 
Example 36
Project: Backmemed   File: BlockSoulSand.java   Source Code and License 5 votes vote down vote up
/**
 * Called When an Entity Collided with the Block
 */
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
{
	if(!Wrapper.getHacks().findMod(NoSlowdown.class).isEnabled()) {
		entityIn.motionX *= 0.4D;
		entityIn.motionZ *= 0.4D;
	}
}
 
Example 37
Project: BaseClient   File: PlayerSelector.java   Source Code and License 5 votes vote down vote up
private static List<Predicate<Entity>> func_179648_b(Map<String, String> p_179648_0_)
{
    List<Predicate<Entity>> list = Lists.<Predicate<Entity>>newArrayList();
    final int i = parseIntWithDefault(p_179648_0_, "lm", -1);
    final int j = parseIntWithDefault(p_179648_0_, "l", -1);

    if (i > -1 || j > -1)
    {
        list.add(new Predicate<Entity>()
        {
            public boolean apply(Entity p_apply_1_)
            {
                if (!(p_apply_1_ instanceof EntityPlayerMP))
                {
                    return false;
                }
                else
                {
                    EntityPlayerMP entityplayermp = (EntityPlayerMP)p_apply_1_;
                    return (i <= -1 || entityplayermp.experienceLevel >= i) && (j <= -1 || entityplayermp.experienceLevel <= j);
                }
            }
        });
    }

    return list;
}
 
Example 38
Project: connor41-etfuturum2   File: SlimeBlock.java   Source Code and License 5 votes vote down vote up
@Override
public void onFallenUpon(World world, int x, int y, int z, Entity entity, float fallDistance) {
	if (!entity.isSneaking()) {
		entity.fallDistance = 0;
		if (entity.motionY < 0)
			entity.getEntityData().setDouble(Reference.MOD_ID + ":slime", -entity.motionY);
	}
}
 
Example 39
Project: Backmemed   File: BlockPortal.java   Source Code and License 5 votes vote down vote up
/**
 * Called When an Entity Collided with the Block
 */
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
{
    if (!entityIn.isRiding() && !entityIn.isBeingRidden() && entityIn.isNonBoss())
    {
        entityIn.setPortal(pos);
    }
}
 
Example 40
Project: CustomWorldGen   File: BlockFluidBase.java   Source Code and License 5 votes vote down vote up
@Override
public Vec3d modifyAcceleration(World world, BlockPos pos, Entity entity, Vec3d vec)
{
    if (densityDir > 0) return vec;
    Vec3d vec_flow = this.getFlowVector(world, pos);
    return vec.addVector(
            vec_flow.xCoord * (quantaPerBlock * 4),
            vec_flow.yCoord * (quantaPerBlock * 4),
            vec_flow.zCoord * (quantaPerBlock * 4));
}
 
Example 41
Project: Backmemed   File: ParticleSnowShovel.java   Source Code and License 5 votes vote down vote up
/**
 * 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.particleAge + partialTicks) / (float)this.particleMaxAge * 32.0F;
    f = MathHelper.clamp(f, 0.0F, 1.0F);
    this.particleScale = this.snowDigParticleScale * f;
    super.renderParticle(worldRendererIn, entityIn, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ);
}
 
Example 42
Project: Backmemed   File: EntitySelector.java   Source Code and License 5 votes vote down vote up
private static List<Predicate<Entity>> getTeamPredicates(Map<String, String> params)
{
    List<Predicate<Entity>> list = Lists.<Predicate<Entity>>newArrayList();
    String s = getArgument(params, field_190847_u);
    final boolean flag = s != null && s.startsWith("!");

    if (flag)
    {
        s = s.substring(1);
    }

    if (s != null)
    {
        final String s_f = s;
        list.add(new Predicate<Entity>()
        {
            public boolean apply(@Nullable Entity p_apply_1_)
            {
                if (!(p_apply_1_ instanceof EntityLivingBase))
                {
                    return false;
                }
                else
                {
                    EntityLivingBase entitylivingbase = (EntityLivingBase)p_apply_1_;
                    Team team = entitylivingbase.getTeam();
                    String s1 = team == null ? "" : team.getRegisteredName();
                    return s1.equals(s_f) != flag;
                }
            }
        });
    }

    return list;
}
 
Example 43
Project: UniversalRemote   File: WorldServerProxy.java   Source Code and License 5 votes vote down vote up
@Override
public List<Entity> getLoadedEntityList() {
	if (m_proxyWorld != null && Util.isPrefixInCallStack(m_modPrefix)) {
		return m_proxyWorld.getLoadedEntityList();
	} else if (m_realWorld != null) {
		return m_realWorld.getLoadedEntityList();
	} else {
		return super.getLoadedEntityList();
	}
}
 
Example 44
Project: ForgeHax   File: EntityUtils.java   Source Code and License 5 votes vote down vote up
public static boolean isAboveWater(Entity entity, boolean packet){
    if (entity == null) return false;

    double y = entity.posY - (packet ? 0.03 : (EntityUtils.isPlayer(entity) ? 0.2 : 0.5)); // increasing this seems to flag more in NCP but needs to be increased so the player lands on solid water

    for(int x = MathHelper.floor(entity.posX); x < MathHelper.ceil(entity.posX); x++)
        for (int z = MathHelper.floor(entity.posZ); z < MathHelper.ceil(entity.posZ); z++) {
            BlockPos pos = new BlockPos(x, MathHelper.floor(y), z);

            if (getWorld().getBlockState(pos).getBlock() instanceof BlockLiquid) return true;
        }

    return false;
}
 
Example 45
Project: UniversalRemote   File: EntityPlayerProxy.java   Source Code and License 5 votes vote down vote up
@Override
public boolean isRidingOrBeingRiddenBy(Entity entityIn) {
	if (m_realPlayer == null) {
		return super.isRidingOrBeingRiddenBy(entityIn);
	} else {
		return m_realPlayer.isRidingOrBeingRiddenBy(entityIn);
	}
}
 
Example 46
Project: UniversalRemote   File: EntityPlayerProxy.java   Source Code and License 5 votes vote down vote up
@Override
public boolean isEntityEqual(Entity entityIn) {
	if (m_realPlayer == null) {
		return super.isEntityEqual(entityIn);
	} else {
		return m_realPlayer.isEntityEqual(entityIn);
	}
}
 
Example 47
Project: BaseClient   File: CommandTestFor.java   Source Code and License 5 votes vote down vote up
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length < 1)
    {
        throw new WrongUsageException("commands.testfor.usage", new Object[0]);
    }
    else
    {
        Entity entity = func_175768_b(sender, args[0]);
        NBTTagCompound nbttagcompound = null;

        if (args.length >= 2)
        {
            try
            {
                nbttagcompound = JsonToNBT.getTagFromJson(buildString(args, 1));
            }
            catch (NBTException nbtexception)
            {
                throw new CommandException("commands.testfor.tagError", new Object[] {nbtexception.getMessage()});
            }
        }

        if (nbttagcompound != null)
        {
            NBTTagCompound nbttagcompound1 = new NBTTagCompound();
            entity.writeToNBT(nbttagcompound1);

            if (!NBTUtil.func_181123_a(nbttagcompound, nbttagcompound1, true))
            {
                throw new CommandException("commands.testfor.failure", new Object[] {entity.getName()});
            }
        }

        notifyOperators(sender, this, "commands.testfor.success", new Object[] {entity.getName()});
    }
}
 
Example 48
Project: Backmemed   File: BlockCauldron.java   Source Code and License 5 votes vote down vote up
/**
 * Called When an Entity Collided with the Block
 */
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
{
    int i = ((Integer)state.getValue(LEVEL)).intValue();
    float f = (float)pos.getY() + (6.0F + (float)(3 * i)) / 16.0F;

    if (!worldIn.isRemote && entityIn.isBurning() && i > 0 && entityIn.getEntityBoundingBox().minY <= (double)f)
    {
        entityIn.extinguish();
        this.setWaterLevel(worldIn, pos, state, i - 1);
    }
}
 
Example 49
Project: Backmemed   File: ModelEvoker.java   Source Code and License 5 votes vote down vote up
/**
 * 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.field_191223_g.rotationPointZ = 0.0F;
    this.field_191223_g.rotationPointX = -5.0F;
    this.field_191224_h.rotationPointZ = 0.0F;
    this.field_191224_h.rotationPointX = 5.0F;
    this.field_191223_g.rotateAngleX = MathHelper.cos(ageInTicks * 0.6662F) * 0.25F;
    this.field_191224_h.rotateAngleX = MathHelper.cos(ageInTicks * 0.6662F) * 0.25F;
    this.field_191223_g.rotateAngleZ = 2.3561945F;
    this.field_191224_h.rotateAngleZ = -2.3561945F;
    this.field_191223_g.rotateAngleY = 0.0F;
    this.field_191224_h.rotateAngleY = 0.0F;
}
 
Example 50
Project: CustomWorldGen   File: EntitySenses.java   Source Code and License 5 votes vote down vote up
/**
 * Checks, whether 'our' entity can see the entity given as argument (true) or not (false), caching the result.
 */
public boolean canSee(Entity entityIn)
{
    if (this.seenEntities.contains(entityIn))
    {
        return true;
    }
    else if (this.unseenEntities.contains(entityIn))
    {
        return false;
    }
    else
    {
        this.entityObj.worldObj.theProfiler.startSection("canSee");
        boolean flag = this.entityObj.canEntityBeSeen(entityIn);
        this.entityObj.worldObj.theProfiler.endSection();

        if (flag)
        {
            this.seenEntities.add(entityIn);
        }
        else
        {
            this.unseenEntities.add(entityIn);
        }

        return flag;
    }
}
 
Example 51
Project: Thermionics   File: ItemBlockEquivalentState.java   Source Code and License 5 votes vote down vote up
public boolean isValidArmor(ItemStack stack, EntityEquipmentSlot armorType, Entity entity) {
	if (block instanceof IArmor) {
		return ((IArmor)block).isValidArmor(stack, armorType, entity);
	} else {
		return super.isValidArmor(stack, armorType, entity);
	}
}
 
Example 52
Project: BaseClient   File: EntityHorse.java   Source Code and License 5 votes vote down vote up
private void dropItemsInChest(Entity entityIn, AnimalChest animalChestIn)
{
    if (animalChestIn != null && !this.worldObj.isRemote)
    {
        for (int i = 0; i < animalChestIn.getSizeInventory(); ++i)
        {
            ItemStack itemstack = animalChestIn.getStackInSlot(i);

            if (itemstack != null)
            {
                this.entityDropItem(itemstack, 0.0F);
            }
        }
    }
}
 
Example 53
Project: UniversalRemote   File: WorldServerProxy.java   Source Code and License 5 votes vote down vote up
@Override
public <T extends Entity> T findNearestEntityWithinAABB(Class<? extends T> entityType, AxisAlignedBB aabb,
		T closestTo) {
	if (m_proxyWorld != null && Util.isPrefixInCallStack(m_modPrefix)) {
		return m_proxyWorld.findNearestEntityWithinAABB(entityType, aabb, closestTo);
	} else if (m_realWorld != null) {
		return m_realWorld.findNearestEntityWithinAABB(entityType, aabb, closestTo);
	} else {
		return super.findNearestEntityWithinAABB(entityType, aabb, closestTo);
	}
}
 
Example 54
Project: BaseClient   File: MobAppearance.java   Source Code and License 5 votes vote down vote up
/**
 * Renders the particle
 */
public void renderParticle(WorldRenderer worldRendererIn, Entity entityIn, float partialTicks, float p_180434_4_, float p_180434_5_, float p_180434_6_, float p_180434_7_, float p_180434_8_)
{
    if (this.entity != null)
    {
        RenderManager rendermanager = Minecraft.getMinecraft().getRenderManager();
        rendermanager.setRenderPosition(EntityFX.interpPosX, EntityFX.interpPosY, EntityFX.interpPosZ);
        float f = 0.42553192F;
        float f1 = ((float)this.particleAge + partialTicks) / (float)this.particleMaxAge;
        GlStateManager.depthMask(true);
        GlStateManager.enableBlend();
        GlStateManager.enableDepth();
        GlStateManager.blendFunc(770, 771);
        float f2 = 240.0F;
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, f2, f2);
        GlStateManager.pushMatrix();
        float f3 = 0.05F + 0.5F * MathHelper.sin(f1 * (float)Math.PI);
        GlStateManager.color(1.0F, 1.0F, 1.0F, f3);
        GlStateManager.translate(0.0F, 1.8F, 0.0F);
        GlStateManager.rotate(180.0F - entityIn.rotationYaw, 0.0F, 1.0F, 0.0F);
        GlStateManager.rotate(60.0F - 150.0F * f1 - entityIn.rotationPitch, 1.0F, 0.0F, 0.0F);
        GlStateManager.translate(0.0F, -0.4F, -1.5F);
        GlStateManager.scale(f, f, f);
        this.entity.rotationYaw = this.entity.prevRotationYaw = 0.0F;
        this.entity.rotationYawHead = this.entity.prevRotationYawHead = 0.0F;
        rendermanager.renderEntityWithPosYaw(this.entity, 0.0D, 0.0D, 0.0D, 0.0F, partialTicks);
        GlStateManager.popMatrix();
        GlStateManager.enableDepth();
    }
}
 
Example 55
Project: CustomWorldGen   File: LootContext.java   Source Code and License 4 votes vote down vote up
@Nullable
public Entity getKillerPlayer()
{
    return this.player;
}
 
Example 56
Project: Halloween   File: ModelCurse.java   Source Code and License 4 votes vote down vote up
@Override
public void render(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
	this.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entity);
	this.head.render(scale);
}
 
Example 57
Project: BaseClient   File: WorldClient.java   Source Code and License 4 votes vote down vote up
/**
 * also releases skins.
 */
public void removeAllEntities()
{
    this.loadedEntityList.removeAll(this.unloadedEntityList);

    for (int i = 0; i < this.unloadedEntityList.size(); ++i)
    {
        Entity entity = (Entity)this.unloadedEntityList.get(i);
        int j = entity.chunkCoordX;
        int k = entity.chunkCoordZ;

        if (entity.addedToChunk && this.isChunkLoaded(j, k, true))
        {
            this.getChunkFromChunkCoords(j, k).removeEntity(entity);
        }
    }

    for (int l = 0; l < this.unloadedEntityList.size(); ++l)
    {
        this.onEntityRemoved((Entity)this.unloadedEntityList.get(l));
    }

    this.unloadedEntityList.clear();

    for (int i1 = 0; i1 < this.loadedEntityList.size(); ++i1)
    {
        Entity entity1 = (Entity)this.loadedEntityList.get(i1);

        if (entity1.ridingEntity != null)
        {
            if (!entity1.ridingEntity.isDead && entity1.ridingEntity.riddenByEntity == entity1)
            {
                continue;
            }

            entity1.ridingEntity.riddenByEntity = null;
            entity1.ridingEntity = null;
        }

        if (entity1.isDead)
        {
            int j1 = entity1.chunkCoordX;
            int k1 = entity1.chunkCoordZ;

            if (entity1.addedToChunk && this.isChunkLoaded(j1, k1, true))
            {
                this.getChunkFromChunkCoords(j1, k1).removeEntity(entity1);
            }

            this.loadedEntityList.remove(i1--);
            this.onEntityRemoved(entity1);
        }
    }
}
 
Example 58
Project: ObsidianSuite   File: ModelAnimatedPlayer.java   Source Code and License 4 votes vote down vote up
@Override
	public void setRotationAngles(float swingTime, float swingMax, float clock, float lookX, float lookY, float f5, Entity entity) 
	{				
		super.setRotationAngles(swingTime, swingMax, clock, lookX, lookY, f5, entity);		

		//Look TODO sort head lookX
		head.setValue(lookY/(180F/(float)Math.PI), 0);

		if(entity.isSneaking())
			head.setValue(head.getValue(0) - 0.7F, 0);
		
//		EntityAnimationProperties animProps = (EntityAnimationProperties) entity.getExtendedProperties("Animation");
//		if (animProps == null)
//			GuiDebug.instance.animationText = "null";
//		else
//		{
//			AnimationSequence seq = animProps.getActiveAnimation();
//			if (seq == null)
//				GuiDebug.instance.animationText = "null";
//			else
//				GuiDebug.instance.animationText = seq.getName();
//		}		
		
		String state = "";	
		
		GuiDebug.instance.stateText = state;
		
		//Jump height debugging
//		if(state.equals("Jump") || previousState.equals("Jump")) {
//			float currentTime = (System.nanoTime()-startTime)/1000000000F;
//			float height = (float) (entity.posY-5.62F);
//			if(height != prevHeight) {
//				//Calculations
//				float outputTime = totalTime/(float)readings;
//				outputTime = Math.round(outputTime*1000F)/1000F;
//				float outputHeight = Math.round(prevHeight*1000F)/1000F;
//				//Output
//				System.out.println(outputTime + " " + outputHeight);
//				//Reset
//				totalTime = currentTime;
//				readings = 1;
//			}			
//			else {
//				totalTime += currentTime;
//				readings++;
//			}
//			prevHeight = height;
//		}
//		else {
//			prevHeight = 0.0F;
//			totalTime = 0;
//			readings = 0;
//		}
		
		//Timing debug
//		if(!state.equals(previousState)) {
//			endTime = System.nanoTime();
//			float duration = (endTime - startTime)/1000000000F;
//			if(previousState.equals("Jump"))
//				System.out.println(previousState + " lasted for " + duration + " seconds");
//			startTime = endTime;
//		}
		
		previousState = state;
	}
 
Example 59
Project: CustomWorldGen   File: EntitySelector.java   Source Code and License 4 votes vote down vote up
private static <T extends Entity> List<T> filterResults(Map<String, String> params, Class <? extends T > entityClass, List<Predicate<Entity>> inputList, String type, World worldIn, BlockPos position)
{
    List<T> list = Lists.<T>newArrayList();
    String s = getArgument(params, "type");
    s = s != null && s.startsWith("!") ? s.substring(1) : s;
    boolean flag = !type.equals("e");
    boolean flag1 = type.equals("r") && s != null;
    int i = parseIntWithDefault(params, "dx", 0);
    int j = parseIntWithDefault(params, "dy", 0);
    int k = parseIntWithDefault(params, "dz", 0);
    int l = parseIntWithDefault(params, "r", -1);
    Predicate<Entity> predicate = Predicates.and(inputList);
    Predicate<Entity> predicate1 = Predicates.<Entity>and(EntitySelectors.IS_ALIVE, predicate);
    int i1 = worldIn.playerEntities.size();
    int j1 = worldIn.loadedEntityList.size();
    boolean flag2 = i1 < j1 / 16;

    if (!params.containsKey("dx") && !params.containsKey("dy") && !params.containsKey("dz"))
    {
        if (l >= 0)
        {
            AxisAlignedBB axisalignedbb1 = new AxisAlignedBB((double)(position.getX() - l), (double)(position.getY() - l), (double)(position.getZ() - l), (double)(position.getX() + l + 1), (double)(position.getY() + l + 1), (double)(position.getZ() + l + 1));

            if (flag && flag2 && !flag1)
            {
                list.addAll(worldIn.<T>getPlayers(entityClass, predicate1));
            }
            else
            {
                list.addAll(worldIn.<T>getEntitiesWithinAABB(entityClass, axisalignedbb1, predicate1));
            }
        }
        else if (type.equals("a"))
        {
            list.addAll(worldIn.<T>getPlayers(entityClass, predicate));
        }
        else if (!type.equals("p") && (!type.equals("r") || flag1))
        {
            list.addAll(worldIn.<T>getEntities(entityClass, predicate1));
        }
        else
        {
            list.addAll(worldIn.<T>getPlayers(entityClass, predicate1));
        }
    }
    else
    {
        final AxisAlignedBB axisalignedbb = getAABB(position, i, j, k);

        if (flag && flag2 && !flag1)
        {
            Predicate<Entity> predicate2 = new Predicate<Entity>()
            {
                public boolean apply(@Nullable Entity p_apply_1_)
                {
                    return p_apply_1_ != null && axisalignedbb.intersectsWith(p_apply_1_.getEntityBoundingBox());
                }
            };
            list.addAll(worldIn.<T>getPlayers(entityClass, Predicates.<T>and(predicate1, predicate2)));
        }
        else
        {
            list.addAll(worldIn.<T>getEntitiesWithinAABB(entityClass, axisalignedbb, predicate1));
        }
    }

    return list;
}
 
Example 60
Project: BaseClient   File: EntitySelectors.java   Source Code and License 4 votes vote down vote up
public boolean apply(Entity p_apply_1_)
{
    return p_apply_1_ instanceof IInventory && p_apply_1_.isEntityAlive();
}