net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent Java Examples

The following examples show how to use net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent. 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: EntitySpawning.java    From ToroQuest with GNU General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public void onZombieVillagerDeath(LivingUpdateEvent event) {
	if (!event.getEntity().getEntityWorld().isRemote && event.getEntity().isDead && event.getEntity() instanceof EntityZombieVillager) {

		EntityLiving convertTo = null;

		if (hasRoyalEffect(event)) {
			convertTo = new EntityVillageLord(event.getEntity().world);
		} else if (hasLoyalEffect(event)) {
			convertTo = new EntityGuard(event.getEntity().world);
		}

		if (convertTo == null) {
			return;
		}

		if (handlePossibleConversion((EntityLiving) event.getEntity(), convertTo)) {
			removeVillager(event);
		}
	}
}
 
Example #2
Source File: ItemFootUpgrade.java    From Cyberware with MIT License 6 votes vote down vote up
@SubscribeEvent
public void handleHorseMove(LivingUpdateEvent event)
{
	EntityLivingBase e = event.getEntityLiving();
	if (e instanceof EntityHorse)
	{
		EntityHorse horse = (EntityHorse) e;
		for (Entity pass : horse.getPassengers())
		{
			if (pass instanceof EntityLivingBase && CyberwareAPI.isCyberwareInstalled(pass, new ItemStack(this, 1, 0)))
			{
				horse.addPotionEffect(new PotionEffect(MobEffects.SPEED, 1, 5, true, false));
				break;
			}
		}
	}
}
 
Example #3
Source File: AtmosphereHandler.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
@SubscribeEvent
public void onTick(LivingUpdateEvent event) {
	Entity entity = event.getEntity();
	if(!entity.world.isRemote && entity.world.provider.getDimension() == this.dimId) {
		IAtmosphere atmosType = getAtmosphereType(entity);

		if(entity instanceof EntityPlayer && atmosType != prevAtmosphere.get(entity)) {
			PacketHandler.sendToPlayer(new PacketAtmSync(atmosType.getUnlocalizedName(), getAtmospherePressure(entity)), (EntityPlayer)entity);
			prevAtmosphere.put((EntityPlayer)entity, atmosType);
		}

		if(atmosType.canTick() &&
				!(event.getEntityLiving().isInLava() || event.getEntityLiving().isInWater()) ) {
			AtmosphereEvent event2 = new AtmosphereEvent.AtmosphereTickEvent(entity, atmosType);
			MinecraftForge.EVENT_BUS.post(event2);
			if(!event2.isCanceled() && !Configuration.bypassEntity.contains(event.getEntity().getClass()))
				atmosType.onTick((EntityLivingBase)event.getEntityLiving());
		}
	}
}
 
Example #4
Source File: PlanetEventHandler.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
@SubscribeEvent
public void playerTick(LivingUpdateEvent event) {

	if(event.getEntity().world.isRemote && event.getEntity().posY > 260 && event.getEntity().posY < 270 && event.getEntity().motionY < -.1) {
		RocketEventHandler.destroyOrbitalTextures(event.getEntity().world);
	}
	if(event.getEntity().isInWater()) {
		if(AtmosphereType.LOWOXYGEN.isImmune(event.getEntityLiving()))
			event.getEntity().setAir(300);
	}

	if(!event.getEntity().world.isRemote && event.getEntity().world.getTotalWorldTime() % 20 ==0 && event.getEntity() instanceof EntityPlayer) {
		if(DimensionManager.getInstance().getDimensionProperties(event.getEntity().world.provider.getDimension()).getName().equals("Luna") && 
				event.getEntity().getPosition().distanceSq(67, 80, 2347) < 512 ) {
			ARAchivements.WENT_TO_THE_MOON.trigger((EntityPlayerMP)event.getEntity());
		}	
	}

	GravityHandler.applyGravity(event.getEntity());
}
 
