Jump to content

[1.8] How to get/set NBTtagcompound from custom GUI?


Warix

Recommended Posts

So i tried to do what title says, and i get error for null exception, i tried to set nbt from this.mc.thePlayer.getItemInUse();

my code:

 

package ga.warixmods.mymodmod.inventory;

 

import java.io.IOException;

 

import org.lwjgl.input.Keyboard;

 

import ga.warixmods.mymodmod.client.gui.GuiWandButton1;

import ga.warixmods.mymodmod.client.gui.GuiWandButton2;

import ga.warixmods.mymodmod.client.gui.GuiWandButton3;

import ga.warixmods.mymodmod.client.gui.GuiWandButton4;

import ga.warixmods.mymodmod.init.mod1Items;

import net.minecraft.client.Minecraft;

import net.minecraft.client.gui.FontRenderer;

import net.minecraft.client.gui.GuiButton;

import net.minecraft.client.gui.GuiLabel;

import net.minecraft.client.gui.GuiScreen;

import net.minecraft.client.gui.GuiTextField;

import net.minecraft.client.renderer.GlStateManager;

import net.minecraft.client.renderer.Tessellator;

import net.minecraft.client.renderer.WorldRenderer;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.entity.player.InventoryPlayer;

import net.minecraft.init.Blocks;

import net.minecraft.inventory.Container;

import net.minecraft.inventory.ContainerRepair;

import net.minecraft.item.ItemStack;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.util.BlockPos;

import net.minecraft.util.ChatComponentTranslation;

import net.minecraft.util.IChatComponent;

import net.minecraft.util.ResourceLocation;

import net.minecraft.world.IInteractionObject;

import net.minecraft.world.World;

 

public class GuiWand extends GuiScreen{

public static final int GUI_ID = 20;

public ItemStack stack = mc.thePlayer.getItemInUse();

public GuiWand () {}

    @Override

    public void initGui()

    {

    buttonList.add(new GuiWandButton1(0, width / 2 - 100 , height / 2 - 20,"1"));

    buttonList.add(new GuiWandButton2(1, width / 2 - 50, height / 2 - 20,"1"));

    buttonList.add(new GuiWandButton3(2, width / 2 + 0, height / 2 - 20,"1"));

    buttonList.add(new GuiWandButton4(3, width / 2  + 50, height / 2 - 20,"1"));

    }

    protected static final ResourceLocation buttonTextures1 = new ResourceLocation("agkm:textures/gui/demo_background.png");

@Override

    public void drawScreen(int mouseX, int mouseY, float partialTicks)

    {

this.drawDefaultBackground();

        mc.getTextureManager().bindTexture(buttonTextures1);

        this.drawTexturedModalRect(width / 2 - 125, height / 2 - 75,0,0, 247, 125);

        this.fontRendererObj.drawString("Choose the power you want to use:", width / 2- 100, height / 2  - 50, 1);

        super.drawScreen(mouseX, mouseY, partialTicks);

        mc.thePlayer.setCurrentItemOrArmor(4, new ItemStack(mod1Items.murasame,1));

       

       

    }

    @Override

    public void actionPerformed(GuiButton button) throws IOException

    {

    NBTTagCompound nbt = new NBTTagCompound();

    switch(button.id)

    {

    case 0: 

    if(!stack.getTagCompound().hasKey("power"))

    {

        nbt.setInteger("id", 0);

        stack.getTagCompound().setTag("power", nbt);

    }

    this.mc.displayGuiScreen((GuiScreen)null);

    this.mc.setIngameFocus();

    break;

    case 1:

    if(!stack.getTagCompound().hasKey("power"))

    {

        nbt.setInteger("id", 1);

        stack.getTagCompound().setTag("power", nbt);

    }

    this.mc.displayGuiScreen((GuiScreen)null);

    this.mc.setIngameFocus();

    break;

    case 2:

    if(!stack.getTagCompound().hasKey("power"))

    {

        nbt.setInteger("id", 2);

        stack.getTagCompound().setTag("power", nbt);

    }

    this.mc.displayGuiScreen((GuiScreen)null);

    this.mc.setIngameFocus();

    break;

    case 3:

    if(!stack.getTagCompound().hasKey("power"))

    {

        nbt.setInteger("id", 3);

        stack.getTagCompound().setTag("power", nbt);

    }

    this.mc.displayGuiScreen((GuiScreen)null);

    this.mc.setIngameFocus();

    break;

   

   

   

    }

    this.updateScreen();

    }

 

 

 

 

 

 

}

 

 

Basically i want to make item, when you right click with him it uses power depending on nbt tag, and when u shift right click you choose which power you want to use from custom gui. If there is better solution for this please tell me. and also there is error :

 

 

[13:17:47] [main/INFO] [GradleStart]: Extra: []

[13:17:47] [main/INFO] [GradleStart]: Running with arguments: [--userProperties, {}, --assetsDir, C:/Users/Tn1/.gradle/caches/minecraft/assets, --assetIndex, 1.8, --accessToken, {REDACTED}, --version, 1.8, --tweakClass, net.minecraftforge.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.tweakers.CoremodTweaker]

[13:17:47] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker

[13:17:47] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker

[13:17:47] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker

[13:17:47] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLTweaker

[13:17:47] [main/INFO] [FML]: Forge Mod Loader version 8.99.124.1450 for Minecraft 1.8 loading

[13:17:47] [main/INFO] [FML]: Java is Java HotSpot 64-Bit Server VM, version 1.8.0_45, running on Windows 8.1:amd64:6.3, installed at C:\Program Files\Java\jre1.8.0_45

[13:17:47] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation

[13:17:47] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.CoremodTweaker

[13:17:47] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.fml.relauncher.FMLCorePlugin

[13:17:47] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin

[13:17:47] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker

[13:17:47] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLDeobfTweaker

[13:17:47] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.AccessTransformerTweaker

[13:17:47] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker

[13:17:47] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker

[13:17:47] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper

[13:17:47] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work!

[13:17:49] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing

[13:17:49] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper

[13:17:49] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLDeobfTweaker

[13:17:49] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.AccessTransformerTweaker

[13:17:49] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.TerminalTweaker

[13:17:49] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.TerminalTweaker

[13:17:49] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main}

[13:17:50] [Client thread/INFO]: Setting user: Player366

[13:17:52] [Client thread/INFO]: LWJGL Version: 2.9.1

[13:17:53] [Client thread/INFO] [sTDOUT]: [net.minecraftforge.fml.client.SplashProgress:start:235]: ---- Minecraft Crash Report ----

// Would you like a cupcake?

 

Time: 7/19/15 1:17 PM

Description: Loading screen debug info

 

This is just a prompt for computer specs to be printed. THIS IS NOT A ERROR

 

 

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

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

 

-- System Details --

Details:

Minecraft Version: 1.8

Operating System: Windows 8.1 (amd64) version 6.3

Java Version: 1.8.0_45, Oracle Corporation

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

Memory: 736601368 bytes (702 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)

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

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

FML:

Loaded coremods (and transformers):

GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.4.13283 Compatibility Profile Context 14.501.1003.0' Renderer: 'ASUS R7 250X Series'

[13:17:53] [Client thread/INFO] [MinecraftForge]: Attempting early MinecraftForge initialization

[13:17:53] [Client thread/INFO] [FML]: MinecraftForge v11.14.3.1450 Initialized

[13:17:53] [Client thread/INFO] [FML]: Replaced 204 ore recipies

[13:17:53] [Client thread/INFO] [MinecraftForge]: Completed early MinecraftForge initialization

[13:17:54] [Client thread/INFO] [FML]: Found 0 mods from the command line. Injecting into mod discoverer

[13:17:54] [Client thread/INFO] [FML]: Searching C:\Users\Tn1\Desktop\modding\eclipse\mods for mods

[13:17:55] [Client thread/INFO] [FML]: Forge Mod Loader has identified 4 mods to load

[13:17:56] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, agkm] at CLIENT

[13:17:56] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, agkm] at SERVER

[13:17:56] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:my mod Mod (AGK MOD)

[13:17:56] [Client thread/INFO] [FML]: Processing ObjectHolder annotations

[13:17:56] [Client thread/INFO] [FML]: Found 384 ObjectHolder annotations

[13:17:56] [Client thread/INFO] [FML]: Identifying ItemStackHolder annotations

[13:17:56] [Client thread/INFO] [FML]: Found 0 ItemStackHolder annotations

[13:17:56] [Client thread/INFO] [FML]: Configured a dormant chunk cache size of 0

[13:17:56] [Client thread/INFO] [FML]: Applying holder lookups

