Java Code Examples for net.minecraft.entity.EntityLivingBase

The following examples show how to use net.minecraft.entity.EntityLivingBase. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: WirelessRedstone   Source File: WirelessBolt.java    License: MIT License 6 votes vote down vote up
private void vecBBDamageSegment(Vector3 start, Vector3 end, ArrayList<Entity> entitylist) {
    Vec3 start3D = start.toVec3D();
    Vec3 end3D = end.toVec3D();

    for (Iterator<Entity> iterator = entitylist.iterator(); iterator.hasNext(); ) {
        Entity entity = iterator.next();
        if (entity instanceof EntityLivingBase &&
                (entity.boundingBox.isVecInside(start3D) || entity.boundingBox.isVecInside(end3D))) {
            if (entity instanceof EntityPlayer)
                entity.attackEntityFrom(WirelessRedstoneCore.damagebolt, playerdamage);
            else
                entity.attackEntityFrom(WirelessRedstoneCore.damagebolt, entitydamage);

            ether.jamEntity((EntityLivingBase) entity, true);
        }
    }
}
 
Example 2
Source Project: PneumaticCraft   Source File: ItemManometer.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean itemInteractionForEntity(ItemStack iStack, EntityPlayer player, EntityLivingBase entity){
    if(!player.worldObj.isRemote) {
        if(entity instanceof IManoMeasurable) {
            if(((IPressurizable)iStack.getItem()).getPressure(iStack) > 0F) {
                List<String> curInfo = new ArrayList<String>();
                ((IManoMeasurable)entity).printManometerMessage(player, curInfo);
                if(curInfo.size() > 0) {
                    ((IPressurizable)iStack.getItem()).addAir(iStack, -30);
                    for(String s : curInfo) {
                        player.addChatComponentMessage(new ChatComponentTranslation(s));
                    }
                    return true;
                }
            } else {
                player.addChatComponentMessage(new ChatComponentTranslation(EnumChatFormatting.RED + "The Manometer doesn't have any charge!"));
            }
        }
    }
    return false;
}
 
Example 3
Source Project: Cyberware   Source File: SwitchHeldItemAndRotationPacket.java    License: MIT License 6 votes vote down vote up
public static void faceEntity(Entity player, Entity entityIn)
{
	double d0 = entityIn.posX - player.posX;
	double d2 = entityIn.posZ - player.posZ;
	double d1;

	if (entityIn instanceof EntityLivingBase)
	{
		EntityLivingBase entitylivingbase = (EntityLivingBase)entityIn;
		d1 = entitylivingbase.posY + (double)entitylivingbase.getEyeHeight() - (player.posY + (double)player.getEyeHeight());
	}
	else
	{
		d1 = (entityIn.getEntityBoundingBox().minY + entityIn.getEntityBoundingBox().maxY) / 2.0D - (player.posY + (double)player.getEyeHeight());
	}

	double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2);
	float f = (float)(MathHelper.atan2(d2, d0) * (180D / Math.PI)) - 90.0F;
	float f1 = (float)(-(MathHelper.atan2(d1, d3) * (180D / Math.PI)));
	player.rotationPitch = f1;
	player.rotationYaw = f;
}
 
Example 4
private void signContract(ItemStack stack, EntityPlayer oldOwner, EntityLivingBase target)
{
    NBTTagCompound nbt = NBTUtils.getCompoundTag(stack, null, true);
    UUID uuidOwner = oldOwner.getUniqueID();
    nbt.setLong("OwnerM", uuidOwner.getMostSignificantBits());
    nbt.setLong("OwnerL", uuidOwner.getLeastSignificantBits());

    UUID uuidTarget = target.getUniqueID();
    nbt.setLong("OwnableM", uuidTarget.getMostSignificantBits());
    nbt.setLong("OwnableL", uuidTarget.getLeastSignificantBits());

    nbt.setFloat("Health", target.getHealth());
    String str = EntityList.getEntityString(target);

    if (str != null)
    {
        nbt.setString("EntityString", str);
    }

    if (target.hasCustomName())
    {
        nbt.setString("CustomName", target.getCustomNameTag());
    }

    oldOwner.getEntityWorld().playSound(null, oldOwner.getPosition(), SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE, SoundCategory.PLAYERS, 0.5f, 1f);
}
 
