net.minecraft.inventory.EntityEquipmentSlot Java Examples

The following examples show how to use net.minecraft.inventory.EntityEquipmentSlot. 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: MetalMaterial.java    From BaseMetals with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Gets the protection value for helmets, chestplates, leg armor, and boots 
 * made from this material
 * @return the protection value for helmets, chestplates, leg armor, and boots 
 * made from this material
 */
public int[] getDamageReductionArray(){
	if(cache == null){
		final float minimum = 5f; // most metals should be better than leather armor
		final float hardnessFactor = 1.25f;
		final float total = hardnessFactor * hardness + minimum;
		cache = new int[4];
		final int feetIndex = EntityEquipmentSlot.FEET.getIndex();
		final int legsIndex = EntityEquipmentSlot.LEGS.getIndex();
		final int chestIndex = EntityEquipmentSlot.CHEST.getIndex();
		final int headIndex = EntityEquipmentSlot.HEAD.getIndex();
		cache[headIndex] = Math.round(0.1f * total);// head
		cache[chestIndex] = Math.round(0.4f * total);// torso
		cache[legsIndex] = Math.round(0.35f * total);// legs
		cache[feetIndex] = Math.round(0.15f * total);// feet
	}
	return cache;
}
 
Example #2
Source File: AutoArmorHack.java    From ForgeWurst with GNU General Public License v3.0 6 votes vote down vote up
private int getArmorValue(ItemArmor item, ItemStack stack)
{
	int armorPoints = item.damageReduceAmount;
	int prtPoints = 0;
	int armorToughness = (int)item.toughness;
	int armorType = item.getArmorMaterial()
		.getDamageReductionAmount(EntityEquipmentSlot.LEGS);
	
	if(useEnchantments.isChecked())
	{
		Enchantment protection = Enchantments.PROTECTION;
		int prtLvl =
			EnchantmentHelper.getEnchantmentLevel(protection, stack);
		
		EntityPlayerSP player = WMinecraft.getPlayer();
		DamageSource dmgSource = DamageSource.causePlayerDamage(player);
		prtPoints = protection.calcModifierDamage(prtLvl, dmgSource);
	}
	
	return armorPoints * 5 + prtPoints * 3 + armorToughness + armorType;
}
 
Example #3
Source File: ItemKatana.java    From Sakura_mod with MIT License 6 votes vote down vote up
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
	super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected);
	if(worldIn.isRemote) return;
	if(entityIn instanceof EntityPlayer){
		EntityPlayer player = (EntityPlayer) entityIn;
		ItemStack mainhand =player.getHeldItem(EnumHand.MAIN_HAND);
		ItemStack offhand =player.getHeldItem(EnumHand.OFF_HAND);
		boolean flag1 =!(mainhand.isEmpty())&&!(offhand.isEmpty()),
				flag2 = mainhand.getItem() instanceof ItemKatana && offhand.getItem() instanceof ItemKatana;
		if(flag1&&flag2) {
            player.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, ItemStack.EMPTY);
            player.dropItem(offhand, false);
            player.sendStatusMessage(new TextComponentTranslation("sakura.katana.wrong_duel", new Object()), false);
		}
	}
}
 