[13:17:56] [Client thread/INFO] [FML]: Holder lookups applied

[13:17:56] [Client thread/INFO] [FML]: Injecting itemstacks

[13:17:56] [Client thread/INFO] [FML]: Itemstack injection complete

[13:17:56] [sound Library Loader/INFO]: Starting up SoundSystem...

[13:17:57] [Thread-9/INFO]: Initializing LWJGL OpenAL

[13:17:57] [Thread-9/INFO]: (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)

[13:17:57] [Thread-9/INFO]: OpenAL initialized.

[13:17:57] [sound Library Loader/INFO]: Sound engine started

[13:18:01] [Client thread/INFO]: Created: 512x512 textures-atlas

[13:18:02] [Client thread/INFO] [FML]: Injecting itemstacks

[13:18:02] [Client thread/INFO] [FML]: Itemstack injection complete

[13:18:02] [Client thread/INFO] [FML]: Forge Mod Loader has successfully loaded 4 mods

[13:18:02] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:my mod Mod (AGK MOD)

[13:18:02] [Client thread/INFO]: SoundSystem shutting down...

[13:18:03] [Client thread/WARN]: Author: Paul Lamb, www.paulscode.com

[13:18:03] [sound Library Loader/INFO]: Starting up SoundSystem...

[13:18:03] [Thread-11/INFO]: Initializing LWJGL OpenAL

[13:18:03] [Thread-11/INFO]: (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)

[13:18:03] [Thread-11/INFO]: OpenAL initialized.

[13:18:03] [sound Library Loader/INFO]: Sound engine started

[13:18:06] [Client thread/INFO]: Created: 512x512 textures-atlas

[13:18:10] [server thread/INFO]: Starting integrated minecraft server version 1.8

[13:18:10] [server thread/INFO]: Generating keypair

[13:18:10] [server thread/INFO] [FML]: Injecting existing block and item data into this server instance

[13:18:10] [server thread/INFO] [FML]: Applying holder lookups

[13:18:10] [server thread/INFO] [FML]: Holder lookups applied

[13:18:10] [server thread/INFO] [FML]: Loading dimension 0 (New World) (net.minecraft.server.integrated.IntegratedServer@60de9bb8)

[13:18:10] [server thread/INFO] [FML]: Loading dimension 1 (New World) (net.minecraft.server.integrated.IntegratedServer@60de9bb8)

[13:18:10] [server thread/INFO] [FML]: Loading dimension -1 (New World) (net.minecraft.server.integrated.IntegratedServer@60de9bb8)

[13:18:10] [server thread/INFO]: Preparing start region for level 0

[13:18:11] [server thread/INFO]: Changing view distance to 12, from 10

[13:18:12] [Netty Local Client IO #0/INFO] [FML]: Server protocol version 2

[13:18:12] [Netty Server IO #1/INFO] [FML]: Client protocol version 2

[13:18:12] [Netty Server IO #1/INFO] [FML]: Client attempting to join with 4 mods : [email protected],[email protected],[email protected],[email protected]

[13:18:12] [Netty Local Client IO #0/INFO] [FML]: [Netty Local Client IO #0] Client side modded connection established

[13:18:12] [server thread/INFO] [FML]: [server thread] Server side modded connection established

[13:18:12] [server thread/INFO]: Player366[local:E:dda6a5c2] logged in with entity id 186 at (62.97394899228291, 4.0, 135.61851548244766)

[13:18:12] [server thread/INFO]: Player366 joined the game

[13:18:13] [pool-2-thread-1/WARN]: Couldn't look up profile properties for com.mojang.authlib.GameProfile@4a4cdeb0[id=7c45a0ca-f821-3da7-8901-484be45197c6,name=Player366,properties={},legacy=false]

com.mojang.authlib.exceptions.AuthenticationException: The client has sent too many requests within a certain amount of time

at com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService.makeRequest(YggdrasilAuthenticationService.java:65) ~[YggdrasilAuthenticationService.class:?]

at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillGameProfile(YggdrasilMinecraftSessionService.java:158) [YggdrasilMinecraftSessionService.class:?]

at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:53) [YggdrasilMinecraftSessionService$1.class:?]

at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:50) [YggdrasilMinecraftSessionService$1.class:?]

at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache.get(LocalCache.java:3934) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4827) [guava-17.0.jar:?]

at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillProfileProperties(YggdrasilMinecraftSessionService.java:148) [YggdrasilMinecraftSessionService.class:?]

at net.minecraft.client.resources.SkinManager$3.run(SkinManager.java:138) [skinManager$3.class:?]

at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_45]

at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_45]

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_45]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_45]

at java.lang.Thread.run(Unknown Source) [?:1.8.0_45]

[13:18:24] [server thread/INFO]: Stopping server

[13:18:24] [server thread/INFO]: Saving players

[13:18:24] [server thread/INFO]: Saving worlds

[13:18:24] [server thread/INFO]: Saving chunks for level 'New World'/Overworld

[13:18:24] [server thread/INFO]: Saving chunks for level 'New World'/Nether

[13:18:24] [server thread/INFO]: Saving chunks for level 'New World'/The End

[13:18:25] [server thread/INFO] [FML]: Unloading dimension 0

[13:18:25] [server thread/INFO] [FML]: Unloading dimension -1

[13:18:25] [server thread/INFO] [FML]: Unloading dimension 1

[13:18:25] [server thread/INFO] [FML]: Applying holder lookups

[13:18:25] [server thread/INFO] [FML]: Holder lookups applied

[13:18:25] [Client thread/FATAL]: Unreported exception thrown!

java.lang.NullPointerException

at ga.warixmods.mymodmod.inventory.GuiWand.<init>(GuiWand.java:37) ~[GuiWand.class:?]

at ga.warixmods.mymodmod.proxy.CommonProxy.getClientGuiElement(CommonProxy.java:12) ~[CommonProxy.class:?]

at net.minecraftforge.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:266) ~[NetworkRegistry.class:?]

at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:97) ~[FMLNetworkHandler.class:?]

at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2577) ~[EntityPlayer.class:?]

at ga.warixmods.mymodmod.item.ItemDemonsExtractWand.onItemRightClick(ItemDemonsExtractWand.java:79) ~[itemDemonsExtractWand.class:?]

at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:168) ~[itemStack.class:?]

at net.minecraft.client.multiplayer.PlayerControllerMP.sendUseItem(PlayerControllerMP.java:475) ~[PlayerControllerMP.class:?]

at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1600) ~[Minecraft.class:?]

at net.minecraft.client.Minecraft.runTick(Minecraft.java:2131) ~[Minecraft.class:?]

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1087) ~[Minecraft.class:?]

at net.minecraft.client.Minecraft.run(Minecraft.java:376) [Minecraft.class:?]

at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_45]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_45]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_45]

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]

at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]

at GradleStart.main(Unknown Source) [start/:?]

[13:18:25] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:663]: ---- Minecraft Crash Report ----

// Hey, that tickles! Hehehe!

 

Time: 7/19/15 1:18 PM

Description: Unexpected error

 

java.lang.NullPointerException: Unexpected error

at ga.warixmods.mymodmod.inventory.GuiWand.<init>(GuiWand.java:37)

at ga.warixmods.mymodmod.proxy.CommonProxy.getClientGuiElement(CommonProxy.java:12)

at net.minecraftforge.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:266)

at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:97)

at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2577)

at ga.warixmods.mymodmod.item.ItemDemonsExtractWand.onItemRightClick(ItemDemonsExtractWand.java:79)

at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:168)

at net.minecraft.client.multiplayer.PlayerControllerMP.sendUseItem(PlayerControllerMP.java:475)

at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1600)

at net.minecraft.client.Minecraft.runTick(Minecraft.java:2131)

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

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

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

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)

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)

at GradleStart.main(Unknown Source)

 

 

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

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

 

-- Head --

Stacktrace:

at ga.warixmods.mymodmod.inventory.GuiWand.<init>(GuiWand.java:37)

at ga.warixmods.mymodmod.proxy.CommonProxy.getClientGuiElement(CommonProxy.java:12)

at net.minecraftforge.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:266)

at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:97)

at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2577)

at ga.warixmods.mymodmod.item.ItemDemonsExtractWand.onItemRightClick(ItemDemonsExtractWand.java:79)

at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:168)

at net.minecraft.client.multiplayer.PlayerControllerMP.sendUseItem(PlayerControllerMP.java:475)

at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1600)

 

-- Affected level --

Details:

Level name: MpServer

