use of blusunrize.immersiveengineering.api.tool.BulletHandler.IBullet in project ImmersiveEngineering by BluSunrize.
the class EntityRevolvershot method onImpact.
protected void onImpact(RayTraceResult mop) {
boolean headshot = false;
if (mop.entityHit instanceof EntityLivingBase)
headshot = Utils.isVecInEntityHead((EntityLivingBase) mop.entityHit, new Vec3d(posX, posY, posZ));
if (this.bulletType != null) {
IBullet bullet = BulletHandler.getBullet(bulletType);
if (bullet != null)
bullet.onHitTarget(world, mop, this.shootingEntity, this, headshot);
if (headshot && mop.entityHit instanceof EntityAgeable && ((EntityAgeable) mop.entityHit).isChild() && ((EntityLivingBase) mop.entityHit).getHealth() <= 0) {
if (this.shootingEntity instanceof EntityPlayer)
Utils.unlockIEAdvancement((EntityPlayer) this.shootingEntity, "main/secret_birthdayparty");
world.playSound(null, posX, posY, posZ, IESounds.birthdayParty, SoundCategory.PLAYERS, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
ImmersiveEngineering.packetHandler.sendToDimension(new MessageBirthdayParty((EntityLivingBase) mop.entityHit), world.provider.getDimension());
}
}
if (!this.world.isRemote) {
// if(bulletType==3)
// world.createExplosion(shootingEntity, posX, posY, posZ, 2, false);
this.secondaryImpact(mop);
}
if (mop.typeOfHit == Type.BLOCK) {
IBlockState state = this.world.getBlockState(mop.getBlockPos());
if (state.getBlock().getMaterial(state) != Material.AIR)
state.getBlock().onEntityCollision(this.world, mop.getBlockPos(), state, this);
}
this.setDead();
}
use of blusunrize.immersiveengineering.api.tool.BulletHandler.IBullet in project ImmersiveEngineering by BluSunrize.
the class ItemBullet method getSubItems.
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> list) {
if (this.isInCreativeTab(tab)) {
list.add(new ItemStack(this, 1, 0));
list.add(new ItemStack(this, 1, 1));
for (Map.Entry<String, IBullet> entry : BulletHandler.registry.entrySet()) if (entry.getValue().isProperCartridge()) {
ItemStack s = new ItemStack(this, 1, 2);
ItemNBTHelper.setString(s, "bullet", entry.getKey());
list.add(s);
}
}
}
use of blusunrize.immersiveengineering.api.tool.BulletHandler.IBullet in project ImmersiveEngineering by BluSunrize.
the class ItemBullet method getItemStackDisplayName.
@Override
public String getItemStackDisplayName(ItemStack stack) {
if (stack.getItemDamage() == 2) {
String s = "item.immersiveengineering.bullet.";
String key = ItemNBTHelper.getString(stack, "bullet");
// handle legacy bullets
key = BulletHandler.handleLeagcyNames(key);
s += key;
IBullet bullet = BulletHandler.getBullet(key);
if (bullet != null)
s = bullet.getTranslationKey(stack, s);
return I18n.translateToLocal(s + ".name").trim();
}
return super.getItemStackDisplayName(stack);
}
use of blusunrize.immersiveengineering.api.tool.BulletHandler.IBullet in project ImmersiveEngineering by BluSunrize.
the class ItemBullet method addInformation.
@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack stack, @Nullable World world, List<String> list, ITooltipFlag flag) {
if (stack.getItemDamage() == 2) {
String key = ItemNBTHelper.getString(stack, "bullet");
IBullet bullet = BulletHandler.getBullet(key);
if (bullet != null)
bullet.addTooltip(stack, world, list, flag);
}
}
Aggregations