net.minecraft.entity.EntityLiving Java Examples

The following examples show how to use net.minecraft.entity.EntityLiving. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityTofuChinger.java    From TofuCraftReload with MIT License 6 votes vote down vote up
@Override
protected void initEntityAI()
{
    this.tasks.addTask(0, new EntityAISwimming(this));
    this.tasks.addTask(1, new EntityTofuChinger.AIMeleeAttack());
    this.tasks.addTask(5, new EntityAIWanderAvoidWater(this, 1.0D));
    this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
    this.tasks.addTask(6, new EntityAILookIdle(this));
    this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F));

    this.targetTasks.addTask(0, new EntityAIHurtByTarget(this,true));
    this.targetTasks.addTask(1, new EntityAINearestAttackableTarget<>(this, EntityTofuSlime.class,false));
    this.targetTasks.addTask(1, new EntityAINearestAttackableTarget<>(this,EntityPlayer.class,true));
    this.targetTasks.addTask(1, new EntityAINearestAttackableTarget<>(this,EntityTofunian.class,true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget<>(this, EntityRabbit.class,true));
}
 
Example #2
Source File: InfusionVisualDisguiseArmor.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
public ItemStack getCurrentDisguise() {
    if(transparent) {
        return new ItemStack(Items.potionitem, 1, POTION_METAS[(int)((System.currentTimeMillis() / 1000) % POTION_METAS.length)]);
    }

    Random random = new Random(System.currentTimeMillis() / 1000);
    int first = getRecipeInput(random);
    int firstPos = EntityLiving.getArmorPosition(armorItems[first]);

    int next;
    do {
        next = random.nextInt(armorItems.length);
    }
    while (next == first || EntityLiving.getArmorPosition(armorItems[next]) != firstPos || !canSee(armorItems[next]));
    return armorItems[next];
}
 
Example #3
Source File: EntityUtil.java    From EnderZoo with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
public static void cancelCurrentTasks(EntityLiving ent) {
  Iterator<EntityAITaskEntry> iterator = ent.tasks.taskEntries.iterator();
  List<EntityAITasks.EntityAITaskEntry> currentTasks = new ArrayList<EntityAITasks.EntityAITaskEntry>();
  while (iterator.hasNext()) {
    EntityAITaskEntry entityaitaskentry = iterator.next();
    if (entityaitaskentry != null) {
      currentTasks.add(entityaitaskentry);
    }
  }
  // Only available way to stop current execution is to remove all current
  // tasks, then re-add them
  for (EntityAITaskEntry task : currentTasks) {
    ent.tasks.removeTask(task.action);
    ent.tasks.addTask(task.priority, task.action);
  }
  ent.getNavigator().clearPathEntity();
}
 
Example #4
Source File: ProtectionManager.java    From MyTown2 with The Unlicense 6 votes vote down vote up
public static boolean checkExist(Entity entity, boolean spawn) {
    if(entity instanceof EntityLiving) {
        if (Config.instance.mobTravelInTowns.get() && !spawn) {
            return false;
        }
        if(!getFlagValueAtLocation(FlagType.ENTITIES, entity.dimension, (int) Math.floor(entity.posX), (int) Math.floor(entity.posY), (int) Math.floor(entity.posZ))) {
            entity.isDead = true;
            entity.setDead();
            return true;
        }
    }

    for(SegmentEntity segment : segmentsTrackedEntity.get(entity.getClass())) {
        if(!segment.shouldExist(entity)) {
            entity.isDead = true;
            entity.setDead();
            return true;
        }
    }

    return false;
}
 
Example #5
Source File: EntityDabSquirrel.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void updatePassenger(Entity passenger) {
    super.updatePassenger(passenger);

    if (passenger instanceof EntityLiving) {
        EntityLiving entityliving = (EntityLiving) passenger;
        this.renderYawOffset = entityliving.renderYawOffset;
    }

    if (this.prevRearingAmount > 0.0F) {
        float f3 = MathHelper.sin(this.renderYawOffset * 0.017453292F);
        float f = MathHelper.cos(this.renderYawOffset * 0.017453292F);
        float f1 = 0.7F * this.prevRearingAmount;
        float f2 = 0.15F * this.prevRearingAmount;
        passenger.setPosition(this.posX + f1 * f3, this.posY + this.getMountedYOffset() + passenger.getYOffset() + f2 - 2F, this.posZ - f1 * f);

        if (passenger instanceof EntityLivingBase) {
            ((EntityLivingBase) passenger).renderYawOffset = this.renderYawOffset;
        }
    }
    this.stepHeight = 4F;
}
 
