Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by FlashHUN

  1. I did, but I don't know what to do. I'm just a beginner developer asking for help. I understand that I should be using sides, but I don't know where and when.
  2. I haven't updated anything because I don't know what to update and how. Like I said, if I don't send packets in PlayerEvent.Clone, then the stuff doesn't get synced from the server to the client when the event happens. I need to be able to access data from the client side player to be able to send it to the server from the GUI. What should I do?
  3. Alright, I was just confused because diesieben said Anyways, I still don't know why the memory leak is happening and why the player data doesn't sync when the player relogs.
  4. What if I need to edit player capability data through a GUI? How would I get the server side player in a GUI and edit their server side capabilities through the GUI? Also, when I don't send packets in the PlayerEvent.Clone the capabilities don't sync between the client and server.
  5. I'm working on a mod where I have to sync player capabilities from the server to the client and vice versa quite often, but every 100th packet sent causes a memory leak causing the client to not get the data from the server. Also when I exit a singleplayer world and enter it again (haven't tested on servers yet, it's probably the same though) the data from the server doesn't get synced with the client. What could be causing this? Leak message: PacketMana (all packets are set up this way): import io.netty.buffer.ByteBuf; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; public class PacketMana implements IMessage { EntityPlayerMP player; private int data; @Override public void fromBytes(ByteBuf buf) { IMana mana = Minecraft.getMinecraft().player.getCapability(CapabilityMana.MANA_CAPABILITY, null); data = mana.setMana(buf.readInt()); } @Override public void toBytes(ByteBuf buf) { IMana mana = Minecraft.getMinecraft().player.getCapability(CapabilityMana.MANA_CAPABILITY, null); buf.writeInt(mana.getMana()); } public PacketMana() { IMana mana = Minecraft.getMinecraft().player.getCapability(CapabilityMana.MANA_CAPABILITY, null); data = mana.getMana(); } public PacketMana(EntityPlayerMP player) { this.player = player; IMana mana = player.getCapability(CapabilityMana.MANA_CAPABILITY, null); data = mana.getMana(); } public static class Handler implements IMessageHandler<PacketMana, IMessage> { @Override public IMessage onMessage(PacketMana message, MessageContext ctx) { FMLCommonHandler.instance().getWorldThread(ctx.netHandler).addScheduledTask(() -> handle(message, ctx)); return null; } private void handle(PacketMana message, MessageContext ctx) { EntityPlayerMP playerEntity = ctx.getServerHandler().player; playerEntity.getCapability(CapabilityMana.MANA_CAPABILITY, null).setMana(message.data); } } } Events for syncing data (sync(player) is a function that sends all packets to the player): @SubscribeEvent public static void loginEvent(final PlayerLoggedInEvent event) { EntityPlayerMP player = (EntityPlayerMP)event.player; Minecraft.getMinecraft().addScheduledTask(() -> sync(player)); System.out.println("Synced"); } @SubscribeEvent public static void changeDimesionEvent(final PlayerChangedDimensionEvent event) { EntityPlayerMP player = (EntityPlayerMP)event.player; Minecraft.getMinecraft().addScheduledTask(() -> sync(player)); System.out.println("Synced"); } @SubscribeEvent public static void respawnEvent(final PlayerRespawnEvent event) { EntityPlayerMP player = (EntityPlayerMP)event.player; Minecraft.getMinecraft().addScheduledTask(() -> sync(player)); System.out.println("Synced"); } } Player Clone Event: @SubscribeEvent public static void playerClone(final PlayerEvent.Clone event) { final IMana oldMana = getMana(event.getOriginal()); final IMana newMana = getMana(event.getEntityPlayer()); if (newMana != null && oldMana != null) { newMana.setMaxMana(oldMana.getMaxMana()); newMana.setManaTimer(oldMana.getManaTimer()); newMana.setMana(oldMana.getMana()); newMana.setClan(oldMana.getClan()); newMana.setLand(oldMana.getLand()); newMana.setAffiliation(oldMana.getAffiliation()); newMana.setGenjutsu(oldMana.getGenjutsu()); newMana.setTaijutsu(oldMana.getTaijutsu()); newMana.setKenjutsu(oldMana.getKenjutsu()); newMana.setSharingan(oldMana.getSharingan()); newMana.setSharinganSize(oldMana.getSharinganSize()); newMana.setSharinganPattern(oldMana.getSharinganPattern()); newMana.setSharinganActive(oldMana.getSharinganActive()); newMana.setByakugan(oldMana.getByakugan()); newMana.setByakuganSize(oldMana.getByakuganSize()); newMana.setByakuganActive(oldMana.getByakuganActive()); newMana.setKetsuryuugan(oldMana.getKetsuryuugan()); newMana.setKetsuryuuganActive(oldMana.getKetsuryuuganActive()); newMana.setCurseMark(oldMana.getCurseMark()); newMana.setCurseMarkSize(oldMana.getCurseMarkSize()); newMana.setCurseMarkType(oldMana.getCurseMarkType()); newMana.setCurseMarkActive(oldMana.getCurseMarkActive()); newMana.setFireRelease(oldMana.getFireRelease()); newMana.setWindRelease(oldMana.getWindRelease()); newMana.setWaterRelease(oldMana.getWaterRelease()); newMana.setLightningRelease(oldMana.getLightningRelease()); newMana.setEarthRelease(oldMana.getEarthRelease()); newMana.setWoodRelease(oldMana.getWoodRelease()); newMana.setYinRelease(oldMana.getYinRelease()); newMana.setYangRelease(oldMana.getYangRelease()); newMana.setIceRelease(oldMana.getIceRelease()); newMana.setShikotsumyaku(oldMana.getShikotsumyaku()); Minecraft.getMinecraft().addScheduledTask(() -> sync((EntityPlayerMP)event.getEntityPlayer())); } System.out.println("Player Clone Event Successful"); }
  6. Like I said, I haven't really worked with the newer versions, but thanks for clarifying. I cannot seem to figure out what is wrong though. I haven't found any examples that I could learn how to do it from and I don't seem to be capable of doing it without one. I never really worked with packets before and it just seems like a lot at first.
  7. I understand what I need to do and the basics of how I need to do it, but I cannot make it work. How can I make a packet that gets data from the CapabilityMana class (I'm guessing?) and sends it to the client through the PacketHandler? I know how to set up a PacketHandler, I just never really worked with packets and player nbt before and this is what's getting me stuck. Also, is there any way to detect the data changing automatically instead of having to flood classes that change a lot of things with sending packets when changing?
  8. I am making a mod where I need to show a GUI on the player's screen showing their current mana/max mana. The problem is, even if the values update, the GUI doesn't, it just shows the default values. I'm new to 1.12.2 modding, so I don't really know what might be causing it. Help would be greatly appreciated. GUI class: Mana class: IMana interface: CapabilityMana class: CapabilityProviderSerializable class: CapabilityProviderSimple class: CapabilityUtils class: InjectionUtils class:
  9. I want to make an overlay on the player's eyes that is as close to the player skin as possible, but the only way I've found on how to do this is to make an armour with a custom model. My problem is, that the example code I used works perfectly fine, but when I try to do the same with my own model, it just doesn't want to render the armour model. (I'm new to coding but I somewhat understand the basics of it) Here's the error: [12:27:01] [Client thread/ERROR]: Couldn't render entity java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(Unknown Source) ~[?:1.8.0_121] at flash.twosskillmod.armor.ArmorTM.getArmorTexture(ArmorTM.java:104) ~[ArmorTM.class:?] at net.minecraftforge.client.ForgeHooksClient.getArmorTexture(ForgeHooksClient.java:80) ~[ForgeHooksClient.class:?] at net.minecraft.client.renderer.entity.RenderBiped.getArmorResource(RenderBiped.java:411) ~[RenderBiped.class:?] at net.minecraft.client.renderer.entity.RenderPlayer.shouldRenderPass(RenderPlayer.java:70) ~[RenderPlayer.class:?] at net.minecraft.client.renderer.entity.RenderPlayer.shouldRenderPass(RenderPlayer.java:517) ~[RenderPlayer.class:?] at net.minecraft.client.renderer.entity.RendererLivingEntity.doRender(RendererLivingEntity.java:173) [RendererLivingEntity.class:?] at net.minecraft.client.renderer.entity.RenderPlayer.doRender(RenderPlayer.java:167) [RenderPlayer.class:?] at net.minecraft.client.renderer.entity.RenderPlayer.doRender(RenderPlayer.java:565) [RenderPlayer.class:?] at net.minecraft.client.renderer.entity.RenderManager.func_147939_a(RenderManager.java:300) [RenderManager.class:?] at net.minecraft.client.renderer.entity.RenderManager.renderEntityWithPosYaw(RenderManager.java:283) [RenderManager.class:?] at net.minecraft.client.gui.inventory.GuiInventory.func_147046_a(GuiInventory.java:112) [GuiInventory.class:?] at net.minecraft.client.gui.inventory.GuiContainerCreative.drawGuiContainerBackgroundLayer(GuiContainerCreative.java:839) [GuiContainerCreative.class:?] at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:93) [GuiContainer.class:?] at net.minecraft.client.renderer.InventoryEffectRenderer.drawScreen(InventoryEffectRenderer.java:44) [InventoryEffectRenderer.class:?] at net.minecraft.client.gui.inventory.GuiContainerCreative.drawScreen(GuiContainerCreative.java:673) [GuiContainerCreative.class:?] at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1137) [EntityRenderer.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1067) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:962) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_121] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_121] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_121] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_121] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?] at GradleStart.main(Unknown Source) [start/:?] What line 104 in ArmorTM.java says: name = name.substring(0, name.indexOf('_')); And here are all the classes: ClientProxy: https://pastebin.com/dHmNYtdE Main: https://pastebin.com/42rrrPr8 Armor: https://pastebin.com/P7a4h2ze Model: https://pastebin.com/2Lf2HVb8 Resource: package flash.twosskillmod; public class Resource { public static final String RESOURCE_PREFIX = References.mod_id+":"; } References: package flash.twosskillmod; public class References { public final static String name = "TWOS Skills Mod"; public final static String version = "1.0"; public final static String mod_id = "twos"; public final static String proxy_client = "flash.twosskillmod.proxy.ProxyClient"; public final static String proxy_common = "flash.twosskillmod.proxy.ProxyCommon"; } Help would be appreciated!
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.