All players: 1 total; [EntityPlayerSP['Player366'/186, l='MpServer', x=62.97, y=4.00, z=135.62]]

Chunk stats: MultiplayerChunkCache: 625, 625

Level seed: 0

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

Level generator options:

Level spawn location: -237.00,4.00,111.00 - World: (-237,4,111), Chunk: (at 3,0,15 in -15,6; contains blocks -240,0,96 to -225,255,111), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)

Level time: 506837 game time, 5899 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: 127 total; [EntityVillager['Villager'/89, l='MpServer', x=51.53, y=4.00, z=120.66], EntityVillager['Villager'/90, l='MpServer', x=50.69, y=5.00, z=118.56], EntityVillager['Villager'/91, l='MpServer', x=60.28, y=4.00, z=128.22], EntityVillager['Villager'/92, l='MpServer', x=51.47, y=5.00, z=126.09], EntityVillager['Villager'/93, l='MpServer', x=48.75, y=5.00, z=126.47], EntityVillager['Villager'/94, l='MpServer', x=56.38, y=4.00, z=119.26], EntityVillager['Villager'/95, l='MpServer', x=53.59, y=6.00, z=115.31], EntityVillager['Villager'/96, l='MpServer', x=51.28, y=4.00, z=127.56], EntityVillager['Villager'/97, l='MpServer', x=56.22, y=4.00, z=125.50], EntityVillager['Villager'/98, l='MpServer', x=57.97, y=4.00, z=115.72], EntityVillager['Villager'/99, l='MpServer', x=55.53, y=4.00, z=112.81], EntityVillager['Villager'/100, l='MpServer', x=52.50, y=6.00, z=119.22], EntityVillager['Villager'/101, l='MpServer', x=60.16, y=4.00, z=116.34], EntityVillager['Villager'/102, l='MpServer', x=49.31, y=4.00, z=120.84], EntityVillager['Villager'/103, l='MpServer', x=47.81, y=4.00, z=123.50], EntityVillager['Villager'/104, l='MpServer', x=54.34, y=4.00, z=129.56], EntityVillager['Villager'/105, l='MpServer', x=57.31, y=4.00, z=116.56], EntityVillager['Villager'/106, l='MpServer', x=54.47, y=5.00, z=117.16], EntityBat['Bat'/107, l='MpServer', x=59.81, y=6.10, z=123.19], EntityVillager['Villager'/108, l='MpServer', x=59.06, y=4.00, z=116.66], EntityVillager['Villager'/109, l='MpServer', x=62.50, y=5.00, z=121.44], EntityVillager['Villager'/110, l='MpServer', x=52.78, y=4.00, z=123.63], EntityVillager['Villager'/111, l='MpServer', x=52.72, y=6.00, z=115.16], EntityVillager['Villager'/112, l='MpServer', x=54.78, y=4.00, z=124.31], EntityVillager['Villager'/113, l='MpServer', x=56.56, y=4.00, z=118.09], EntityVillager['Villager'/114, l='MpServer', x=50.50, y=5.00, z=106.81], EntityVillager['Villager'/115, l='MpServer', x=63.75, y=4.00, z=114.72], EntityVillager['Villager'/116, l='MpServer', x=68.70, y=4.00, z=115.79], EntityVillager['Villager'/117, l='MpServer', x=67.66, y=4.00, z=124.34], EntityVillager['Villager'/118, l='MpServer', x=79.06, y=4.00, z=117.91], EntityVillager['Villager'/119, l='MpServer', x=67.03, y=4.00, z=115.69], EntityVillager['Villager'/120, l='MpServer', x=63.54, y=4.00, z=117.47], EntityVillager['Villager'/121, l='MpServer', x=67.53, y=4.00, z=125.28], EntityVillager['Villager'/122, l='MpServer', x=65.75, y=4.00, z=109.66], EntityVillager['Villager'/123, l='MpServer', x=70.91, y=5.50, z=121.84], EntityVillager['Villager'/124, l='MpServer', x=79.69, y=1.00, z=116.69], EntityVillager['Villager'/125, l='MpServer', x=79.28, y=1.00, z=116.69], EntityVillager['Villager'/126, l='MpServer', x=69.63, y=5.00, z=120.03], EntityVillager['Villager'/127, l='MpServer', x=79.28, y=1.00, z=116.28], EntityVillager['Villager'/128, l='MpServer', x=79.69, y=1.00, z=116.28], EntityVillager['Villager'/129, l='MpServer', x=79.69, y=1.00, z=116.28], EntityVillager['Villager'/130, l='MpServer', x=69.88, y=5.50, z=120.94], EntityVillager['Villager'/131, l='MpServer', x=67.19, y=4.00, z=123.06], EntityVillager['Villager'/132, l='MpServer', x=39.50, y=4.00, z=126.38], EntityVillager['Villager'/133, l='MpServer', x=39.50, y=4.00, z=127.31], EntityVillager['Villager'/134, l='MpServer', x=44.50, y=4.00, z=125.22], EntityVillager['Villager'/135, l='MpServer', x=38.69, y=4.50, z=116.28], EntityVillager['Villager'/136, l='MpServer', x=47.06, y=5.50, z=126.47], EntityVillager['Villager'/137, l='MpServer', x=34.65, y=3.00, z=125.18], EntityVillager['Villager'/138, l='MpServer', x=46.47, y=3.00, z=113.16], EntityVillager['Villager'/139, l='MpServer', x=34.25, y=3.00, z=126.59], EntityVillager['Villager'/140, l='MpServer', x=36.53, y=4.00, z=112.19], EntityVillager['Villager'/141, l='MpServer', x=55.19, y=4.00, z=135.56], EntityVillager['Villager'/143, l='MpServer', x=58.59, y=4.00, z=128.31], EntityVillager['Villager'/144, l='MpServer', x=54.13, y=4.00, z=135.47], EntityVillager['Villager'/145, l='MpServer', x=56.47, y=5.00, z=133.03], EntityVillager['Villager'/146, l='MpServer', x=53.00, y=4.00, z=130.48], EntityVillager['Villager'/147, l='MpServer', x=52.97, y=4.00, z=128.38], EntityVillager['Villager'/148, l='MpServer', x=52.13, y=4.00, z=129.52], EntityVillager['Villager'/149, l='MpServer', x=56.44, y=5.00, z=138.66], EntityVillager['Villager'/150, l='MpServer', x=39.44, y=4.00, z=135.16], EntityVillager['Villager'/151, l='MpServer', x=52.41, y=4.00, z=133.97], EntityVillager['Villager'/152, l='MpServer', x=60.53, y=4.00, z=146.22], EntityVillager['Villager'/153, l='MpServer', x=61.31, y=4.00, z=135.06], EntityVillager['Villager'/154, l='MpServer', x=52.50, y=4.00, z=138.84], EntityVillager['Villager'/155, l='MpServer', x=46.69, y=4.00, z=121.66], EntityVillager['Villager'/156, l='MpServer', x=61.47, y=5.00, z=154.09], EntityVillager['Villager'/157, l='MpServer', x=52.13, y=4.00, z=158.03], EntityVillager['Villager'/158, l='MpServer', x=61.91, y=5.00, z=150.06], EntityVillager['Villager'/159, l='MpServer', x=61.25, y=4.00, z=132.78], EntityVillager['Villager'/160, l='MpServer', x=63.38, y=5.00, z=154.31], EntityVillager['Villager'/161, l='MpServer', x=25.63, y=5.00, z=122.56], EntityVillager['Villager'/162, l='MpServer', x=30.75, y=3.00, z=117.78], EntityVillager['Villager'/163, l='MpServer', x=21.34, y=5.00, z=125.28], EntityVillager['Villager'/164, l='MpServer', x=26.88, y=4.00, z=115.47], EntityVillager['Villager'/165, l='MpServer', x=29.25, y=4.00, z=120.88], EntityVillager['Villager'/166, l='MpServer', x=17.53, y=4.00, z=106.69], EntityVillager['Villager'/167, l='MpServer', x=23.28, y=5.00, z=109.72], EntityVillager['Villager'/168, l='MpServer', x=26.38, y=3.00, z=123.47], EntityBat['Bat'/169, l='MpServer', x=7.56, y=6.10, z=124.81], EntityVillager['Villager'/170, l='MpServer', x=51.38, y=4.00, z=102.47], EntityVillager['Villager'/171, l='MpServer', x=59.06, y=4.00, z=100.34], EntityVillager['Villager'/172, l='MpServer', x=60.13, y=4.00, z=100.56], EntityVillager['Villager'/173, l='MpServer', x=61.63, y=6.00, z=108.13], EntityVillager['Villager'/174, l='MpServer', x=63.28, y=4.00, z=106.53], EntityVillager['Villager'/175, l='MpServer', x=58.28, y=4.00, z=99.28], EntityVillager['Villager'/176, l='MpServer', x=52.22, y=4.00, z=103.41], EntityVillager['Villager'/177, l='MpServer', x=59.97, y=4.00, z=99.28], EntityVillager['Villager'/178, l='MpServer', x=42.75, y=4.00, z=140.69], EntityVillager['Villager'/179, l='MpServer', x=40.91, y=4.00, z=134.69], EntityVillager['Villager'/180, l='MpServer', x=36.53, y=4.00, z=141.13], EntityVillager['Villager'/181, l='MpServer', x=37.81, y=3.00, z=128.28], EntityVillager['Villager'/182, l='MpServer', x=41.84, y=5.00, z=142.47], EntityVillager['Villager'/183, l='MpServer', x=43.83, y=5.00, z=131.47], EntityVillager['Villager'/184, l='MpServer', x=43.63, y=4.00, z=140.28], EntityIceShards['entity.agkm.ice_shards.name'/67257, l='MpServer', x=62.88, y=5.44, z=135.49], EntityVillager['Villager'/185, l='MpServer', x=42.22, y=4.00, z=138.53], EntityPlayerSP['Player366'/186, l='MpServer', x=62.97, y=4.00, z=135.62], EntityVillager['Villager'/188, l='MpServer', x=62.45, y=4.00, z=131.92], EntityVillager['Villager'/189, l='MpServer', x=64.19, y=4.00, z=132.22], EntityVillager['Villager'/190, l='MpServer', x=72.96, y=5.00, z=138.75], EntityVillager['Villager'/191, l='MpServer', x=69.25, y=4.00, z=130.56], EntityVillager['Villager'/192, l='MpServer', x=47.72, y=4.00, z=148.50], EntityVillager['Villager'/193, l='MpServer', x=23.78, y=4.00, z=130.84], EntityVillager['Villager'/194, l='MpServer', x=81.59, y=4.00, z=124.66], EntityVillager['Villager'/195, l='MpServer', x=79.84, y=4.00, z=118.84], EntityVillager['Villager'/196, l='MpServer', x=27.06, y=4.00, z=144.59], EntityVillager['Villager'/197, l='MpServer', x=47.72, y=5.00, z=104.00], EntityVillager['Villager'/198, l='MpServer', x=42.84, y=3.00, z=110.13], EntityVillager['Villager'/199, l='MpServer', x=32.19, y=4.00, z=110.25], EntityVillager['Villager'/200, l='MpServer', x=43.69, y=2.00, z=109.28], EntityVillager['Villager'/201, l='MpServer', x=65.31, y=4.00, z=106.38], EntityVillager['Villager'/202, l='MpServer', x=64.50, y=4.00, z=108.81], EntityVillager['Villager'/203, l='MpServer', x=85.09, y=4.00, z=122.53], EntityVillager['Villager'/204, l='MpServer', x=77.66, y=4.00, z=126.28], EntityVillager['Villager'/205, l='MpServer', x=90.19, y=4.00, z=117.72], EntityVillager['Villager'/206, l='MpServer', x=18.38, y=4.00, z=101.34], EntityVillager['Villager'/207, l='MpServer', x=26.25, y=5.00, z=107.75], EntityVillager['Villager'/208, l='MpServer', x=24.59, y=4.00, z=101.25], EntityVillager['Villager'/209, l='MpServer', x=19.19, y=4.00, z=108.56], EntityVillager['Villager'/210, l='MpServer', x=23.69, y=4.00, z=102.47], EntityVillager['Villager'/211, l='MpServer', x=24.00, y=6.00, z=103.69], EntityVillager['Villager'/212, l='MpServer', x=12.47, y=3.00, z=132.81], EntityVillager['Villager'/213, l='MpServer', x=37.78, y=3.00, z=94.59], EntityVillager['Villager'/214, l='MpServer', x=47.81, y=9.00, z=83.44], EntityVillager['Villager'/215, l='MpServer', x=28.69, y=4.00, z=95.06], EntityBat['Bat'/217, l='MpServer', x=127.36, y=12.49, z=68.02]]