Example #6
Source File: ModelDabSquirrel.java    From CommunityMod with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) {
	float f = limbSwing;
	float f1 = limbSwingAmount;

	this.lArm01.rotateAngleX = MathHelper.cos(f * 0.6662F) * 0.5F * f1 - 0.20943951023931953F;
	this.rArm01.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * 0.5F * f1 - 0.20943951023931953F;
	this.rLeg01.rotateAngleX = MathHelper.cos(f * 0.6662F) * 0.5F * f1 - 0.17453292519943295F;
	this.lLeg01.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * 0.5F * f1 - 0.17453292519943295F;
	this.tail01.rotateAngleX = MathHelper.sin(f * 0.2F) * 0.5F * f1 - (float) Math.toRadians(30);

	if (entityIn instanceof EntityLiving) {
		EntityLiving e = (EntityLiving) entityIn;
		float yawOffset = interpolateRotation(e.prevRenderYawOffset, e.renderYawOffset, Minecraft.getMinecraft().getRenderPartialTicks());
		float yawHead = interpolateRotation(e.prevRotationYawHead, e.rotationYawHead, Minecraft.getMinecraft().getRenderPartialTicks());

		this.neck.rotateAngleX = (e.prevRotationPitch + (e.rotationPitch - e.prevRotationPitch) * Minecraft.getMinecraft().getRenderPartialTicks()) * 0.017453292F - 13;
		this.neck.rotateAngleY = (yawHead - yawOffset) * 0.017453292F * 0.5F;
		//if (entityIn instanceof EntityDabSquirrel) {
			//EntityDabSquirrel ent = (EntityDabSquirrel) e;
			//this.chest.rotateAngleX = ent.isBesideClimbableBlock() ? (float) Math.toRadians(-90) : 0.10471975511965977F;
		//}
	}

	super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
}
 
Example #7
Source File: EntityUtil.java    From EnderZoo with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
private static boolean canLandAtLocation(EntityLiving ent, int x, int y, int z) {

    World world = ent.getEntityWorld();
    ent.setPosition(x + 0.5, y, z + 0.5);
    if (!SpawnUtil.isSpaceAvailableForSpawn(world, ent, false, false)) {
      return false;
    }

    BlockPos below = new BlockPos(x, y, z).down();
    IBlockState bs = world.getBlockState(below);
    if (!bs.getMaterial().isSolid()) {
      return false;
    }    
    AxisAlignedBB collides = bs.getCollisionBoundingBox(world, below);
    return collides != null;
  }
 
Example #8
Source File: MoCEntitySnake.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected Entity findPlayerToAttack()
{
    if (worldObj.difficultySetting > 0)
    {
        EntityPlayer entityplayer = worldObj.getClosestVulnerablePlayerToEntity(this, 4D);
        if (!getIsTamed() && (entityplayer != null)) // && getIsAdult() )
        {

            if (isNotScared() && isPissed()) { return entityplayer; }

        }
        if ((rand.nextInt(100) == 0))
        {
            EntityLiving entityliving = getClosestEntityLiving(this, 8D);
            return entityliving;
        }
    }
    return null;
}
 
Example #9
Source File: DispenserBehaviorMobEgg.java    From Artifacts with MIT License 6 votes vote down vote up
/**
 * Dispense the specified stack, play the dispense sound and spawn particles.
 */
public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack)
{
    EnumFacing enumfacing = BlockDispenser.func_149937_b/*getFacing*/(par1IBlockSource.getBlockMetadata());
    double d0 = par1IBlockSource.getX() + (double)enumfacing.getFrontOffsetX();
    double d1 = (double)((float)par1IBlockSource.getYInt() + 0.2F) + enumfacing.getFrontOffsetY();
    double d2 = par1IBlockSource.getZ() + (double)enumfacing.getFrontOffsetZ();
    Entity entity = ItemMonsterPlacer.spawnCreature(par1IBlockSource.getWorld(), par2ItemStack.getItemDamage(), d0, d1, d2);

    if (entity instanceof EntityLiving && par2ItemStack.hasDisplayName())
    {
        ((EntityLiving)entity).setCustomNameTag(par2ItemStack.getDisplayName());
    }

    par2ItemStack.splitStack(1);
    return par2ItemStack;
}
 
