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

The following examples show how to use net.minecraft.entity.player.EntityPlayer#getCurrentArmor() . 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: PlayerSpecials.java    From Chisel-2 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void renderExtras(EntityPlayer player, boolean post) {
	if (!post) {
		GL11.glPushMatrix();
		Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
		if (player.isSneaking()) {
			GL11.glRotatef(28.64789F, 1.0F, 0.0F, 0.0F);
		}
		boolean armor = player.getCurrentArmor(1) != null;
		GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F);
		GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
		GL11.glTranslatef(-0.25F, -0.85F, armor ? 0.2F : 0.28F);
		GL11.glScalef(0.5F, 0.5F, 0.5F);
		GL11.glColor3f(1.0F, 1.0F, 1.0F);
		int light = 0xF000F0;
		int lightmapX = light % 0x10000;
		int lightmapY = light / 0x10000;
		OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY);

		IIcon icon = toRender.getIconIndex();
		ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 1.0F / 16.0F);
		GL11.glPopMatrix();
	}
}
 
Example 2
Source File: HUDHandler.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public void playerTick(TickEvent.PlayerTickEvent event){
    if(event.phase == TickEvent.Phase.END) {
        Minecraft mc = FMLClientHandler.instance().getClient();
        EntityPlayer player = event.player;
        if(player == mc.thePlayer) {
            ItemStack helmetStack = player.getCurrentArmor(3);
            if(helmetStack != null && helmetStack.getItem() == Itemss.pneumaticHelmet) {
                if(player.worldObj.isRemote) {
                    update(mc.thePlayer);
                }
            } else {
                CommonHUDHandler.getHandlerForPlayer(player).ticksExisted = 0;
            }
        }
    }
}
 
Example 3
Source File: HackUpgradeRenderHandler.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public static boolean enabledForPlayer(EntityPlayer player){
    ItemStack helmet = player.getCurrentArmor(3);
    if(helmet != null) {
        return enabledForStacks(ItemPneumaticArmor.getUpgradeStacks(helmet));
    } else {
        return false;
    }
}
 
Example 4
Source File: ArmorSet.java    From HexxitGear with GNU General Public License v3.0 5 votes vote down vote up
private static List<Item> getPlayerArmors(EntityPlayer player) {
    List<Item> playerSet = new ArrayList<Item>(4);

    for (int i = 0; i < 4; i++) {
        if (player.getCurrentArmor(i) != null) {
            playerSet.add(player.getCurrentArmor(i).getItem());
        }
    }

    return playerSet;
}
 
Example 5
Source File: CommonHUDHandler.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void tickEnd(TickEvent.PlayerTickEvent event){
    if(event.phase == TickEvent.Phase.END) {
        EntityPlayer player = event.player;
        if(this == PneumaticCraft.proxy.getCommonHudHandler()) {
            getHandlerForPlayer(player).tickEnd(event);
        } else {
            ItemStack helmetStack = player.getCurrentArmor(3);
            if(helmetStack != null && helmetStack.getItem() == Itemss.pneumaticHelmet) {
                helmetPressure = ((IPressurizable)helmetStack.getItem()).getPressure(helmetStack);
                if(ticksExisted == 0) {
                    checkHelmetInventory(helmetStack);
                }
                ticksExisted++;
                if(!player.worldObj.isRemote) {
                    if(ticksExisted > getStartupTime() && !player.capabilities.isCreativeMode) {
                        ((IPressurizable)helmetStack.getItem()).addAir(helmetStack, (int)-UpgradeRenderHandlerList.instance().getAirUsage(player, false));
                    }
                }

            } else {
                ticksExisted = 0;
            }
            if(!player.worldObj.isRemote) handleHacking(player);
        }
    }
}
 