Example #4
Source File: EntityMage.java    From ToroQuest with GNU General Public License v3.0 6 votes vote down vote up
protected void handleAttackLogicUpdate() {
	PotionType potiontype = null;

	if (this.rand.nextFloat() < 0.15F && this.isInsideOfMaterial(Material.WATER) && !this.isPotionActive(MobEffects.WATER_BREATHING)) {
		potiontype = PotionTypes.WATER_BREATHING;
	} else if (this.rand.nextFloat() < 0.15F && this.isBurning() && !this.isPotionActive(MobEffects.FIRE_RESISTANCE)) {
		potiontype = PotionTypes.FIRE_RESISTANCE;
	} else if (this.rand.nextFloat() < 0.05F && this.getHealth() < this.getMaxHealth()) {
		potiontype = PotionTypes.HEALING;
	} else if (this.rand.nextFloat() < 0.5F && this.getAttackTarget() != null && !this.isPotionActive(MobEffects.SPEED)
			&& this.getAttackTarget().getDistanceSq(this) > 121.0D) {
		potiontype = PotionTypes.SWIFTNESS;
	}

	if (potiontype != null) {
		this.world.playSound(null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_DRINK, this.getSoundCategory(), 1.0F,
				0.8F + this.rand.nextFloat() * 0.4F);
		this.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), potiontype));
		this.attackTimer = 10;
		this.setAggressive(true);
		IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);
		iattributeinstance.removeModifier(MODIFIER);
		iattributeinstance.applyModifier(MODIFIER);
	}
}
 
Example #5
Source File: EntityWitherWitch.java    From EnderZoo with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
@Override
public void attackEntityWithRangedAttack(EntityLivingBase entity, float rangeRatio) {   
  //the EntityPotion class validates if this potion is throwable, and if not it logs error "ThrownPotion entity {} has no item?!
  if(attackTimer <= 0 && getHeldItem(EnumHand.MAIN_HAND).getItem() == Items.SPLASH_POTION && !isHealing) {

    attackedWithPotion = entity;

    double x = entity.posX + entity.motionX - posX;
    double y = entity.posY + entity.getEyeHeight() - 1.100000023841858D - posY;
    double z = entity.posZ + entity.motionZ - posZ;
    float groundDistance = MathHelper.sqrt(x * x + z * z);

    ItemStack potion = getHeldItem(EnumHand.MAIN_HAND);
    attackTimer = getHeldItem(EnumHand.MAIN_HAND).getMaxItemUseDuration();

    EntityPotion entitypotion = new EntityPotion(world, this, potion);
    entitypotion.rotationPitch -= -20.0F;
    entitypotion.setThrowableHeading(x, y + groundDistance * 0.2F, z, 0.75F, 8.0F);
    world.spawnEntity(entitypotion);

    setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStack.EMPTY);
  }
}
 
Example #6
Source File: TileChemicalReactor.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
@Override
public void registerRecipes() {
	//Chemical Reactor
	RecipesMachine.getInstance().addRecipe(TileChemicalReactor.class, new Object[] {new ItemStack(AdvancedRocketryItems.itemCarbonScrubberCartridge,1, 0), new ItemStack(Items.COAL, 1, 1)}, 40, 20, new ItemStack(AdvancedRocketryItems.itemCarbonScrubberCartridge, 1, AdvancedRocketryItems.itemCarbonScrubberCartridge.getMaxDamage()));
	RecipesMachine.getInstance().addRecipe(TileChemicalReactor.class, new ItemStack(Items.DYE,5,0xF), 100, 1, Items.BONE, new FluidStack(AdvancedRocketryFluids.fluidNitrogen, 10));
	RecipesMachine.getInstance().addRecipe(TileChemicalReactor.class, new FluidStack(AdvancedRocketryFluids.fluidRocketFuel, 20), 100, 10, new FluidStack(AdvancedRocketryFluids.fluidOxygen, 10), new FluidStack(AdvancedRocketryFluids.fluidHydrogen, 10));

	if(Configuration.enableOxygen) {
		for(ResourceLocation key : Item.REGISTRY.getKeys()) {
			Item item = Item.REGISTRY.getObject(key);

			if(item instanceof ItemArmor && !(item instanceof ItemSpaceArmor)) {
				ItemStack enchanted = new ItemStack(item);
				enchanted.addEnchantment(AdvancedRocketryAPI.enchantmentSpaceProtection, 1);

				if(((ItemArmor)item).armorType == EntityEquipmentSlot.CHEST)
					RecipesMachine.getInstance().addRecipe(TileChemicalReactor.class, enchanted, 100, 10, item, "gemDiamond", new ItemStack(AdvancedRocketryItems.itemPressureTank, 1, 3));
				else
					RecipesMachine.getInstance().addRecipe(TileChemicalReactor.class, enchanted, 100, 10, item, "gemDiamond");

			}
		}
	}
}
 