Example #5
Source File: LivingTickHandler.java    From SimplyJetpacks with MIT License 6 votes vote down vote up
@SubscribeEvent
public void mobUseJetpack(LivingUpdateEvent evt) {
    if (!evt.entityLiving.worldObj.isRemote && evt.entityLiving instanceof EntityMob) {
        ItemStack armor = evt.entityLiving.getEquipmentInSlot(3);
        if (armor != null && armor.getItem() instanceof ItemJetpack) {
            ItemJetpack jetpackItem = (ItemJetpack) armor.getItem();
            Jetpack jetpack = jetpackItem.getPack(armor);
            if (jetpack != null) {
                if (jetpack instanceof JetpackPotato || MathHelper.RANDOM.nextInt(3) == 0) {
                    jetpack.setMobMode(armor);
                    jetpack.flyUser(evt.entityLiving, armor, jetpackItem, false);
                }
            }
            if (evt.entityLiving.posY > evt.entityLiving.worldObj.getActualHeight() + 10) {
                evt.entityLiving.attackEntityFrom(DamageSource.generic, 80);
            }
        }
    }
}
 
Example #6
Source File: FMEventHandler.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 6 votes vote down vote up
@SubscribeEvent
public void onEntityUpdate(LivingUpdateEvent event){
    if(Compat.bm && event.entityLiving != null && event.entityLiving instanceof EntityPlayer && !event.entityLiving.worldObj.isRemote){
        EntityPlayer player = (EntityPlayer)event.entityLiving;
        String name = player.getDisplayName();
        if(player.isPotionActive(DarkPotions.bloodSeal)){
            try {
                if (lastLP.containsKey(name)) {
                    if (SoulNetworkHandler.getCurrentEssence(name) > lastLP.get(name))
                        SoulNetworkHandler.setCurrentEssence(name, lastLP.get(name));
                    else
                        lastLP.put(name, SoulNetworkHandler.getCurrentEssence(name));
                }
                else
                    lastLP.put(name, SoulNetworkHandler.getCurrentEssence(name));
            }
            catch(Throwable e){
                Compat.bm = false;
            }
        }
        else if(lastLP.containsKey(name))
            lastLP.remove(name);
    }
}
 
Example #7
Source File: EntitySpawning.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
private void removeVillager(LivingUpdateEvent event) {
	List<EntityVillager> list = event.getEntity().world.getEntitiesWithinAABB(EntityVillager.class,
			new AxisAlignedBB(event.getEntity().getPosition()));
	if (list.size() < 1) {
		return;
	}
	list.get(0).setDead();
}
 
Example #8
Source File: EssentialsMissingHandler.java    From Cyberware with MIT License 5 votes vote down vote up
@SubscribeEvent
public void triggerCyberwareEvent(LivingUpdateEvent event)
{
	EntityLivingBase e = event.getEntityLiving();
	
	if (CyberwareAPI.hasCapability(e))
	{
		CyberwareUpdateEvent event2 = new CyberwareUpdateEvent(e);
		MinecraftForge.EVENT_BUS.post(event2);
	}
}
 
Example #9
Source File: ServerEventHandler.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
@SubscribeEvent
public void livingUpdate(LivingUpdateEvent event) {
	ModEnchantments.onLivingUpdate(event.entityLiving);

	if (EtFuturum.enableVillagerZombies)
		if (!event.entityLiving.worldObj.isRemote && event.entityLiving.getClass() == EntityZombie.class) {
			EntityZombie zombie = (EntityZombie) event.entityLiving;
			if (zombie.isVillager()) {
				EntityZombieVillager villagerZombie = new EntityZombieVillager(zombie.worldObj);
				villagerZombie.copyLocationAndAnglesFrom(zombie);
				villagerZombie.onSpawnWithEgg(null);
				villagerZombie.worldObj.spawnEntityInWorld(villagerZombie);

				zombie.setDead();
			}
		}

	if (EtFuturum.enableShearableGolems)
		if (!event.entityLiving.worldObj.isRemote && event.entityLiving.getClass() == EntitySnowman.class) {
			EntityNewSnowGolem golen = new EntityNewSnowGolem(event.entityLiving.worldObj);
			golen.copyLocationAndAnglesFrom(event.entityLiving);
			golen.onSpawnWithEgg(null);
			golen.worldObj.spawnEntityInWorld(golen);

			event.entityLiving.setDead();
		}
}
 