Example #10
Source File: MobEspHack.java    From ForgeWurst with GNU General Public License v3.0 6 votes vote down vote up
private void renderBoxes(double partialTicks)
{
	for(EntityLiving e : mobs)
	{
		GL11.glPushMatrix();
		GL11.glTranslated(e.prevPosX + (e.posX - e.prevPosX) * partialTicks,
			e.prevPosY + (e.posY - e.prevPosY) * partialTicks,
			e.prevPosZ + (e.posZ - e.prevPosZ) * partialTicks);
		GL11.glScaled(e.width + 0.1, e.height + 0.1, e.width + 0.1);
		
		float f = WEntity.getDistance(WMinecraft.getPlayer(), e) / 20F;
		GL11.glColor4f(2 - f, f, 0, 0.5F);
		
		GL11.glCallList(mobBox);
		
		GL11.glPopMatrix();
	}
}
 
Example #11
Source File: MoCTools.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
public static void buckleMobsNotPlayers(EntityLiving entityattacker, Double dist, World worldObj)
{
    List list = worldObj.getEntitiesWithinAABBExcludingEntity(entityattacker, entityattacker.boundingBox.expand(dist, 2D, dist));
    for (int i = 0; i < list.size(); i++)
    {
        Entity entitytarget = (Entity) list.get(i);
        if (!(entitytarget instanceof EntityLiving) || (entitytarget instanceof EntityPlayer) ||(entityattacker.riddenByEntity != null && entitytarget == entityattacker.riddenByEntity))
        {
            continue;
        }
        //EntityMob entitymob = (EntityMob) entity;
        entitytarget.attackEntityFrom(DamageSource.causeMobDamage(entityattacker), 2);
        bigsmack(entityattacker, entitytarget, 0.6F);
        playCustomSound(entityattacker, "tud", worldObj);
        //todo tuck sound!!
    }
}
 
Example #12
Source File: MoCEntityMouse.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onLivingUpdate()
{
    super.onLivingUpdate();
    if(!worldObj.isRemote)
    {
        if(rand.nextInt(15) == 0)
        {
            EntityLiving entityliving = getBoogey(6D);
            if(entityliving != null)
            {
                runLikeHell(entityliving);

            }
        }
        if(!onGround && (ridingEntity != null))
        {
            rotationYaw = ridingEntity.rotationYaw;
        }
    }
}
 
Example #13
Source File: EntityEventHandler.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onAttackEntity(LivingAttackEvent event)
{
    // When a "passified" entity is attacked by another entity, remove the "passified" tag,
    // and restore the target AI tasks by re-adding all the AI tasks from a fresh clone
    if ((event.getEntity() instanceof EntityLiving) && event.getEntity().getEntityWorld().isRemote == false &&
        event.getSource() instanceof EntityDamageSource && event.getEntity().getTags().contains(ItemSyringe.TAG_PASSIFIED))
    {
        ItemSyringe.removePassifiedState((EntityLiving) event.getEntity());
    }
}
 
Example #14
Source File: TileAIShutdown.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void killAI() {
    ChunkCoordinates cc = getCoords();
    List objEntityList = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, BOX.copy().offset(xCoord, yCoord, zCoord));
    for (Object o : objEntityList) {
        if(o != null && o instanceof EntityLiving &&
                !((EntityLiving) o).isDead && canAffect((EntityLiving) o)) {
            EntityLiving el = (EntityLiving) o;
            if(storedAmount <= 0) return;
            AffectedEntity affected = removeAI(el);
            trackedEntities.get(cc).add(affected);
        }
    }
}
 
Example #15
Source File: EntitySpawning.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onCreateVillager(EntityJoinWorldEvent event) {
	if (!event.getWorld().isRemote && event.getEntity() instanceof EntityVillager) {

		cleanMap();

		if (handlePossibleConversion((EntityLiving) event.getEntity(), null)) {
			event.getEntity().setDead();
		}
	}
}
 
