Search in sources :

Example 1 with EntityGrenade

use of icbm.classic.content.entity.EntityGrenade in project ICBM-Classic by BuiltBrokenModding.

the class RenderGrenade method doRender.

@Override
public void doRender(Entity entity, double x, double y, double z, float par8, float par9) {
    /** Renders the grenade based on the explosive ID. */
    IIcon icon = ICBMClassic.itemGrenade.getIconFromDamage(((EntityGrenade) entity).haoMa.ordinal());
    GL11.glPushMatrix();
    GL11.glTranslatef((float) x, (float) y + 0.4f, (float) z);
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glScalef(0.6F, 0.6F, 0.6F);
    RenderUtility.setSpriteTexture(new ItemStack(ICBMClassic.itemGrenade));
    Tessellator tessellator = Tessellator.instance;
    this.renderIcon(tessellator, icon);
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) IIcon(net.minecraft.util.IIcon) EntityGrenade(icbm.classic.content.entity.EntityGrenade) ItemStack(net.minecraft.item.ItemStack)

Example 2 with EntityGrenade

use of icbm.classic.content.entity.EntityGrenade 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."));
        }
    }
}
Also used : ExplosivePreDetonationEvent(resonant.api.explosion.ExplosionEvent.ExplosivePreDetonationEvent) EntityGrenade(icbm.classic.content.entity.EntityGrenade) Explosives(icbm.classic.content.explosive.Explosives) ChatComponentText(net.minecraft.util.ChatComponentText)

Aggregations

EntityGrenade (icbm.classic.content.entity.EntityGrenade)2 Explosives (icbm.classic.content.explosive.Explosives)1 Tessellator (net.minecraft.client.renderer.Tessellator)1 ItemStack (net.minecraft.item.ItemStack)1 ChatComponentText (net.minecraft.util.ChatComponentText)1 IIcon (net.minecraft.util.IIcon)1 ExplosivePreDetonationEvent (resonant.api.explosion.ExplosionEvent.ExplosivePreDetonationEvent)1