Retry entities: 0 total; []

Server brand: fml,forge

Server type: Integrated singleplayer server

Stacktrace:

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

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

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

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

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)

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)

at GradleStart.main(Unknown Source)

 

-- System Details --

Details:

Minecraft Version: 1.8

Operating System: Windows 8.1 (amd64) version 6.3

Java Version: 1.8.0_45, Oracle Corporation

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

Memory: 595797040 bytes (568 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)

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

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

FML: MCP v9.10 FML v8.0.99.99 Minecraft Forge 11.14.3.1450 4 mods loaded, 4 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.05} [Minecraft Coder Pack] (minecraft.jar)

UCHIJAAAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8-11.14.3.1450.jar)

UCHIJAAAA Forge{11.14.3.1450} [Minecraft Forge] (forgeSrc-1.8-11.14.3.1450.jar)

UCHIJAAAA agkm{1.0} [my mod Mod (AGK MOD)] (bin)

Loaded coremods (and transformers):

GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.4.13283 Compatibility Profile Context 14.501.1003.0' Renderer: 'ASUS R7 250X Series'

Launched Version: 1.8

LWJGL: 2.9.1

OpenGL: ASUS R7 250X Series GL version 4.4.13283 Compatibility Profile Context 14.501.1003.0, ATI Technologies Inc.

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: No

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)

[13:18:25] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:663]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\Tn1\Desktop\modding\eclipse\.\crash-reports\crash-2015-07-19_13.18.25-client.txt

AL lib: (EE) alc_cleanup: 1 device not closed

Java HotSpot 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release

 

 

 

I get error when i try to shift right click with that item.

:D
Link to comment
Share on other sites

Thanks, i know they can be null but they won't since they are only called when i use that item with shift right click i guess. Or am I using wrong function to get item in hand? i tried with .getHeldItem() but it gives same error, i will try to do packets.

:D
Link to comment
Share on other sites

- What does the "mc" thing point to in that code? It is not resolved from the code you pasted. It may be null.

- Are you sure the client player already exists when you open the GUI? Otherwise Minecraft#thePlayer will be null.

It's pointing to GuiScreen class

code:

 

 

package net.minecraft.client.gui;

 

import com.google.common.base.Splitter;

import com.google.common.collect.Lists;

import com.google.common.collect.Sets;

import java.awt.Toolkit;

import java.awt.datatransfer.ClipboardOwner;

import java.awt.datatransfer.DataFlavor;

import java.awt.datatransfer.StringSelection;

import java.awt.datatransfer.Transferable;

import java.io.File;

import java.io.IOException;

import java.net.URI;

import java.net.URISyntaxException;

import java.util.ArrayList;

import java.util.Arrays;

import java.util.Iterator;

import java.util.List;

import java.util.Set;

import net.minecraft.client.Minecraft;

import net.minecraft.client.gui.stream.GuiTwitchUserMode;

import net.minecraft.client.renderer.GlStateManager;

import net.minecraft.client.renderer.RenderHelper;

import net.minecraft.client.renderer.Tessellator;

import net.minecraft.client.renderer.WorldRenderer;

import net.minecraft.client.renderer.entity.RenderItem;

import net.minecraft.entity.EntityList;

import net.minecraft.event.ClickEvent;

import net.minecraft.event.HoverEvent;

import net.minecraft.item.ItemStack;

import net.minecraft.nbt.JsonToNBT;

import net.minecraft.nbt.NBTException;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.stats.Achievement;

import net.minecraft.stats.StatBase;

import net.minecraft.stats.StatList;

import net.minecraft.util.ChatComponentTranslation;

import net.minecraft.util.EnumChatFormatting;

import net.minecraft.util.IChatComponent;

import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent;

import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;

import net.minecraftforge.common.MinecraftForge;

import net.minecraftforge.fml.relauncher.Side;

import net.minecraftforge.fml.relauncher.SideOnly;

import org.apache.commons.lang3.StringUtils;

import org.apache.logging.log4j.LogManager;

import org.apache.logging.log4j.Logger;

import org.lwjgl.input.Keyboard;

import org.lwjgl.input.Mouse;

import tv.twitch.chat.ChatUserInfo;

 

@SideOnly(Side.CLIENT)

public abstract class GuiScreen extends Gui implements GuiYesNoCallback

{

    private static final Logger LOGGER = LogManager.getLogger();

    private static final Set PROTOCOLS = Sets.newHashSet(new String[] {"http", "https"});

