Jump to content

[1.6.4] -=[Solved]=- Bow crash


Atheera

Recommended Posts

Hi there!

I'm trying to make a bow the textures don't work and when I rightclick it, it crashes.

I've used a method I found by coolAlias and it seems fine to me but, well. It crashes the game.

 

Bow texture names:

ObsidianInfusedBow_standby

ObsidianInfusedBow_pulling_0

ObsidianInfusedBow_pulling_1

ObsidianInfusedBow_pulling_2

 

Bow class:

 

 

package extendedobsidian.atheera.com;

 

import net.minecraft.client.renderer.texture.IconRegister;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.enchantment.Enchantment;

import net.minecraft.enchantment.EnchantmentHelper;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.entity.projectile.EntityArrow;

import net.minecraft.item.EnumAction;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.util.Icon;

import net.minecraft.world.World;

import net.minecraftforge.common.MinecraftForge;

import net.minecraftforge.event.entity.player.ArrowLooseEvent;

import net.minecraftforge.event.entity.player.ArrowNockEvent;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

public class ObsidianInfusedBow extends Item {

 

    public static final String[] bowPullIconNameArray = new String[] {"ObsidianInfusedBow_pulling_0", "ObsidianInfusedBow_pulling_1", "ObsidianInfusedBow_pulling_2"};

    @SideOnly(Side.CLIENT)

    private Icon[] iconArray;

 

    public ObsidianInfusedBow(int par1) {

        super(par1);

        this.maxStackSize = 1;

        this.setMaxDamage(2560);

    }

 

    public boolean hasEffect(ItemStack itemstack) {

    return true;

    }

   

    public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4) {

        int j = this.getMaxItemUseDuration(par1ItemStack) - par4;

 

        ArrowLooseEvent event = new ArrowLooseEvent(par3EntityPlayer, par1ItemStack, j);

        MinecraftForge.EVENT_BUS.post(event);

        if (event.isCanceled()) {

            return;

        }

        j = event.charge;

 

        boolean flag = par3EntityPlayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0;

 

        if (flag || par3EntityPlayer.inventory.hasItem(Core.itemObsidianInfusedArrow.itemID)) {

            float f = (float)j / 20.0F;

            f = (f * f + f * 2.0F) / 3.0F;

 

            if ((double)f < 0.1D) {

                return;

            }

 

            if (f > 1.0F) {

                f = 1.0F;

            }

 

            EntityArrow entityarrow = new EntityArrow(par2World, par3EntityPlayer, f * 2.0F);

 

            if (f == 1.0F) {

                entityarrow.setIsCritical(true);

            }

 

            int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, par1ItemStack);

 

            if (k > 0) {

                entityarrow.setDamage(entityarrow.getDamage() + (double)k * 0.5D + 0.5D);

            }

 

            int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, par1ItemStack);

 

            if (l > 0) {

                entityarrow.setKnockbackStrength(l);

            }

 

            if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, par1ItemStack) > 0) {

                entityarrow.setFire(100);

            }

 

            par1ItemStack.damageItem(1, par3EntityPlayer);

            par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);

 

            if (flag) {

                entityarrow.canBePickedUp = 2;

            }else{

                par3EntityPlayer.inventory.consumeInventoryItem(Core.itemObsidianInfusedArrow.itemID);

            }

 

            if (!par2World.isRemote) {

                par2World.spawnEntityInWorld(entityarrow);

            }

        }

    }

 

    public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)

    {

        return par1ItemStack;

    }

 

    public int getMaxItemUseDuration(ItemStack par1ItemStack) {

        return 36000;

    }

 

    public EnumAction getItemUseAction(ItemStack par1ItemStack) {

        return EnumAction.bow;

    }

 

    public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {

        ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack);

        MinecraftForge.EVENT_BUS.post(event);

        if (event.isCanceled()) {

            return event.result;

        }

 

        if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(Core.itemObsidianInfusedArrow.itemID)) {

            par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));

        }

 

        return par1ItemStack;

    }

 

    public int getItemEnchantability() {

        return 18;

    }

   

    @Override

    @SideOnly(Side.CLIENT)

    public Icon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) {

            if (usingItem == null) { return itemIcon; }

            int ticksInUse = stack.getMaxItemUseDuration() - useRemaining;

 

            if (ticksInUse > 18) {

                    return iconArray[2];

            } else if (ticksInUse > 14) {

                    return iconArray[1];

            } else if (ticksInUse > 0) {

                    return iconArray[0];

            } else {

                    return itemIcon;

            }

    }

 

    @SideOnly(Side.CLIENT)

    public Icon getItemIconForUseDuration(int par1) {

        return this.iconArray[par1];

    }

   

}

 

 

 

