После проверки на броню краш

Я сделал проверку есть ли у игрока полный набор угольной брони, но когда производится проверка происходит краш

Код:
if(par5EntityPlayer.inventory.armorItemInSlot(0).getItem() != null && par5EntityPlayer.inventory.armorItemInSlot(1).getItem() != null && par5EntityPlayer.inventory.armorItemInSlot(2).getItem() != null && par5EntityPlayer.inventory.armorItemInSlot(3).getItem() != null)
                {
                    if(par5EntityPlayer.inventory.armorItemInSlot(1).getItem() == Items.coal_helmet && par5EntityPlayer.inventory.armorItemInSlot(2).getItem() == Items.coal_chest && par5EntityPlayer.inventory.armorItemInSlot(3).getItem() == Items.coal_leggings && par5EntityPlayer.inventory.armorItemInSlot(4).getItem() == Items.coal_boots)
                    {
                        par5EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Item.coal));
                    }
                }
 

timaxa007

Модератор
5,831
409
672
1. Какая версия Minecraft?
2. Ты уверен, что из-за этого кода у тебя краш?
3.
smurfik997 написал(а):
Items твой класс или Minecraft?
 
timaxa007 написал(а):
1. Какая версия Minecraft?
2. Ты уверен, что из-за этого кода у тебя краш?
3.
smurfik997 написал(а):
Items твой класс или Minecraft?
Items мой класс. Версия 1.6.4. Я уверен что это из-за этого кода.
 
Dovakin написал(а):
---- Minecraft Crash Report ----
// I feel sad now :(

Time: 29.03.15 11:34
Description: Unexpected error

java.lang.NullPointerException
at assets.new_craft.src.block.radiation_block.onBlockClicked(radiation_block.java:45)
at net.minecraft.client.multiplayer.PlayerControllerMP.clickBlock(PlayerControllerMP.java:213)
at net.minecraft.client.Minecraft.clickMouse(Minecraft.java:1383)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1863)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:910)
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 assets.new_craft.src.block.radiation_block.onBlockClicked(radiation_block.java:45)
at net.minecraft.client.multiplayer.PlayerControllerMP.clickBlock(PlayerControllerMP.java:213)
at net.minecraft.client.Minecraft.clickMouse(Minecraft.java:1383)

-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [EntityClientPlayerMP['Player79'/17, l='MpServer', x=-176,09, y=65,62, z=-170,18]]
Chunk stats: MultiplayerChunkCache: 441
Level seed: 0
Level generator: ID 01 - flat, ver 0. Features enabled: false
Level generator options: 
Level spawn location: World: (-184,4,-175), Chunk: (at 8,0,1 in -12,-11; contains blocks -192,0,-176 to -177,255,-161), Region: (-1,-1; contains chunks -32,-32 to -1,-1, blocks -512,0,-512 to -1,255,-1)
Level time: 189021 game time, 22370 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: survival (ID 0). Hardcore: false. Cheats: false
Forced entities: 7 total; [EntityClientPlayerMP['Player79'/17, l='MpServer', x=-176,09, y=65,62, z=-170,18], EntityChicken['Курица'/8, l='MpServer', x=-228,56, y=64,00, z=-109,44], EntityChicken['Курица'/10, l='MpServer', x=-161,47, y=64,00, z=-97,53], EntityHorse['Лошадь'/11, l='MpServer', x=-116,56, y=64,00, z=-146,75], EntityChicken['Курица'/12, l='MpServer', x=-97,56, y=64,00, z=-174,44], EntitySheep['Овца'/13, l='MpServer', x=-108,72, y=64,00, z=-150,84], EntityHorse['Лошадь'/14, l='MpServer', x=-108,50, y=64,00, z=-129,81]]
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 (x86) version 6.1
Java Version: 1.7.0_72, Oracle Corporation
Java VM Version: Java HotSpot(TM) Client VM (mixed mode), Oracle Corporation
Memory: 838958560 bytes (800 MB) / 1060372480 bytes (1011 MB) up to 1060372480 bytes (1011 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 9826 (550256 bytes; 0 MB) allocated, 2 (112 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
new_craft{1.0.3} [§aНовые крафты] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
Launched Version: 1.6
LWJGL: 2.9.0
OpenGL: ATI Radeon HD 3800 Series  GL version 3.3.10834 Compatibility Profile Context, ATI Technologies Inc.
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Pack: Faithful-1.6.zip
Current Language: Русский (Россия)
Profiler Position: N/A (disabled)
Vec3 Pool Size: 198 (11088 bytes; 0 MB) allocated, 15 (840 bytes; 0 MB) used
 
1,683
1
[font=Verdana, Helvetica, Arial, sans-serif]radiation_block.java: line[/font][font=Verdana, Helvetica, Arial, sans-serif] 45[/font]
 
1,239
2
24
at assets.new_craft.src.block.radiation_block.onBlockClicked(radiation_block.java:45)
Тщательно перепроверь onBlockClicked
 

timaxa007

Модератор
5,831
409
672
smurfik997, Dragon2488 написал-же:
Dragon2488 написал(а):
.Ибо надо проверять на нулл.
Т.е. примерно так:
Код:
if (player.inventory.armorItemInSlot(3) != null && 
    player.inventory.armorItemInSlot(2) != null && 
    player.inventory.armorItemInSlot(1) != null && 
    player.inventory.armorItemInSlot(0) != null && 
    player.inventory.armorItemInSlot(3).getItem() == Items.coal_helmet && 
    player.inventory.armorItemInSlot(2).getItem() == Items.coal_chest && 
    player.inventory.armorItemInSlot(1).getItem() == Items.coal_leggings && 
    player.inventory.armorItemInSlot(0).getItem() == Items.coal_boots) {
player.inventory.addItemStackToInventory(new ItemStack(Item.coal));
}
 
timaxa007 написал(а):
smurfik997, Dragon2488 написал-же:
Dragon2488 написал(а):
.Ибо надо проверять на нулл.
Т.е. примерно так:
Код:
if (player.inventory.armorItemInSlot(3) != null && 
    player.inventory.armorItemInSlot(2) != null && 
    player.inventory.armorItemInSlot(1) != null && 
    player.inventory.armorItemInSlot(0) != null && 
    player.inventory.armorItemInSlot(3).getItem() == Items.coal_helmet && 
    player.inventory.armorItemInSlot(2).getItem() == Items.coal_chest && 
    player.inventory.armorItemInSlot(1).getItem() == Items.coal_leggings && 
    player.inventory.armorItemInSlot(0).getItem() == Items.coal_boots) {
player.inventory.addItemStackToInventory(new ItemStack(Item.coal));
}
Спасибо я попробую
 
1,683
1
Agravaine написал(а):
x_ab98c68b.jpg
Хотя проверка вроде бы есть
 
Сверху