Example #7
Source File: ContainerCreativeInv.java    From NotEnoughItems with MIT License 6 votes vote down vote up
public ContainerCreativeInv(EntityPlayer player, ExtendedCreativeInv extraInv) {
    this.player = player;
    InventoryPlayer invPlayer = player.inventory;
    for (int row = 0; row < 6; row++) {
        for (int col = 0; col < 9; col++) {
            addSlotToContainer(new Slot(extraInv, col + row * 9, 8 + col * 18, 5 + row * 18));
        }
    }

    for (int row = 0; row < 3; ++row) {
        for (int col = 0; col < 9; ++col) {
            addSlotToContainer(new Slot(invPlayer, col + row * 9 + 9, 8 + col * 18, 118 + row * 18));
        }
    }

    for (int col = 0; col < 9; ++col) {
        addSlotToContainer(new Slot(invPlayer, col, 8 + col * 18, 176));
    }
    for (int i = 0; i < 4; i++) {
        EntityEquipmentSlot entityEquipmentSlot = VALID_EQUIPMENT_SLOTS[i];
        addSlotToContainer(new SlotArmor(invPlayer, 36 + (3 - i), -15, 23 + i * 18, entityEquipmentSlot));
    }
    addSlotToContainer(new SlotArmor(invPlayer, 40, -15, 23 + 4 * 18, VALID_EQUIPMENT_SLOTS[4], 64));
}
 
Example #8
Source File: ProfileMagicArcher.java    From minecraft-roguelike with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void addEquipment(World world, Random rand, int level, IEntity mob) {
	
	mob.setMobClass(MobType.STRAY, false);
	
	mob.setSlot(EntityEquipmentSlot.OFFHAND, TippedArrow.get(Potion.HARM));
	mob.setSlot(EntityEquipmentSlot.MAINHAND, ItemWeapon.getBow(rand, level, Enchant.canEnchant(world.getDifficulty(), rand, level)));
	
	for(EntityEquipmentSlot slot : new EntityEquipmentSlot[]{
			EntityEquipmentSlot.HEAD,
			EntityEquipmentSlot.CHEST,
			EntityEquipmentSlot.LEGS,
			EntityEquipmentSlot.FEET
			}){
		ItemStack item = ItemArmour.get(rand, Slot.getSlot(slot), Quality.WOOD);
		Enchant.enchantItem(rand, item, 20);
		ItemArmour.dyeArmor(item, 51, 0, 102);
		mob.setSlot(slot, item);
	}
}
 
Example #9
Source File: CraftEntityEquipment.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
private void setDropChance(EntityEquipmentSlot slot, float chance) {
    if (slot == EntityEquipmentSlot.MAINHAND || slot == EntityEquipmentSlot.OFFHAND) {
        ((EntityLiving) entity.getHandle()).inventoryHandsDropChances[slot.getIndex()] = chance - 0.1F;
    } else {
        ((EntityLiving) entity.getHandle()).inventoryArmorDropChances[slot.getIndex()] = chance - 0.1F;
    }
}
 
Example #10
Source File: WhatAreThose.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SubscribeEvent
public static void onEquipEvent(TickEvent.PlayerTickEvent event) {
    if (rand.nextInt(1000) < 1) {
        EntityPlayer player = event.player;
        BlockPos pos = new BlockPos(player.posX, player.posY, player.posZ);
        IBlockState state = player.world.getBlockState(pos.add(0, -1, 0));
        if (player.onGround) {
            for (ItemStack stack : player.inventory.armorInventory) {
                if (stack.getItem() instanceof ItemArmor && ((ItemArmor) stack.getItem()).getEquipmentSlot() == EntityEquipmentSlot.FEET && state == Blocks.DIAMOND_BLOCK) {
                    player.sendMessage(new TextComponentString("What are THOOOOOSE!?"));
                }
            }
        }
    }
}
 