Crashlog:

 

 

---- Minecraft Crash Report ----

// Why is it breaking :(

 

Time: 2014-05-06 14:41

Description: Unexpected error

 

java.lang.NullPointerException

at extendedobsidian.atheera.com.ObsidianInfusedBow.getIcon(ObsidianInfusedBow.java:139)

at net.minecraft.entity.player.EntityPlayer.getItemIcon(EntityPlayer.java:2103)

at net.minecraft.client.renderer.ItemRenderer.renderItem(ItemRenderer.java:98)

at net.minecraft.client.renderer.ItemRenderer.renderItemInFirstPerson(ItemRenderer.java:490)

at net.minecraft.client.renderer.EntityRenderer.renderHand(EntityRenderer.java:712)

at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1296)

at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1002)

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:946)

at net.minecraft.client.Minecraft.run(Minecraft.java:838)

at net.minecraft.client.main.Main.main(Main.java:93)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:131)

at net.minecraft.launchwrapper.Launch.main(Launch.java:27)

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- Head --

Stacktrace:

at extendedobsidian.atheera.com.ObsidianInfusedBow.getIcon(ObsidianInfusedBow.java:139)

at net.minecraft.entity.player.EntityPlayer.getItemIcon(EntityPlayer.java:2103)

at net.minecraft.client.renderer.ItemRenderer.renderItem(ItemRenderer.java:98)

at net.minecraft.client.renderer.ItemRenderer.renderItemInFirstPerson(ItemRenderer.java:490)

at net.minecraft.client.renderer.EntityRenderer.renderHand(EntityRenderer.java:712)

at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1296)

 

-- Affected level --

Details:

Level name: MpServer

All players: 1 total; [EntityClientPlayerMP['lliinnkk10'/34, l='MpServer', x=1032,52, y=5,62, z=-73,27]]

Chunk stats: MultiplayerChunkCache: 441

Level seed: 0

Level generator: ID 01 - flat, ver 0. Features enabled: false

Level generator options:

Level spawn location: World: (1018,4,-72), Chunk: (at 10,0,8 in 63,-5; contains blocks 1008,0,-80 to 1023,255,-65), Region: (1,-1; contains chunks 32,-32 to 63,-1, blocks 512,0,-512 to 1023,255,-1)

Level time: 111523 game time, 111523 day time

Level dimension: 0

Level storage version: 0x00000 - Unknown?

Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)

Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false