Example #10
Source File: EntityLivingHandler.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onEntityLivingUpdateClient(LivingUpdateEvent event)
{
	if (event.getEntity().getEntityWorld().isRemote && event.getEntityLiving() instanceof EntityPlayerSP)
	{
		EntityPlayerSP player = (EntityPlayerSP)event.getEntityLiving();
		updateEncumb(player);
	}
}
 
Example #11
Source File: LivingTickHandler.java    From SimplyJetpacks with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onLivingTick(LivingUpdateEvent evt) {
    if (!evt.entityLiving.worldObj.isRemote) {
        ParticleType jetpackState = null;
        ItemStack armor = evt.entityLiving.getEquipmentInSlot(3);
        Jetpack jetpack = null;
        if (armor != null && armor.getItem() instanceof ItemJetpack) {
            jetpack = ((ItemJetpack) armor.getItem()).getPack(armor);
            if (jetpack != null) {
                jetpackState = jetpack.getDisplayParticleType(armor, (ItemJetpack) armor.getItem(), evt.entityLiving);
            }
        }
        
        if (jetpackState != lastJetpackState.get(evt.entityLiving.getEntityId())) {
            if (jetpackState == null) {
                lastJetpackState.remove(evt.entityLiving.getEntityId());
            } else {
                lastJetpackState.put(evt.entityLiving.getEntityId(), jetpackState);
            }
            PacketHandler.instance.sendToAllAround(new MessageJetpackSync(evt.entityLiving.getEntityId(), jetpackState != null ? jetpackState.ordinal() : -1), new TargetPoint(evt.entityLiving.dimension, evt.entityLiving.posX, evt.entityLiving.posY, evt.entityLiving.posZ, 256));
        } else if (jetpack != null && evt.entityLiving.worldObj.getTotalWorldTime() % 160L == 0) {
            PacketHandler.instance.sendToAllAround(new MessageJetpackSync(evt.entityLiving.getEntityId(), jetpackState != null ? jetpackState.ordinal() : -1), new TargetPoint(evt.entityLiving.dimension, evt.entityLiving.posX, evt.entityLiving.posY, evt.entityLiving.posZ, 256));
        }
        
        if (evt.entityLiving.worldObj.getTotalWorldTime() % 200L == 0) {
            Iterator<Integer> itr = lastJetpackState.keySet().iterator();
            while (itr.hasNext()) {
                int entityId = itr.next();
                if (evt.entityLiving.worldObj.getEntityByID(entityId) == null) {
                    itr.remove();
                }
            }
        }
    }
}
 
Example #12
Source File: ProxyCommon.java    From WearableBackpacks with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onLivingUpdate(LivingUpdateEvent event) {

	// Update equipped backpacks and check
	// if they've been removed somehow.

	EntityLivingBase entity = event.getEntityLiving();
	BackpackCapability backpack = (BackpackCapability)entity
		.getCapability(IBackpack.CAPABILITY, null);
	if (backpack == null) return;

	if (backpack.spawnWith != null)
		onSpawnedWith(entity, backpack, backpack.spawnWith);
	boolean hasBackpack = !backpack.getStack().isEmpty();

	if (backpack.isChestArmor()) {
		if (entity instanceof EntityPlayer)
			SlotBackpackWrapper.replace((EntityPlayer)entity, backpack.getStack());

		if (!hasBackpack) {
			// Backpack has been removed somehow.
			backpack.getType().onFaultyRemoval(entity, backpack);
			backpack.setStack(ItemStack.EMPTY);
			return;
		}
	} else if (!hasBackpack) return;

	backpack.getType().onEquippedTick(entity, backpack);
	if (entity.world.isRemote)
		BackpackHelper.updateLidTicks(backpack, entity.posX, entity.posY + 1.0, entity.posZ);

}
 
