use of net.minecraft.world.item.ArmorMaterial in project MoreBoots by North-West-Wind.
the class BootRecyclerBlockEntity method calculateFuelValue.
private int calculateFuelValue(ItemStack stack) {
ArmorMaterial material = ((ArmorItem) stack.getItem()).getMaterial();
int armor = material.getDefenseForSlot(EquipmentSlot.FEET);
float toughness = material.getToughness();
int enchantability = material.getEnchantmentValue();
int enchantments = EnchantmentHelper.getEnchantments(stack).size();
int durability = material.getDurabilityForSlot(EquipmentSlot.FEET);
return (int) ((Math.pow(durability, 2) / 2.0 + Math.pow(armor + toughness, 4) + Math.pow(enchantability + enchantments, 4)));
}
use of net.minecraft.world.item.ArmorMaterial in project BladesEdge by shadowygaming.
the class MagmaArmor method evaluateArmorEffects.
private void evaluateArmorEffects(Player player) {
for (Map.Entry<ArmorMaterial, MobEffectInstance> entry : MATERIAL_TO_EFFECT_MAP.entrySet()) {
ArmorMaterial mapArmorMaterial = entry.getKey();
MobEffectInstance mapStatusEffect = entry.getValue();
if (hasCorrectArmorOn(mapArmorMaterial, player)) {
addStatusEffectForMaterial(player, mapArmorMaterial, mapStatusEffect);
}
}
}
use of net.minecraft.world.item.ArmorMaterial in project Forge-Tutorial-1.18.1 by Tutorials-By-Kaupenjoe.
the class ModArmorItem method evaluateArmorEffects.
private void evaluateArmorEffects(Player player) {
for (Map.Entry<ArmorMaterial, MobEffectInstance> entry : MATERIAL_TO_EFFECT_MAP.entrySet()) {
ArmorMaterial mapArmorMaterial = entry.getKey();
MobEffectInstance mapStatusEffect = entry.getValue();
if (hasCorrectArmorOn(mapArmorMaterial, player)) {
addStatusEffectForMaterial(player, mapArmorMaterial, mapStatusEffect);
}
}
}
use of net.minecraft.world.item.ArmorMaterial in project EdenRing by paulevsGitch.
the class BrainTreeBlock method hitLighting.
private void hitLighting(ServerLevel world, Random random, BlockPos pos) {
List<LivingEntity> entities = world.getNearbyEntities(LivingEntity.class, TargetingConditions.forNonCombat(), null, new AABB(pos).inflate(16, 16, 16));
if (!entities.isEmpty()) {
LivingEntity entity = entities.get(random.nextInt(entities.size()));
if (entity instanceof Player && ((Player) entity).isCreative()) {
return;
}
MutableBlockPos mpos = pos.mutable();
float dx = (float) (entity.getX() - pos.getX() - 0.5);
float dy = (float) (entity.getY() - pos.getY() - 0.5);
float dz = (float) (entity.getZ() - pos.getZ() - 0.5);
float ax = Mth.abs(dx);
float ay = Mth.abs(dy);
float az = Mth.abs(dz);
float max = MHelper.max(ax, ay, az);
int count = Mth.ceil(max);
dx /= count;
dy /= count;
dz /= count;
boolean hit = true;
for (int i = 2; i < count; i++) {
mpos.set(pos.getX() + dx * i, pos.getY() + dy * i, pos.getZ() + dz * i);
BlockState blockState = world.getBlockState(mpos);
if (blockState.getMaterial().blocksMotion() && !(blockState.getBlock() instanceof BrainTreeBlock)) {
hit = false;
break;
}
}
if (hit) {
LightningRayEntity lightningRay = EdenEntities.LIGHTNING_RAY.create(world);
lightningRay.teleportTo(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
lightningRay.setEnd(entity.position());
world.addFreshEntity(lightningRay);
world.playLocalSound(entity.getX(), entity.getY(), entity.getZ(), SoundEvents.LIGHTNING_BOLT_IMPACT, SoundSource.WEATHER, MHelper.randRange(1.0F, 5.0F, random), MHelper.randRange(0.5F, 1.5F, random), false);
if (entity.isInvulnerable()) {
return;
}
float resistance = 0;
Iterator<ItemStack> iterator = entity.getArmorSlots().iterator();
while (iterator.hasNext()) {
ItemStack stack = iterator.next();
if (stack.getItem() instanceof ArmorItem) {
ArmorItem item = (ArmorItem) stack.getItem();
ArmorMaterial material = item.getMaterial();
for (ArmorMaterial m : PROTECTIVE) {
if (material == m) {
resistance += 0.25F;
break;
}
}
}
}
if (resistance < 1) {
entity.hurt(DamageSource.LIGHTNING_BOLT, (1 - resistance) * 3F);
}
}
}
}
Aggregations