Example 6
Source File: EventHandlerPneumaticCraft.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
private void warnPlayerIfNecessary(LivingSetAttackTargetEvent event){
    EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer;
    if(event.target == player && (event.entityLiving instanceof EntityGolem || event.entityLiving instanceof EntityMob)) {
        ItemStack helmetStack = player.getCurrentArmor(3);
        if(helmetStack != null && helmetStack.getItem() == Itemss.pneumaticHelmet && ((IPressurizable)helmetStack.getItem()).getPressure(helmetStack) > 0 && ItemPneumaticArmor.getUpgrades(ItemMachineUpgrade.UPGRADE_ENTITY_TRACKER, helmetStack) > 0 && GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade.coreComponents").checked && GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade." + EntityTrackUpgradeHandler.UPGRADE_NAME).checked) {
            HUDHandler.instance().getSpecificRenderer(EntityTrackUpgradeHandler.class).warnIfNecessary(event.entityLiving);
        }
    } else {
        HUDHandler.instance().getSpecificRenderer(EntityTrackUpgradeHandler.class).removeTargetingEntity(event.entityLiving);
    }
}
 
Example 7
Source File: DroneAIBlockInteraction.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sends particle spawn packets to any close player that has a charged pneumatic helmet with entity tracker.
 * @param pos
 */
protected void indicateToListeningPlayers(ChunkPosition pos){
    for(EntityPlayer player : (List<EntityPlayer>)drone.getWorld().playerEntities) {
        if(player.getCurrentArmor(3) != null && player.getCurrentArmor(3).getItem() == Itemss.pneumaticHelmet && ItemPneumaticArmor.getUpgrades(ItemMachineUpgrade.UPGRADE_ENTITY_TRACKER, player.getCurrentArmor(3)) > 0 && ((IPressurizable)Itemss.pneumaticHelmet).getPressure(player.getCurrentArmor(3)) > 0) {
            NetworkHandler.sendTo(new PacketSpawnParticle("reddust", pos.chunkPosX + 0.5, pos.chunkPosY + 0.5, pos.chunkPosZ + 0.5, 0, 0, 0), (EntityPlayerMP)player);
        }
    }
}
 
Example 8
Source File: GuiSearcher.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void updateScreen(){
    EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer;
    if(parentScreen instanceof GuiHelmetMainScreen) {
        if(player.getCurrentArmor(3) == null || player.getCurrentArmor(3).getItem() != Itemss.pneumaticHelmet) {
            mc.displayGuiScreen(parentScreen);
            onGuiClosed();
        }
    }
}
 
Example 9
Source File: DroneDebugUpgradeHandler.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public static boolean enabledForPlayer(EntityPlayer player){
    ItemStack helmet = player.getCurrentArmor(3);
    if(helmet != null) {
        return enabledForStacks(ItemPneumaticArmor.getUpgradeStacks(helmet));
    } else {
        return false;
    }
}
 
Example 10
Source File: MoCItemArmor.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
/**
   * Called to tick armor in the armor slot. Override to do something
   *
   * @param world
   * @param player
   * @param itemStack
   */
  @Override
  public void onArmorTickUpdate(World world, EntityPlayer player, ItemStack itemStack)
  {
  	if(world.rand.nextInt(50)==0 && player.getCurrentArmor(3) != null)
{
//System.out.println("player has a helmet");
ItemStack myStack = player.getCurrentArmor(3);
if (myStack != null && myStack.getItem() instanceof MoCItemArmor)
{
	MoCTools.updatePlayerArmorEffects(player);
	//System.out.println("player has equipped a MoC helmet");
}
}
  }
 
Example 11
Source File: IManaProficiencyArmor.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
public static boolean hasProficiency(EntityPlayer player) {
	for(int i = 0; i < 4; i++) {
		ItemStack armor = player.getCurrentArmor(i);
		if(armor != null) {
			Item item = armor.getItem();
			if(item instanceof IManaProficiencyArmor && ((IManaProficiencyArmor) item).shouldGiveProficiency(armor, i, player))
				return true;
		}
	}
	return false;
}
 
Example 12
Source File: ItemElectricBootsTraveller.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onPlayerJump(LivingEvent.LivingJumpEvent event) {
    if (event.entityLiving instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.entityLiving;
        boolean hasArmor = player.getCurrentArmor(0) != null && player.getCurrentArmor(0).getItem() == this;

        if (hasArmor)
            player.motionY += jumpBonus;
    }
}
 