Example #16
Source File: ItemEntityEgg.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
	if (world.isRemote)
		return stack;
	else {
		MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(world, player, true);

		if (movingobjectposition == null)
			return stack;
		else {
			if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
				int i = movingobjectposition.blockX;
				int j = movingobjectposition.blockY;
				int k = movingobjectposition.blockZ;

				if (!world.canMineBlock(player, i, j, k))
					return stack;

				if (!player.canPlayerEdit(i, j, k, movingobjectposition.sideHit, stack))
					return stack;

				if (world.getBlock(i, j, k) instanceof BlockLiquid) {
					Entity entity = spawnEntity(world, stack.getItemDamage(), i, j, k);

					if (entity != null) {
						if (entity instanceof EntityLivingBase && stack.hasDisplayName())
							((EntityLiving) entity).setCustomNameTag(stack.getDisplayName());

						if (!player.capabilities.isCreativeMode)
							stack.stackSize--;
					}
				}
			}

			return stack;
		}
	}
}
 
Example #17
Source File: ItemMobSpawner.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public static void loadSpawners(World world) {
    if (loaded) return;
    loaded = true;
    HashMap<Class<Entity>, String> classToStringMapping = (HashMap<Class<Entity>, String>) EntityList.classToStringMapping;
    HashMap<Class<Entity>, Integer> classToIDMapping = (HashMap<Class<Entity>, Integer>) EntityList.classToIDMapping;
    for (Class<Entity> eclass : classToStringMapping.keySet()) {
        if (!EntityLiving.class.isAssignableFrom(eclass))
            continue;
        try {
            EntityLiving entityliving = (EntityLiving) eclass.getConstructor(new Class[]{World.class}).newInstance(world);
            entityliving.isChild();

            int id = classToIDMapping.get(eclass);
            String name = classToStringMapping.get(eclass);

            if (name.equals("EnderDragon"))
                continue;

            IDtoNameMap.put(id, name);

            if (name.equals("Pig"))
                idPig = id;
        } catch (Throwable ignored) {
        }
    }

    for(Iterator<Entry<Integer, String>> it = IDtoNameMap.entrySet().iterator(); it.hasNext();) {
        Entry<Integer, String> e = it.next();
        if(getEntity(e.getKey()).getClass() == EntityPig.class && !e.getValue().equals("Pig"))
            it.remove();
    }
}
 
Example #18
Source File: MoCEntityDeer.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onLivingUpdate()
{
    super.onLivingUpdate();
    if (!worldObj.isRemote)
    {
        if ((getType() == 3) && !getIsAdult() && (rand.nextInt(250) == 0))
        {
            setEdad(getEdad() + 1);
            if (getEdad() >= 130)
            {
                setAdult(true);
                int i = rand.nextInt(1);
                setType(i);// = i;
            }
        }
        if (rand.nextInt(5) == 0)
        {
            EntityLiving entityliving = getBoogey(10D);
            if (entityliving != null)
            {
                setMySpeed(true);

                runLikeHell(entityliving);

            }
            else
            {
                setMySpeed(false);
            }
        }
    }
}
 
Example #19
Source File: EntityEventHandler.java    From GriefPrevention with MIT License 5 votes vote down vote up
@Listener(order = Order.FIRST, beforeModifications = true)
public void onEntityCollideEntity(CollideEntityEvent event) {
    if (!GPFlags.ENTITY_COLLIDE_ENTITY || event instanceof CollideEntityEvent.Impact) {
        return;
    }
    //if (GriefPreventionPlugin.isSourceIdBlacklisted(ClaimFlag.ENTITY_COLLIDE_ENTITY.toString(), event.getSource(), event.getEntities().get(0).getWorld().getProperties())) {
    //    return;
    //}

    Object rootCause = event.getCause().root();
    final boolean isRootEntityItemFrame = rootCause instanceof EntityItemFrame;
    if (!isRootEntityItemFrame) {
        return;
    }

    GPTimings.ENTITY_COLLIDE_EVENT.startTimingIfSync();
    event.filterEntities(new Predicate<Entity>() {
        @Override
        public boolean test(Entity entity) {
            // Avoid living entities breaking itemframes
            if (isRootEntityItemFrame && entity instanceof EntityLiving) {
                return false;
            }

            return true;
        }
    });
    GPTimings.ENTITY_COLLIDE_EVENT.stopTimingIfSync();
}
 