Example #11
Source File: EntityFallenKnight.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
private void addRandomArmor() {

    float occupiedDiffcultyMultiplier = EntityUtil.getDifficultyMultiplierForLocation(world, posX, posY, posZ);

    int equipmentLevel = getRandomEquipmentLevel(occupiedDiffcultyMultiplier);
    int armorLevel = equipmentLevel;
    if(armorLevel == 1) {
      //Skip gold armor, I don't like it
      armorLevel++;
    }
    float chancePerPiece = isHardDifficulty() ? Config.fallenKnightChancePerArmorPieceHard
        : Config.fallenKnightChancePerArmorPiece;
    chancePerPiece *= (1 + occupiedDiffcultyMultiplier); //If we have the max occupied factor, double the chance of improved armor

    for(EntityEquipmentSlot slot : EntityEquipmentSlot.values()) {
      ItemStack itemStack = getItemStackFromSlot(slot);
      if(itemStack.isEmpty() && rand.nextFloat() <= chancePerPiece) {
        Item item = EntityLiving.getArmorByChance(slot, armorLevel);
        if(item != null) {
          ItemStack stack = new ItemStack(item);
          if(armorLevel == 0) {
            ((ItemArmor) item).setColor(stack, 0);
          }          
          setItemStackToSlot(slot, stack);
        }
      }
    }
    if(rand.nextFloat() > Config.fallenKnightRangedRatio) {
      setItemStackToSlot(EntityEquipmentSlot.MAINHAND, getSwordForLevel(equipmentLevel));
      if(Math.random() <= Config.fallenKnightChanceShield) {
        setItemStackToSlot(EntityEquipmentSlot.OFFHAND, getShieldForLevel(getRandomEquipmentLevel()));
      }
    } else {
      setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.BOW));
    }
  }
 
Example #12
Source File: GTItemEnergyPack.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
public GTItemEnergyPack(int index, String tex, int max, String reg, String unl, int lvl, int limit) {
	super(index, EntityEquipmentSlot.CHEST);
	this.indexitem = index;
	this.setMaxDamage(0);
	this.texture = tex;
	this.maxEnergy = max;
	this.setRegistryName(reg);
	this.setUnlocalizedName(GTMod.MODID + unl);
	this.setCreativeTab(GTMod.creativeTabGT);
	this.tier = lvl; // 1;
	this.transferlimit = limit;
	this.rare = EnumRarity.COMMON;
}
 
Example #13
Source File: SlotItemHandlerArmor.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean isItemValid(ItemStack stack)
{
    if (stack.isEmpty())
    {
        return false;
    }

    EntityEquipmentSlot slot = ContainerHandyBag.EQUIPMENT_SLOT_TYPES[this.armorSlotIndex];
    return stack.getItem().isValidArmor(stack, slot, this.container.player);
}
 
Example #14
Source File: ContainerEUStorage.java    From Production-Line with MIT License 5 votes vote down vote up
public ContainerEUStorage(EntityPlayer player, T tile) {
    super(player, tile, 196);
    this.addSlotToContainer(new SlotDischarge(this.tile, this.tile.tier, 0, 56, 53));
    this.addSlotToContainer(new Slot(this.tile, 1, 56, 17));
    for (int i = 0; i < 4; i++) {
        this.addSlotToContainer(new SlotArmor(player.inventory, EntityEquipmentSlot.values()[i + 2], 8 + i * 18, 84));
    }
}
 