Example 13
Source File: GuiHandler.java    From SimplyJetpacks with MIT License 5 votes vote down vote up
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
    switch (ID) {
    case PACK:
        ItemStack chestplate = player.getCurrentArmor(2);
        if (chestplate != null && chestplate.getItem() instanceof ItemPack) {
            ItemPack packItem = (ItemPack) chestplate.getItem();
            PackBase pack = packItem.getPack(chestplate);
            if (pack != null) {
                return new GuiPack(new ContainerPack(chestplate, packItem, pack));
            }
        }
    }
    return null;
}
 
Example 14
Source File: GuiHandler.java    From SimplyJetpacks with MIT License 5 votes vote down vote up
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
    switch (ID) {
    case PACK:
        ItemStack chestplate = player.getCurrentArmor(2);
        if (chestplate != null && chestplate.getItem() instanceof ItemPack) {
            ItemPack packItem = (ItemPack) chestplate.getItem();
            PackBase pack = packItem.getPack(chestplate);
            if (pack != null) {
                return new ContainerPack(chestplate, packItem, pack);
            }
        }
    }
    return null;
}
 
Example 15
Source File: ContainerPack.java    From SimplyJetpacks with MIT License 4 votes vote down vote up
@Override
public boolean canInteractWith(EntityPlayer player) {
    return player.getCurrentArmor(2) == this.chestplate;
}
 
Example 16
Source File: ContainerSearcher.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean canInteractWith(EntityPlayer player){
    return player.getCurrentArmor(3) != null && player.getCurrentArmor(3).getItem() == Itemss.pneumaticHelmet;
}
 
Example 17
Source File: InventorySearch.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public InventorySearch(EntityPlayer player){
    helmetStack = player.getCurrentArmor(3);
}
 
Example 18
Source File: ItemJetpackFueller.java    From SimplyJetpacks with MIT License 4 votes vote down vote up
@Override
public void onUsingTick(ItemStack itemStack, EntityPlayer player, int count) {
    MovingObjectPosition blockPos = BlockHelper.getCurrentMovingObjectPosition(player, true);
    if (blockPos == null || blockPos.sideHit < 0) {
        player.setItemInUse(null, 1);
    } else {
        player.setItemInUse(itemStack, this.getMaxItemUseDuration(itemStack));
        if (player.worldObj.isRemote) {
            return;
        }
        
        ItemStack chestplate = player.getCurrentArmor(2);
        if (chestplate == null || !(chestplate.getItem() instanceof ItemPack)) {
            return;
        }
        ItemPack packItem = (ItemPack) chestplate.getItem();
        PackBase pack = packItem.getPack(chestplate);
        if (pack == null) {
            return;
        }
        FuelType fuelType = pack.fuelType;
        
        ForgeDirection pullSide = ForgeDirection.values()[blockPos.sideHit];
        player.worldObj.getBlock(blockPos.blockX, blockPos.blockY, blockPos.blockZ);
        TileEntity tile = player.worldObj.getTileEntity(blockPos.blockX, blockPos.blockY, blockPos.blockZ);
        int toPull = Math.min(pack.fuelPerTickIn, packItem.getMaxFuelStored(chestplate) - packItem.getFuelStored(chestplate));
        int pulled = 0;
        
        if (fuelType == FuelType.ENERGY && tile instanceof IEnergyProvider) {
            IEnergyProvider energyTile = (IEnergyProvider) tile;
            pulled = energyTile.extractEnergy(pullSide, toPull, false);
            
        } else if (fuelType == FuelType.FLUID) {
            if (tile instanceof IFluidHandler) {
                IFluidHandler fluidTile = (IFluidHandler) tile;
                FluidStack fluid = fluidTile.drain(pullSide, toPull, false);
                if (fluid == null || !fluid.getFluid().getName().equals(pack.fuelFluid)) {
                    return;
                }
                fluid = fluidTile.drain(pullSide, toPull, true);
                pulled = fluid.amount;
            }
        }
        
        if (pulled > 0) {
            packItem.addFuel(chestplate, pulled, false);
        }
    }
}