ColinGBos / Hammerz

Minecraft Mod adding hammers to various other toolsets
MIT License
5 stars 4 forks source link

Repair results in an invalid item #7

Closed OnmyojiOmn closed 8 years ago

OnmyojiOmn commented 8 years ago

Repairing a hammer by crafting two of the same type results in an invalid, grayed-out item. If the item is taken out of the crafting table and placed in the inventory the game crashes. Attempting to load that world will also crash the game.

Also, the description of the mod implies that repairing is done with an ingot/block similarly to TiC tools, but that doesn't seem to work.

---- Minecraft Crash Report ----

WARNING: coremods are present:
  ThaumcraftLoader (Thaumcraft-1.8.9-5.1.4.jar)
  FldLoadingPlugin (FastLeafDecay-1.8-1.6.jar)
Contact their authors BEFORE contacting forge

// Hey, that tickles! Hehehe!

Time: 1/23/16 12:15 AM
Description: Ticking entity

java.lang.NullPointerException: Ticking entity
    at vapourdrive.hammerz.items.hammer.HammerInfoHandler.getUsesMana(HammerInfoHandler.java:49)
    at vapourdrive.hammerz.items.hammer.OnUpdateHandler.onUpdate(OnUpdateHandler.java:14)
    at vapourdrive.hammerz.items.hammer.ItemHammer.func_77663_a(ItemHammer.java:116)
    at net.minecraft.item.ItemStack.func_77945_a(ItemStack.java:410)
    at net.minecraft.entity.player.InventoryPlayer.func_70429_k(InventoryPlayer.java:315)
    at net.minecraft.entity.player.EntityPlayer.func_70636_d(EntityPlayer.java:542)
    at net.minecraft.client.entity.EntityPlayerSP.func_70636_d(EntityPlayerSP.java:794)
    at net.minecraft.entity.EntityLivingBase.func_70071_h_(EntityLivingBase.java:1614)
    at net.minecraft.entity.player.EntityPlayer.func_70071_h_(EntityPlayer.java:283)
    at net.minecraft.client.entity.EntityPlayerSP.func_70071_h_(EntityPlayerSP.java:117)
    at net.minecraft.world.World.func_72866_a(World.java:1860)
    at net.minecraft.world.World.func_72870_g(World.java:1829)
    at net.minecraft.world.World.func_72939_s(World.java:1661)
    at net.minecraft.client.Minecraft.func_71407_l(Minecraft.java:2089)
    at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1024)
    at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:349)
    at net.minecraft.client.main.Main.main(SourceFile:124)
    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:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

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

-- Head --
Stacktrace:
    at vapourdrive.hammerz.items.hammer.HammerInfoHandler.getUsesMana(HammerInfoHandler.java:49)
    at vapourdrive.hammerz.items.hammer.OnUpdateHandler.onUpdate(OnUpdateHandler.java:14)
    at vapourdrive.hammerz.items.hammer.ItemHammer.func_77663_a(ItemHammer.java:116)
    at net.minecraft.item.ItemStack.func_77945_a(ItemStack.java:410)
    at net.minecraft.entity.player.InventoryPlayer.func_70429_k(InventoryPlayer.java:315)
    at net.minecraft.entity.player.EntityPlayer.func_70636_d(EntityPlayer.java:542)
    at net.minecraft.client.entity.EntityPlayerSP.func_70636_d(EntityPlayerSP.java:794)
    at net.minecraft.entity.EntityLivingBase.func_70071_h_(EntityLivingBase.java:1614)
    at net.minecraft.entity.player.EntityPlayer.func_70071_h_(EntityPlayer.java:283)
    at net.minecraft.client.entity.EntityPlayerSP.func_70071_h_(EntityPlayerSP.java:117)
    at net.minecraft.world.World.func_72866_a(World.java:1860)
    at net.minecraft.world.World.func_72870_g(World.java:1829)