Example #15
Source File: ItemSpaceArmor.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public ModelBiped getArmorModel(EntityLivingBase entityLiving,
		ItemStack itemStack, EntityEquipmentSlot armorSlot,
		ModelBiped _default) {

	if(armorSlot == EntityEquipmentSlot.CHEST) {
		for(ItemStack stack : getComponents(itemStack)) {
			if(stack.getItem() instanceof IJetPack)
				return new RenderJetPack(_default);
		}
	}
	return super.getArmorModel(entityLiving, itemStack, armorSlot, _default);
}
 
Example #16
Source File: EntitySamuraiIllager.java    From Sakura_mod with MIT License 5 votes vote down vote up
/**
 * Gives armor or weapon for entity based on given DifficultyInstance
 */
protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty) {
    float f = this.world.getDifficultyForLocation(new BlockPos(this)).getAdditionalDifficulty();

    if (this.rand.nextFloat() < f * 0.2F) {
        this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(ItemLoader.TACHI));
    } else {
        this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(ItemLoader.KATANA));
    }
}
 
Example #17
Source File: ItemArmor.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
@Override
public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type)
{
    if (content.armorTexture != null)
        return content.armorTexture.toString();

    return null;
}
 
Example #18
Source File: ItemSpaceArmor.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
	public void onArmorTick(World world, EntityPlayer player,
			ItemStack armor) {
		super.onArmorTick(world, player, armor);

		if(armor.hasTagCompound()) {

			//Some upgrades modify player capabilities

			EmbeddedInventory inv = loadEmbeddedInventory(armor);
			for(int i = 0; i < inv.getSizeInventory(); i++ ) {
				ItemStack stack = inv.getStackInSlot(i);
				if(!stack.isEmpty()) {
					IArmorComponent component = (IArmorComponent)stack.getItem();
					component.onTick(world, player, armor, inv, stack);
				}
			}

			saveEmbeddedInventory(armor, inv);
		}

		ItemStack feet = player.getItemStackFromSlot(EntityEquipmentSlot.FEET);
		ItemStack leg = player.getItemStackFromSlot(EntityEquipmentSlot.LEGS);
		ItemStack chest = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
		ItemStack helm = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
//		if(!feet.isEmpty() && feet.getItem() instanceof ItemSpaceArmor && !leg.isEmpty() && leg.getItem() instanceof ItemSpaceArmor && !chest.isEmpty() && chest.getItem() instanceof ItemSpaceArmor && !helm.isEmpty() && helm.getItem() instanceof ItemSpaceArmor)
//			player.addStat(ARAchivements.suitedUp);TODO Advancement Trigger
	}
 
Example #19
Source File: EntityBas.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
public void onLivingUpdate() {
	super.onLivingUpdate();

	if (world.getTotalWorldTime() % 100 == 0) {
		spawnLimitedBats();
	}

	if (this.world.isDaytime() && !this.world.isRemote) {
		float f = this.getBrightness();
		BlockPos blockpos = this.getRidingEntity() instanceof EntityBoat
				? (new BlockPos(this.posX, (double) Math.round(this.posY), this.posZ)).up()
				: new BlockPos(this.posX, (double) Math.round(this.posY), this.posZ);

		if (f > 0.5F && this.rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.world.canSeeSky(blockpos)) {
			boolean flag = true;
			ItemStack itemstack = this.getItemStackFromSlot(EntityEquipmentSlot.HEAD);

			if (!itemstack.isEmpty()) {
				if (itemstack.isItemStackDamageable()) {
					itemstack.setItemDamage(itemstack.getItemDamage() + this.rand.nextInt(2));

					if (itemstack.getItemDamage() >= itemstack.getMaxDamage()) {
						this.renderBrokenItemStack(itemstack);
						this.setItemStackToSlot(EntityEquipmentSlot.HEAD, ItemStack.EMPTY);
					}
				}

				flag = false;
			}

			if (flag) {
				this.setFire(8);
			}
		}
	}

}
 