    private static final Splitter NEWLINE_SPLITTER = Splitter.on('\n');

    /** Reference to the Minecraft object. */

    public Minecraft mc;

    /** Holds a instance of RenderItem, used to draw the achievement icons on screen (is based on ItemStack) */

    protected RenderItem itemRender;

    /** The width of the screen object. */

    public int width;

    /** The height of the screen object. */

    public int height;

    /** A list of all the buttons in this container. */

    protected List buttonList = Lists.newArrayList();

    /** A list of all the labels in this container. */

    protected List labelList = Lists.newArrayList();

    public boolean allowUserInput;

    /** The FontRenderer used by GuiScreen */

    protected FontRenderer fontRendererObj;

    /** The button that was just pressed. */

    private GuiButton selectedButton;

    private int eventButton;

    private long lastMouseEvent;

    /**

    * Incremented when the game is in touchscreen mode and the screen is tapped, decremented if the screen isn't

    * tapped. Does not appear to be used.

    */

    private int touchValue;

    private URI clickedLinkURI;

    private static final String __OBFID = "CL_00000710";

 

    /**

    * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks

    */

    public void drawScreen(int mouseX, int mouseY, float partialTicks)

    {

        int k;

 

        for (k = 0; k < this.buttonList.size(); ++k)

        {

            ((GuiButton)this.buttonList.get(k)).drawButton(this.mc, mouseX, mouseY);

        }

 

        for (k = 0; k < this.labelList.size(); ++k)

        {

            ((GuiLabel)this.labelList.get(k)).drawLabel(this.mc, mouseX, mouseY);

        }

    }

 

    /**

    * Fired when a key is typed (except F11 who toggle full screen). This is the equivalent of

    * KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)

    */

    protected void keyTyped(char typedChar, int keyCode) throws IOException

    {

        if (keyCode == 1)

        {

            this.mc.displayGuiScreen((GuiScreen)null);

 

            if (this.mc.currentScreen == null)

            {

                this.mc.setIngameFocus();

            }

        }

    }

 

    /**

    * Returns a string stored in the system clipboard.

    */

    public static String getClipboardString()

    {

        try

        {

            Transferable transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents((Object)null);

 

            if (transferable != null && transferable.isDataFlavorSupported(DataFlavor.stringFlavor))

            {

                return (String)transferable.getTransferData(DataFlavor.stringFlavor);

            }

        }

        catch (Exception exception)

        {

            ;

        }

 

        return "";

    }

 

    /**

    * Stores the given string in the system clipboard

    */

    public static void setClipboardString(String copyText)

