Java Code Examples for net.minecraft.entity.player.EntityPlayer#isInWater()

The following examples show how to use net.minecraft.entity.player.EntityPlayer#isInWater() . 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: DataHelper.java    From GokiStats with MIT License 6 votes vote down vote up
public static float getDamageDealt(EntityPlayer player, Entity target, DamageSource source) {
    float damage = (float) player.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
    float bonusDamage = 0.0F;
    boolean targetIsLiving = target instanceof EntityLivingBase;
    boolean critical;
    ItemStack stack = player.getHeldItemMainhand();
    if (targetIsLiving) {
        bonusDamage = EnchantmentHelper.getModifierForCreature(stack, ((EntityLivingBase) target).getCreatureAttribute());
    }
    if ((damage > 0.0F) || (bonusDamage > 0.0F)) {
        critical = (player.fallDistance > 0.0F) && (!player.onGround) && (!player.isOnLadder()) && (!player.isInWater()) && (!player.isPotionActive(Potion.getPotionFromResourceLocation("blindness"))) && (player.getRidingEntity() == null) && (targetIsLiving);
        if ((critical) && (damage > 0.0F)) {
            damage *= 1.5F;
        }
        damage += bonusDamage;
    }
    return damage;
}
 
Example 2
Source File: ItemThaumiumReinforcedWing.java    From Electro-Magic-Tools with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
    if (world.isRemote) {
        boolean isJumping = Minecraft.getMinecraft().gameSettings.keyBindJump.isPressed();
        boolean isHoldingJump = Minecraft.getMinecraft().gameSettings.keyBindJump.getIsKeyPressed();
        boolean isSneaking = Minecraft.getMinecraft().gameSettings.keyBindSneak.getIsKeyPressed();

        if (isJumping) player.motionY = 0.5;

        if (isHoldingJump && !player.onGround && player.motionY < 0 && !player.capabilities.isCreativeMode)
            player.motionY *= 0.5;

        if (player.isInWater() && !player.capabilities.isCreativeMode) player.motionY = -0.6;

        if ((player.worldObj.isRaining() || player.worldObj.isThundering()) && !player.capabilities.isCreativeMode)
            player.motionY = -0.3;

        if (isSneaking && !player.onGround) player.motionY = -0.6;

    }
    if (player.fallDistance > 0.0F) player.fallDistance = 0;
}
 
Example 3
Source File: ItemFeatherWing.java    From Electro-Magic-Tools with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
    if (world.isRemote) {
        boolean isJumping = Minecraft.getMinecraft().gameSettings.keyBindJump.isPressed();
        boolean isHoldingJump = Minecraft.getMinecraft().gameSettings.keyBindJump.getIsKeyPressed();
        boolean isSneaking = Minecraft.getMinecraft().gameSettings.keyBindSneak.getIsKeyPressed();

        if (isJumping) player.motionY = 0.25;

        if (isHoldingJump && !player.onGround && player.motionY < 0 && !player.capabilities.isCreativeMode)
            player.motionY *= 0.9;

        if (player.isInWater() && !player.capabilities.isCreativeMode) player.motionY = -0.6;

        if ((player.worldObj.isRaining() || player.worldObj.isThundering()) && !player.capabilities.isCreativeMode)
            player.motionY = -0.3;

        if (isSneaking && !player.onGround) player.motionY = -0.6;
    }
    if (player.fallDistance > 0.0F) player.fallDistance = 0;
}
 
Example 4
Source File: ItemNanoWing.java    From Electro-Magic-Tools with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
    if (world.isRemote) {
        boolean isJumping = Minecraft.getMinecraft().gameSettings.keyBindJump.isPressed();
        boolean isHoldingJump = Minecraft.getMinecraft().gameSettings.keyBindJump.getIsKeyPressed();
        boolean isSneaking = Minecraft.getMinecraft().gameSettings.keyBindSneak.getIsKeyPressed();

        if (isJumping) player.motionY = 0.7;

        if (isHoldingJump && !player.onGround && player.motionY < 0 && !player.capabilities.isCreativeMode)
            player.motionY *= 0.3;

        if (player.isInWater() && !player.capabilities.isCreativeMode) player.motionY = -0.4;

        if ((player.worldObj.isRaining() || player.worldObj.isThundering()) && !player.capabilities.isCreativeMode)
            player.motionY = -0.2;

        if (isSneaking && !player.onGround) player.motionY = -0.6;
    }
    if (player.fallDistance > 0.0F) player.fallDistance = 0;
}
 
Example 5
Source File: JesusHack.java    From ForgeWurst with GNU General Public License v3.0 5 votes vote down vote up
private boolean isLiquidCollisionEnabled(EntityPlayer player)
{
	if(player == null)
		return false;
	
	if(player.isSneaking()
		&& GameSettings.isKeyDown(mc.gameSettings.keyBindSneak))
		return false;
	
	if(player.isInWater() || player.fallDistance > 3)
		return false;
	
	return true;
}
 