-- Entity being ticked --
Details:
    Entity Type: null (net.minecraft.client.entity.EntityPlayerSP)
    Entity ID: 384
    Entity Name: Dokidoki
    Entity's Exact location: -134.76, 71.00, 120.37
    Entity's Block location: -135.00,71.00,120.00 - World: (-135,71,120), Chunk: (at 9,4,8 in -9,7; contains blocks -144,0,112 to -129,255,127), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
    Entity's Momentum: 0.00, 0.00, 0.00
    Entity's Rider: ~~ERROR~~ NullPointerException: null
    Entity's Vehicle: ~~ERROR~~ NullPointerException: null
Stacktrace:
    at net.minecraft.world.World.func_72939_s(World.java:1661)

-- Affected level --
Details:
    Level name: MpServer
    All players: 1 total; [EntityPlayerSP['Dokidoki'/384, l='MpServer', x=-134.76, y=71.00, z=120.37]]
    Chunk stats: MultiplayerChunkCache: 50, 50
    Level seed: 0
    Level generator: ID 00 - default, ver 1. Features enabled: false
    Level generator options: 
    Level spawn location: -96.00,64.00,248.00 - World: (-96,64,248), Chunk: (at 0,4,8 in -6,15; contains blocks -96,0,240 to -81,255,255), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
    Level time: 424462 game time, 601451 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: 49 total; [EntityChicken['Chicken'/131, l='MpServer', x=-170.25, y=75.00, z=154.47], EntityChicken['Chicken'/396, l='MpServer', x=-77.53, y=73.00, z=42.22], EntitySkeleton['Skeleton'/387, l='MpServer', x=-97.50, y=11.00, z=41.50], EntitySheep['Sheep'/386, l='MpServer', x=-174.50, y=95.00, z=46.66], EntitySheep['Sheep'/148, l='MpServer', x=-145.81, y=72.00, z=81.13], EntitySheep['Sheep'/149, l='MpServer', x=-151.00, y=74.00, z=156.97], EntityZombie['Zombie'/171, l='MpServer', x=-123.66, y=62.00, z=127.66], EntityWitch['Witch'/170, l='MpServer', x=-119.53, y=50.00, z=115.81], EntitySkeleton['Skeleton'/169, l='MpServer', x=-120.16, y=30.00, z=121.72], EntitySkeleton['Skeleton'/168, l='MpServer', x=-123.50, y=30.00, z=126.50], EntitySkeleton['Skeleton'/175, l='MpServer', x=-116.50, y=50.00, z=140.09], EntityWitch['Witch'/174, l='MpServer', x=-125.47, y=50.00, z=138.88], EntityBat['Bat'/173, l='MpServer', x=-117.44, y=33.13, z=133.25], EntityBat['Bat'/172, l='MpServer', x=-122.22, y=45.38, z=134.16], EntitySkeleton['Skeleton'/163, l='MpServer', x=-140.50, y=12.00, z=76.50], EntityEnderman['Enderman'/162, l='MpServer', x=-137.50, y=13.00, z=66.50], EntityAuraNode['Aura Node'/434, l='MpServer', x=-264.50, y=47.50, z=-6.50], EntitySkeleton['Skeleton'/167, l='MpServer', x=-113.50, y=54.00, z=99.50], EntityPlayerSP['Dokidoki'/384, l='MpServer', x=-134.76, y=71.00, z=120.37], EntityCow['Cow'/164, l='MpServer', x=-131.38, y=74.00, z=172.41], EntityCow['Cow'/186, l='MpServer', x=-96.94, y=69.00, z=138.16], EntityCreeper['Creeper'/187, l='MpServer', x=-96.50, y=35.00, z=169.50], EntitySkeleton['Skeleton'/184, l='MpServer', x=-96.50, y=13.00, z=81.50], EntityZombie['Zombie'/185, l='MpServer', x=-104.50, y=52.00, z=100.50], EntityBrainyZombie['Angry Zombie'/178, l='MpServer', x=-115.50, y=36.00, z=160.50], EntityCreeper['Creeper'/179, l='MpServer', x=-113.50, y=38.00, z=161.50], EntitySpider['Spider'/176, l='MpServer', x=-116.50, y=50.00, z=135.50], EntitySquid['Squid'/177, l='MpServer', x=-122.53, y=32.06, z=153.50], EntityRabbit['Rabbit'/183, l='MpServer', x=-97.69, y=77.00, z=68.31], EntityAuraNode['Aura Node'/180, l='MpServer', x=-126.50, y=74.50, z=161.50], EntityCow['Cow'/181, l='MpServer', x=-122.34, y=72.00, z=171.44], EntitySquid['Squid'/205, l='MpServer', x=-94.31, y=59.09, z=174.56], EntityTaintacle['Taintacle'/204, l='MpServer', x=-87.50, y=65.00, z=151.50], EntitySquid['Squid'/206, l='MpServer', x=-90.13, y=58.13, z=172.34], EntityZombie['Zombie'/201, l='MpServer', x=-88.50, y=52.00, z=97.50], EntityBat['Bat'/200, l='MpServer', x=-93.66, y=15.31, z=79.44], EntitySkeleton['Skeleton'/203, l='MpServer', x=-85.50, y=18.00, z=138.50], EntityZombie['Zombie'/202, l='MpServer', x=-94.50, y=18.00, z=137.50], EntityBat['Bat'/199, l='MpServer', x=-95.22, y=14.91, z=68.91], EntityItem['item.item.egg'/119, l='MpServer', x=-188.69, y=66.00, z=118.44], EntityChicken['Chicken'/118, l='MpServer', x=-188.66, y=67.69, z=117.31], EntityBat['Bat'/117, l='MpServer', x=-186.53, y=67.09, z=107.75], EntityCreeper['Creeper'/116, l='MpServer', x=-183.50, y=63.00, z=104.50], EntitySheep['Sheep'/115, l='MpServer', x=-186.69, y=69.00, z=91.47], EntityZombie['Zombie'/114, l='MpServer', x=-185.50, y=23.00, z=80.50], EntityCreeper['Creeper'/113, l='MpServer', x=-184.50, y=21.00, z=75.50], EntityCreeper['Creeper'/112, l='MpServer', x=-181.50, y=26.00, z=71.50], EntityAuraNode['Aura Node'/486, l='MpServer', x=-269.50, y=77.50, z=5.50], EntityPig['Pig'/120, l='MpServer', x=-182.03, y=73.00, z=154.13]]
    Retry entities: 0 total; []
    Server brand: fml,forge
    Server type: Integrated singleplayer server