    {

        if (!StringUtils.isEmpty(copyText))

        {

            try

            {

                StringSelection stringselection = new StringSelection(copyText);

                Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringselection, (ClipboardOwner)null);

            }

            catch (Exception exception)

            {

                ;

            }

        }

    }

 

    protected void renderToolTip(ItemStack stack, int x, int y)

    {

        List list = stack.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips);

 

        for (int k = 0; k < list.size(); ++k)

        {

            if (k == 0)

            {

                list.set(k, stack.getRarity().rarityColor + (String)list.get(k));

            }

            else

            {

                list.set(k, EnumChatFormatting.GRAY + (String)list.get(k));

            }

        }

 

        FontRenderer font = stack.getItem().getFontRenderer(stack);

        this.drawHoveringText(list, x, y, (font == null ? fontRendererObj : font));

    }

 

    /**

    * Draws the text when mouse is over creative inventory tab. Params: current creative tab to be checked, current

    * mouse x position, current mouse y position.

    */

    protected void drawCreativeTabHoveringText(String tabName, int mouseX, int mouseY)

    {

        this.drawHoveringText(Arrays.asList(new String[] {tabName}), mouseX, mouseY);

    }

 

    protected void drawHoveringText(List textLines, int x, int y)

    {

        drawHoveringText(textLines, x, y, fontRendererObj); 

    }

 

    protected void drawHoveringText(List textLines, int x, int y, FontRenderer font)

    {

        if (!textLines.isEmpty())

        {

            GlStateManager.disableRescaleNormal();

            RenderHelper.disableStandardItemLighting();

            GlStateManager.disableLighting();

            GlStateManager.disableDepth();

            int k = 0;

            Iterator iterator = textLines.iterator();

 

            while (iterator.hasNext())

            {

                String s = (String)iterator.next();

                int l = font.getStringWidth(s);

 

                if (l > k)

                {

                    k = l;

                }

            }

 

            int j2 = x + 12;

            int k2 = y - 12;

            int i1 = 8;

 

            if (textLines.size() > 1)

            {

                i1 += 2 + (textLines.size() - 1) * 10;

            }

 

            if (j2 + k > this.width)

            {

                j2 -= 28 + k;

            }

 

            if (k2 + i1 + 6 > this.height)

            {

                k2 = this.height - i1 - 6;

            }

 

            this.zLevel = 300.0F;

            this.itemRender.zLevel = 300.0F;

            int j1 = -267386864;

            this.drawGradientRect(j2 - 3, k2 - 4, j2 + k + 3, k2 - 3, j1, j1);

            this.drawGradientRect(j2 - 3, k2 + i1 + 3, j2 + k + 3, k2 + i1 + 4, j1, j1);

            this.drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 + i1 + 3, j1, j1);

            this.drawGradientRect(j2 - 4, k2 - 3, j2 - 3, k2 + i1 + 3, j1, j1);

            this.drawGradientRect(j2 + k + 3, k2 - 3, j2 + k + 4, k2 + i1 + 3, j1, j1);

            int k1 = 1347420415;

            int l1 = (k1 & 16711422) >> 1 | k1 & -16777216;

            this.drawGradientRect(j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + i1 + 3 - 1, k1, l1);

            this.drawGradientRect(j2 + k + 2, k2 - 3 + 1, j2 + k + 3, k2 + i1 + 3 - 1, k1, l1);

            this.drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 - 3 + 1, k1, k1);

            this.drawGradientRect(j2 - 3, k2 + i1 + 2, j2 + k + 3, k2 + i1 + 3, l1, l1);

 

            for (int i2 = 0; i2 < textLines.size(); ++i2)

            {

                String s1 = (String)textLines.get(i2);

                font.drawStringWithShadow(s1, j2, k2, -1);

 

                if (i2 == 0)

                {

                    k2 += 2;

                }

 

                k2 += 10;

            }

 

            this.zLevel = 0.0F;

            this.itemRender.zLevel = 0.0F;

            GlStateManager.enableLighting();

            GlStateManager.enableDepth();

            RenderHelper.enableStandardItemLighting();

            GlStateManager.enableRescaleNormal();

        }

    }

 

    protected void func_175272_a(IChatComponent p_175272_1_, int p_175272_2_, int p_175272_3_)

    {

        if (p_175272_1_ != null && p_175272_1_.getChatStyle().getChatHoverEvent() != null)

        {

            HoverEvent hoverevent = p_175272_1_.getChatStyle().getChatHoverEvent();

 

            if (hoverevent.getAction() == HoverEvent.Action.SHOW_ITEM)

            {

                ItemStack itemstack = null;

 

                try

                {

                    NBTTagCompound nbttagcompound = JsonToNBT.func_180713_a(hoverevent.getValue().getUnformattedText());

 

                    if (nbttagcompound instanceof NBTTagCompound)

                    {

                        itemstack = ItemStack.loadItemStackFromNBT((NBTTagCompound)nbttagcompound);

                    }

                }

                catch (NBTException nbtexception1)

                {

                    ;

                }

 

                if (itemstack != null)

                {

                    this.renderToolTip(itemstack, p_175272_2_, p_175272_3_);

                }

                else

                {

                    this.drawCreativeTabHoveringText(EnumChatFormatting.RED + "Invalid Item!", p_175272_2_, p_175272_3_);

                }

            }

            else

            {

                String s;

 

                if (hoverevent.getAction() == HoverEvent.Action.SHOW_ENTITY)

                {

                    if (this.mc.gameSettings.advancedItemTooltips)

                    {

                        try

                        {

                            NBTTagCompound nbttagcompound2 = JsonToNBT.func_180713_a(hoverevent.getValue().getUnformattedText());

 

                            if (nbttagcompound2 instanceof NBTTagCompound)

                            {

                                ArrayList arraylist1 = Lists.newArrayList();

                                NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttagcompound2;

                                arraylist1.add(nbttagcompound1.getString("name"));

 

                                if (nbttagcompound1.hasKey("type", 8))

                                {

                                    s = nbttagcompound1.getString("type");

                                    arraylist1.add("Type: " + s + " (" + EntityList.getIDFromString(s) + ")");

                                }

 

                                arraylist1.add(nbttagcompound1.getString("id"));

                                this.drawHoveringText(arraylist1, p_175272_2_, p_175272_3_);

                            }

                            else

                            {

                                this.drawCreativeTabHoveringText(EnumChatFormatting.RED + "Invalid Entity!", p_175272_2_, p_175272_3_);

                            }

                        }

                        catch (NBTException nbtexception)

                        {

                            this.drawCreativeTabHoveringText(EnumChatFormatting.RED + "Invalid Entity!", p_175272_2_, p_175272_3_);

                        }

                    }

                }

                else if (hoverevent.getAction() == HoverEvent.Action.SHOW_TEXT)

                {

                    this.drawHoveringText(NEWLINE_SPLITTER.splitToList(hoverevent.getValue().getFormattedText()), p_175272_2_, p_175272_3_);

                }

                else if (hoverevent.getAction() == HoverEvent.Action.SHOW_ACHIEVEMENT)

                {

                    StatBase statbase = StatList.getOneShotStat(hoverevent.getValue().getUnformattedText());

 

                    if (statbase != null)

                    {

                        IChatComponent ichatcomponent1 = statbase.getStatName();

                        ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("stats.tooltip.type." + (statbase.isAchievement() ? "achievement" : "statistic"), new Object[0]);

                        chatcomponenttranslation.getChatStyle().setItalic(Boolean.valueOf(true));

                        s = statbase instanceof Achievement ? ((Achievement)statbase).getDescription() : null;

                        ArrayList arraylist = Lists.newArrayList(new String[] {ichatcomponent1.getFormattedText(), chatcomponenttranslation.getFormattedText()});

 

                        if (s != null)

                        {

                            arraylist.addAll(this.fontRendererObj.listFormattedStringToWidth(s, 150));

                        }

 

                        this.drawHoveringText(arraylist, p_175272_2_, p_175272_3_);

                    }

                    else

                    {

                        this.drawCreativeTabHoveringText(EnumChatFormatting.RED + "Invalid statistic/achievement!", p_175272_2_, p_175272_3_);

                    }

                }

            }

 

            GlStateManager.disableLighting();

        }

    }

 

    /**

    * Sets the text of the chat

    * 

    * @param newChatText The new chat text to be set

    * @param shouldOverwrite Determines if the text currently in the chat should be overwritten or appended

    */

    protected void setText(String newChatText, boolean shouldOverwrite) {}

 

    protected boolean func_175276_a(IChatComponent p_175276_1_)

    {

        if (p_175276_1_ == null)

        {

            return false;

        }

        else

        {

            ClickEvent clickevent = p_175276_1_.getChatStyle().getChatClickEvent();

 

            if (isShiftKeyDown())

            {

                if (p_175276_1_.getChatStyle().getInsertion() != null)

                {

                    this.setText(p_175276_1_.getChatStyle().getInsertion(), false);

                }

            }

            else if (clickevent != null)

            {

                URI uri;

 

                if (clickevent.getAction() == ClickEvent.Action.OPEN_URL)

                {

                    if (!this.mc.gameSettings.chatLinks)

                    {

                        return false;

                    }

 

                    try

                    {

                        uri = new URI(clickevent.getValue());

 

                        if (!PROTOCOLS.contains(uri.getScheme().toLowerCase()))

                        {

                            throw new URISyntaxException(clickevent.getValue(), "Unsupported protocol: " + uri.getScheme().toLowerCase());

                        }

 

                        if (this.mc.gameSettings.chatLinksPrompt)

                        {

                            this.clickedLinkURI = uri;

                            this.mc.displayGuiScreen(new GuiConfirmOpenLink(this, clickevent.getValue(), 31102009, false));

                        }

                        else

                        {

                            this.func_175282_a(uri);

                        }

                    }

                    catch (URISyntaxException urisyntaxexception)

                    {

                        LOGGER.error("Can\'t open url for " + clickevent, urisyntaxexception);

                    }

                }

                else if (clickevent.getAction() == ClickEvent.Action.OPEN_FILE)

                {

                    uri = (new File(clickevent.getValue())).toURI();

                    this.func_175282_a(uri);

                }

                else if (clickevent.getAction() == ClickEvent.Action.SUGGEST_COMMAND)

                {

                    this.setText(clickevent.getValue(), true);

                }

                else if (clickevent.getAction() == ClickEvent.Action.RUN_COMMAND)

                {

                    this.sendChatMessage(clickevent.getValue(), false);

                }

                else if (clickevent.getAction() == ClickEvent.Action.TWITCH_USER_INFO)

                {

                    ChatUserInfo chatuserinfo = this.mc.getTwitchStream().func_152926_a(clickevent.getValue());

 

                    if (chatuserinfo != null)

                    {

                        this.mc.displayGuiScreen(new GuiTwitchUserMode(this.mc.getTwitchStream(), chatuserinfo));

                    }

                    else

                    {

                        LOGGER.error("Tried to handle twitch user but couldn\'t find them!");

                    }

                }

                else

                {

                    LOGGER.error("Don\'t know how to handle " + clickevent);

                }

 

                return true;

            }

 

            return false;

        }

    }

 

    public void sendChatMessage(String msg)

    {

        this.sendChatMessage(msg, true);

    }

 

    public void sendChatMessage(String msg, boolean addToChat)

    {

        if (addToChat)

        {

            this.mc.ingameGUI.getChatGUI().addToSentMessages(msg);

        }

 

        if (net.minecraftforge.client.ClientCommandHandler.instance.executeCommand(mc.thePlayer, msg) != 0) return;

        this.mc.thePlayer.sendChatMessage(msg);

    }

 

    /**

    * Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton

    */

    protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException

    {

        if (mouseButton == 0)

        {

            for (int l = 0; l < this.buttonList.size(); ++l)

            {

                GuiButton guibutton = (GuiButton)this.buttonList.get(l);

 

                if (guibutton.mousePressed(this.mc, mouseX, mouseY))

                {

                    ActionPerformedEvent.Pre event = new ActionPerformedEvent.Pre(this, guibutton, this.buttonList);

                    if (MinecraftForge.EVENT_BUS.post(event))

                        break;

                    this.selectedButton = event.button;

                    event.button.playPressSound(this.mc.getSoundHandler());

                    this.actionPerformed(event.button);

                    if (this.equals(this.mc.currentScreen))

                        MinecraftForge.EVENT_BUS.post(new ActionPerformedEvent.Post(this, event.button, this.buttonList));

                }

            }

        }

    }

 

    /**

    * Called when a mouse button is released.  Args : mouseX, mouseY, releaseButton

    */

    protected void mouseReleased(int mouseX, int mouseY, int state)

    {

        if (this.selectedButton != null && state == 0)

        {

            this.selectedButton.mouseReleased(mouseX, mouseY);

            this.selectedButton = null;

        }

    }

 

    /**

    * Called when a mouse button is pressed and the mouse is moved around. Parameters are : mouseX, mouseY,

    * lastButtonClicked & timeSinceMouseClick.

    */

    protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {}

 

    protected void actionPerformed(GuiButton button) throws IOException {}

 

    /**

    * Causes the screen to lay out its subcomponents again. This is the equivalent of the Java call

    * Container.validate()

    */

    public void setWorldAndResolution(Minecraft mc, int width, int height)

    {

        this.mc = mc;

        this.itemRender = mc.getRenderItem();

        this.fontRendererObj = mc.fontRendererObj;

        this.width = width;

        this.height = height;

        if (!MinecraftForge.EVENT_BUS.post(new InitGuiEvent.Pre(this, this.buttonList)))

        {

            this.buttonList.clear();

            this.initGui();

        }

        MinecraftForge.EVENT_BUS.post(new InitGuiEvent.Post(this, this.buttonList));

    }

 

    /**

    * Adds the buttons (and other controls) to the screen in question.

    */

    public void initGui() {}

 

    /**

    * Delegates mouse and keyboard input.

    */

    public void handleInput() throws IOException

    {

        if (Mouse.isCreated())

        {

            while (Mouse.next())

            {

                this.handleMouseInput();

            }

        }

 

        if (Keyboard.isCreated())

        {

            while (Keyboard.next())

            {

                this.handleKeyboardInput();

            }

        }

    }

 

    /**

    * Handles mouse input.

    */

    public void handleMouseInput() throws IOException

    {

        int i = Mouse.getEventX() * this.width / this.mc.displayWidth;

        int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;

        int k = Mouse.getEventButton();

 

        if (Mouse.getEventButtonState())

        {

            if (this.mc.gameSettings.touchscreen && this.touchValue++ > 0)

            {

                return;

            }

 

            this.eventButton = k;

            this.lastMouseEvent = Minecraft.getSystemTime();

            this.mouseClicked(i, j, this.eventButton);

        }

        else if (k != -1)

        {

            if (this.mc.gameSettings.touchscreen && --this.touchValue > 0)

            {

                return;

            }

 

            this.eventButton = -1;

            this.mouseReleased(i, j, k);

        }

        else if (this.eventButton != -1 && this.lastMouseEvent > 0L)

        {

            long l = Minecraft.getSystemTime() - this.lastMouseEvent;

            this.mouseClickMove(i, j, this.eventButton, l);

        }

    }

 

    /**

    * Handles keyboard input.

    */

    public void handleKeyboardInput() throws IOException

    {

        if (Keyboard.getEventKeyState())

        {

            this.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());

        }

 

        this.mc.dispatchKeypresses();

    }

 

    /**

    * Called from the main game loop to update the screen.

    */

    public void updateScreen() {}

 

    /**

    * Called when the screen is unloaded. Used to disable keyboard repeat events

    */

    public void onGuiClosed() {}

 

    /**

    * Draws either a gradient over the background screen (when it exists) or a flat gradient over background.png

    */

    public void drawDefaultBackground()

    {

        this.drawWorldBackground(0);

    }

 

    public void drawWorldBackground(int tint)

    {

        if (this.mc.theWorld != null)

        {

            this.drawGradientRect(0, 0, this.width, this.height, -1072689136, -804253680);

        }

        else

        {

            this.drawBackground(tint);

        }

    }

 

    /**

    * Draws the background (i is always 0 as of 1.2.2)

    */

    public void drawBackground(int tint)

    {

        GlStateManager.disableLighting();

        GlStateManager.disableFog();

        Tessellator tessellator = Tessellator.getInstance();

        WorldRenderer worldrenderer = tessellator.getWorldRenderer();

        this.mc.getTextureManager().bindTexture(optionsBackground);

        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

        float f = 32.0F;

        worldrenderer.startDrawingQuads();

        worldrenderer.setColorOpaque_I(4210752);

        worldrenderer.addVertexWithUV(0.0D, (double)this.height, 0.0D, 0.0D, (double)((float)this.height / f + (float)tint));

        worldrenderer.addVertexWithUV((double)this.width, (double)this.height, 0.0D, (double)((float)this.width / f), (double)((float)this.height / f + (float)tint));

        worldrenderer.addVertexWithUV((double)this.width, 0.0D, 0.0D, (double)((float)this.width / f), (double)tint);

        worldrenderer.addVertexWithUV(0.0D, 0.0D, 0.0D, 0.0D, (double)tint);

        tessellator.draw();

    }

 

    /**

    * Returns true if this GUI should pause the game when it is displayed in single-player

    */

    public boolean doesGuiPauseGame()

    {

        return true;

    }

 

    public void confirmClicked(boolean result, int id)

    {

        if (id == 31102009)

        {

            if (result)

            {

                this.func_175282_a(this.clickedLinkURI);

            }

 

            this.clickedLinkURI = null;

            this.mc.displayGuiScreen(this);

        }

    }

 

    private void func_175282_a(URI p_175282_1_)

    {

        try

        {

            Class oclass = Class.forName("java.awt.Desktop");

            Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]);

            oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {p_175282_1_});

        }

        catch (Throwable throwable)

        {

            LOGGER.error("Couldn\'t open link", throwable);

        }

    }

 

    /**

    * Returns true if either windows ctrl key is down or if either mac meta key is down

    */

    public static boolean isCtrlKeyDown()

    {

        return Minecraft.isRunningOnMac ? Keyboard.isKeyDown(219) || Keyboard.isKeyDown(220) : Keyboard.isKeyDown(29) || Keyboard.isKeyDown(157);

    }

 

    /**

    * Returns true if either shift key is down

    */

    public static boolean isShiftKeyDown()

    {

        return Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54);

    }

 

    public static boolean func_175283_s()

    {

        return Keyboard.isKeyDown(56) || Keyboard.isKeyDown(184);

    }

 

    public static boolean func_175277_d(int p_175277_0_)

    {

        return p_175277_0_ == 45 && isCtrlKeyDown();

    }

 

    public static boolean func_175279_e(int p_175279_0_)

    {

        return p_175279_0_ == 47 && isCtrlKeyDown();

    }

 

    public static boolean func_175280_f(int p_175280_0_)

    {

        return p_175280_0_ == 46 && isCtrlKeyDown();

    }

 

    public static boolean func_175278_g(int p_175278_0_)

    {

        return p_175278_0_ == 30 && isCtrlKeyDown();

    }

 

    public void func_175273_b(Minecraft mcIn, int p_175273_2_, int p_175273_3_)

    {

        this.setWorldAndResolution(mcIn, p_175273_2_, p_175273_3_);

    }

}

 

 

 

