use of hellfirepvp.astralsorcery.common.item.ItemChisel in project AstralSorcery by HellFirePvP.
the class EntityCrystal method hitByEntity.
@Override
public boolean hitByEntity(Entity entity) {
if (!this.getEntityWorld().isRemote() && entity instanceof ServerPlayerEntity) {
ItemStack held = ((ServerPlayerEntity) entity).getHeldItem(Hand.MAIN_HAND);
if (!held.isEmpty() && held.getItem() instanceof ItemChisel) {
ItemStack thisStack = this.getItem();
if (!thisStack.isEmpty() && thisStack.getItem() instanceof ItemCrystalBase) {
CrystalAttributes thisAttributes = ((ItemCrystalBase) thisStack.getItem()).getAttributes(thisStack);
if (thisAttributes != null) {
// TODO chipping sound ?
boolean doDamage = false;
if (rand.nextFloat() < 0.35F) {
int fortuneLevel = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, held);
doDamage = this.splitCrystal(thisAttributes, fortuneLevel);
}
if (doDamage || rand.nextFloat() < 0.35F) {
held.damageItem(1, (PlayerEntity) entity, (player) -> player.sendBreakAnimation(Hand.MAIN_HAND));
}
}
}
}
}
return true;
}
use of hellfirepvp.astralsorcery.common.item.ItemChisel in project AstralSorcery by HellFirePvP.
the class EntityStarmetal method hitByEntity.
@Override
public boolean hitByEntity(Entity entity) {
if (!this.getEntityWorld().isRemote() && entity instanceof ServerPlayerEntity) {
ItemStack held = ((ServerPlayerEntity) entity).getHeldItem(Hand.MAIN_HAND);
if (!held.isEmpty() && held.getItem() instanceof ItemChisel) {
ItemStack thisStack = this.getItem();
if (!thisStack.isEmpty() && thisStack.getItem() instanceof ItemStarmetalIngot) {
boolean doDamage = false;
if (rand.nextFloat() < 0.4F) {
int fortuneLevel = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, held);
doDamage = this.createStardust(fortuneLevel);
}
if (doDamage || rand.nextFloat() < 0.35F) {
held.damageItem(1, (PlayerEntity) entity, (player) -> player.sendBreakAnimation(Hand.MAIN_HAND));
}
}
}
}
return true;
}
Aggregations