Example #20
Source File: ProfileBaby.java    From minecraft-roguelike with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void addEquipment(World world, Random rand, int level, IEntity mob) {
	mob.setChild(true);
	
	if(rand.nextBoolean()){
		MonsterProfile.get(MonsterProfile.VILLAGER).addEquipment(world, rand, level, mob);
	}
	
	ItemStack weapon = ItemTool.getRandom(rand, level, Enchant.canEnchant(world.getDifficulty(), rand, level));
	mob.setSlot(EntityEquipmentSlot.MAINHAND, weapon);
}
 
Example #21
Source File: ProfileSwordsman.java    From minecraft-roguelike with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void addEquipment(World world, Random rand, int level, IEntity mob) {
	ItemStack weapon = rand.nextInt(20) == 0
			? ItemNovelty.getItem(ItemNovelty.VALANDRAH)
			: ItemWeapon.getSword(rand, level, Enchant.canEnchant(world.getDifficulty(), rand, level));
	
	mob.setSlot(EntityEquipmentSlot.MAINHAND, weapon);
	mob.setSlot(EntityEquipmentSlot.OFFHAND, Shield.get(rand));
	MonsterProfile.get(MonsterProfile.TALLMOB).addEquipment(world, rand, level, mob);
}
 
Example #22
Source File: NeedsMoreJpeg.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SideOnly(Side.CLIENT)
private static boolean hasGoggles(Minecraft client) {
    if (client.player == null) {
        return false;
    }

    ItemStack headStack = client.player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
    return headStack.getItem() == JPEG_GOGGLES;
}
 
Example #23
Source File: ItemArmorCyberware.java    From Cyberware with MIT License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, net.minecraft.client.model.ModelBiped _default)
{
	ClientUtils.trench.setModelAttributes(_default);
	ClientUtils.armor.setModelAttributes(_default);
	ClientUtils.trench.bipedRightArm.isHidden = !(entityLiving instanceof EntityPlayer) && !(entityLiving instanceof EntityArmorStand);
	ClientUtils.trench.bipedLeftArm.isHidden = !(entityLiving instanceof EntityPlayer) && !(entityLiving instanceof EntityArmorStand);
	ClientUtils.armor.bipedRightArm.isHidden = ClientUtils.trench.bipedRightArm.isHidden;
	ClientUtils.armor.bipedLeftArm.isHidden = ClientUtils.trench.bipedLeftArm.isHidden;

	if (itemStack != null && itemStack.getItem() == CyberwareContent.trenchcoat) return ClientUtils.trench;
	
	return ClientUtils.armor;
}
 
Example #24
Source File: InfinitePain.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SubscribeEvent
public static void onLandingCreative(PlayerFlyableFallEvent event) {
	EntityLivingBase elb = event.getEntityLiving();
	if(elb.hasItemInSlot(EntityEquipmentSlot.FEET) && elb.getItemStackFromSlot(EntityEquipmentSlot.FEET).getItem() == PAIN_BOOTS) {
		if(event.getDistance() >= minTriggerHeight) {

			boolean notObstructed = true;
			double impactPosition = 0;

			for(int i = (int) elb.posY + 2; i < elb.world.provider.getHeight(); i++) {
				BlockPos pos = new BlockPos(elb.posX, i, elb.posZ);
				IBlockState state = elb.world.getBlockState(pos);
				if(state.isFullBlock() || state.isFullCube()) {
					notObstructed = false;
					impactPosition = i;
					break;
				}
			}


			if(notObstructed) {
				elb.setPositionAndUpdate(elb.posX, elb.world.provider.getHeight() + heightToAdd, elb.posZ);
			} else {
				elb.addVelocity(0, (impactPosition - elb.posY) / 2, 0);
			}
		}
	}
}
 
Example #25
Source File: ItemMetalArmor.java    From BaseMetals with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static ItemMetalArmor createLeggings(MetalMaterial metal){
	ArmorMaterial material = cyano.basemetals.init.Materials.getArmorMaterialFor(metal);
	if(material == null){
		// uh-oh
		FMLLog.severe("Failed to load armor material enum for "+metal);
	}
	return new ItemMetalArmor(metal,material,material.ordinal(),EntityEquipmentSlot.LEGS);
}
 