Stacktrace:
    at net.minecraft.client.multiplayer.WorldClient.func_72914_a(WorldClient.java:404)
    at net.minecraft.client.Minecraft.func_71396_d(Minecraft.java:2536)
    at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:370)
    at net.minecraft.client.main.Main.main(SourceFile:124)
    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:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

-- System Details --
Details:
    Minecraft Version: 1.8.9
    Operating System: Windows 7 (amd64) version 6.1
    CPU: 4x AMD Athlon(tm) X4 760K Quad Core Processor 
    Java Version: 1.7.0_80, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 313241336 bytes (298 MB) / 754769920 bytes (719 MB) up to 2130051072 bytes (2031 MB)
    JVM Flags: 8 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx2G -XX:MaxPermSize=128m -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSIncrementalPacing -XX:ParallelGCThreads=2 -XX:+AggressiveOpts
    IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95
    FML: MCP 9.19 Powered by Forge 11.15.0.1715 Optifine OptiFine_1.8.9_HD_U_H2 17 mods loaded, 17 mods active
    States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
    UCHIJAAAA   mcp{9.18} [Minecraft Coder Pack] (minecraft.jar) 
    UCHIJAAAA   FML{8.0.99.99} [Forge Mod Loader] (forge-1.8.9-11.15.0.1715.jar) 
    UCHIJAAAA   Forge{11.15.0.1715} [Minecraft Forge] (forge-1.8.9-11.15.0.1715.jar) 
    UCHIJAAAA   Baubles{1.1.3.0} [Baubles] (Baubles-1.8.9-1.1.3.0.jar) 
    UCHIJAAAA   aura{unspecified} [Aura Cascade] (AuraCascade-1.8.8-v0.2.2a.jar) 
    UCHIJAAAA   bigtrees{0.2} [The BigTrees Mod] (bigtrees-0.2-1.8.9.jar) 
    UCHIJAAAA   BloodMagic{1.8.9-2.0.0-6} [Blood Magic: Alchemical Wizardry] (BloodMagic-1.8.9-2.0.0-6.jar) 
    UCHIJAAAA   Chameleon{1.8.9-0.2.1} [Chameleon] (Chameleon-1.8.9-0.2.1.jar) 
    UCHIJAAAA   fastleafdecay{1.6} [Fast Leaf Decay] (FastLeafDecay-1.8-1.6.jar) 
    UCHIJAAAA   Thaumcraft{5.1.4} [Thaumcraft] (Thaumcraft-1.8.9-5.1.4.jar) 
    UCHIJAAAA   hammerz{1.8.9-0.1.4.14} [Hammerz] (Hammerz-1.8.9-0.1.4.14.jar) 
    UCHIJAAAA   inventorysorter{0.7.4+26} [Simple Inventory sorting] (inventorysorter-1.8.9-0.7.4+26.jar) 
    UCHIJAAAA   JEI{2.21.0.98} [Just Enough Items] (jei_1.8.9-2.21.0.98.jar) 
    UCHIJAAAA   JEIAddons{0.9.0.32} [Just Enough Items Addons] (JEIAddons_1.8.9-0.9.0.32.jar) 
    UCHIJAAAA   journeymap{5.1.3} [JourneyMap] (journeymap-1.8.8-5.1.3-unlimited.jar) 
    UCHIJAAAA   StorageDrawers{1.8.9-2.2.1} [Storage Drawers] (StorageDrawers-1.8.9-2.2.1.jar) 
    UCHIJAAAA   Waila{1.6.0} [Waila] (Waila-1.6.0-B3_1.8.8.jar) 
    Loaded coremods (and transformers): 
