Lambda Posted December 13, 2016 Posted December 13, 2016 Hello there, So I'm syncing my capability between the server and client, however, when I try to extract mana, I get this error: Dec 12, 2016 9:10:01 PM 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) 0 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.extractMana(CapabilityManaData.java:85) 8520 at com.lambda.plentifulmisc.magic.internal.CapabilityManaData.extractManaInternal(CapabilityManaData.java:43) [21:10:01] [server thread/ERROR]: FMLIndexedMessageCodec exception caught at com.lambda.plentifulmisc.tile.magic.TileEntityChargeStand.updateEntity(TileEntityChargeStand.java:41) java.lang.RuntimeException: PLAYER target expects a Player arg at com.lambda.plentifulmisc.tile.TileEntityBase.update(TileEntityBase.java:193) at net.minecraftforge.fml.common.network.FMLOutboundHandler$OutboundTarget$4.validateArgs(FMLOutboundHandler.java:125) ~[FMLOutboundHandler$OutboundTarget$4.class:?] at net.minecraft.world.World.updateEntities(World.java:1968) 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 net.minecraft.world.WorldServer.updateEntities(WorldServer.java:646) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:794) at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:651) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:698) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:112) ~[MessageToMessageEncoder.class:4.0.23.Final] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:547) at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116) ~[MessageToMessageCodec.class:4.0.23.Final] at java.lang.Thread.run(Thread.java:745) 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:85) [CapabilityManaData.class:?] at com.lambda.plentifulmisc.magic.internal.CapabilityManaData.extractManaInternal(CapabilityManaData.java:43) [CapabilityManaData.class:?] at com.lambda.plentifulmisc.tile.magic.TileEntityChargeStand.updateEntity(TileEntityChargeStand.java:41) [TileEntityChargeStand.class:?] at com.lambda.plentifulmisc.tile.TileEntityBase.update(TileEntityBase.java:193) [TileEntityBase.class:?] at net.minecraft.world.World.updateEntities(World.java:1968) [World.class:?] at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:646) [WorldServer.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:794) [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] [21:10:01] [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.extractManaInternal(CapabilityManaData.java:44) [CapabilityManaData.class:?] at com.lambda.plentifulmisc.tile.magic.TileEntityChargeStand.updateEntity(TileEntityChargeStand.java:41) [TileEntityChargeStand.class:?] at com.lambda.plentifulmisc.tile.TileEntityBase.update(TileEntityBase.java:193) [TileEntityBase.class:?] at net.minecraft.world.World.updateEntities(World.java:1968) [World.class:?] at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:646) [WorldServer.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:794) [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] Dec 12, 2016 9:10:01 PM 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.extractManaInternal(CapabilityManaData.java:44) at com.lambda.plentifulmisc.tile.magic.TileEntityChargeStand.updateEntity(TileEntityChargeStand.java:41) at com.lambda.plentifulmisc.tile.TileEntityBase.update(TileEntityBase.java:193) at net.minecraft.world.World.updateEntities(World.java:1968) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:646) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:794) 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) I needed to send a packet everytime that it is changed, so in my capability data, I have these: PlentifulMisc.network.sendTo(new ManaNetworkSyncClient(this.getManaStored()), (EntityPlayerMP) this.getEntity()); In every function that is changing the current mana. This is where the error occurs however, here is the entire class for reference: 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.sendTo(new ManaNetworkSyncClient(this.getManaStored()), (EntityPlayerMP) this.getEntity()); 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.getEntity()); 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) this.getEntity()); 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) this.getEntity()); // PlentifulMisc.network.sendToServer(new ManaNetworkSyncServer(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 int getPercentedMana() { return this.getManaStored() / this.getMaxManaStored(); } public void setManaStored(int energy){ this.mana = energy; } } The TE thats crashing it: public class TileEntityChargeStand extends TileEntityCrystalSearchBase { public final int MANA_PER_TICK = 50; public UUID uuid; public TileEntityChargeStand() { super("chargeStand"); } @Override public void updateEntity() { super.updateEntity(); if(!worldObj.isRemote) { System.out.println(storage.getManaStored()); EntityPlayer player = worldObj.getClosestPlayer(pos.getX(), pos.getY() + 1, pos.getZ(), 1, false); if (player != null) { if (player.getUniqueID().equals(uuid) && uuid != null) { if (player.hasCapability(CapabilityMagic.MANA, null)) { if (storage.getManaStored() >= 0) { CapabilityManaData cap = player.getCapability(CapabilityMagic.MANA, null); cap.receiveManaInternal(MANA_PER_TICK, false); this.storage.extractManaInternal(MANA_PER_TICK, false); } } } } } } @Override public void writeSyncableNBT(NBTTagCompound compound, NBTType type) { if(type != NBTType.SAVE_BLOCK) { //e compound.setUniqueId("ChargeUUID", uuid); } uuid = compound.getUniqueId("ChargeUUID"); super.writeSyncableNBT(compound, type); } @Override public void readSyncableNBT(NBTTagCompound compound, NBTType type) { if(type != NBTType.SAVE_BLOCK) { } uuid = compound.getUniqueId("ChargeUUID"); super.readSyncableNBT(compound, type); } } Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
hugo_the_dwarf Posted December 13, 2016 Posted December 13, 2016 Sounds like when you're sending it to the client you're not supplying a correct EntityPlayerMP or none at all. Send the correct one. If you're using an event or action you should have the Entity. just check to see if it is the player, then make sure you're on the serverside, cast it to EntityPlayerMP and then use it in your packet Quote Currently updating my Mod to 1.10.2 https://bitbucket.org/hugo_the_dwarf/riseoftristram2016/src?at=master
Lambda Posted December 13, 2016 Author Posted December 13, 2016 Ah yes, seems like if I do a check of the entity, it will work! Thanks Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Recommended Posts
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.