Forced entities: 23 total; [EntitySheep['Sheep'/32, l='MpServer', x=1104,69, y=4,00, z=-84,41], EntitySheep['Sheep'/3, l='MpServer', x=968,94, y=4,00, z=-116,91], EntityCow['Cow'/4, l='MpServer', x=963,66, y=4,00, z=-96,25], EntityCow['Cow'/5, l='MpServer', x=962,34, y=4,00, z=-4,28], EntityArrow['arrow'/9, l='MpServer', x=1005,22, y=4,00, z=-13,50], EntitySheep['Sheep'/12, l='MpServer', x=1013,16, y=4,00, z=-153,25], EntityPig['Pig'/15, l='MpServer', x=1009,19, y=4,00, z=-10,88], EntityArrow['arrow'/17, l='MpServer', x=1025,69, y=4,03, z=-79,00], EntityArrow['arrow'/16, l='MpServer', x=1026,31, y=4,03, z=-79,00], EntityArrow['arrow'/19, l='MpServer', x=1026,34, y=4,03, z=-79,00], EntityArrow['arrow'/18, l='MpServer', x=1024,00, y=4,38, z=-79,00], EntityArrow['arrow'/21, l='MpServer', x=1026,22, y=4,03, z=-79,00], EntityArrow['arrow'/20, l='MpServer', x=1026,25, y=4,03, z=-79,00], EntitySheep['Sheep'/23, l='MpServer', x=1054,69, y=4,00, z=-129,31], EntityClientPlayerMP['lliinnkk10'/34, l='MpServer', x=1032,52, y=5,62, z=-73,27], EntityArrow['arrow'/22, l='MpServer', x=1036,91, y=4,00, z=-20,41], EntityItem['item.item.leather'/25, l='MpServer', x=1049,66, y=4,13, z=-36,19], EntityArrow['arrow'/24, l='MpServer', x=1053,00, y=4,00, z=-33,34], EntityArrow['arrow'/27, l='MpServer', x=1050,72, y=4,00, z=-17,38], EntityItem['item.item.beefRaw'/26, l='MpServer', x=1050,84, y=4,13, z=-35,81], EntityXPOrb['Experience Orb'/29, l='MpServer', x=1049,94, y=4,25, z=-30,44], EntityArrow['arrow'/28, l='MpServer', x=1055,38, y=4,00, z=-19,63], EntityArrow['arrow'/31, l='MpServer', x=1057,84, y=4,00, z=-14,31]]

Retry entities: 0 total; []

Server brand: fml,forge

Server type: Integrated singleplayer server

Stacktrace:

at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:440)

at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2312)

at net.minecraft.client.Minecraft.run(Minecraft.java:863)

at net.minecraft.client.main.Main.main(Main.java:93)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:131)

at net.minecraft.launchwrapper.Launch.main(Launch.java:27)

 

-- System Details --

Details:

Minecraft Version: 1.6.4

Operating System: Windows 7 (amd64) version 6.1

Java Version: 1.7.0_51, Oracle Corporation

Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

Memory: 685200544 bytes (653 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)

JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

AABB Pool Size: 11635 (651560 bytes; 0 MB) allocated, 220 (12320 bytes; 0 MB) used

Suspicious classes: FML and Forge are installed

IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0

FML: MCP v8.11 FML v6.4.49.965 Minecraft Forge 9.11.1.965 4 mods loaded, 4 mods active

mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

FML{6.4.49.965} [Forge Mod Loader] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Forge{9.11.1.965} [Minecraft Forge] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

extendedobsidian{1.6.4-1.0} [§5Extended Obsidian] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Launched Version: 1.6

LWJGL: 2.9.0

OpenGL: AMD Radeon HD 7570 GL version 4.2.11476 Compatibility Profile Context, ATI Technologies Inc.

Is Modded: Definitely; Client brand changed to 'fml,forge'

Type: Client (map_client.txt)

Resource Pack: Default

Current Language: English (US)

Profiler Position: N/A (disabled)

Vec3 Pool Size: 88 (4928 bytes; 0 MB) allocated, 88 (4928 bytes; 0 MB) used

 

 

Link to comment
Share on other sites

You forgot to register the icons in your iconArray.

 

Isn't this registering it?:

    public static final String[] bowPullIconNameArray = new String[] {"ObsidianInfusedBow_pulling_0", "ObsidianInfusedBow_pulling_1", "ObsidianInfusedBow_pulling_2"};

    @SideOnly(Side.CLIENT)

    private Icon[] iconArray;

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.