I did check now and it seems that mc is null. I don't have other ideas how to access players inventory so i guess only solution left is to do packets?

:D
Link to comment
Share on other sites

you are opening your gui via your gia handler. the handler gives you an entityplayer object that you can pass using the constructor of ur gui

Hey i tried that but i can't get it to work, NBT isn't working for me from gui, it won't set data i need. I don't get any errors but it just don't set data.

 

gui code:

 

 

package ga.warixmods.mymodmod.inventory;

 

import java.io.IOException;

 

import org.lwjgl.input.Keyboard;

 

import ga.warixmods.mymodmod.client.gui.GuiWandButton1;

import ga.warixmods.mymodmod.client.gui.GuiWandButton2;

import ga.warixmods.mymodmod.client.gui.GuiWandButton3;

import ga.warixmods.mymodmod.client.gui.GuiWandButton4;

import ga.warixmods.mymodmod.init.mymod2Items;

import net.minecraft.client.Minecraft;

import net.minecraft.client.gui.FontRenderer;

import net.minecraft.client.gui.GuiButton;

import net.minecraft.client.gui.GuiLabel;

import net.minecraft.client.gui.GuiScreen;

import net.minecraft.client.gui.GuiTextField;

import net.minecraft.client.renderer.GlStateManager;

import net.minecraft.client.renderer.Tessellator;

import net.minecraft.client.renderer.WorldRenderer;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.entity.player.InventoryPlayer;

import net.minecraft.init.Blocks;

import net.minecraft.inventory.Container;

import net.minecraft.inventory.ContainerRepair;

import net.minecraft.item.ItemStack;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.util.BlockPos;

import net.minecraft.util.ChatComponentTranslation;

import net.minecraft.util.IChatComponent;

import net.minecraft.util.ResourceLocation;

import net.minecraft.world.IInteractionObject;

import net.minecraft.world.World;

 

public class GuiWand extends GuiScreen{

public static final int GUI_ID = 20;

public static EntityPlayer playerIn;

public GuiWand (EntityPlayer playerIn1) {

playerIn = playerIn1;

}

    @Override

    public void initGui()

    {

    buttonList.add(new GuiWandButton1(0, width / 2 - 100 , height / 2 - 20,"1"));

    buttonList.add(new GuiWandButton2(1, width / 2 - 50, height / 2 - 20,"1"));

    buttonList.add(new GuiWandButton3(2, width / 2 + 0, height / 2 - 20,"1"));

    buttonList.add(new GuiWandButton4(3, width / 2  + 50, height / 2 - 20,"1"));

    }

    protected static final ResourceLocation buttonTextures1 = new ResourceLocation("agkm:textures/gui/demo_background.png");

@Override

    public void drawScreen(int mouseX, int mouseY, float partialTicks)

    {

this.drawDefaultBackground();

        mc.getTextureManager().bindTexture(buttonTextures1);

        this.drawTexturedModalRect(width / 2 - 125, height / 2 - 75,0,0, 247, 125);

        this.fontRendererObj.drawString("Choose the power you want to use:", width / 2- 100, height / 2  - 50, 1);

        super.drawScreen(mouseX, mouseY, partialTicks);

        mc.thePlayer.setCurrentItemOrArmor(4, new ItemStack(mymod2Items.murasame,1));

       

       

    }

    @Override

    public void actionPerformed(GuiButton button) throws IOException

