net.minecraft.entity.passive.EntityWaterMob Java Examples

The following examples show how to use net.minecraft.entity.passive.EntityWaterMob. 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: RadarHack.java    From ForgeWurst with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onUpdate(WUpdateEvent event)
{
	EntityPlayerSP player = event.getPlayer();
	World world = WPlayer.getWorld(player);
	
	entities.clear();
	Stream<Entity> stream = world.loadedEntityList.parallelStream()
		.filter(e -> !e.isDead && e != player)
		.filter(e -> !(e instanceof EntityFakePlayer))
		.filter(e -> e instanceof EntityLivingBase)
		.filter(e -> ((EntityLivingBase)e).getHealth() > 0);
	
	if(filterPlayers.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityPlayer));
	
	if(filterSleeping.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityPlayer
			&& ((EntityPlayer)e).isPlayerSleeping()));
	
	if(filterMonsters.isChecked())
		stream = stream.filter(e -> !(e instanceof IMob));
	
	if(filterAnimals.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityAnimal
			|| e instanceof EntityAmbientCreature
			|| e instanceof EntityWaterMob));
	
	if(filterInvisible.isChecked())
		stream = stream.filter(e -> !e.isInvisible());
	
	entities.addAll(stream.collect(Collectors.toList()));
}
 
Example #2
Source File: EntityUtils.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Adds the persistenceRequired flag to entities, if they need it in order to not despawn.
 * The checks are probably at most accurate for vanilla entities.
 * @param livingBase
 * @return
 */
public static boolean applyMobPersistence(EntityLiving living)
{
    if (living.isNoDespawnRequired() == false)
    {
        boolean canDespawn = ((living instanceof EntityMob) && living.isNonBoss()) ||
                              (living instanceof EntityWaterMob) ||
                              ((living instanceof EntityTameable) && ((EntityTameable)living).isTamed() == false);

        if (canDespawn == false)
        {
            try
            {
                canDespawn = (boolean) methodHandle_EntityLiving_canDespawn.invokeExact(living);
            }
            catch (Throwable t)
            {
                EnderUtilities.logger.warn("Error while trying to invoke EntityLiving.canDespawn() on entity '{}' via a MethodHandle", living, t);
            }
        }

        if (canDespawn)
        {
            // Sets the persistenceRequired boolean
            living.enablePersistence();
            living.getEntityWorld().playSound(null, living.getPosition(), Sounds.JAILER, SoundCategory.MASTER, 0.8f, 1.2f);

            return true;
        }
    }

    return false;
}
 
Example #3
Source File: CraftWaterMob.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftWaterMob(CraftServer server, EntityWaterMob entity) {
    super(server, entity);
}
 
Example #4
Source File: CraftWaterMob.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EntityWaterMob getHandle() {
    return (EntityWaterMob) entity;
}
 
Example #5
Source File: KillauraHack.java    From ForgeWurst with GNU General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void onUpdate(WUpdateEvent event)
{
	EntityPlayerSP player = event.getPlayer();
	World world = WPlayer.getWorld(player);
	
	if(player.getCooledAttackStrength(0) < 1)
		return;
	
	double rangeSq = Math.pow(range.getValue(), 2);
	Stream<EntityLivingBase> stream = world.loadedEntityList
		.parallelStream().filter(e -> e instanceof EntityLivingBase)
		.map(e -> (EntityLivingBase)e)
		.filter(e -> !e.isDead && e.getHealth() > 0)
		.filter(e -> WEntity.getDistanceSq(player, e) <= rangeSq)
		.filter(e -> e != player)
		.filter(e -> !(e instanceof EntityFakePlayer));
	
	if(filterPlayers.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityPlayer));
	
	if(filterSleeping.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityPlayer
			&& ((EntityPlayer)e).isPlayerSleeping()));
	
	if(filterFlying.getValue() > 0)
		stream = stream.filter(e -> {
			
			if(!(e instanceof EntityPlayer))
				return true;
			
			AxisAlignedBB box = e.getEntityBoundingBox();
			box = box.union(box.offset(0, -filterFlying.getValue(), 0));
			// Using expand() with negative values doesn't work in 1.10.2.
			return world.collidesWithAnyBlock(box);
		});
	
	if(filterMonsters.isChecked())
		stream = stream.filter(e -> !(e instanceof IMob));
	
	if(filterPigmen.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityPigZombie));
	
	if(filterEndermen.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityEnderman));
	
	if(filterAnimals.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityAnimal
			|| e instanceof EntityAmbientCreature
			|| e instanceof EntityWaterMob));
	
	if(filterBabies.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityAgeable
			&& ((EntityAgeable)e).isChild()));
	
	if(filterPets.isChecked())
		stream = stream
			.filter(e -> !(e instanceof EntityTameable
				&& ((EntityTameable)e).isTamed()))
			.filter(e -> !WEntity.isTamedHorse(e));
	
	if(filterVillagers.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityVillager));
	
	if(filterGolems.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityGolem));
	
	if(filterInvisible.isChecked())
		stream = stream.filter(e -> !e.isInvisible());
	
	target = stream.min(priority.getSelected().comparator).orElse(null);
	if(target == null)
		return;
	
	RotationUtils
		.faceVectorPacket(target.getEntityBoundingBox().getCenter());
	mc.playerController.attackEntity(player, target);
	player.swingArm(EnumHand.MAIN_HAND);
}