Lambda
Members-
Posts
486 -
Joined
-
Last visited
Everything posted by Lambda
-
How would I get two of the TEs from the list and compare them, thats my question
-
Yes I know that, I need to be able to grab another te and check their blockpos
-
How would I get another instance of a te to compare it to?
-
[1.11] EntityJoinedWorldEvent Ticking memory connection
Lambda replied to Lambda's topic in Modder Support
Is there anyway to access the player? -
[1.11] EntityJoinedWorldEvent Ticking memory connection
Lambda replied to Lambda's topic in Modder Support
How would I get an instance of the server? I need to be able to access their capability. -
Hey there, I'm trying to sync a value when the player joins the game, however, using EntityJoinedWorldEvent seems to cause this on join: // Why did you do that? Time: 12/11/16 11:03 AM Description: Ticking memory connection java.lang.NullPointerException: Ticking memory connection at com.lambda.plentifulmisc.magic.hud.ManaEvent.EntityJoinedWorldEvent(ManaEvent.java:60) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_11_ManaEvent_EntityJoinedWorldEvent_EntityJoinWorldEvent.invoke(.dynamic) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185) at net.minecraft.world.World.spawnEntityInWorld(World.java:1291) at net.minecraft.world.WorldServer.spawnEntityInWorld(WorldServer.java:1124) at net.minecraft.server.management.PlayerList.playerLoggedIn(PlayerList.java:386) at net.minecraft.server.management.PlayerList.initializeConnectionToPlayer(PlayerList.java:169) at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.completeServerSideConnection(NetworkDispatcher.java:265) at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.access$100(NetworkDispatcher.java:73) at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:214) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:308) at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:195) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:817) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:698) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:547) at java.lang.Thread.run(Thread.java:745) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Client thread Stacktrace: at com.lambda.plentifulmisc.magic.hud.ManaEvent.EntityJoinedWorldEvent(ManaEvent.java:60) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_11_ManaEvent_EntityJoinedWorldEvent_EntityJoinWorldEvent.invoke(.dynamic) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185) at net.minecraft.world.World.spawnEntityInWorld(World.java:1291) at net.minecraft.world.WorldServer.spawnEntityInWorld(WorldServer.java:1124) at net.minecraft.server.management.PlayerList.playerLoggedIn(PlayerList.java:386) at net.minecraft.server.management.PlayerList.initializeConnectionToPlayer(PlayerList.java:169) at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.completeServerSideConnection(NetworkDispatcher.java:265) at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.access$100(NetworkDispatcher.java:73) at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:214) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:308) -- Ticking connection -- Details: Connection: net.minecraft.network.NetworkManager@4f6404d0 Stacktrace: at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:195) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:817) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:698) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:547) at java.lang.Thread.run(Thread.java:745) Here is the event: @SubscribeEvent public static void EntityJoinedWorldEvent(EntityJoinWorldEvent event) { Minecraft mc = Minecraft.getMinecraft(); if(event.getEntity() instanceof EntityPlayer) { if (mc.thePlayer.hasCapability(CapabilityMagic.MANA, null)) { CapabilityManaData cap = mc.thePlayer.getCapability(CapabilityMagic.MANA, null); if (!event.isCancelable()) { PlentifulMisc.network.sendTo(new ManaNetworkSyncClient(cap.getManaStored()), (EntityPlayerMP) cap.getEntity()); } } } } Thanks,
-
No I fixed it, the Item i was using to change the mana wasn't check !worldObj.isremote , Its working perfect now! Thanks!
-
Okay doing this: PlentifulMisc.network.sendTo(new ManaNetworkSyncClient(this.getManaStored()), (EntityPlayerMP) this.getEntity()); seems to crash with this: java.lang.ClassCastException: net.minecraft.client.entity.EntityPlayerSP cannot be cast to net.minecraft.entity.player.EntityPlayerMP
-
Okay, what should I use for the player arg? I tried: public class CapabilityManaData extends ManaHandler { private EntityLivingBase entity; private EntityPlayerMP entityPlayerMP; public CapabilityManaData(){ super(500000); } public CapabilityManaData(int capacity, int maxReceive, int maxExtract){ super(capacity, maxReceive, maxExtract); } public EntityLivingBase getEntity() { return entity; } public void setEntity(EntityLivingBase entity) { this.entity = entity; } public int extractManaInternal(int maxExtract, boolean simulate){ int before = this.maxExtract; this.maxExtract = Integer.MAX_VALUE; int toReturn = this.extractMana(maxExtract, simulate); PlentifulMisc.network.sendTo(new ManaNetworkSyncClient(this.getManaStored()),entityPlayerMP); this.maxExtract = before; return toReturn; } public int receiveManaInternal(int maxReceive, boolean simulate){ int before = this.maxReceive; this.maxReceive = Integer.MAX_VALUE; int toReturn = this.receiveMana(maxReceive, simulate); PlentifulMisc.network.sendTo(new ManaNetworkSyncClient(this.getManaStored()), entityPlayerMP); this.maxReceive = before; return toReturn; } @Override public int receiveMana(int maxReceive, boolean simulate){ if(!this.canReceive()){ return 0; } int mana = this.getManaStored(); int manaReceived = Math.min(this.capacity-mana, Math.min(this.maxReceive, maxReceive)); if(!simulate){ this.setManaStored(mana+manaReceived); } PlentifulMisc.network.sendTo(new ManaNetworkSyncClient(this.getManaStored()), entityPlayerMP); return manaReceived; } @Override public int extractMana(int maxExtract, boolean simulate){ if(!this.canExtract()){ return 0; } int mana = this.getManaStored(); int manaExtracted = Math.min(mana, Math.min(this.maxExtract, maxExtract)); if(!simulate){ this.setManaStored(mana-manaExtracted); } PlentifulMisc.network.sendTo(new ManaNetworkSyncClient(this.getManaStored()), entityPlayerMP); return manaExtracted; } public void readFromNBT(NBTTagCompound compound){ this.setManaStored(compound.getInteger("Mana")); } public NBTBase writeData() { NBTTagCompound tag = new NBTTagCompound(); tag.setInteger("Mana", mana); return tag; } public void readData(NBTBase nbt) { NBTTagCompound tag = (NBTTagCompound) nbt; this.setManaStored(tag.getInteger("Mana")); } public void writeToNBT(NBTTagCompound compound){ compound.setInteger("Mana", this.getManaStored()); } public void setManaStored(int energy){ this.mana = energy; } } creating a variable, but obviously that crashed with: 01:09:27] [Client thread/ERROR]: FMLIndexedMessageCodec exception caught java.lang.RuntimeException: PLAYER target expects a Player arg at net.minecraftforge.fml.common.network.FMLOutboundHandler$OutboundTarget$4.validateArgs(FMLOutboundHandler.java:125) ~[FMLOutboundHandler$OutboundTarget$4.class:?] at net.minecraftforge.fml.common.network.FMLOutboundHandler.write(FMLOutboundHandler.java:282) ~[FMLOutboundHandler.class:?] at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:658) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:716) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:651) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:112) ~[MessageToMessageEncoder.class:4.0.23.Final] at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116) ~[MessageToMessageCodec.class:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:658) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:716) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:706) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:741) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:895) ~[DefaultChannelPipeline.class:4.0.23.Final] at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:240) ~[AbstractChannel.class:4.0.23.Final] at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.sendTo(SimpleNetworkWrapper.java:254) [simpleNetworkWrapper.class:?] at com.lambda.plentifulmisc.magic.internal.CapabilityManaData.receiveManaInternal(CapabilityManaData.java:53) [CapabilityManaData.class:?] at com.lambda.plentifulmisc.items.magic.ItemTestMagic.onItemRightClick(ItemTestMagic.java:26) [itemTestMagic.class:?] at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:210) [itemStack.class:?] at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClick(PlayerControllerMP.java:529) [PlayerControllerMP.class:?] at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1622) [Minecraft.class:?] at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2274) [Minecraft.class:?] at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2051) [Minecraft.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1839) [Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1117) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:405) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91] 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 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:26) [start/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91] at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) [idea_rt.jar:?] [01:09:27] [server thread/ERROR]: FMLIndexedMessageCodec exception caught java.lang.RuntimeException: PLAYER target expects a Player arg at net.minecraftforge.fml.common.network.FMLOutboundHandler$OutboundTarget$4.validateArgs(FMLOutboundHandler.java:125) ~[FMLOutboundHandler$OutboundTarget$4.class:?] at net.minecraftforge.fml.common.network.FMLOutboundHandler.write(FMLOutboundHandler.java:282) ~[FMLOutboundHandler.class:?] at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:658) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:716) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:651) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:112) ~[MessageToMessageEncoder.class:4.0.23.Final] at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116) ~[MessageToMessageCodec.class:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:658) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:716) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:706) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:741) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:895) ~[DefaultChannelPipeline.class:4.0.23.Final] at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:240) ~[AbstractChannel.class:4.0.23.Final] at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.sendTo(SimpleNetworkWrapper.java:254) [simpleNetworkWrapper.class:?] at com.lambda.plentifulmisc.magic.internal.CapabilityManaData.receiveMana(CapabilityManaData.java:69) [CapabilityManaData.class:?] at com.lambda.plentifulmisc.magic.internal.CapabilityManaData.receiveManaInternal(CapabilityManaData.java:52) [CapabilityManaData.class:?] at com.lambda.plentifulmisc.items.magic.ItemTestMagic.onItemRightClick(ItemTestMagic.java:26) [itemTestMagic.class:?] at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:210) [itemStack.class:?] at net.minecraft.server.management.PlayerInteractionManager.processRightClick(PlayerInteractionManager.java:385) [PlayerInteractionManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:728) [NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItem.processPacket(CPacketPlayerTryUseItem.java:43) [CPacketPlayerTryUseItem.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItem.processPacket(CPacketPlayerTryUseItem.java:9) [CPacketPlayerTryUseItem.class:?] at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) [PacketThreadUtil$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_91] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_91] at net.minecraft.util.Util.runTask(Util.java:26) [util.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:753) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:698) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) [integratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:547) [MinecraftServer.class:?] at java.lang.Thread.run(Thread.java:745) [?:1.8.0_91] [01:09:27] [Client thread/ERROR]: FMLIndexedMessageCodec exception caught java.lang.RuntimeException: PLAYER target expects a Player arg at net.minecraftforge.fml.common.network.FMLOutboundHandler$OutboundTarget$4.validateArgs(FMLOutboundHandler.java:125) ~[FMLOutboundHandler$OutboundTarget$4.class:?] at net.minecraftforge.fml.common.network.FMLOutboundHandler.write(FMLOutboundHandler.java:282) ~[FMLOutboundHandler.class:?] at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:658) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:716) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:651) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:112) ~[MessageToMessageEncoder.class:4.0.23.Final] at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116) ~[MessageToMessageCodec.class:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:658) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:716) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:706) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:741) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:895) ~[DefaultChannelPipeline.class:4.0.23.Final] at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:240) ~[AbstractChannel.class:4.0.23.Final] at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.sendTo(SimpleNetworkWrapper.java:254) [simpleNetworkWrapper.class:?] at com.lambda.plentifulmisc.magic.internal.CapabilityManaData.extractMana(CapabilityManaData.java:84) [CapabilityManaData.class:?] at com.lambda.plentifulmisc.magic.internal.CapabilityManaData.extractManaInternal(CapabilityManaData.java:42) [CapabilityManaData.class:?] at com.lambda.plentifulmisc.items.magic.ItemTestMagic.onItemRightClick(ItemTestMagic.java:28) [itemTestMagic.class:?] at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:210) [itemStack.class:?] at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClick(PlayerControllerMP.java:529) [PlayerControllerMP.class:?] at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1622) [Minecraft.class:?] at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2274) [Minecraft.class:?] at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2051) [Minecraft.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1839) [Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1117) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:405) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91] 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 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:26) [start/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91] at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) [idea_rt.jar:?] Dec 11, 2016 1:09:27 AM io.netty.channel.embedded.EmbeddedChannel recordException WARNING: More than one exception was raised. Will report only the first one and log others. java.lang.RuntimeException: PLAYER target expects a Player arg at net.minecraftforge.fml.common.network.FMLOutboundHandler$OutboundTarget$4.validateArgs(FMLOutboundHandler.java:125) at net.minecraftforge.fml.common.network.FMLOutboundHandler.write(FMLOutboundHandler.java:282) at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:658) at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:716) at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:651) at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:112) at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116) at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:658) at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:716) at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:706) at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:741) at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:895) at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:240) at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.sendTo(SimpleNetworkWrapper.java:254) at com.lambda.plentifulmisc.magic.internal.CapabilityManaData.receiveManaInternal(CapabilityManaData.java:53) at com.lambda.plentifulmisc.items.magic.ItemTestMagic.onItemRightClick(ItemTestMagic.java:26) at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:210) at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClick(PlayerControllerMP.java:529) at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1622) at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2274) at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2051) at net.minecraft.client.Minecraft.runTick(Minecraft.java:1839) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1117) at net.minecraft.client.Minecraft.run(Minecraft.java:405) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) Dec 11, 2016 1:09:27 AM io.netty.channel.embedded.EmbeddedChannel recordException WARNING: More than one exception was raised. Will report only the first one and log others. java.lang.RuntimeException: PLAYER target expects a Player arg at net.minecraftforge.fml.common.network.FMLOutboundHandler$OutboundTarget$4.validateArgs(FMLOutboundHandler.java:125) at net.minecraftforge.fml.common.network.FMLOutboundHandler.write(FMLOutboundHandler.java:282) at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:658) at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:716) at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:651) at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:112) at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116) at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:658) at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:716) at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:706) at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:741) at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:895) at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:240) at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.sendTo(SimpleNetworkWrapper.java:254) at com.lambda.plentifulmisc.magic.internal.CapabilityManaData.receiveMana(CapabilityManaData.java:69) at com.lambda.plentifulmisc.magic.internal.CapabilityManaData.receiveManaInternal(CapabilityManaData.java:52) at com.lambda.plentifulmisc.items.magic.ItemTestMagic.onItemRightClick(ItemTestMagic.java:26) at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:210) at net.minecraft.server.management.PlayerInteractionManager.processRightClick(PlayerInteractionManager.java:385) at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:728) at net.minecraft.network.play.client.CPacketPlayerTryUseItem.processPacket(CPacketPlayerTryUseItem.java:43) at net.minecraft.network.play.client.CPacketPlayerTryUseItem.processPacket(CPacketPlayerTryUseItem.java:9) at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at net.minecraft.util.Util.runTask(Util.java:26) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:753) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:698) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:547) at java.lang.Thread.run(Thread.java:745) Dec 11, 2016 1:09:27 AM io.netty.channel.embedded.EmbeddedChannel recordException WARNING: More than one exception was raised. Will report only the first one and log others. java.lang.RuntimeException: PLAYER target expects a Player arg Thanks,
-
So what method would I use for sending it to client? sentTo ?
-
Incompatible types.
-
Actually, futher debugging shows that it isnt even called, @Override public IMessage onMessage(ManaNetworkSyncClient message, MessageContext ctx) { IThreadListener mainThread = Minecraft.getMinecraft(); mainThread.addScheduledTask(new Runnable() { @Override public void run() { System.out.println("okay its running"); //NEITHER IS THIS if(Minecraft.getMinecraft().thePlayer.hasCapability(CapabilityMagic.MANA, null)) { System.out.println("YES"); //ISNT BENING CALLED CapabilityManaData cap = Minecraft.getMinecraft().thePlayer.getCapability(CapabilityMagic.MANA, null); cap.setManaStored(message.mana); } System.out.println(String.format("Received %s from %s", message.mana, ctx.getServerHandler().playerEntity.getDisplayName())); } }); return null; // no response in this case } both system.out are not being called, so I'm guess something is wrong. I am registering my packet, maybe something with sending my packets?
-
Okay: Where I'm sending packets: public class CapabilityManaData extends ManaHandler { private EntityLivingBase entity; public CapabilityManaData(){ super(500000); } public CapabilityManaData(int capacity, int maxReceive, int maxExtract){ super(capacity, maxReceive, maxExtract); } public EntityLivingBase getEntity() { return entity; } public void setEntity(EntityLivingBase entity) { this.entity = entity; } public int extractManaInternal(int maxExtract, boolean simulate){ int before = this.maxExtract; this.maxExtract = Integer.MAX_VALUE; int toReturn = this.extractMana(maxExtract, simulate); PlentifulMisc.network.sendToServer(new ManaNetworkSyncClient(this.getManaStored())); this.maxExtract = before; return toReturn; } public int receiveManaInternal(int maxReceive, boolean simulate){ int before = this.maxReceive; this.maxReceive = Integer.MAX_VALUE; int toReturn = this.receiveMana(maxReceive, simulate); PlentifulMisc.network.sendToServer(new ManaNetworkSyncClient(this.getManaStored())); this.maxReceive = before; return toReturn; } @Override public int receiveMana(int maxReceive, boolean simulate){ if(!this.canReceive()){ return 0; } int mana = this.getManaStored(); int manaReceived = Math.min(this.capacity-mana, Math.min(this.maxReceive, maxReceive)); if(!simulate){ this.setManaStored(mana+manaReceived); } PlentifulMisc.network.sendToServer(new ManaNetworkSyncClient(this.getManaStored())); return manaReceived; } @Override public int extractMana(int maxExtract, boolean simulate){ if(!this.canExtract()){ return 0; } int mana = this.getManaStored(); int manaExtracted = Math.min(mana, Math.min(this.maxExtract, maxExtract)); if(!simulate){ this.setManaStored(mana-manaExtracted); } PlentifulMisc.network.sendToServer(new ManaNetworkSyncClient(this.getManaStored())); return manaExtracted; } public void readFromNBT(NBTTagCompound compound){ this.setManaStored(compound.getInteger("Mana")); } public NBTBase writeData() { NBTTagCompound tag = new NBTTagCompound(); tag.setInteger("Mana", mana); return tag; } public void readData(NBTBase nbt) { NBTTagCompound tag = (NBTTagCompound) nbt; this.setManaStored(tag.getInteger("Mana")); } public void writeToNBT(NBTTagCompound compound){ compound.setInteger("Mana", this.getManaStored()); } public void setManaStored(int energy){ this.mana = energy; } } -So everytime extract/receive mana is called, it will update. Handler: public class ManaNetworkHandler implements IMessageHandler<ManaNetworkSyncClient, IMessage> { public ManaNetworkHandler(){} @Override public IMessage onMessage(ManaNetworkSyncClient message, MessageContext ctx) { IThreadListener mainThread = Minecraft.getMinecraft(); mainThread.addScheduledTask(new Runnable() { @Override public void run() { if(Minecraft.getMinecraft().thePlayer.hasCapability(CapabilityMagic.MANA, null)) { CapabilityManaData cap = Minecraft.getMinecraft().thePlayer.getCapability(CapabilityMagic.MANA, null); cap.setManaStored(message.mana); } System.out.println(String.format("Received %s from %s", message.mana, ctx.getServerHandler().playerEntity.getDisplayName())); } }); return null; // no response in this case } } Network: public class ManaNetworkSyncClient implements IMessage { public int mana; public ManaNetworkSyncClient(){} public ManaNetworkSyncClient(int toSend) { this.mana = toSend; } @Override public void toBytes(ByteBuf buf) { // Writes the int into the buf buf.writeInt(mana); } @Override public void fromBytes(ByteBuf buf) { // Reads the int back from the buf. Note that if you have multiple values, you must read in the same order you wrote. mana = buf.readInt(); } }
-
Did that but, still no luck I'm trying to sync a cap between the client and server, however, I'm having a bit of a hard time doing so
-
-
Yes, the side is changed, and I made it so the packets updated when the mana is changed now, still the display isnt updating properly. and resets to 0 on relog
-
-
Okay, this seemed to work better.. on logging in It was synced until I subtracted w/ the infusion recipe, in which it desynced again: CapabilityManaData storage = mc.thePlayer.getCapability(CapabilityMagic.MANA, null); PlentifulMisc.network.sendToServer(new ManaNetworkSyncClient(storage.getManaStored())); String string = "MANA: " + Integer.toString(storage.getManaStored()); mc.fontRendererObj.drawString(string, 50 + 1, 50, 50); the output: 8000 8000 8000 8000 8000 8000 8000 500 8000 500 8000 500 8000 8000 500 500 8000 500
-
That seemed to fix my error, however Its still not updating my display, do I need to do something here?: CapabilityManaData storage = mc.thePlayer.getCapability(CapabilityMagic.MANA, null); String string = "MANA: " + Integer.toString(storage.getManaStored()); mc.fontRendererObj.drawString(string, 50 + 1, 50, 50);
-
Yeah, still the same error
-
Yeah I had one here: public ManaSyncMessageClient(){}
-
Okay, steps closer, however, now I'm getting this crash: java.lang.RuntimeException: java.lang.InstantiationException: com.lambda.plentifulmisc.PlentifulMisc$ManaSyncMessageClient$MessageHandler at com.google.common.base.Throwables.propagate(Throwables.java:160) ~[guava-17.0.jar:?] at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.instantiate(SimpleNetworkWrapper.java:174) ~[forgeSrc-1.11-13.19.0.2180.jar:?] at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.registerMessage(SimpleNetworkWrapper.java:164) ~[forgeSrc-1.11-13.19.0.2180.jar:?] at com.lambda.plentifulmisc.PlentifulMisc.preInit(PlentifulMisc.java:84) ~[PlentifulMisc/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91] at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:602) ~[forgeSrc-1.11-13.19.0.2180.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:243) ~[forgeSrc-1.11-13.19.0.2180.jar:?] at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:221) ~[forgeSrc-1.11-13.19.0.2180.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:145) [LoadController.class:?] at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:615) [Loader.class:?] at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:264) [FMLClientHandler.class:?] at net.minecraft.client.Minecraft.startGame(Minecraft.java:476) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:385) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91] 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 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:26) [start/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91] at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) [idea_rt.jar:?] Caused by: java.lang.InstantiationException: com.lambda.plentifulmisc.PlentifulMisc$ManaSyncMessageClient$MessageHandler at java.lang.Class.newInstance(Class.java:427) ~[?:1.8.0_91] at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.instantiate(SimpleNetworkWrapper.java:171) ~[forgeSrc-1.11-13.19.0.2180.jar:?] ... 50 more Caused by: java.lang.NoSuchMethodException: com.lambda.plentifulmisc.PlentifulMisc$ManaSyncMessageClient$MessageHandler.<init>() at java.lang.Class.getConstructor0(Class.java:3082) ~[?:1.8.0_91] at java.lang.Class.newInstance(Class.java:412) ~[?:1.8.0_91] at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.instantiate(SimpleNetworkWrapper.java:171) ~[forgeSrc-1.11-13.19.0.2180.jar:?] ... 50 more It crashes on the registration: network.registerMessage(ManaSyncMessageClient.MessageHandler.class, ManaSyncMessageClient.class, 0, Side.SERVER); Here is the updated packet: class ManaSyncMessageClient implements IMessage { private int mana; public ManaSyncMessageClient(){} public ManaSyncMessageClient(int toSend) { this.mana = toSend; } @Override public void toBytes(ByteBuf buf) { // Writes the int into the buf buf.writeInt(mana); } @Override public void fromBytes(ByteBuf buf) { // Reads the int back from the buf. Note that if you have multiple values, you must read in the same order you wrote. mana = buf.readInt(); } public class MessageHandler implements IMessageHandler<ManaSyncMessageClient, IMessage> { @Override public IMessage onMessage(ManaSyncMessageClient message, MessageContext ctx) { IThreadListener mainThread = Minecraft.getMinecraft(); // or Minecraft.getMinecraft() on the client mainThread.addScheduledTask(new Runnable() { @Override public void run() { if(Minecraft.getMinecraft().thePlayer.hasCapability(CapabilityMagic.MANA, null)) { CapabilityManaData cap = Minecraft.getMinecraft().thePlayer.getCapability(CapabilityMagic.MANA, null); cap.setManaStored(mana); } System.out.println(String.format("Received %s from %s", message.mana, ctx.getServerHandler().playerEntity.getDisplayName())); } }); return null; // no response in this case } } } Thanks for your help
-
Closer..? @Override public IMessage onMessage(PMMessages message, MessageContext ctx) { IThreadListener mainThread = (WorldServer) ctx.getServerHandler().playerEntity.worldObj; // or Minecraft.getMinecraft() on the client mainThread.addScheduledTask(new Runnable() { @Override public void run() { CapabilityManaData cap = ctx.getServerHandler().playerEntity.getCapability(CapabilityMagic.MANA, null); cap.setManaStored(mana); System.out.println(String.format("Received %s from %s", message.mana, ctx.getServerHandler().playerEntity.getDisplayName())); } }); return null; // no response in this case }
-
Okay so something like this? public class MessageHandler implements IMessageHandler<Messages, IMessage> { @Override public IMessage onMessage(Messages message, MessageContext ctx) { EntityPlayerMP serverPlayer = ctx.getServerHandler().playerEntity; int amount = message.mana; if(serverPlayer.hasCapability(CapabilityMagic.MANA, null)) { CapabilityManaData cap = serverPlayer.getCapability(CapabilityMagic.MANA, null); amount += cap.getManaStored(); } return null; } } If so how would I access ti and access the amount variable.
-
Okay, that was pretty easy:) , now would would I register it so that capability data is 'packet-ized?' :^)