Posted April 5, 201411 yr English: Hey, I'm new in modding and I want to write an Minecraft Mod which adds an Logitech G19(s) applet but I haven't figured out how to get the players life or foodlevel if the Client connects to a server or one of those are changing. --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- German: Hey, Ich bin recht neu im modden und habe vor ein applet für die Logitech G19(s) zu machen doch ich kriege es einfach nicht hin das Leben / den Hunger Status des Spielers zu bekommen wenn er auf einen Server verbindet oder sich das Leben bzw. der Hunger Status ändert. Mfg FFS2309
April 5, 201411 yr Author I know this methods but from where can I get the Player Object , thats my main question . (Mein Englisch ist nicht das beste ... )
April 5, 201411 yr Author Thanks but which event can I use because at the ClientConnectedToServerEvent it is giving an error [16:02:14] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLTweaker [16:02:14] [main/INFO] [LaunchWrapper]: Using primary tweak class name cpw.mods.fml.common.launcher.FMLTweaker [16:02:14] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLTweaker [16:02:14] [main/INFO] [FML]: Forge Mod Loader version 7.2.116.1024 for Minecraft 1.7.2 loading [16:02:14] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.7.0_45, running on Windows 7:amd64:6.1, installed at K:\Program Files\Java\jre7 [16:02:14] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation [16:02:14] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker [16:02:14] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLDeobfTweaker [16:02:14] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker [16:02:14] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker [16:02:14] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper [16:02:14] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work! [16:02:15] [main/ERROR] [FML]: The minecraft jar file:/C:/Users/Fabi/.gradle/caches/minecraft/net/minecraftforge/forge/1.7.2-10.12.0.1024/forgeSrc-1.7.2-10.12.0.1024.jar!/net/minecraft/client/ClientBrandRetriever.class appears to be corrupt! There has been CRITICAL TAMPERING WITH MINECRAFT, it is highly unlikely minecraft will work! STOP NOW, get a clean copy and try again! [16:02:15] [main/ERROR] [FML]: FML has been ordered to ignore the invalid or missing minecraft certificate. This is very likely to cause a problem! [16:02:15] [main/ERROR] [FML]: Technical information: ClientBrandRetriever was at jar:file:/C:/Users/Fabi/.gradle/caches/minecraft/net/minecraftforge/forge/1.7.2-10.12.0.1024/forgeSrc-1.7.2-10.12.0.1024.jar!/net/minecraft/client/ClientBrandRetriever.class, there were 0 certificates for it [16:02:15] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing [16:02:15] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper [16:02:15] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLDeobfTweaker [16:02:15] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main} [16:02:16] [main/INFO]: Setting user: Player387 [16:02:16] [Client thread/INFO]: LWJGL Version: 2.9.0 [16:02:17] [Client thread/INFO] [MinecraftForge]: Attempting early MinecraftForge initialization [16:02:17] [Client thread/INFO] [FML]: MinecraftForge v10.12.0.1024 Initialized [16:02:17] [Client thread/INFO] [FML]: Replaced 128 ore recipies [16:02:17] [Client thread/INFO] [MinecraftForge]: Completed early MinecraftForge initialization [16:02:17] [Client thread/INFO] [FML]: Searching E:\Programmieren\ForgeMCP\eclipse\mods for mods [16:02:18] [Client thread/ERROR] [FML]: FML has detected a mod that is using a package name based on 'net.minecraft.src' : net.minecraft.src.FMLRenderAccessLibrary. This is generally a severe programming error. There should be no mod code in the minecraft namespace. MOVE YOUR MOD! If you're in eclipse, select your source code and 'refactor' it into a new package. Go on. DO IT NOW! [16:02:19] [Client thread/INFO] [FML]: Forge Mod Loader has identified 4 mods to load [16:02:19] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:MCLCD [16:02:19] [Client thread/INFO] [FML]: Configured a dormant chunk cache size of 0 Starting up SoundSystem... Initializing LWJGL OpenAL (The LWJGL binding of OpenAL. For more information, see http://www.lwjgl.org) OpenAL initialized. [16:02:20] [sound Library Loader/INFO]: Sound engine started [16:02:20] [Client thread/INFO]: Created: 512x256 textures/blocks-atlas [16:02:20] [Client thread/INFO]: Created: 256x256 textures/items-atlas [16:02:20] [Client thread/INFO] [FML]: Forge Mod Loader has successfully loaded 4 mods [16:02:21] [MCO Availability Checker #1/ERROR]: Couldn't connect to Realms [16:02:25] [Client thread/INFO]: Connecting to ***., 25566 [16:02:26] [Netty Client IO #0/INFO] [FML]: [Netty Client IO #0] Client side vanilla connection established [16:02:26] [Netty Client IO #0/ERROR] [FML]: HandshakeMessageHandler exception java.lang.NullPointerException at de.impulsecraft.event.EventsHandler.drawStats(EventsHandler.java:61) ~[EventsHandler.class:?] at de.impulsecraft.event.EventsHandler.onClientConnectToServer(EventsHandler.java:51) ~[EventsHandler.class:?] at cpw.mods.fml.common.eventhandler.ASMEventHandler_4_EventsHandler_onClientConnectToServer_ClientConnectedToServerEvent.invoke(.dynamic) ~[?:?] at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51) ~[ASMEventHandler.class:?] at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122) ~[EventBus.class:?] at cpw.mods.fml.common.network.handshake.NetworkDispatcher.completeClientSideConnection(NetworkDispatcher.java:163) ~[NetworkDispatcher.class:?] at cpw.mods.fml.common.network.handshake.NetworkDispatcher.abortClientHandshake(NetworkDispatcher.java:439) ~[NetworkDispatcher.class:?] at cpw.mods.fml.common.network.handshake.FMLHandshakeClientState$2.accept(FMLHandshakeClientState.java:46) ~[FMLHandshakeClientState$2.class:?] at cpw.mods.fml.common.network.handshake.FMLHandshakeClientState$2.accept(FMLHandshakeClientState.java:36) ~[FMLHandshakeClientState$2.class:?] at cpw.mods.fml.common.network.handshake.HandshakeMessageHandler.userEventTriggered(HandshakeMessageHandler.java:40) ~[HandshakeMessageHandler.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeUserEventTriggered(DefaultChannelHandlerContext.java:308) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.fireUserEventTriggered(DefaultChannelHandlerContext.java:294) [DefaultChannelHandlerContext.class:?] at io.netty.channel.ChannelInboundHandlerAdapter.userEventTriggered(ChannelInboundHandlerAdapter.java:108) [ChannelInboundHandlerAdapter.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeUserEventTriggered(DefaultChannelHandlerContext.java:308) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.fireUserEventTriggered(DefaultChannelHandlerContext.java:294) [DefaultChannelHandlerContext.class:?] at io.netty.channel.ChannelInboundHandlerAdapter.userEventTriggered(ChannelInboundHandlerAdapter.java:108) [ChannelInboundHandlerAdapter.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeUserEventTriggered(DefaultChannelHandlerContext.java:308) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.fireUserEventTriggered(DefaultChannelHandlerContext.java:294) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelPipeline.fireUserEventTriggered(DefaultChannelPipeline.java:779) [DefaultChannelPipeline.class:?] at cpw.mods.fml.common.network.handshake.NetworkDispatcher.handleVanilla(NetworkDispatcher.java:200) [NetworkDispatcher.class:?] at cpw.mods.fml.common.network.handshake.NetworkDispatcher.channelRead0(NetworkDispatcher.java:188) [NetworkDispatcher.class:?] at cpw.mods.fml.common.network.handshake.NetworkDispatcher.channelRead0(NetworkDispatcher.java:42) [NetworkDispatcher.class:?] at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:98) [simpleChannelInboundHandler.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?] at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:173) [byteToMessageDecoder.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?] at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:173) [byteToMessageDecoder.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?] at io.netty.handler.timeout.ReadTimeoutHandler.channelRead(ReadTimeoutHandler.java:149) [ReadTimeoutHandler.class:?] at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) [DefaultChannelHandlerContext.class:?] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) [DefaultChannelPipeline.class:?] at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:100) [AbstractNioByteChannel$NioByteUnsafe.class:?] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:480) [NioEventLoop.class:?] at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:447) [NioEventLoop.class:?] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:341) [NioEventLoop.class:?] at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101) [singleThreadEventExecutor$2.class:?] at java.lang.Thread.run(Unknown Source) [?:1.7.0_45] [16:02:26] [Client thread/INFO]: [CHAT] Player387 joined the game. It is an unmodded bukkit server maybe this is the problem ? Or is there any Event which I can user for connecting, but then i also need one for the change of the value of live and foodlevel Mfg FFS2309 //EDIT At line 61 I'm having the code p.getHealth(); if I remove this it is throwing the same exception but with the line from p.getFoodStats().getFoodLevel();
April 5, 201411 yr Author 1. Like sayed in the first post I'm writing a mod which gets info like Health and displays on a Logitech G19s 2. How do I use a TickHandler ? I've searched in the jds, google(in the most time useless cause you only find stuff like how to install forge ...) and in this Forum but I don't find any way for 1.7.2 Mfg FFS2309
April 5, 201411 yr Author 1. I need like nothing from Forge , only Playerinfo the rest is to get a Graphics object from the Keyboard where I draw everything and the code for my Classes: EventHandler.java package de.impulsecraft.event; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.io.IOException; import com.mojang.authlib.minecraft.MinecraftSessionService; import scala.collection.parallel.immutable.Repetition; import net.djpowell.lcdjni.LcdConnection; import net.djpowell.lcdjni.LcdDevice; import net.djpowell.lcdjni.LcdRGBABitmap; import net.djpowell.lcdjni.Priority; import net.djpowell.lcdjni.SyncType; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.settings.GameSettings; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.network.Packet; import net.minecraft.server.management.PlayerManager; import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.common.MinecraftForge; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent; import cpw.mods.fml.common.gameevent.TickEvent.WorldTickEvent; import cpw.mods.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent; import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.Side; import de.impulsecraft.mclcd.MCLcd; public class EventsHandler { public LcdConnection con = MCLcd.instance.con; public LcdDevice device = MCLcd.instance.device; public LcdRGBABitmap cbmp = device.createRGBABitmap(); @SubscribeEvent public void onClientConnectToServer(ClientConnectedToServerEvent event){ drawStats(); } private void drawStats(){ EntityClientPlayerMP p = Minecraft.getMinecraft().thePlayer; float health = p.getHealth(); int hunger = p.getFoodStats().getFoodLevel(); String Playername = p.getDisplayName(); Graphics g = cbmp.getGraphics(); g.setColor(Color.BLUE); g.fillRect(0, 0, cbmp.getImage().getWidth(), cbmp.getImage().getHeight()); g.setColor(Color.RED); g.setFont(g.getFont().deriveFont(Font.BOLD, 20)); g.drawString("Life:" + health,0 ,30); g.drawString("Satuation:" + hunger, 0, 50); g.drawString(Playername, 0, 100); g.dispose(); cbmp.updateScreen(Priority.ALERT, SyncType.SYNC); try { cbmp.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } MCLcd.java(Main Class) package de.impulsecraft.mclcd; import java.awt.Color; import java.awt.Graphics; import java.awt.Image; import java.awt.image.BufferedImage; import java.awt.image.ImageConsumer; import java.awt.image.ImageProducer; import java.io.File; import java.io.IOException; import java.sql.ClientInfoStatus; import javax.imageio.ImageIO; import javax.imageio.stream.ImageInputStream; import com.mojang.authlib.GameProfile; import com.mojang.authlib.yggdrasil.response.User.Property; import net.djpowell.lcdjni.AppletCapability; import net.djpowell.lcdjni.DeviceType; import net.djpowell.lcdjni.LcdConnection; import net.djpowell.lcdjni.LcdDevice; import net.djpowell.lcdjni.LcdRGBABitmap; import net.djpowell.lcdjni.Priority; import net.djpowell.lcdjni.SyncType; import net.minecraft.client.settings.GameSettings; import net.minecraft.entity.player.EntityPlayer; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; // used in 1.6.2 //import cpw.mods.fml.common.Mod.PreInit; // used in 1.5.2 //import cpw.mods.fml.common.Mod.Init; // used in 1.5.2 //import cpw.mods.fml.common.Mod.PostInit; // used in 1.5.2 import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLEvent; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLModDisabledEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; import cpw.mods.fml.common.gameevent.TickEvent.WorldTickEvent; import cpw.mods.fml.common.network.internal.FMLNetworkHandler; import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.common.registry.GameRegistry; import de.impulsecraft.event.EventsHandler; //import cpw.mods.fml.common.network.NetworkMod; // not used in 1.7 @Mod(modid="MCLCD", name="MCLcd", version="0.0.1") //@NetworkMod(clientSideRequired=true) // not used in 1.7 public class MCLcd { // The instance of your mod that Forge uses. @Instance(value = "MCLCD") public static MCLcd instance; public LcdConnection con; public LcdDevice device; // Says where the client and server 'proxy' code is loaded. @SidedProxy(clientSide="de.impulsecraft.client.ClientProxy", serverSide="de.impulsecraft.mclcd.CommonProxy") public static CommonProxy proxy; @EventHandler // used in 1.6.2 //@PreInit // used in 1.5.2 public void preInit(FMLPreInitializationEvent event) { // Stub Method } @EventHandler // used in 1.6.2 //@Init // used in 1.5.2 public void load(FMLInitializationEvent event) { proxy.registerRenderers(); } @EventHandler // used in 1.6.2 //@PostInit // used in 1.5.2 public void postInit(FMLPostInitializationEvent event) { con = new LcdConnection("Minecraft", false, AppletCapability.getCaps(AppletCapability.QVGA), null, null); device = con.openDevice(DeviceType.QVGA, null); FMLCommonHandler.instance().bus().register(new EventsHandler()); } @EventHandler public void modDisabled(FMLModDisabledEvent event){ con.close(); } public void test(){ } } The Proxy classes don't contain any code, only a registerRenderers() method of type void which also contains nothing 2. I think I should use that as normal Event or is there something special ? Mfg FFS2309
April 5, 201411 yr Author Thanks, I will try but isn't it very performance intensive to check every time ? (I don't care it has to work fine on my pc but if I would publish it in the far future is that something I would care about)
April 5, 201411 yr Author Thanks that is working just fine but only with TickType.PLAYER else the client crashes
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.