下面列出了怎么用net.minecraft.inventory.EntityEquipmentSlot的API类实例代码及写法,或者点击链接到github查看源代码。
@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);
}
}
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;
}
/**
* 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;
}
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));
}
@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);
}
}
@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");
}
}
}
}
@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);
}
}
}
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);
}
}
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);
}
public static ItemMetalArmor createChestplate(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.CHEST);
}
/**
* 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));
}
}
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));
}
}
@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);
}
@Override
public boolean isImmune(EntityLivingBase player) {
//Checks if player is wearing spacesuit or anything that extends ItemSpaceArmor
ItemStack feet = player.getItemStackFromSlot(EntityEquipmentSlot.FEET);
ItemStack leg = player.getItemStackFromSlot(EntityEquipmentSlot.LEGS /*so hot you can fry an egg*/ );
ItemStack chest = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
ItemStack helm = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
return (player instanceof EntityPlayer && ((((EntityPlayer)player).capabilities.isCreativeMode) || ((EntityPlayer)player).isSpectator()))
|| player.getRidingEntity() instanceof EntityRocketBase || player.getRidingEntity() instanceof EntityElevatorCapsule ||
protectsFrom(helm) && protectsFrom(leg) && protectsFrom(feet) && protectsFrom(chest);
}
/**
* Gets a map of item attribute modifiers, used by ItemSword to increase hit damage.
*/
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot) {
Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);
if (equipmentSlot == EntityEquipmentSlot.MAINHAND) {
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", this.attackDamage, 0));
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2.2000000953674316D, 0));
}
return multimap;
}
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));
}
}
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;
}
}
@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!?"));
}
}
}
}
}
@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);
}
@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);
}
@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;
}
@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;
}
@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);
}
}
}
}
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);
}
}
}
@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;
}
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);
}
}
}
}
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;
}
}
@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);
}
}
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);
}
@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
}