Example #26
Source File: AutoTool.java    From ForgeHax with MIT License 5 votes vote down vote up
private double getAttackSpeed(InvItem item) {
  return Optional.ofNullable(
      item.getItemStack()
          .getAttributeModifiers(EntityEquipmentSlot.MAINHAND)
          .get(SharedMonsterAttributes.ATTACK_DAMAGE.getName()))
      .map(
          at ->
              at.stream().findAny().map(AttributeModifier::getAmount).map(Math::abs).orElse(0.D))
      .orElse(0.D);
}
 
Example #27
Source File: ArmorRenderHooks.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void renderArmorLayer(LayerArmorBase<ModelBase> layer, EntityLivingBase entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale, EntityEquipmentSlot slotIn) {
    ItemStack itemStack = entity.getItemStackFromSlot(slotIn);

    if (isArmorItem(itemStack, slotIn)) {
        IArmorItem armorItem = (IArmorItem) itemStack.getItem();
        ModelBase armorModel = layer.getModelFromSlot(slotIn);
        if (armorModel instanceof ModelBiped) {
            armorModel = ForgeHooksClient.getArmorModel(entity, itemStack, slotIn, (ModelBiped) armorModel);
        }
        armorModel.setModelAttributes(layer.renderer.getMainModel());
        armorModel.setLivingAnimations(entity, limbSwing, limbSwingAmount, partialTicks);
        layer.setModelSlotVisible(armorModel, slotIn);

        GlStateManager.enableBlend();
        GlStateManager.blendFunc(SourceFactor.ONE, DestFactor.ONE_MINUS_SRC_ALPHA);

        int layers = armorItem.getArmorLayersAmount(itemStack);
        for (int layerIndex = 0; layerIndex < layers; layerIndex++) {
            int i = armorItem.getArmorLayerColor(itemStack, layerIndex);
            float f = (float) (i >> 16 & 255) / 255.0F;
            float f1 = (float) (i >> 8 & 255) / 255.0F;
            float f2 = (float) (i & 255) / 255.0F;
            GlStateManager.color(f, f1, f2, 1.0f);
            String type = layerIndex == 0 ? null : "layer_" + layerIndex;
            layer.renderer.bindTexture(getArmorTexture(entity, itemStack, slotIn, type));
            armorModel.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
        }
        if (itemStack.hasEffect()) {
            LayerArmorBase.renderEnchantedGlint(layer.renderer, entity, armorModel, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale);
        }
    }
}
 
Example #28
Source File: EntityCyberZombie.java    From Cyberware with MIT License 5 votes vote down vote up
@Override
protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty)
{
	super.setEquipmentBasedOnDifficulty(difficulty);
	
	if (CyberwareConfig.KATANA && !CyberwareConfig.NO_CLOTHES && this.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND) != null && this.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND).getItem() == Items.IRON_SWORD)
	{
		this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(CyberwareContent.katana));
		this.setDropChance(EntityEquipmentSlot.MAINHAND, 0F);
	}
}
 
Example #29
Source File: ItemTerraTool.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack)
{
	Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(slot);

	if (slot == EntityEquipmentSlot.MAINHAND)
	{
		multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Tool modifier 2", (double)this.damageVsEntity, 0));
		multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", (double)this.attackSpeed, 0));
	}

	return multimap;
}
 
Example #30
Source File: ArmorMetaItem.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static EntityEquipmentSlot getSlotByIndex(int index) {
    switch (index) {
        case 0: return EntityEquipmentSlot.FEET;
        case 1: return EntityEquipmentSlot.LEGS;
        case 2: return EntityEquipmentSlot.CHEST;
        default: return EntityEquipmentSlot.HEAD;
    }
}