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

The following examples show how to use net.minecraft.entity.player.EntityPlayer#isInsideOfMaterial() . 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 check out the related API usage on the sidebar.
Example 1
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
    IElectricItem electricItem = itemStack.getCapability(GregtechCapabilities.CAPABILITY_ELECTRIC_ITEM, null);
    if (electricItem.getCharge() >= energyUsagePerTick) {
        if (player.isInsideOfMaterial(Material.WATER) && world.isRemote && world.getTotalWorldTime() % 20 == 0L) {
            Vec3d pos = player.getPositionVector().add(new Vec3d(0.0, player.getEyeHeight(), 0.0));
            Particle particle = new ParticleBubble.Factory().createParticle(0, world, pos.x, pos.y, pos.z, 0.0, 0.0, 0.0);
            particle.setMaxAge(Integer.MAX_VALUE);
            Minecraft.getMinecraft().effectRenderer.addEffect(particle);
        }
        if (player.isInsideOfMaterial(Material.WATER) && !player.isPotionActive(MobEffects.WATER_BREATHING)) {
            if (player.getAir() < 300 && drainActivationEnergy(electricItem)) {
                player.setAir(Math.min(player.getAir() + 1, 300));
            }
        }
    }
}
 
Example 2
Source Project: Cyberware   File: ItemCybereyeUpgrade.java    License: MIT License 6 votes vote down vote up
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void handleFog(FogDensity event)
{
	EntityPlayer p = Minecraft.getMinecraft().thePlayer;
	if (CyberwareAPI.isCyberwareInstalled(p, new ItemStack(this, 1, 1)))
	{
		if (p.isInsideOfMaterial(Material.WATER))
		{
			event.setDensity(0.01F);
			event.setCanceled(true);
		}
		else if (p.isInsideOfMaterial(Material.LAVA))
		{
			event.setDensity(0.7F);
			event.setCanceled(true);
		}

	}

}
 
Example 3
@Inject(method = "getPlayerRelativeBlockHardness", at = @At("RETURN"), cancellable = true)
public void modifyBreakSpeed(EntityPlayer playerIn, World worldIn, BlockPos pos, final CallbackInfoReturnable<Float> callbackInfo) {
    float f = callbackInfo.getReturnValue();

    // NoSlowBreak
    final NoSlowBreak noSlowBreak = (NoSlowBreak) LiquidBounce.moduleManager.getModule(NoSlowBreak.class);
    if (noSlowBreak.getState()) {
        if (noSlowBreak.getWaterValue().get() && playerIn.isInsideOfMaterial(Material.water) &&
                !EnchantmentHelper.getAquaAffinityModifier(playerIn)) {
            f *= 5.0F;
        }

        if (noSlowBreak.getAirValue().get() && !playerIn.onGround) {
            f *= 5.0F;
        }
    } else if (playerIn.onGround) { // NoGround
        final NoFall noFall = (NoFall) LiquidBounce.moduleManager.getModule(NoFall.class);
        final Criticals criticals = (Criticals) LiquidBounce.moduleManager.getModule(Criticals.class);

        if (noFall.getState() && noFall.modeValue.get().equalsIgnoreCase("NoGround") ||
                criticals.getState() && criticals.getModeValue().get().equalsIgnoreCase("NoGround")) {
            f /= 5F;
        }
    }

    callbackInfo.setReturnValue(f);
}
 
Example 4
@Inject(method = "getPlayerRelativeBlockHardness", at = @At("RETURN"), cancellable = true)
public void modifyBreakSpeed(EntityPlayer playerIn, World worldIn, BlockPos pos, final CallbackInfoReturnable<Float> callbackInfo) {
    float f = callbackInfo.getReturnValue();

    // NoSlowBreak
    final NoSlowBreak noSlowBreak = (NoSlowBreak) LiquidBounce.moduleManager.getModule(NoSlowBreak.class);
    if (noSlowBreak.getState()) {
        if (noSlowBreak.getWaterValue().get() && playerIn.isInsideOfMaterial(Material.water) &&
                !EnchantmentHelper.getAquaAffinityModifier(playerIn)) {
            f *= 5.0F;
        }

        if (noSlowBreak.getAirValue().get() && !playerIn.onGround) {
            f *= 5.0F;
        }
    } else if (playerIn.onGround) { // NoGround
        final NoFall noFall = (NoFall) LiquidBounce.moduleManager.getModule(NoFall.class);
        final Criticals criticals = (Criticals) LiquidBounce.moduleManager.getModule(Criticals.class);

        if (noFall.getState() && noFall.modeValue.get().equalsIgnoreCase("NoGround") ||
                criticals.getState() && criticals.getModeValue().get().equalsIgnoreCase("NoGround")) {
            f /= 5F;
        }
    }

    callbackInfo.setReturnValue(f);
}
 
Example 5
Source Project: Cyberware   File: ItemLungsUpgrade.java    License: MIT License 4 votes vote down vote up
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onDrawScreenPost(RenderGameOverlayEvent.Post event)
{
	if (event.getType() == ElementType.AIR)
	{
		EntityPlayer p = Minecraft.getMinecraft().thePlayer;
		if (CyberwareAPI.isCyberwareInstalled(p, new ItemStack(this, 1, 0)) && !p.isCreative())
		{
			GL11.glPushMatrix();
			ItemStack stack = CyberwareAPI.getCyberware(p, new ItemStack(this, 1, 0));
			int air = getAir(stack);
			
			Minecraft.getMinecraft().getTextureManager().bindTexture(Gui.ICONS);
	
			ScaledResolution res = event.getResolution();
			GlStateManager.enableBlend();
			int left = res.getScaledWidth() / 2 + 91;
			int top = res.getScaledHeight() - 49 - 8;//- right_height;
			
			float r = 1F;
			float b = 1F;
			float g = 1F;

		
			if (p.isInsideOfMaterial(Material.WATER))
			{
				while (air > 0)
				{
					r += 1F;
					b -= .25F;
					g += .25F;
					GL11.glColor3f(r, g, b);
					int drawAir = Math.min(300, air);
					int full = MathHelper.ceiling_double_int((double)(drawAir - 2) * 10.0D / 300.0D);
					int partial = MathHelper.ceiling_double_int((double)drawAir * 10.0D / 300.0D) - full;
			
					for (int i = 0; i < full + partial; ++i)
					{
						ClientUtils.drawTexturedModalRect(left - i * 8 - 9, top, (i < full ? 16 : 25), 18, 9, 9);
					}
					
					
					air -= 300;
					top -= 8;
				}
			}
		
			GL11.glColor3f(1.0F, 1.0F, 1.0F);
			//GlStateManager.disableBlend();
			GL11.glPopMatrix();
		}
	}
}