use of icbm.classic.content.explosive.Explosives in project ICBM-Classic by BuiltBrokenModding.
the class ItemGrenade method onPlayerStoppedUsing.
@Override
public void onPlayerStoppedUsing(ItemStack itemStack, World world, EntityPlayer entityPlayer, int nengLiang) {
if (!world.isRemote) {
Explosives zhaPin = Explosives.get(itemStack.getItemDamage());
ExplosivePreDetonationEvent evt = new ExplosivePreDetonationEvent(world, entityPlayer, ExplosiveType.ITEM, zhaPin.handler);
MinecraftForge.EVENT_BUS.post(evt);
if (!evt.isCanceled()) {
if (!entityPlayer.capabilities.isCreativeMode) {
itemStack.stackSize--;
if (itemStack.stackSize <= 0) {
entityPlayer.inventory.setInventorySlotContents(entityPlayer.inventory.currentItem, null);
}
}
world.playSoundAtEntity(entityPlayer, "random.fuse", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
world.spawnEntityInWorld(new EntityGrenade(world, entityPlayer, zhaPin, (float) (this.getMaxItemUseDuration(itemStack) - nengLiang) / (float) this.getMaxItemUseDuration(itemStack)));
} else {
entityPlayer.addChatMessage(new ChatComponentText("Grenades are banned in this region."));
}
}
}
use of icbm.classic.content.explosive.Explosives in project ICBM-Classic by BuiltBrokenModding.
the class ItemRocketLauncher method onItemRightClick.
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
if (!world.isRemote) {
long clickMs = System.currentTimeMillis();
if (clickTimePlayer.containsKey(player.getCommandSenderName())) {
if (clickMs - clickTimePlayer.get(player.getCommandSenderName()) < firingDelay) {
//TODO play weapon empty click audio to note the gun is reloading
return itemStack;
}
}
if (this.getEnergy(itemStack) >= ENERGY || player.capabilities.isCreativeMode) {
// Check the player's inventory and look for missiles.
for (int slot = 0; slot < player.inventory.getSizeInventory(); slot++) {
ItemStack inventoryStack = player.inventory.getStackInSlot(slot);
if (inventoryStack != null) {
if (inventoryStack.getItem() instanceof ItemMissile) {
int meta = inventoryStack.getItemDamage();
Explosives ex = Explosives.get(meta);
ExplosivePreDetonationEvent evt = new ExplosivePreDetonationEvent(world, player.posX, player.posY, player.posZ, ExplosiveType.AIR, Explosives.get(meta).handler);
MinecraftForge.EVENT_BUS.post(evt);
if (((Explosion) ex.handler) != null && !evt.isCanceled()) {
// Limit the missile to tier two.
if ((((Explosion) ex.handler).getTier() <= Settings.MAX_ROCKET_LAUCNHER_TIER || Engine.runningAsDev) && ((Explosion) ex.handler).isCruise()) {
EntityMissile entityMissile = new EntityMissile(player);
entityMissile.missileType = EntityMissile.MissileType.LAUNCHER;
entityMissile.explosiveID = ex;
entityMissile.acceleration = 1;
entityMissile.launch(null);
world.spawnEntityInWorld(entityMissile);
if (player.isSneaking()) {
player.mountEntity(entityMissile);
player.setSneaking(false);
}
if (!player.capabilities.isCreativeMode) {
player.inventory.setInventorySlotContents(slot, null);
player.inventoryContainer.detectAndSendChanges();
this.discharge(itemStack, ENERGY, true);
}
//Store last time player launched a rocket
clickTimePlayer.put(player.getCommandSenderName(), clickMs);
return itemStack;
}
} else {
player.addChatComponentMessage(new ChatComponentText(LanguageUtility.getLocal("message.launcher.protected")));
}
}
}
}
}
}
return itemStack;
}
use of icbm.classic.content.explosive.Explosives in project ICBM-Classic by BuiltBrokenModding.
the class BlockExplosive method onBlockPlacedBy.
/** Called when the block is placed in the world. */
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack itemStack) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof TileEntityExplosive) {
Explosives ex = Explosives.get(itemStack.getItemDamage());
((TileEntityExplosive) tile).explosive = ex;
if (!world.isRemote) {
ExplosivePreDetonationEvent evt = new ExplosivePreDetonationEvent(world, x, y, z, ExplosiveType.BLOCK, ex.handler);
MinecraftForge.EVENT_BUS.post(evt);
if (evt.isCanceled()) {
this.dropBlockAsItem(world, x, y, z, ex.ordinal(), 0);
world.setBlock(x, y, z, Blocks.air, 0, 2);
return;
}
}
world.setBlockMetadataWithNotify(x, y, z, VectorHelper.getOrientationFromSide(ForgeDirection.getOrientation(determineOrientation(world, x, y, z, entityLiving)), ForgeDirection.NORTH).ordinal(), 2);
if (world.isBlockIndirectlyGettingPowered(x, y, z)) {
BlockExplosive.triggerExplosive(world, x, y, z, ex, 0);
}
// If so, then detonate.
for (byte i = 0; i < 6; i++) {
Pos position = new Pos(x, y, z).add(ForgeDirection.getOrientation(i));
Block blockId = position.getBlock(world);
if (blockId == Blocks.fire || blockId == Blocks.flowing_lava || blockId == Blocks.lava) {
BlockExplosive.triggerExplosive(world, x, y, z, ex, 2);
break;
}
}
if (entityLiving != null) {
FMLLog.fine(entityLiving.getCommandSenderName() + " placed " + ex.handler.getExplosiveName() + " in: " + x + ", " + y + ", " + z + ".");
}
}
}
use of icbm.classic.content.explosive.Explosives in project ICBM-Classic by BuiltBrokenModding.
the class TileCruiseLauncherClient method renderDynamic.
@Override
@SideOnly(Side.CLIENT)
public void renderDynamic(Pos pos, float frame, int pass) {
float yaw = (float) currentAim.yaw();
float pitch = (float) currentAim.pitch();
GL11.glPushMatrix();
GL11.glTranslatef((float) pos.x() + 0.5F, (float) pos.y() + 1.5F, (float) pos.z() + 0.5F);
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE_FILE);
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
MODEL0.render(0.0625F);
GL11.glRotatef(-yaw, 0F, 1F, 0F);
GL11.glRotatef(-pitch, 1F, 0F, 0F);
MODEL1.render(0.0625F);
GL11.glPopMatrix();
if (cachedMissileStack != null) {
GL11.glPushMatrix();
GL11.glTranslatef((float) pos.x() + 0.5F, (float) pos.y() + 1, (float) pos.z() + 0.5f);
GL11.glRotatef(yaw, 0F, 1F, 0F);
GL11.glRotatef(pitch - 90, 1F, 0F, 0F);
Explosives e = Explosives.get(cachedMissileStack.getItemDamage());
Explosion missile = e == null ? (Explosion) Explosives.CONDENSED.handler : (Explosion) e.handler;
if (missile.missileModelPath.contains("missiles")) {
GL11.glScalef(0.00625f, 0.00625f, 0.00625f);
} else {
GL11.glScalef(0.05f, 0.05f, 0.05f);
}
RenderMissile.renderMissile(missile);
GL11.glPopMatrix();
}
}
Aggregations