ThaumcraftLoader (Thaumcraft-1.8.9-5.1.4.jar)

FldLoadingPlugin (FastLeafDecay-1.8-1.6.jar)
  com.olafski.fastleafdecay.FldTransformer
    GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 350.12' Renderer: 'GeForce GTX 750/PCIe/SSE2'
    Launched Version: 1.8.9-forge1.8.9-11.15.0.1715
    LWJGL: 2.9.4
    OpenGL: GeForce GTX 750/PCIe/SSE2 GL version 4.5.0 NVIDIA 350.12, NVIDIA Corporation
    GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

    Using VBOs: Yes
    Is Modded: Definitely; Client brand changed to 'fml,forge'
    Type: Client (map_client.txt)
    Resource Packs: 
    Current Language: English (US)
    Profiler Position: N/A (disabled)
    CPU: 4x AMD Athlon(tm) X4 760K Quad Core Processor 
ColinGBos commented 8 years ago

Sorry about that crash, I'll have a look at what I need to do to get that output stack proper, it's something that happens automatically for an ItemTool I think so I haven't had a look at at and it isn't something I use so I haven't come across this in my own play. As for repairing them, it should work in the anvil with the valid block used to make the tool. Can you post a screenshot of a damaged hammer with it's respective block in the anvil to confirm?

ColinGBos commented 8 years ago

I found the culprit for the crash, and it's poor design on vanilla's part. Not entirely my fault but something I would have checked if I had known it would cause an issue. In CraftingManager this is the block of code that tries to repair two items. I depend on the existence of the nbt tag that goes with the itemstack for determining what type of hammer it is, and they could definitely do this better. isRepairable() is something that returns true by default for any item that is damageable.

if (itemstack2.getItem() == itemstack3.getItem() && itemstack2.stackSize == 1 && itemstack3.stackSize == 1 && itemstack2.getItem().isRepairable())
{
    Item item = itemstack2.getItem();
    int j = item.getMaxDamage() - itemstack2.getItemDamage();
    int k = item.getMaxDamage() - itemstack3.getItemDamage();
    int l = j + k + item.getMaxDamage() * 5 / 100;
    int i1 = item.getMaxDamage() - l;

    if (i1 < 0)
    {
         i1 = 0;
    }
    return new ItemStack(itemstack2.getItem(), 1, i1);
}