Everything posted by lorizz
-
[SOLVED]IItemRenderer not rendering EQUIPPED and EQUIPPED_FIRST_PERSON texture!
I used the EntityLiving for tessellator, but if it crashes... EDIT: I have no idea on how to do that, I tried with this.renderItem(); method but it crashes when I equip it! How can I do that? I don't understand at all the code you gave to me
-
[SOLVED]IItemRenderer not rendering EQUIPPED and EQUIPPED_FIRST_PERSON texture!
Hi guys I'm lorizz and I need to know why my IItemRenderer class, that is used for a class EXTENDING TO A SWORD, doesn't render my texture in case of EQUIPPED and EQUIPPED_FIRST_PERSON, if I don't use those it renders the texture normally but I need to move the model, so this is why I use IItemRenderer (I use it for another reason that you will may find in my code)! This is the IItemRenderer class: package it.exoworld_client.renderer; import it.exoworld_client.ExoWorld_Client; import it.exoworld_client.extender.ItemDaggerExtender; import it.exoworld_client.registry.ItemRegistry; import it.exoworld_client.watcher.PlayerInformation; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.entity.EntityLiving; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraftforge.client.IItemRenderer; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import cpw.mods.fml.client.FMLClientHandler; public class ItemDaggerRenderer implements IItemRenderer { private static RenderItem renderItem = new RenderItem(); private Minecraft mc; @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { // TODO Auto-generated method stub return type == ItemRenderType.INVENTORY || type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON; } @Override public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { // TODO Auto-generated method stub return false; } @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { EntityLiving entity = (EntityLiving) data[1]; ItemRenderer itemRenderer = this.mc.entityRenderer.itemRenderer; PlayerInformation props = PlayerInformation.get(Minecraft .getMinecraft().thePlayer); ItemDaggerExtender dagger = (ItemDaggerExtender) item.getItem(); int selectedClass = props.getSelectedClass(); int classConfirm = props.getClassConfirm(); Icon daggerIcon = dagger.getIconIndex(item); Icon daggerWrongClass = ItemRegistry.daggerWrongClass .getIconIndex(item); if (type == ItemRenderType.INVENTORY) { if (classConfirm != 1 && selectedClass != 1) { this.renderItem.renderIcon(0, 0, daggerWrongClass, 16, 16); } else { this.renderItem.renderIcon(0, 0, daggerIcon, 16, 16); } } GL11.glPushMatrix(); FMLClientHandler.instance().getClient().renderEngine .bindTexture("/mods/" + ExoWorld_Client.modid + "/textures/items/dagger/" + dagger.getUnlocalizedName().substring(5) + ".png"); if(type == ItemRenderType.EQUIPPED) { } else if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) { } GL11.glPopMatrix(); } } I tried using "Minecraft.getMinecraft().renderEngine.bindTexture()" method but still not working, also I tried using tessellator...crash because of "EntityLiving entity = (EntityLiving) data[1];" and I don't know why, it tells me "ArrayIndexOutOfBounds". Who can help me? Maybe it doesn't work because it's used for a class that extends to a custom extender that extends to an ItemSword? Does my extender need to extends to an Item? I can make my own ItemSword if I need so. Thanks! (I'm italian sorry for my bad english...if I made some grammar mistakes)
-
[SOLVED] DataWatcher crash on RenderGameOverlay
1)yes 2)yes Edit: SOLVED! I didn't register the event in clientside too, only serverside! Thanks anyway!
-
[SOLVED] DataWatcher crash on RenderGameOverlay
How can I fix it? if(this.mc.thePlayer != null) didn't work
-
[SOLVED] DataWatcher crash on RenderGameOverlay
Hi guys, today I learned about DW, I create a class that implements IExtendedEntityProperties and registered my DW. After registering those in EntityConstructing event, they worked perfectly! Load and save are perfect! But the problem is there...... The RenderGameOverlay, it crashes I think because of this cast PlayerInformation props = PlayerInformation.get((EntityPlayer) this.mc.thePlayer); There's always a problem with Player cast D: Here's my PlayerInformation that implements IExtendedEntityProperties: Where it loads in EntityConstructing event: Where it crashes in RenderGameOverlay event: That's the crash log, it's a NullPointer: Please help me, I need to release my mod next two months!
-
Help with custom chat packet handling (casting EntityClientPlayerMP problem)
bump
-
Help with custom chat packet handling (casting EntityClientPlayerMP problem)
Huh...no, quite the opposite actually. By the way, gui is client side only, so you don't need to check. Done, but now it shows me this error with my new code: METHOD: public static void sendPacket(EntityPlayer entityPlayer) { EntityClientPlayerMP player = (EntityClientPlayerMP) entityPlayer; ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream(); DataOutputStream dataOutputStream = new DataOutputStream( byteOutputStream); try { dataOutputStream.writeInt(player.entityId);// this info is unused // when handling the // packet ?? } catch (Exception e) { e.printStackTrace(); } Packet250CustomPayload packet = new Packet250CustomPayload( ECPacketHandler.GCHATSYNC, byteOutputStream.toByteArray()); FMLClientHandler.instance().sendPacket(packet); } ERROR: Caused by: java.lang.RuntimeException: Attempted to load class mods/enetchat/client/gui/EGuiChatGeneral for invalid side SERVER at cpw.mods.fml.common.asm.transformers.SideTransformer.transform(SideTransformer.java:50) at cpw.mods.fml.relauncher.RelaunchClassLoader.runTransformers(RelaunchClassLoader.java:352) at cpw.mods.fml.relauncher.RelaunchClassLoader.findClass(RelaunchClassLoader.java:225) ... 18 more
-
Help With Read Text From File
If you use a MySQL Api it would be very very easy... Use someting like JDBC (Java DataBase Connection)
-
Hardcore Mode in multiplayer server
Why are you creating a Hardcore Mod while there is already one made by Minecraft?... People's brain Anyway make a command like /stopmod or /modstop that when it's done it will close the server, on the server close (so with the FMLOnServerStoppingEvent) save everything you need to be saved. If you can't stop the server check in the MinecraftServer package
-
Help with custom chat packet handling (casting EntityClientPlayerMP problem)
Hey guys, I need help with my own custom chat. I created a chat that implements group system (made by me) and a general one, that is used like as the normal, the problem is the packet handling! I cannot cast EntityClientPlayerMP with EntityPlayerMP and I know that so I'm here to ask you how to do this! I want that when a player write something in the custom chat, it will be showed for every player in the server. PacketHandler class: package mods.enetchat.client.handler; import mods.enetchat.client.gui.EGuiChatGeneral; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.util.EnumChatFormatting; import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteStreams; import cpw.mods.fml.common.network.IPacketHandler; import cpw.mods.fml.common.network.Player; public class ECPacketHandler implements IPacketHandler { public EGuiChatGeneral cGeneral; @Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player playerEntity) { if (packet.channel.equals("GeneralChatSync")) { sendChatMessage(packet, (EntityPlayer) playerEntity); } } public void sendChatMessage(Packet250CustomPayload packet, EntityPlayer player) { String msg = EnumChatFormatting.AQUA + "[Generale] " + EnumChatFormatting.YELLOW + player.username + ":" + EnumChatFormatting.WHITE + " " + cGeneral.stringInInputFieldText; player.addChatMessage(msg); } } EGuiChatGeneral (where there is the sendPacket method and the function to execute): package mods.enetchat.client.gui; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.net.URI; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Random; import mods.enetchat.client.GroupFunctions; import mods.enetchat.client.entity.CustomEntityPlayer; import mods.enetchat.client.gui.groupfunction.GroupSelectionPhase1; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.gui.ChatClickData; import net.minecraft.client.gui.GuiConfirmOpenLink; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiTextField; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.network.packet.Packet203AutoComplete; import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.world.World; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class EGuiChatGeneral extends GuiScreen { private String field_73898_b = ""; /** * keeps position of which chat message you will select when you press up, * (does not increase for duplicated messages sent immediately after each * other) */ private int sentHistoryCursor = -1; private boolean field_73897_d = false; private boolean field_73905_m = false; private int field_73903_n = 0; private List field_73904_o = new ArrayList(); /** used to pass around the URI to various dialogues and to the host os */ private URI clickedURI = null; /** Chat entry field */ protected GuiTextField inputField; /** Channels */ private GuiTextField channelGeneral; private GuiTextField channelGroup; /** Class includes */ public GroupFunctions groupFunctions = new GroupFunctions(); public CustomEntityPlayer customEntityPlayer; public GroupSelectionPhase1 groupSelectionPhase1 = new GroupSelectionPhase1( this); /** Various strings */ private String stringGroupName = this.groupSelectionPhase1.localizedNewWorldText; /** * is the text that appears when you press the chat key and the input box * appears pre-filled */ public static String stringInInputFieldText; private String defaultInputFieldText = ""; public EGuiChatGeneral() { } public EGuiChatGeneral(String par1Str) { this.defaultInputFieldText = par1Str; } /** * Adds the buttons (and other controls) to the screen in question. */ public void initGui() { Keyboard.enableRepeatEvents(true); this.sentHistoryCursor = this.mc.ingameGUI.getChatGUI() .getSentMessages().size(); this.inputField = new GuiTextField(this.fontRenderer, 0, this.height - 25, this.width - 0, 23); this.inputField.setMaxStringLength(100); this.inputField.setEnableBackgroundDrawing(true); this.inputField.setFocused(true); this.inputField.setText(this.defaultInputFieldText); this.inputField.setCanLoseFocus(false); // Channel List this.channelGeneral = new GuiTextField(this.fontRenderer, 320, this.height - 38, 53, 12); this.channelGeneral.setMaxStringLength(24); this.channelGeneral.setEnableBackgroundDrawing(true); this.channelGeneral.setText("\u00A7bGenerale"); this.channelGeneral.setCanLoseFocus(true); this.channelGroup = new GuiTextField(this.fontRenderer, 320 + 53, this.height - 38, 53, 12); this.channelGroup.setMaxStringLength(24); this.channelGroup.setEnableBackgroundDrawing(true); this.channelGroup.setText("\u00A7fGruppo"); this.channelGroup.setCanLoseFocus(true); } /** * Called when the screen is unloaded. Used to disable keyboard repeat * events */ public void onGuiClosed() { Keyboard.enableRepeatEvents(false); this.mc.ingameGUI.getChatGUI().resetScroll(); } /** * Called from the main game loop to update the screen. */ public void updateScreen() { this.inputField.updateCursorCounter(); } /** * Fired when a key is typed. This is the equivalent of * KeyListener.keyTyped(KeyEvent e). */ public void sendPacket(World world, EntityPlayer playerEntity) { Random random = new Random(); int randomInt1 = random.nextInt(); int randomInt2 = random.nextInt(); ByteArrayOutputStream bos = new ByteArrayOutputStream(; DataOutputStream outputStream = new DataOutputStream(bos); try { outputStream.writeInt(randomInt1); outputStream.writeInt(randomInt2); } catch (Exception ex) { ex.printStackTrace(); } Packet250CustomPayload packet = new Packet250CustomPayload(); packet.channel = "GeneralChatSync"; packet.data = bos.toByteArray(); packet.length = bos.size(); Side side = FMLCommonHandler.instance().getEffectiveSide(); if (world.isRemote) { // We are on the server side. EntityPlayerMP player = (EntityPlayerMP) playerEntity; } else if (!world.isRemote) { EntityClientPlayerMP player = (EntityClientPlayerMP) playerEntity; // We are on the client side. PacketDispatcher.sendPacketToServer(packet); } else { // We have an errornous state! } } public void keyTyped(char par1, int par2) { this.field_73905_m = false; if (par2 == 15) { this.completePlayerName(); } else { this.field_73897_d = false; } if (par2 == 1) { this.mc.displayGuiScreen((GuiScreen) null); } else if (par2 == 28) { World world = Minecraft.getMinecraft().theWorld; this.stringInInputFieldText = this.inputField.getText().trim(); if (this.stringInInputFieldText.length() > 0) { this.mc.ingameGUI.getChatGUI().addToSentMessages( this.stringInInputFieldText); if (!this.mc.handleClientCommand(this.stringInInputFieldText)) { if (this.inputField.getText().trim().startsWith("/")) { this.mc.thePlayer .sendChatMessage(this.stringInInputFieldText); } else { this.sendPacket(world, player); } } } this.mc.displayGuiScreen((GuiScreen) null); } else if (par2 == 200) { this.getSentHistory(-1); } else if (par2 == 208) { this.getSentHistory(1); } else if (par2 == 201) { this.mc.ingameGUI.getChatGUI().scroll( this.mc.ingameGUI.getChatGUI().func_96127_i() - 1); } else if (par2 == 209) { this.mc.ingameGUI.getChatGUI().scroll( -this.mc.ingameGUI.getChatGUI().func_96127_i() + 1); } else { this.inputField.textboxKeyTyped(par1, par2); } } /** * Handles mouse input. */ public void handleMouseInput() { super.handleMouseInput(); int i = Mouse.getEventDWheel(); if (i != 0) { if (i > 1) { i = 1; } if (i < -1) { i = -1; } if (!isShiftKeyDown()) { i *= 7; } this.mc.ingameGUI.getChatGUI().scroll(i); } } /** * Called when the mouse is clicked. */ protected void mouseClicked(int par1, int par2, int par3) { if (par3 == 0 && this.mc.gameSettings.chatLinks) { ChatClickData chatclickdata = this.mc.ingameGUI.getChatGUI() .func_73766_a(Mouse.getX(), Mouse.getY()); if (chatclickdata != null) { URI uri = chatclickdata.getURI(); if (uri != null) { if (this.mc.gameSettings.chatLinksPrompt) { this.clickedURI = uri; this.mc.displayGuiScreen(new GuiConfirmOpenLink(this, chatclickdata.getClickedUrl(), 0, false)); } else { this.func_73896_a(uri); } return; } } } this.inputField.mouseClicked(par1, par2, par3); super.mouseClicked(par1, par2, par3); } public void confirmClicked(boolean par1, int par2) { if (par2 == 0) { if (par1) { this.func_73896_a(this.clickedURI); } this.clickedURI = null; this.mc.displayGuiScreen(this); } } private void func_73896_a(URI par1URI) { 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[] { par1URI }); } catch (Throwable throwable) { throwable.printStackTrace(); } } /** * Autocompletes player name */ public void completePlayerName() { String s; if (this.field_73897_d) { this.inputField.deleteFromCursor(this.inputField.func_73798_a(-1, this.inputField.getCursorPosition(), false) - this.inputField.getCursorPosition()); if (this.field_73903_n >= this.field_73904_o.size()) { this.field_73903_n = 0; } } else { int i = this.inputField.func_73798_a(-1, this.inputField.getCursorPosition(), false); this.field_73904_o.clear(); this.field_73903_n = 0; String s1 = this.inputField.getText().substring(i).toLowerCase(); s = this.inputField.getText().substring(0, this.inputField.getCursorPosition()); this.func_73893_a(s, s1); if (this.field_73904_o.isEmpty()) { return; } this.field_73897_d = true; this.inputField.deleteFromCursor(i - this.inputField.getCursorPosition()); } if (this.field_73904_o.size() > 1) { StringBuilder stringbuilder = new StringBuilder(); for (Iterator iterator = this.field_73904_o.iterator(); iterator .hasNext(); stringbuilder.append(s)) { s = (String) iterator.next(); if (stringbuilder.length() > 0) { stringbuilder.append(", "); } } this.mc.ingameGUI.getChatGUI() .printChatMessageWithOptionalDeletion( stringbuilder.toString(), 1); } this.inputField.writeText((String) this.field_73904_o .get(this.field_73903_n++)); } private void func_73893_a(String par1Str, String par2Str) { if (par1Str.length() >= 1) { this.mc.thePlayer.sendQueue .addToSendQueue(new Packet203AutoComplete(par1Str)); this.field_73905_m = true; } } /** * input is relative and is applied directly to the sentHistoryCursor so -1 * is the previous message, 1 is the next message from the current cursor * position */ public void getSentHistory(int par1) { int j = this.sentHistoryCursor + par1; int k = this.mc.ingameGUI.getChatGUI().getSentMessages().size(); if (j < 0) { j = 0; } if (j > k) { j = k; } if (j != this.sentHistoryCursor) { if (j == k) { this.sentHistoryCursor = k; this.inputField.setText(this.field_73898_b); } else { if (this.sentHistoryCursor == k) { this.field_73898_b = this.inputField.getText(); } this.inputField.setText((String) this.mc.ingameGUI.getChatGUI() .getSentMessages().get(j)); this.sentHistoryCursor = j; } } } /** * Draws the screen and all the components in it. */ public void drawScreen(int par1, int par2, float par3) { this.inputField.drawTextBox(); this.channelGeneral.drawTextBox(); this.channelGroup.drawTextBox(); super.drawScreen(par1, par2, par3); } public void func_73894_a(String[] par1ArrayOfStr) { if (this.field_73905_m) { this.field_73904_o.clear(); String[] astring1 = par1ArrayOfStr; int i = par1ArrayOfStr.length; for (int j = 0; j < i; ++j) { String s = astring1[j]; if (s.length() > 0) { this.field_73904_o.add(s); } } if (this.field_73904_o.size() > 0) { this.field_73897_d = true; this.completePlayerName(); } } } /** * Returns true if this GUI should pause the game when it is displayed in * single-player */ public boolean doesGuiPauseGame() { return false; } } This is what I wrote in my main class: @NetworkMod(clientSideRequired = true, serverSideRequired = false, channels = { "GeneralChatSync" }, packetHandler = ECPacketHandler.class) THE PROBLEM IS: 1) I cannot cast EntityClientPlayerMP with EntityPlayerMP (obviously), so how can I do that? Crashlog (The importants errors): 2013-11-22 21:52:01 [iNFO] [sTDERR] net.minecraft.util.ReportedException: Updating screen events 2013-11-22 21:52:01 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1507) 2013-11-22 21:52:01 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:835) 2013-11-22 21:52:01 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.run(Minecraft.java:760) 2013-11-22 21:52:01 [iNFO] [sTDERR] at java.lang.Thread.run(Unknown Source) 2013-11-22 21:52:01 [iNFO] [sTDERR] Caused by: java.lang.ClassCastException: net.minecraft.client.entity.EntityClientPlayerMP cannot be cast to net.minecraft.entity.player.EntityPlayerMP 2013-11-22 21:52:01 [iNFO] [sTDERR] at mods.enetchat.client.gui.EGuiChatGeneral.sendPacket(EGuiChatGeneral.java:154) 2013-11-22 21:52:01 [iNFO] [sTDERR] at mods.enetchat.client.gui.EGuiChatGeneral.keyTyped(EGuiChatGeneral.java:189) 2013-11-22 21:52:01 [iNFO] [sTDERR] at net.minecraft.client.gui.GuiScreen.handleKeyboardInput(GuiScreen.java:243) 2013-11-22 21:52:01 [iNFO] [sTDERR] at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:182) 2013-11-22 21:52:01 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1500) 2013-11-22 21:52:01 [iNFO] [sTDERR] ... 3 more
-
[SOLVED] KeyHandler crashed on ServerPacketHandler load
There is it: package mods.exoworld.handler; import java.util.EnumSet; import mods.exoworld.Main; import mods.exoworld.event.ExoArmorPowerup; import mods.exoworld.item.ExoTNTHelmet; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.ITickHandler; import cpw.mods.fml.common.TickType; public class ExoServerTickHandler implements ITickHandler { public float counter = 49.0F; public boolean powerupIsAvailable = false; public ExoKeyHandler keyHandler; public void onPlayerTick(EntityPlayer player) { ItemStack helmet = player.inventory.armorItemInSlot(3); ItemStack chestplate = player.inventory.armorItemInSlot(2); ItemStack leggings = player.inventory.armorItemInSlot(1); ItemStack boots = player.inventory.armorItemInSlot(0); if (player.inventory.armorItemInSlot(2) != null && player.inventory.armorItemInSlot(1) != null && player.inventory.armorItemInSlot(0) != null && helmet.itemID == Main.ExoTNTHelmet.itemID && chestplate.itemID == Main.ExoTNTChestplate.itemID && leggings.itemID == Main.ExoTNTLeggings.itemID && boots.itemID == Main.ExoTNTBoots.itemID) { player.fallDistance = 0.0F; System.out.println(counter); counter += 0.021F; if (counter > 50F && powerupIsAvailable == false) { player.sendChatToPlayer("ExoModChat: La tua armatura è possente! Premi F per scatenare la tua furia!"); powerupIsAvailable = true; } if (powerupIsAvailable == true) { counter -= 5F; if (counter < 0F) { counter = 0F; } } } } @Override public void tickStart(EnumSet<TickType> type, Object... tickData) { // TODO Auto-generated method stub if (type.equals(EnumSet.of(TickType.PLAYER))) { onPlayerTick((EntityPlayer) tickData[0]); } } @Override public void tickEnd(EnumSet<TickType> type, Object... tickData) { // TODO Auto-generated method stub } @Override public EnumSet<TickType> ticks() { // TODO Auto-generated method stub return EnumSet.of(TickType.PLAYER, TickType.SERVER); } @Override public String getLabel() { // TODO Auto-generated method stub return "ExotiumWorld's ServerTickHandler"; } } I FIXED IT! I just put "static" on the boolean variable and in the counter variable, I excepted that ahaha thanks! +1 for the rest help!
-
[SOLVED] KeyHandler crashed on ServerPacketHandler load
Error on this statement: if (event.powerupIsAvailable == true) { //java.lang.NullPointerException player.worldObj.createExplosion(null, player.posX + 5, player.posY, player.posZ, 5.0F, false); player.worldObj.createExplosion(null, player.posX - 5, player.posY, player.posZ, 5.0F, false); player.worldObj.createExplosion(null, player.posX, player.posY, player.posZ + 5, 5.0F, false); player.worldObj.createExplosion(null, player.posX, player.posY, player.posZ - 5, 5.0F, false); event.powerupIsAvailable = false; } And there: ExoArmorPowerup.handlePacket(packet, (EntityPlayer) player); //java.lang.NullPointerException
-
[SOLVED] KeyHandler crashed on ServerPacketHandler load
I tried doing this, but I have no idea on how to do that, I tried using EntityPlayerMP in each class, EntityPlayer and EntityPlayerMP both but nothing D: can you try to fix it at your own?
-
[SOLVED] KeyHandler crashed on ServerPacketHandler load
Hey, everytime I try to run my mod on the server, where the server need to use PacketHandler for send packets from the client to the server in a KeyHandler class, it crashes, the game doesn't close because it's a Server Crash not a Client Crash... D: ServerPacketHandler: package mods.exoworld.handler; import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.IOException; import mods.exoworld.event.ExoArmorPowerup; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet250CustomPayload; import cpw.mods.fml.common.network.IPacketHandler; import cpw.mods.fml.common.network.Player; public class ExoServerPacketHandler implements IPacketHandler { public static String[] Chanels; public static final String ARMORPOWERUP = "ExoArmorPowerup"; // Before adding it remember to add it also in chanels, in network mod // attribute @Override public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { if (packet.channel.equals(ARMORPOWERUP)) { ExoArmorPowerup.handlePacket(packet, (EntityPlayer) player); } } } KeyHandler: package mods.exoworld.handler; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.util.EnumSet; import java.util.Random; import mods.exoworld.event.ExoArmorPowerup; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.network.packet.Packet250CustomPayload; import org.lwjgl.input.Keyboard; import cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.TickType; import cpw.mods.fml.relauncher.Side; public class ExoServerKeyHandler extends KeyHandler { public ExoArmorPowerup eventArmorPowerup; public EntityPlayer player; public static KeyBinding armorPowerup = new KeyBinding("Armor's Powerup", Keyboard.KEY_F); public static KeyBinding[] arrayOfKeys = new KeyBinding[] { armorPowerup }; public static boolean[] areRepeating = new boolean[] { false }; public ExoServerKeyHandler() { super(arrayOfKeys, areRepeating); } @Override public String getLabel() { return "ExotiumWorld's ServerKeyHandler"; } @Override public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) { if(kb.keyCode == armorPowerup.keyCode) { if(tickEnd) { System.out.println("Key up"); eventArmorPowerup.sendPacket(); } } } @Override public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd) { } // FireModeHandler.switchFireMode(); @Override public EnumSet<TickType> ticks() { return EnumSet.of(TickType.CLIENT); } } EventHandler: package mods.exoworld.event; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.util.Random; import mods.exoworld.handler.ExoServerPacketHandler; import mods.exoworld.handler.ExoServerTickHandler; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.world.World; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; public class ExoArmorPowerup { public static ExoServerTickHandler event; public static EntityPlayer player; public static World world; public static void sendPacket() { EntityPlayer player = Minecraft.getMinecraft().thePlayer; ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream(); DataOutputStream dataOutputStream = new DataOutputStream( byteOutputStream); try { dataOutputStream.writeInt(player.entityId); } catch (Exception e) { e.printStackTrace(); } Packet250CustomPayload packet = new Packet250CustomPayload( ExoServerPacketHandler.ARMORPOWERUP, byteOutputStream.toByteArray()); FMLClientHandler.instance().sendPacket(packet); } public static void handlePacket(Packet250CustomPayload packet, EntityPlayer player2) { // TODO Auto-generated method stub if (event.powerupIsAvailable == true) { world.createExplosion(null, player.posX + 5, player.posY, player.posZ, 5.0F, false); world.createExplosion(null, player.posX - 5, player.posY, player.posZ, 5.0F, false); world.createExplosion(null, player.posX, player.posY, player.posZ + 5, 5.0F, false); world.createExplosion(null, player.posX, player.posY, player.posZ - 5, 5.0F, false); event.powerupIsAvailable = false; } } } The ServerPacketHandler is registered in the MainMod class like this: @NetworkMod(clientSideRequired = true, serverSideRequired = false, channels = { ExoServerPacketHandler.ARMORPOWERUP }, packetHandler = ExoServerPacketHandler.class) Any help? Thanks to all!
-
[1.5.2] [Forge] TickHandler any example on how to do that??
Done
-
[1.5.2] [Forge] TickHandler any example on how to do that??
*pretend i didnt see anything.............* in your frirst post you talk about registerng with the server yet your tickhabdler return a tick type of client and render, 2 type which dont exists server side. you want this tick handler server side or client side ? Bold word are just wtf? Anyway Server side
-
[1.5.2] [Forge] TickHandler any example on how to do that??
Nooooo you don't say? : I just wrote it... still not work
-
[1.5.2] [Forge] TickHandler any example on how to do that??
Hi guys, I wanted to make a special armour that it charge and then ask you to press F for release the Fury Mode. I created it in my ItemClass, it worked good but the problem is, the server is not registering this. So I asked to my friend that can make mod and said to me: "You need to register a new TickHandler for this thing" but the problem is, I can't figure out I tried doing this: TickHandler class: package mods.exoworld.handler; import java.util.EnumSet; import mods.exoworld.Main; import mods.exoworld.item.ExoTNTHelmet; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import cpw.mods.fml.common.ITickHandler; import cpw.mods.fml.common.TickType; public class ExoServerTickHandler implements ITickHandler { public ExoTNTHelmet event; public World world; public EntityPlayer player; @Override public void tickStart(EnumSet<TickType> type, Object... tickData) { // TODO Auto-generated method stub } public void onTickArmor(EntityPlayer player, World world, ItemStack itemStack, ExoTNTHelmet event) { ItemStack helmet = player.inventory.armorItemInSlot(3); ItemStack chestplate = player.inventory.armorItemInSlot(2); ItemStack leggings = player.inventory.armorItemInSlot(1); ItemStack boots = player.inventory.armorItemInSlot(0); if (helmet.itemID == Main.ExoTNTHelmet.itemID && chestplate.itemID == Main.ExoTNTChestplate.itemID && leggings.itemID == Main.ExoTNTLeggings.itemID && boots.itemID == Main.ExoTNTBoots.itemID) { event.counter += 0.021F; System.out.println(event.counter); if(event.counter > 50F) { event.powerupIsAvailable = true; } if (event.powerupIsAvailable == true) { event.counter -= 5F; if (event.counter < 0F) { event.counter = 0F; } } } } public void onPowerupActivated() { while (event.counter < 0F) { // I want that every 5 ticks the function do this code below if (event.powerupIsAvailable == true) world.createExplosion(null, player.posX + 5, player.posY, player.posZ, 5.0F, false); world.createExplosion(null, player.posX - 5, player.posY, player.posZ, 5.0F, false); world.createExplosion(null, player.posX, player.posY, player.posZ + 5, 5.0F, false); world.createExplosion(null, player.posX, player.posY, player.posZ - 5, 5.0F, false); event.powerupIsAvailable = false; } } @Override public void tickEnd(EnumSet<TickType> type, Object... tickData) { // TODO Auto-generated method stub } @Override public EnumSet<TickType> ticks() { // TODO Auto-generated method stub return EnumSet.of(TickType.CLIENT, TickType.RENDER); } @Override public String getLabel() { // TODO Auto-generated method stub return null; } } My KeyHandler code: package mods.exoworld.handler; import java.util.EnumSet; import mods.exoworld.item.ExoTNTHelmet; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; import org.lwjgl.input.Keyboard; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.KeyBindingRegistry.KeyHandler; import cpw.mods.fml.common.TickType; public class ExoKeyHandler extends KeyHandler { public ExoServerTickHandler tickHandler; public static KeyBinding armorPowerup = new KeyBinding( "Armor Powerup", Keyboard.KEY_F); public static KeyBinding[] arrayOfKeys = new KeyBinding[] { armorPowerup }; public static boolean[] areRepeating = new boolean[] { false }; public ExoKeyHandler() { super(arrayOfKeys, areRepeating); } @Override public String getLabel() { return "ExoWorld's KeyHandler"; } @Override public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) { if (tickEnd) { if (kb.keyCode == armorPowerup.keyCode) { tickHandler.onPowerupActivated(); } } } @Override public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd) { } @Override public EnumSet<TickType> ticks() { return EnumSet.of(TickType.CLIENT); } } P.S.: Never used TickHandler in my life, no tutorials, no examples = never use this sh@t again
-
[SOLVED]Custom TickHandler counting milliseconds
Oh my god thanks! It worked
-
[SOLVED]Custom TickHandler counting milliseconds
I know what SideOnly means -.- I just put that in onItemRightClick for mistake, now it works on server PERFECTLY How???
-
[SOLVED]Custom TickHandler counting milliseconds
Guys I have a mod that add something specials for my server, it's the RageMode, whenever the player do the right click after a combo of 80 hits, it will start the rage mode BUT: I want that the rage mode ends after 7.2 seconds! I tried making a TickHandler but I can't figure out how to do that, I never did something with ticks, if you can help me and the code works I'll finally know how to do ticks :3 My ExoRageModeEvent code: public class ExoRageModeEvent extends ItemSword { public static int comboStreak = 0; public static int maxComboStreak = 240; public static int minComboStreak = 3; public static boolean rageMode = false; public static boolean soundStarted = false; public ExoRageModeEvent(int par1, EnumToolMaterial par2EnumToolMaterial) { super(par1, par2EnumToolMaterial); // TODO Auto-generated constructor stub } @SideOnly(Side.CLIENT) public void onUpdate(ItemStack item, World world, Entity entity, int par4, boolean par5) { if (par5 && (entity instanceof EntityPlayer)) { if (rageMode == false) { EntityPlayer player = (EntityPlayer) entity; } else { EntityPlayer player = (EntityPlayer) entity; /* * wait 7.2 seconds; rageMode = false; */ } } else { EntityPlayer player = (EntityPlayer) entity; player.capabilities.setPlayerWalkSpeed(0.1F); rageMode = false; comboStreak = 0; } } public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving) { par2EntityLiving.setPosition(par2EntityLiving.posX, par2EntityLiving.posY, par2EntityLiving.posZ); comboStreak += 1; if (par3EntityLiving instanceof EntityPlayer) { if (comboStreak == 80) { EntityPlayer player = (EntityPlayer) par3EntityLiving; player.sendChatToPlayer("Your powerup is ready! Right click to activate it!"); } } if (comboStreak > maxComboStreak) { comboStreak = 240; } return true; } @SideOnly(Side.CLIENT) public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if (comboStreak >= 80) { rageMode = true; // Wait 0.05 seconds because if I put in the condition "soundStarted == false" // it will automatically read first the soundStarted = true under that "playSoundEffect" // because the song will load 0.01 second after! par2World.playSoundEffect(par3EntityPlayer.posX, par3EntityPlayer.posY, par3EntityPlayer.posZ, "ExoWorld.RageMode", 1.0F, 1.0F); soundStarted = true; } if (comboStreak >= 90) { comboStreak = 0; } return par1ItemStack; } } Any help? Thanks!
-
Detecting if the player is colliding a block
Hey guys, I'm making a Mirror's Edge mod (called Mirror's Craft) I need to do the Wallrun function D: Making the animation I'll think after all, but now I need the function to detect the player colliding a block, how can I do this?? I searched everywhere, but no results
-
How do I create a custom bucket with the normal bucket?
So vogner, how can I do that?
-
[unsolved]Installing mod gives java.lang.NoClassDefFoundError
Have you created the basic mod class?
-
[1.5.1] Block/Item Texture/Icon location?
Just put simply this this.iconIndex = iconRegister.registerIcon("NameOfYourModFolder:NameOfYourItem/Block"); example this.iconIndex = iconRegister.registerIcon("mod:superpickaxe"); .-.
IPS spam blocked by CleanTalk.