Example 5
protected void manageCats() {
  if(cats.isEmpty()) {
    return;
  }
  if(noActiveTargetTime > 40) {
    pacifyCats();
    return;
  }
  EntityLivingBase currentTarget = getActiveTarget();
  EntityLivingBase hitBy = getRevengeTarget();
  if(hitBy == null) {
    //agro the cats if we have been hit or we have actually thrown a potion
    hitBy = attackedWithPotion;
  }
  angerCats(currentTarget, hitBy);
}
 
Example 6
default void explode(Entity entityIn) {
	if (potions.isEmpty()) {
		potions.add(1);
		potions.add(3);
		potions.add(5);
		potions.add(8);
		potions.add(11);
		potions.add(12);
		potions.add(21);
	}

	Random rand = new Random();
	int range = 5;
	List<EntityLivingBase> entities = entityIn.world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(entityIn.posX - range, entityIn.posY - range, entityIn.posZ - range, entityIn.posX + range, entityIn.posY + range, entityIn.posZ + range));
	for (EntityLivingBase e : entities)
		e.addPotionEffect(new PotionEffect(Potion.getPotionById(potions.get(rand.nextInt(potions.size()))), rand.nextInt(30) * 20, rand.nextInt(2) + 1));

	ClientRunnable.run(new ClientRunnable() {
		@Override
		@SideOnly(Side.CLIENT)
		public void runIfClient() {
			LibParticles.FIZZING_EXPLOSION(entityIn.world, entityIn.getPositionVector());
		}
	});
}
 
Example 7
Source Project: AgriCraft   Source File: RenderWaterPad.java    License: MIT License 6 votes vote down vote up
@Override
public void renderInventoryBlock(ITessellator tess, World world, IBlockState state, BlockWaterPad block,
        ItemStack stack, EntityLivingBase entity, ItemCameraTransforms.TransformType type) {

    // Icons
    final TextureAtlasSprite matIcon = BaseIcons.DIRT.getIcon();
    final TextureAtlasSprite waterIcon = BaseIcons.WATER_STILL.getIcon();

    // Draw Base
    renderBase(tess, matIcon);

    // Draw Sides
    for (EnumFacing dir : EnumFacing.HORIZONTALS) {
        renderSide(tess, dir, matIcon);
    }

    // Full
    if (AgriProperties.POWERED.getValue(state)) {
        renderWater(tess, waterIcon);
    }
}
 
Example 8
@Override
@SuppressWarnings("unused")
public boolean run(@NotNull World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
	Entity targetEntity = spell.getVictim(world);
	BlockPos targetPos = spell.getTargetPos();
	Entity caster = spell.getCaster(world);

	double potency = spellRing.getAttributeValue(world, AttributeRegistry.POTENCY, spell);
	double duration = spellRing.getAttributeValue(world, AttributeRegistry.DURATION, spell) * 10;

	if (!spellRing.taxCaster(world, spell, true)) return false;

	if (targetEntity != null) {
		world.playSound(null, targetEntity.getPosition(), ModSounds.TELEPORT, SoundCategory.NEUTRAL, 1, 1);
		((EntityLivingBase) targetEntity).addPotionEffect(new PotionEffect(ModPotions.LOW_GRAVITY, (int) duration, (int) potency, true, false));
	}
	return true;
}
 
Example 9
Source Project: Artifacts   Source File: ComponentExplosive.java    License: MIT License 6 votes vote down vote up
@Override
public boolean itemInteractionForEntity(ItemStack itemStack, EntityPlayer player, EntityLivingBase entityLiving) {
	if(player.worldObj.isRemote) {
		PacketBuffer out =  new PacketBuffer(Unpooled.buffer());
		
		//System.out.println("Building packet...");
		out.writeInt(PacketHandlerServer.EXPLOSIONS);
		out.writeInt(player.getEntityId());
		out.writeInt(player.inventory.currentItem);
		//out.writeFloat(par3EntityPlayer.getHealth()+1);
		CToSMessage packet = new CToSMessage(out);
		//System.out.println("Sending packet..." + player);
		DragonArtifacts.artifactNetworkWrapper.sendToServer(packet);
		//par1ItemStack.damageItem(1, par2EntityPlayer);
		
		return true;

	}
	return false;
}
 
Example 10
Source Project: TFC2   Source File: BlockStairsTFC.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand)
{
	IBlockState iblockstate = super.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer, hand);
	iblockstate = iblockstate.withProperty(BlockStairs.FACING, placer.getHorizontalFacing()).withProperty(BlockStairs.SHAPE, EnumShape.STRAIGHT);
	return (facing != EnumFacing.DOWN) && ((facing == EnumFacing.UP) || (hitY <= 0.5D)) ? iblockstate.withProperty(BlockStairs.HALF, EnumHalf.BOTTOM) : iblockstate.withProperty(BlockStairs.HALF, EnumHalf.TOP);
}
 