    {

   

    NBTTagCompound nbt  = playerIn.getHeldItem().getTagCompound();

 

 

    switch(button.id)

    {

    case 0: 

 

   

    playerIn.getHeldItem().getTagCompound().setInteger("id", 0);

 

   

    this.mc.displayGuiScreen((GuiScreen)null);

    this.mc.setIngameFocus();

    break;

    case 1:

 

   

   

   

    playerIn.getHeldItem().getTagCompound().setInteger("id", 1);

   

   

    this.mc.displayGuiScreen((GuiScreen)null);

    this.mc.setIngameFocus();

    break;

    case 2:

   

    playerIn.getHeldItem().getTagCompound().setInteger("id", 2);

   

   

    this.mc.displayGuiScreen((GuiScreen)null);

    this.mc.setIngameFocus();

    break;

    case 3:

   

    playerIn.getHeldItem().getTagCompound().setInteger("id", 3);

   

   

    this.mc.displayGuiScreen((GuiScreen)null);

    this.mc.setIngameFocus();

    break;

   

   

   

   

    }

    this.updateScreen();

    }

 

 

 

 

 

 

}

 

 

 

 

reading from nbt:

 

package ga.warixmods.mymodmod.item;

 

import java.util.Random;

 

import ga.warixmods.mymodmod.mymod;

import ga.warixmods.mymodmod.entity.projectile.EntityIceShards;

import ga.warixmods.mymodmod.inventory.GuiWand;

import net.minecraft.block.Block;

import net.minecraft.block.BlockLiquid;

import net.minecraft.block.material.Material;

import net.minecraft.block.state.IBlockState;

import net.minecraft.client.Minecraft;

import net.minecraft.client.renderer.GlStateManager;

import net.minecraft.client.renderer.Tessellator;

import net.minecraft.client.renderer.WorldRenderer;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.entity.projectile.EntitySnowball;

import net.minecraft.init.Blocks;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.util.BlockPos;

import net.minecraft.util.EnumFacing;

import net.minecraft.util.MovingObjectPosition;

import net.minecraft.util.ResourceLocation;

import net.minecraft.world.World;

 

public class ItemsticksExtractWand extends Item {

 

private NBTTagCompound spower;

public int id;

Block isFull;

    IBlockState ice = Blocks.ice.getDefaultState();

    IBlockState packed_ice = Blocks.packed_ice.getDefaultState();

    public Minecraft mc;

    public int height = 100;

    public int width = 100;

    public static final ResourceLocation optionsBackground = new ResourceLocation("textures/gui/options_background.png");

    public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)

    {   

    if(!playerIn.isSneaking())

    {

   

   

   

   

    NBTTagCompound nbt = (NBTTagCompound) itemStackIn.getTagCompound();

   

id = nbt.getInteger("id");

switch(id)

{

case 0: iceShards(itemStackIn, worldIn, playerIn); break;

case 1:  break;

 

}

    }else 

    {

playerIn.openGui(mymod.instance, GuiWand.GUI_ID, worldIn, 0, 0, 0);

        }

return itemStackIn;

 

}

    public boolean onItemUse(ItemStack itemStackIn, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)

    {   

    if(!playerIn.isSneaking())

    {

   

NBTTagCompound nbt = (NBTTagCompound) itemStackIn.getTagCompound();

 

id = nbt.getInteger("id");

 

 

switch(id)

{

case 0:  break;

case 1: buildIce(itemStackIn, playerIn, worldIn, pos, side, hitZ, hitZ, hitZ); break;

 

}

 

 

    }else 

    {

    playerIn.openGui(mymod.instance, GuiWand.GUI_ID, worldIn, 0, 0, 0);

        }

        return false;

   

    }

    //on item right click

public void freezeTime(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)

{

 

}

public void iceShards(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)

{

        worldIn.playSoundAtEntity(playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if(!worldIn.isRemote)

        {

        worldIn.spawnEntityInWorld(new EntityIceShards(worldIn, playerIn));

        }

}

//on item right click on block

public void freezeWater(ItemStack stack, EntityPlayer playerIn, World worldIn)

{

 

boolean isEmpty = true;

MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, isEmpty);

if(movingobjectposition != null)

{

if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK  )

        {

BlockPos pos =  movingobjectposition.getBlockPos();

int y = pos.getY();

 

BlockPos northeast = new BlockPos( pos.getX() + 1 , y , pos.getZ() - 1 );

BlockPos northwest = new BlockPos( pos.getX() - 1 , y , pos.getZ() - 1 );

BlockPos southwest = new BlockPos( pos.getX() - 1 , y , pos.getZ() + 1 );

BlockPos southeast = new BlockPos( pos.getX() + 1 , y , pos.getZ() + 1 );

if(isWater(pos,worldIn))

{

worldIn.setBlockState(pos, getRandomState(ice,packed_ice));

}

if(isWater(pos.north(),worldIn))

{

worldIn.setBlockState(pos.north(), getRandomState(ice,packed_ice));

}

if(isWater(pos.north(2),worldIn))

{

worldIn.setBlockState(pos.north(2), getRandomState(ice,packed_ice));

}

if(isWater(pos.west(),worldIn))

{

worldIn.setBlockState(pos.west(), getRandomState(ice,packed_ice));

}

if(isWater(pos.west(2),worldIn))

{

worldIn.setBlockState(pos.west(2), getRandomState(ice,packed_ice));

}

if(isWater(pos.south(),worldIn))

{

worldIn.setBlockState(pos.south(), getRandomState(ice,packed_ice));

}

if(isWater(pos.south(2),worldIn))

{

worldIn.setBlockState(pos.south(2), getRandomState(ice,packed_ice));

}

if(isWater(pos.east(),worldIn))

{

worldIn.setBlockState(pos.east(), getRandomState(ice,packed_ice));

}

if(isWater(pos.east(2),worldIn))

{

worldIn.setBlockState(pos.east(2), getRandomState(ice,packed_ice));

}

if(isWater(northeast,worldIn))

{

worldIn.setBlockState(northeast, getRandomState(ice,packed_ice));

}

if(isWater(northwest,worldIn))

{

worldIn.setBlockState(northwest, getRandomState(ice,packed_ice));

}

if(isWater(southwest,worldIn))

{

worldIn.setBlockState(southwest, getRandomState(ice,packed_ice));

}

if(isWater(southeast,worldIn))

{

worldIn.setBlockState(southeast, getRandomState(ice,packed_ice));

}

       

}

}

}

 

public void buildIce(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)

{

if(!worldIn.isRemote)

{

worldIn.setBlockState(pos.up(), getRandomState(ice,packed_ice));

worldIn.setBlockState(pos.down(), getRandomState(ice,packed_ice));

worldIn.setBlockState(pos.east(), getRandomState(ice,packed_ice));

worldIn.setBlockState(pos.west(), getRandomState(ice,packed_ice));

worldIn.setBlockState(pos.north(), getRandomState(ice,packed_ice));

worldIn.setBlockState(pos.south(), getRandomState(ice,packed_ice));

}

worldIn.markBlockForUpdate(pos.up());

worldIn.markBlockForUpdate(pos.down());

worldIn.markBlockForUpdate(pos.east());

worldIn.markBlockForUpdate(pos.west());

worldIn.markBlockForUpdate(pos.north());

worldIn.markBlockForUpdate(pos.south());

}

  public IBlockState getRandomState(IBlockState state1, IBlockState state2)

    {

if(new Random().nextInt(100) > 50)

{

return state1;

}

else

{

return state2;

}

 

}

 

 

  public boolean isWater(BlockPos pos,World worldIn)

  {

  IBlockState iblockstate = worldIn.getBlockState(pos);

      Material material = iblockstate.getBlock().getMaterial();

  if(material == Material.water && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0)

  {

  return true;

  }

  else

  {

  return false;

  }

 

  }

 

 

 

}

 

 

setting nbt:

 

package ga.warixmods.mymodmod.item;

 

import ga.warixmods.mymodmod.entity.player.WandInventory;

import ga.warixmods.mymodmod.init.mymod2Items;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.ItemFood;

import net.minecraft.item.ItemStack;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.world.World;

 

public class ItemsticksExtract extends ItemFood{

 

public ItemsticksExtract(int amount, boolean isWolfFood) {

super(amount, isWolfFood);

// TODO Auto-generated constructor stub

 

}

    protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player)

    {

    ItemStack wand = new ItemStack(mymod2Items.sticks_extract_wand,1);

   

   

 

NBTTagCompound nbt = new NBTTagCompound();

nbt.setInteger("id", 0);

wand.setTagCompound(nbt);

   

    if(player.inventory.getFirstEmptyStack() != -1)

    {

        player.inventory.addItemStackToInventory(wand);

    }

    else

    {

    player.entityDropItem(wand, 0);

    }

       

    }

 

 

}

 

 

:D
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.