Java Code Examples for net.minecraft.entity.EntityLivingBase#getEquipmentInSlot()

The following examples show how to use net.minecraft.entity.EntityLivingBase#getEquipmentInSlot() . 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: ModEnchantments.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
public static void onLivingUpdate(EntityLivingBase entity) {
	if (entity.worldObj.isRemote)
		return;
	if (!EtFuturum.enableFrostWalker)
		return;

	ItemStack boots = entity.getEquipmentInSlot(1);
	int level = 0;
	if ((level = EnchantmentHelper.getEnchantmentLevel(frostWalker.effectId, boots)) > 0)
		if (entity.onGround) {
			int x = (int) entity.posX;
			int y = (int) entity.posY;
			int z = (int) entity.posZ;

			int radius = 1 + level;

			for (int i = -radius; i <= radius; i++)
				for (int j = -radius; j <= radius; j++) {
					Block block = entity.worldObj.getBlock(x + i, y - 1, z + j);
					if (block == Blocks.water || block == Blocks.flowing_water)
						entity.worldObj.setBlock(x + i, y - 1, z + j, ModBlocks.frosted_ice);
				}
		}
}
 
Example 2
Source File: PackBase.java    From SimplyJetpacks with MIT License 6 votes vote down vote up
protected void chargeInventory(EntityLivingBase user, ItemStack stack, ItemPack item) {
    if (this.fuelType == FuelType.ENERGY) {
        for (int i = 0; i <= 4; i++) {
            ItemStack currentStack = user.getEquipmentInSlot(i);
            if (currentStack != null && currentStack != stack && currentStack.getItem() instanceof IEnergyContainerItem) {
                IEnergyContainerItem heldEnergyItem = (IEnergyContainerItem) currentStack.getItem();
                if (this.usesFuel) {
                    int energyToAdd = Math.min(item.useFuel(stack, this.fuelPerTickOut, true), heldEnergyItem.receiveEnergy(currentStack, this.fuelPerTickOut, true));
                    item.useFuel(stack, energyToAdd, false);
                    heldEnergyItem.receiveEnergy(currentStack, energyToAdd, false);
                } else {
                    heldEnergyItem.receiveEnergy(currentStack, this.fuelPerTickOut, false);
                }
            }
        }
    }
}
 
Example 3
Source File: RenderUtils.java    From SimplyJetpacks with MIT License 6 votes vote down vote up
public static ModelBiped getArmorModel(PackBase pack, EntityLivingBase entity) {
    ModelBiped model = null;
    switch (pack.armorModel) {
    case JETPACK:
        model = ModelJetpack.INSTANCE;
        break;
    case FLUX_PACK:
        model = ModelFluxPack.INSTANCE;
    default:
    }
    if (model == null) {
        return null;
    }
    model.isSneak = entity.isSneaking();
    model.isRiding = entity.isRiding();
    model.isChild = entity.isChild();
    model.heldItemRight = entity.getEquipmentInSlot(0) != null ? 1 : 0;
    if (entity instanceof EntityPlayer) {
        model.aimedBow = ((EntityPlayer) entity).getItemInUseDuration() > 2;
    }
    return model;
}
 
Example 4
Source File: ClientEventHandler.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
private void setRenderHead(EntityLivingBase entity, boolean setRender){
    if(entity.getEquipmentInSlot(4) != null && entity.getEquipmentInSlot(4).getItem() == Itemss.pneumaticHelmet && (Config.useHelmetModel || DateEventHandler.isIronManEvent())) {
        Render renderer = RenderManager.instance.getEntityRenderObject(entity);
        if(renderer instanceof RenderBiped) {
            ((RenderBiped)renderer).modelBipedMain.bipedHead.showModel = setRender;
        }
    }
}