Example 11
Source Project: Cyberware   Source File: ItemBrainUpgrade.java    License: MIT License 5 votes vote down vote up
@SubscribeEvent
public void handleTeleJam(EnderTeleportEvent event)
{
	EntityLivingBase te = event.getEntityLiving();
	
	if (CyberwareAPI.isCyberwareInstalled(te, new ItemStack(this, 1, 1)))
	{
		event.setCanceled(true);
		return;
	}
	if (te != null)
	{
		float range = 25F;
		List<EntityLivingBase> test = te.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(te.posX - range, te.posY - range, te.posZ - range, te.posX + te.width + range, te.posY + te.height + range, te.posZ + te.width + range));
		for (EntityLivingBase e : test)
		{
			if (te.getDistanceToEntity(e) <= range)
			{
				if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(this, 1, 1)))
				{
					event.setCanceled(true);
					return;
				}
			}
		}
	}
	
}
 
Example 12
@Override
public boolean shouldExecute() {
  EntityLivingBase target = entityHost.getAttackTarget();
  if (target == null) {
    return false;
  }
  attackTarget = target;
  return true;
}
 
Example 13
Source Project: TofuCraftReload   Source File: EntityTofuChinger.java    License: MIT License 5 votes vote down vote up
protected void checkAndPerformAttack(EntityLivingBase p_190102_1_, double p_190102_2_)
{
    double d0 = this.getAttackReachSqr(p_190102_1_);

    if (p_190102_2_ <= d0 && this.attackTick <= 0)
    {
        this.attackTick = 20;
        this.attacker.attackEntityAsMob(p_190102_1_);
        EntityTofuChinger.this.setMouseOpen(false);
    }
    else if (p_190102_2_ <= d0 * 2.0D)
    {
        if (this.attackTick <= 0)
        {
            EntityTofuChinger.this.setMouseOpen(false);
            this.attackTick = 20;
        }

        if (this.attackTick <= 10)
        {
            EntityTofuChinger.this.setMouseOpen(true);

        }

        if (this.attackTick <= 5)
        {
            EntityTofuChinger.this.playAttackSound();
        }
    }
    else
    {
        this.attackTick = 20;
        EntityTofuChinger.this.setMouseOpen(false);
    }
}
 
Example 14
@SubscribeEvent
public static void onLanding(LivingFallEvent event) {
	EntityLivingBase elb = event.getEntityLiving();
	if(elb.hasItemInSlot(EntityEquipmentSlot.FEET) && elb.getItemStackFromSlot(EntityEquipmentSlot.FEET).getItem() == PAIN_BOOTS) {
		if(event.getDistance() >= minTriggerHeight) {

			boolean notObstructed = true;
			double impactPosition = 0;

			for(int i = (int) elb.posY + 2; i < elb.world.provider.getHeight(); i++) {
				BlockPos pos = new BlockPos(elb.posX, i, elb.posZ);
				IBlockState state = elb.world.getBlockState(pos);
				if(state.isFullBlock() || state.isFullCube()) {
					notObstructed = false;
					impactPosition = i;
					break;
				}
			}


			if(notObstructed) {
				elb.setPositionAndUpdate(elb.posX, elb.world.provider.getHeight() + heightToAdd, elb.posZ);
				event.setDamageMultiplier(0);
			} else {
				elb.addVelocity(0, (impactPosition - elb.posY) / 2, 0);
				elb.attackEntityFrom(DamageSource.GENERIC, damageOnImpact);
				event.setDamageMultiplier(0);
			}
		}
	}
}
 
Example 15
Source Project: Chisel   Source File: BlockMarbleStairs.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack)
{
    int l = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
    int i1 = par1World.getBlockMetadata(par2, par3, par4) & 4;
    int odd = par6ItemStack.getItemDamage();

    if(l == 0)
    {
        par1World.setBlockMetadataWithNotify(par2, par3, par4, 2 | i1 + odd, 2);
    }

    if(l == 1)
    {
        par1World.setBlockMetadataWithNotify(par2, par3, par4, 1 | i1 + odd, 2);
    }

    if(l == 2)
    {
        par1World.setBlockMetadataWithNotify(par2, par3, par4, 3 | i1 + odd, 2);
    }

    if(l == 3)
    {
        par1World.setBlockMetadataWithNotify(par2, par3, par4, 0 | i1 + odd, 2);
    }
}
 