Example #20
Source File: MoCEntityShark.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected Entity findPlayerToAttack()
{
    if ((worldObj.difficultySetting > 0) && (getEdad() >= 100))
    {
        EntityPlayer entityplayer = worldObj.getClosestVulnerablePlayerToEntity(this, 16D);
        if ((entityplayer != null) && entityplayer.isInWater() && !getIsTamed()) { return entityplayer; }
        if (rand.nextInt(30) == 0)
        {
            EntityLiving entityliving = FindTarget(this, 16D);
            if ((entityliving != null) && entityliving.isInWater()) { return entityliving; }
        }
    }
    return null;
}
 
Example #21
Source File: MoCRenderBigCat.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected float handleRotationFloat(EntityLiving entityliving, float f)
{
    MoCEntityBigCat entitybigcat = (MoCEntityBigCat) entityliving;
    stretch(entitybigcat);
    return entityliving.ticksExisted + f;
}
 
Example #22
Source File: VanishTracker.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public static void ai(LivingSetAttackTargetEvent event) {
	if (event.getEntityLiving() instanceof EntityPlayer) return;
	if (!(event.getEntityLiving() instanceof EntityLiving)) return;

	EntityLivingBase potentialPotion = ((EntityLiving) event.getEntityLiving()).getAttackTarget();
	if (potentialPotion != null && isVanished(potentialPotion)) {
		((EntityLiving) event.getEntityLiving()).setAttackTarget(null);
	}
}
 
Example #23
Source File: MoCEntityMob.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
public boolean entitiesToIgnore(Entity entity)
{
    return ((!(entity instanceof EntityLiving)) 
            || (entity instanceof EntityMob)
            || (entity instanceof MoCEntityEgg)
            || (entity instanceof EntityPlayer && this.getIsTamed()) 
            || (entity instanceof MoCEntityKittyBed) || (entity instanceof MoCEntityLitterBox) 
            || (this.getIsTamed() && (entity instanceof MoCEntityAnimal && ((MoCEntityAnimal) entity).getIsTamed())) 
            || ((entity instanceof EntityWolf) && !(MoCreatures.proxy.attackWolves)) 
            || ((entity instanceof MoCEntityHorse) && !(MoCreatures.proxy.attackHorses))

    );
}
 
Example #24
Source File: EntityArcher.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
public EntityArcher(World par1World) {
    super(par1World);
    this.isImmuneToFire = true;
    this.tasks.addTask(1, new EntityAISwimming(this));
    this.tasks.addTask(2, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
    this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, true, false, IMob.mobSelector));
    this.tasks.addTask(4, new EntityAIWander(this, 0.30D));
}
 
Example #25
Source File: GuardAIFollow.java    From YouTubeModdingTutorial with MIT License 5 votes vote down vote up
public GuardAIFollow(final EntityLiving entity, double speedModifier, float stopDistance, float areaSize) {
    this.entity = entity;
    this.speedModifier = speedModifier;
    this.navigation = entity.getNavigator();
    this.stopDistance = stopDistance;
    this.areaSize = areaSize;
    this.setMutexBits(3);
}
 
Example #26
Source File: MoCRenderOstrich.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void preRenderCallback(EntityLiving entityliving, float f)
{
    MoCEntityOstrich entityostrich = (MoCEntityOstrich) entityliving;
    if (entityostrich.getType() == 1)
    {
        stretch(entityostrich);
    }

    super.preRenderCallback(entityliving, f);

}
 