Example #13
Source File: EntitySpawning.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private boolean hasRoyalEffect(LivingUpdateEvent event) {
	return ((EntityZombieVillager) event.getEntity()).getActivePotionEffect(PotionRoyal.INSTANCE) != null;
}
 
Example #14
Source File: EntitySpawning.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private boolean hasLoyalEffect(LivingUpdateEvent event) {
	return ((EntityZombieVillager) event.getEntity()).getActivePotionEffect(PotionLoyalty.INSTANCE) != null;
}
 
Example #15
Source File: EssentialsMissingHandlerClient.java    From Cyberware with MIT License 4 votes vote down vote up
@SubscribeEvent(priority=EventPriority.LOWEST)
public void handleMissingEssentials(LivingUpdateEvent event)
{
	EntityLivingBase e = event.getEntityLiving();
	
	if (e != null && e == Minecraft.getMinecraft().thePlayer)
	{
		ICyberwareUserData cyberware = CyberwareAPI.getCapability(e);
		GameSettings settings = Minecraft.getMinecraft().gameSettings;
		boolean stillMissingArm = false;
		boolean stillMissingSecondArm = false;
		
		boolean leftUnpowered = false;
		ItemStack armLeft = cyberware.getCyberware(new ItemStack(CyberwareContent.cyberlimbs, 1, 0));
		if (armLeft != null && !ItemCyberlimb.isPowered(armLeft))
		{
			leftUnpowered = true;
		}
		
		boolean rightUnpowered = false;
		ItemStack armRight = cyberware.getCyberware(new ItemStack(CyberwareContent.cyberlimbs, 1, 1));
		if (armRight != null && !ItemCyberlimb.isPowered(armRight))
		{
			rightUnpowered = true;
		}
		
		
		boolean hasSkin = cyberware.isCyberwareInstalled(new ItemStack(CyberwareContent.skinUpgrades, 1, 2));
		hasRoboLeft = armLeft != null && !hasSkin;
		hasRoboRight = armRight != null && !hasSkin;
		boolean hasRightArm = cyberware.hasEssential(EnumSlot.ARM, EnumSide.RIGHT) && !rightUnpowered;
		boolean hasLeftArm = cyberware.hasEssential(EnumSlot.ARM, EnumSide.LEFT) && !leftUnpowered;
		
		if (!hasRightArm)
		{
			if (settings.mainHand != EnumHandSide.LEFT)
			{
				oldHand = settings.mainHand;
				settings.mainHand = EnumHandSide.LEFT;
				settings.sendSettingsToServer();
			}

			if (!missingArm)
			{
				missingArm = true;
			}
			stillMissingArm = true;


			if (!hasLeftArm)
			{
				if (!missingSecondArm)
				{
					missingSecondArm = true;
				}
				stillMissingSecondArm = true;
			}

		}
		else if (!hasLeftArm)
		{
			if (settings.mainHand != EnumHandSide.RIGHT)
			{
				oldHand = settings.mainHand;
				settings.mainHand = EnumHandSide.RIGHT;
				settings.sendSettingsToServer();
			}

			if (!missingArm)
			{
				missingArm = true;
			}
			stillMissingArm = true;
		

			if (!hasRightArm)
			{
				if (!missingSecondArm)
				{
					missingSecondArm = true;
				}
				stillMissingSecondArm = true;
			}

		}

		if (!stillMissingArm && oldHand != null)
		{
			missingArm = false;
			settings.mainHand = oldHand;
			settings.sendSettingsToServer();
		
		}

		if (!stillMissingSecondArm)
		{
			missingSecondArm = false;
		}
	}
}