Example 16
Source Project: ToroQuest   Source File: EntityMonolithEye.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected void initEntityAI() {
	tasks.addTask(1, new EntityAIStayCentered(this));
	tasks.addTask(4, new AIAttack(this));
	tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 20.0F));
	targetTasks.addTask(1,
			new EntityAINearestAttackableTarget(this, EntityLivingBase.class, 10, true, false, new MonolithEyeTargetSelector(this)));
}
 
Example 17
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int slot, boolean selected) {
	NBTTagCompound nbt = StackUtil.getNbtData((stack));
	if (worldIn.getTotalWorldTime() % 2 == 0) {
		if (!(entityIn instanceof EntityPlayer) || !nbt.getBoolean(ACTIVE)) {
			this.setDamage(stack, 0);
			return;
		}
		double x = entityIn.posX;
		double y = entityIn.posY + 1.5;
		double z = entityIn.posZ;
		int pulled = 0;
		for (EntityItem item : worldIn.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(x, y, z, x + 1, y
				+ 1, z + 1).grow(range))) {
			if (item.getEntityData().getBoolean("PreventRemoteMovement")) {
				continue;
			}
			if (!canPull(stack) || pulled > 200) {
				break;
			}
			item.addVelocity((x - item.posX) * speed, (y - item.posY) * speed, (z - item.posZ) * speed);
			ElectricItem.manager.use(stack, energyCost, (EntityLivingBase) entityIn);
			pulled++;
		}
		this.setDamage(stack, pulled > 0 ? 1 : 0);
	}
}
 
Example 18
Source Project: ToroQuest   Source File: EntityMonolithEye.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected void redirectArrowAtAttacker(DamageSource source) {
	if ("arrow".equals(source.getDamageType())) {

		if (source.getTrueSource() != null && source.getTrueSource() instanceof EntityLivingBase) {
			attackWithArrow((EntityLivingBase) source.getTrueSource());
		}

		if (source.getImmediateSource() != null) {
			source.getImmediateSource().setDead();
		}

	}
}
 
Example 19
public TileInfusionClaw() {
    if(Gadomancy.proxy.getSide() == Side.CLIENT) {
        animationStates = new float[12];
        EntityLivingBase entity = Minecraft.getMinecraft().renderViewEntity;
        lastRenderTick = entity == null ? 0 : entity.ticksExisted;
    }
}
 
Example 20
@Override
public void onDescUpdate(){
    super.onDescUpdate();
    Entity entity = worldObj.getEntityByID(targetEntityId);
    if(entity instanceof EntityLivingBase) {
        getMinigun().setAttackTarget((EntityLivingBase)entity);
    } else {
        getMinigun().setAttackTarget(null);
    }
}
 
Example 21
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack par6ItemStack){
    super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLiving, par6ItemStack);
    TileEntity te = par1World.getTileEntity(par2, par3, par4);
    if(te instanceof TileEntityAirCannon) {
        TileEntityAirCannon teAc = (TileEntityAirCannon)te;
        teAc.onNeighbourBlockChange(par2, par3, par4, this);
    }
}
 
Example 22
@Inject(method = "doRender", at = @At("HEAD"))
private <T extends EntityLivingBase> void injectChamsPre(T entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo callbackInfo) {
    final Chams chams = (Chams) LiquidBounce.moduleManager.getModule(Chams.class);

    if (chams.getState() && chams.getTargetsValue().get() && EntityUtils.isSelected(entity, false)) {
        GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
        GL11.glPolygonOffset(1.0F, -1000000F);
    }
}
 
Example 23
public static int getFortuneLevel(EntityLivingBase entity) {
    int fortuneLevel = getRealEnchantmentLevel(Enchantment.fortune.effectId, entity.getHeldItem());
    if(entity.isPotionActive(RegisteredPotions.POTION_LUCK)) {
        int lvl = entity.getActivePotionEffect(RegisteredPotions.POTION_LUCK).getAmplifier() + 1; //Amplifier 0-indexed
        fortuneLevel += lvl;
    }
    return fortuneLevel;
}
 