Example #27
Source File: EntityFallenKnight.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
private void addRandomArmor() {

    float occupiedDiffcultyMultiplier = EntityUtil.getDifficultyMultiplierForLocation(world, posX, posY, posZ);

    int equipmentLevel = getRandomEquipmentLevel(occupiedDiffcultyMultiplier);
    int armorLevel = equipmentLevel;
    if(armorLevel == 1) {
      //Skip gold armor, I don't like it
      armorLevel++;
    }
    float chancePerPiece = isHardDifficulty() ? Config.fallenKnightChancePerArmorPieceHard
        : Config.fallenKnightChancePerArmorPiece;
    chancePerPiece *= (1 + occupiedDiffcultyMultiplier); //If we have the max occupied factor, double the chance of improved armor

    for(EntityEquipmentSlot slot : EntityEquipmentSlot.values()) {
      ItemStack itemStack = getItemStackFromSlot(slot);
      if(itemStack.isEmpty() && rand.nextFloat() <= chancePerPiece) {
        Item item = EntityLiving.getArmorByChance(slot, armorLevel);
        if(item != null) {
          ItemStack stack = new ItemStack(item);
          if(armorLevel == 0) {
            ((ItemArmor) item).setColor(stack, 0);
          }          
          setItemStackToSlot(slot, stack);
        }
      }
    }
    if(rand.nextFloat() > Config.fallenKnightRangedRatio) {
      setItemStackToSlot(EntityEquipmentSlot.MAINHAND, getSwordForLevel(equipmentLevel));
      if(Math.random() <= Config.fallenKnightChanceShield) {
        setItemStackToSlot(EntityEquipmentSlot.OFFHAND, getShieldForLevel(getRandomEquipmentLevel()));
      }
    } else {
      setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.BOW));
    }
  }
 
Example #28
Source File: ShowArmor.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
private void drawPotionEffects(EntityLiving entity) {
    int i = 100;
    int j = 10;
    boolean flag = true;
    Collection collection = entity.getActivePotionEffects();
    if (!collection.isEmpty()) {
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glDisable(GL11.GL_LIGHTING);
        int k = 33;

        if (collection.size() > 5) {
            k = 132 / (collection.size() - 1);
        }

        for (Iterator iterator = entity.getActivePotionEffects().iterator(); iterator.hasNext(); j += k) {
            PotionEffect potioneffect = (PotionEffect) iterator.next();
            Potion potion = Potion.potionTypes[potioneffect.getPotionID()];
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            Wrapper.INSTANCE.mc().getTextureManager().bindTexture(new ResourceLocation("textures/gui/container/inventory.png"));
            this.drawTexturedModalRect(i, j, 0, 166, 140, 32);

            if (potion.hasStatusIcon()) {
                int l = potion.getStatusIconIndex();
                this.drawTexturedModalRect(i + 6, j + 7, l % 8 * 18, 198 + l / 8 * 18, 18, 18);
            }

            potion.renderInventoryEffect(i, j, potioneffect, Wrapper.INSTANCE.mc());
            String s1 = I18n.format(potion.getName());

            s1 += " " + potioneffect.getAmplifier();

            Wrapper.INSTANCE.fontRenderer().drawStringWithShadow(s1, i + 10 + 18, j + 6, 16777215);
            String s = Potion.getDurationString(potioneffect);
            Wrapper.INSTANCE.fontRenderer().drawStringWithShadow(s, i + 10 + 18, j + 6 + 10, 8355711);
        }
    }
}
 
Example #29
Source File: EntityDrone.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public EntityDrone(World world){
    super(world);
    setSize(0.7F, 0.35F);
    ReflectionHelper.setPrivateValue(EntityLiving.class, this, new EntityPathNavigateDrone(this, world), "navigator", "field_70699_by");
    ReflectionHelper.setPrivateValue(EntityLiving.class, this, new DroneMoveHelper(this), "moveHelper", "field_70765_h");
    tasks.addTask(1, chargeAI = new DroneGoToChargingStation(this));
}
 
Example #30
Source File: PotionTimeSlow.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void applyAttributesModifiersToEntity(EntityLivingBase entityLivingBaseIn, @Nonnull AbstractAttributeMap attributeMapIn, int amplifier) {
	super.applyAttributesModifiersToEntity(entityLivingBaseIn, attributeMapIn, amplifier);

	if (timeScale(entityLivingBaseIn) == 0 && entityLivingBaseIn instanceof EntityCreature) {
		((EntityLiving) entityLivingBaseIn).setNoAI(true);

		if(entityLivingBaseIn instanceof EntityCreeper) {
			((EntityCreeper)entityLivingBaseIn).setCreeperState(-1);
		}
	}

	entityLivingBaseIn.world.playSound(null, entityLivingBaseIn.getPosition(), ModSounds.SLOW_MOTION_IN, SoundCategory.NEUTRAL, 1f, 1);
}