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

The following are Jave code examples for showing how to use isInsideOfMaterial() of the net.minecraft.entity.player.EntityPlayer class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: CustomWorldGen   File: GuiIngameForge.java   View Source Code Vote up 6 votes
protected void renderAir(int width, int height)
{
    if (pre(AIR)) return;
    mc.mcProfiler.startSection("air");
    EntityPlayer player = (EntityPlayer)this.mc.getRenderViewEntity();
    GlStateManager.enableBlend();
    int left = width / 2 + 91;
    int top = height - right_height;

    if (player.isInsideOfMaterial(Material.WATER))
    {
        int air = player.getAir();
        int full = MathHelper.ceiling_double_int((double)(air - 2) * 10.0D / 300.0D);
        int partial = MathHelper.ceiling_double_int((double)air * 10.0D / 300.0D) - full;

        for (int i = 0; i < full + partial; ++i)
        {
            drawTexturedModalRect(left - i * 8 - 9, top, (i < full ? 16 : 25), 18, 9, 9);
        }
        right_height += 10;
    }

    GlStateManager.disableBlend();
    mc.mcProfiler.endSection();
    post(AIR);
}
 
Example 2
Project: Lanolin   File: EventHandlerCommon.java   View Source Code Vote up 5 votes
@SubscribeEvent
public void onBlockBreak(BlockEvent.BreakEvent event){
    EntityPlayer player = event.getPlayer();
    if(player.isInsideOfMaterial(Material.WATER)) {
        //Player is inside water, check for lanolin
        if (player.getHeldItemMainhand().hasTagCompound() && player.getHeldItemMainhand().getTagCompound().hasKey("lanolin")) {
            int newLanolin = player.getHeldItemMainhand().getTagCompound().getInteger("lanolin") - 1;
            if (newLanolin <= 0)
                player.getHeldItemMainhand().getTagCompound().removeTag("lanolin");
            else
                player.getHeldItemMainhand().getTagCompound().setInteger("lanolin", newLanolin);
        }
    }
}
 
Example 3
Project: Mods   File: ItemParachute.java   View Source Code Vote up 5 votes
@Override
public void onArmorTick(World world, final EntityPlayer player, ItemStack itemStack) {
	if (itemStack.getTagCompound().getBoolean("Deployed")) {
		player.motionY=Math.max(-0.1f, player.motionY);
		player.fallDistance=0f;
		/*if (player.ticksExisted % 30 == 0) {
			itemStack.damageItem(1, player);
		}*/
		if (player.onGround || player.isInsideOfMaterial(Material.WATER))
			itemStack.getTagCompound().setBoolean("Deployed", false);
	}
}
 
Example 4
Project: Lanolin   File: EventHandlerCommon.java   View Source Code Vote up 4 votes
@SubscribeEvent
public void breakSpeed(PlayerEvent.BreakSpeed event){
    // Check if the break speed has been modified due to water
    // prevent the modification if there is lanolin on the tool being used
    // decrement the lanolin when the block is successfully broken
    EntityPlayer player = event.getEntityPlayer();
    IBlockState state = event.getState();
    BlockPos pos = event.getPos();
    if(player.isInsideOfMaterial(Material.WATER)) {
        //Player is inside water, check for lanolin
        if(player.getHeldItemMainhand().hasTagCompound() && player.getHeldItemMainhand().getTagCompound().hasKey("lanolin")){
            // Recalculate ala EntityPlayer.getDigSpeed(), but skip the water portion
            float f = player.inventory.getStrVsBlock(state);

            if (f > 1.0F)
            {
                int i = EnchantmentHelper.getEfficiencyModifier(player);
                ItemStack itemstack = player.getHeldItemMainhand();

                if (i > 0 && !itemstack.isEmpty())
                {
                    f += (float)(i * i + 1);
                }
            }

            if (player.isPotionActive(MobEffects.HASTE))
            {
                f *= 1.0F + (float)(player.getActivePotionEffect(MobEffects.HASTE).getAmplifier() + 1) * 0.2F;
            }

            if (player.isPotionActive(MobEffects.MINING_FATIGUE))
            {
                float f1;

                switch (player.getActivePotionEffect(MobEffects.MINING_FATIGUE).getAmplifier())
                {
                    case 0:
                        f1 = 0.3F;
                        break;
                    case 1:
                        f1 = 0.09F;
                        break;
                    case 2:
                        f1 = 0.0027F;
                        break;
                    case 3:
                    default:
                        f1 = 8.1E-4F;
                }

                f *= f1;
            }
            if(f > event.getNewSpeed()){
                event.setNewSpeed(f < 0 ? 0 : f);
            }
        }
    }
}