Jump to content

[1.11] Capability Display not updating.


Lambda

Recommended Posts

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();
    }

}

Relatively new to modding.

Currently developing:

https://github.com/LambdaXV/DynamicGenerators

Link to comment
Share on other sites

Does it ever get passed this if statement?

if(Minecraft.getMinecraft().thePlayer.hasCapability(CapabilityMagic.MANA, null)) {

And if so what side is not updating it will say this if you add a string to your println.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

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?

Relatively new to modding.

Currently developing:

https://github.com/LambdaXV/DynamicGenerators

Link to comment
Share on other sites

Incompatible types.

Check to see if your toBytes and fromBytes are being called.

Nevermind I now see the problem you are sending it to the server and not the client.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

So what method would I use for sending it to client?

sentTo

?

SimpleNetworkWrapper#sendTo(new Message(), player);

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

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,

Relatively new to modding.

Currently developing:

https://github.com/LambdaXV/DynamicGenerators

Link to comment
Share on other sites

You have a EntityLivingBase field in your capability right? Is that not supposed to be the player? If not you need some way to set the player in the capability.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

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

Relatively new to modding.

Currently developing:

https://github.com/LambdaXV/DynamicGenerators

Link to comment
Share on other sites

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

Where do you set it? And where do you call your methods that change the amount of mana.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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