Example 6
Source File: ItemQuantumWing.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
    if (world.isRemote) {
        boolean isJumping = Minecraft.getMinecraft().gameSettings.keyBindJump.isPressed();
        boolean isHoldingJump = Minecraft.getMinecraft().gameSettings.keyBindJump.getIsKeyPressed();
        boolean isSneaking = Minecraft.getMinecraft().gameSettings.keyBindSneak.getIsKeyPressed();

        if (isJumping) player.motionY = 0.85;

        if (isHoldingJump && !player.onGround && player.motionY < 0 && !player.capabilities.isCreativeMode)
            player.motionY *= 0.3;

        if (player.isInWater() && !player.capabilities.isCreativeMode) player.motionY = -0.1;

        if ((player.worldObj.isRaining() || player.worldObj.isThundering()) && !player.capabilities.isCreativeMode)
            player.motionY = -0.05;

        if (isSneaking && isHoldingJump) player.motionY = 0;

        if (isSneaking && !player.onGround && !isHoldingJump) player.motionY = -0.6;
    }
    if (player.fallDistance > 0.0F) player.fallDistance = 0;
}
 
Example 7
Source File: MoCEntityFishy.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) && (getType() == 10))
    {
        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 8
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 9
Source File: ItemReinforcedDiamondArmor.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {

	if (player.isInWater()) {

	}

	// Minecraft.getMinecraft().thePlayer.movementInput =

	effectPlayer(player, MobEffects.SLOWNESS, 2);

	// effectPlayer(player, MobEffects.jump, -2);

	if (player.isSwingInProgress) {
		player.addExhaustion(0.025f);
	}
}
 
Example 10
Source File: MoCEntityRay.java    From mocreaturesdev with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onLivingUpdate()
{
    /*if (rand.nextInt(200)==0)
    {
        switchany = !switchany;
    }*/

    super.onLivingUpdate();
    if (!worldObj.isRemote)
    {
        if (!getIsAdult() && (rand.nextInt(50) == 0))
        {
            setEdad(getEdad() + 1);
            if ((getType() == 1 && getEdad() >= 180) || (getType() > 1 && getEdad() >= 90))
            {
                setAdult(true);
            }
        }

        poisoncounter++;
        if (poisoncounter > 100)
        {
            attacking = false;
        }

        if (getType() > 1 && poisoncounter > 250 && (worldObj.difficultySetting > 0))
        {

            EntityPlayer entityplayertarget = worldObj.getClosestPlayer(posX, posY, posZ, 2D);
            {
                if (entityplayertarget != null && entityplayertarget.isInWater())
                {
                	if (entityplayertarget.ridingEntity != null && entityplayertarget.ridingEntity instanceof EntityBoat)
                	{
                		//don't poison players on boats
                	}else
                	{
                		MoCreatures.poisonPlayer(entityplayertarget);
                        entityplayertarget.addPotionEffect(new PotionEffect(Potion.poison.id, 120, 0));
                        poisoncounter = 0;
                        attacking = true;
                	}
                    
                }

            }
        }
    }

    //tempRotation = prevRenderYawOffset;
    //float percentChangeRotation = (prevRenderYawOffset - renderYawOffset)

}
 
Example 11
Source File: MoCEntityJellyFish.java    From mocreaturesdev with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onLivingUpdate()
{
    
    if (rand.nextInt(2) == 0)
    {
        pulsingSize += 0.01F;

    }
    
    if (pulsingSize > 0.4F)
    {
        pulsingSize = 0.0F;
    }
    super.onLivingUpdate();
    if (MoCreatures.isServer())
    {
        
        if(rand.nextInt(200) == 0)
        {
            setGlowing(!worldObj.isDaytime()); 
        }
        
        
        if (!getIsAdult() && (rand.nextInt(200) == 0))
        {
            setEdad(getEdad() + 1);
            if (getEdad() >= 100)
            {
                setAdult(true);
            }
        }

        poisoncounter++;
        

        if (poisoncounter > 250 && (worldObj.difficultySetting > 0))
        {

            EntityPlayer entityplayertarget = worldObj.getClosestPlayer(posX, posY, posZ, 2D);
            {
                if (entityplayertarget != null && entityplayertarget.isInWater())
                {
                	if (entityplayertarget.ridingEntity != null && entityplayertarget.ridingEntity instanceof EntityBoat)
                	{
                		//don't poison players on boats
                	}else
                	{
                    MoCreatures.poisonPlayer(entityplayertarget);
                    entityplayertarget.addPotionEffect(new PotionEffect(Potion.poison.id, 120, 0));
                    poisoncounter = 0;
                	}
                    //attacking = true;
                }

            }
        }

        
        
    }
}