Example 24
Source Project: SimplyJetpacks   Source File: JetpackPotato.java    License: MIT License 5 votes vote down vote up
protected void decrementTimer(ItemStack itemStack, EntityLivingBase user) {
    int timer = NBTHelper.getNBT(itemStack).getInteger(TAG_ROCKET_TIMER);
    timer = timer > 0 ? timer - 1 : 0;
    NBTHelper.getNBT(itemStack).setInteger(TAG_ROCKET_TIMER, timer);
    if (timer == 0) {
        this.setFired(itemStack);
        user.worldObj.playSoundAtEntity(user, SimplyJetpacks.RESOURCE_PREFIX + "rocket", 1.0F, 1.0F);
    }
}
 
Example 25
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) {
    super.onUpdate(stack, world, entity, par4, par5);
    if ((!entity.worldObj.isRemote) && ((stack.getItemDamage() == 14)) && ((entity instanceof EntityLivingBase)) && (!((EntityLivingBase) entity).isEntityUndead()) && (!((EntityLivingBase) entity).isPotionActive(Config.potionTaintPoisonID)) && (world.rand.nextInt(4321) <= stack.stackSize)) {
        ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(Config.potionTaintPoisonID, 120, 0, false));
        if ((entity instanceof EntityPlayer)) {
            InventoryUtils.consumeInventoryItem((EntityPlayer) entity, stack.getItem(), stack.getItemDamage());
        }
    }
}
 
Example 26
@Override
protected void addItemOverrides()
{
    this.addPropertyOverride(new ResourceLocation(Reference.MOD_ID, "signed"), new IItemPropertyGetter()
    {
        @Override
        public float apply(ItemStack stack, World worldIn, EntityLivingBase entityIn)
        {
            return ItemPetContract.this.isSigned(stack) ? 1.0F : 0.0F;
        }
    });
}
 
Example 27
Source Project: TFC2   Source File: ItemFoodTFC.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
 * the Item before the action is complete.
 */
@Override
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase player)
{
	/*FoodStatsTFC fs = Core.getPlayerFoodStats(player);
	fs.addNutrition(foodGroup, nourishment);
	Core.setPlayerFoodStats((EntityPlayer)player, fs);
	worldIn.playSound((EntityPlayer)null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F);
	this.onFoodEaten(stack, worldIn, (EntityPlayer)player);
	((EntityPlayer) player).addStat(StatList.getObjectUseStats(this));*/
	return stack;
}
 
Example 28
protected int shouldRenderPass(EntityLivingBase entity, int pass, float par3) {
    if (pass != 0) {
        return super.shouldRenderPass(entity, pass, par3);
    }

    EntityGolemBase golem = (EntityGolemBase) entity;

    AdditionalGolemCore core = GadomancyApi.getAdditionalGolemCore(golem);
    if (core != null) {
        golem.getDataWatcher().getWatchedObject(21).setObject((byte) -1);
    }

    int ret = super.shouldRenderPass(entity, pass, par3);

    //fix for render bug in tc
    if (RenderGolemHelper.requiresRenderFix((EntityGolemBase) entity)) {
        RenderGolemHelper.renderCarriedItemsFix(golem);

        if(toolItem != null) {
            RenderGolemHelper.renderToolItem(golem, toolItem, mainModel, renderManager);
        }
    }

    if (core != null) {
        golem.getDataWatcher().getWatchedObject(21).setObject((byte) 1);
        RenderGolemHelper.renderCore(golem, core);
    }

    return ret;
}
 
Example 29
public LaserHitsBlockEvent(World world1, Entity lasershot1, EntityLivingBase owner1, float range1, float power1, int blockBreaks1, boolean explosive1, boolean smelt1, int x1, int y1, int z1, int side1, float dropChance1, boolean removeBlock1, boolean dropBlock1) {
    super(world1, lasershot1, owner1, range1, power1, blockBreaks1, explosive1, smelt1);
    this.x = x1;
    this.y = y1;
    this.z = z1;
    this.side = side1;
    this.removeBlock = removeBlock1;
    this.dropBlock = dropBlock1;
    this.dropChance = dropChance1;
}
 
Example 30
@Override
public void onUnequipped(ItemStack itemStack, EntityLivingBase entity) {
    if(itemStack == null) return;
    if(entity instanceof EntityPlayer && itemStack.getItem() instanceof ItemEtherealFamiliar) {
        DataFamiliar familiarData = SyncDataHolder.getDataServer("FamiliarData");
        Aspect a = getFamiliarAspect(itemStack);
        if(a != null) {
            familiarData.handleUnequip(((EntityPlayer) entity).worldObj, (EntityPlayer) entity, a);
        }
    }
}