Jump to content

DoctorOne

Members
  • Posts

    15
  • Joined

  • Last visited

Posts posted by DoctorOne

  1. 19 minutes ago, diesieben07 said:

    Post the complete log.

    Here

    [19:15:38] [Netty Server IO #6/ERROR] [FML]: There was a critical exception handling a packet on channel mkrex
    java.lang.NoSuchFieldError: player
    	at com.mahmudkocas.realextras.MyMessageHandler.onMessage(MyMessageHandler.java:32) ~[MyMessageHandler.class:?]
    	at com.mahmudkocas.realextras.MyMessageHandler.onMessage(MyMessageHandler.java:1) ~[MyMessageHandler.class:?]
    	at net.minecraftforge.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper.channelRead0(SimpleChannelHandlerWrapper.java:56) ~[SimpleChannelHandlerWrapper.class:?]
    	at net.minecraftforge.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper.channelRead0(SimpleChannelHandlerWrapper.java:36) ~[SimpleChannelHandlerWrapper.class:?]
    	at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) ~[SimpleChannelInboundHandler.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) ~[AbstractChannelHandlerContext.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) ~[AbstractChannelHandlerContext.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) ~[AbstractChannelHandlerContext.class:?]
    	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) ~[MessageToMessageDecoder.class:?]
    	at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) ~[MessageToMessageCodec.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) ~[AbstractChannelHandlerContext.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) ~[AbstractChannelHandlerContext.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) ~[AbstractChannelHandlerContext.class:?]
    	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334) ~[DefaultChannelPipeline$HeadContext.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) ~[AbstractChannelHandlerContext.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) ~[AbstractChannelHandlerContext.class:?]
    	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926) ~[DefaultChannelPipeline.class:?]
    	at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:274) ~[EmbeddedChannel.class:?]
    	at net.minecraftforge.fml.common.network.internal.FMLProxyPacket.func_148833_a(FMLProxyPacket.java:99) [FMLProxyPacket.class:?]
    	at net.minecraft.network.NetworkManager.channelRead0(NetworkManager.java:147) [gw.class:?]
    	at net.minecraft.network.NetworkManager.channelRead0(NetworkManager.java:49) [gw.class:?]
    	at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [SimpleChannelInboundHandler.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [AbstractChannelHandlerContext.class:?]
    	at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.handleServerSideCustomPacket(NetworkDispatcher.java:452) [NetworkDispatcher.class:?]
    	at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.channelRead0(NetworkDispatcher.java:264) [NetworkDispatcher.class:?]
    	at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.channelRead0(NetworkDispatcher.java:72) [NetworkDispatcher.class:?]
    	at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) [SimpleChannelInboundHandler.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [AbstractChannelHandlerContext.class:?]
    	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293) [ByteToMessageDecoder.class:?]
    	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267) [ByteToMessageDecoder.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [AbstractChannelHandlerContext.class:?]
    	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293) [ByteToMessageDecoder.class:?]
    	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267) [ByteToMessageDecoder.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [AbstractChannelHandlerContext.class:?]
    	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293) [ByteToMessageDecoder.class:?]
    	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267) [ByteToMessageDecoder.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [AbstractChannelHandlerContext.class:?]
    	at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:287) [IdleStateHandler.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [AbstractChannelHandlerContext.class:?]
    	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334) [DefaultChannelPipeline$HeadContext.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [AbstractChannelHandlerContext.class:?]
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [AbstractChannelHandlerContext.class:?]
    	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926) [DefaultChannelPipeline.class:?]
    	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:134) [AbstractNioByteChannel$NioByteUnsafe.class:?]
    	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:624) [NioEventLoop.class:?]
    	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:559) [NioEventLoop.class:?]
    	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:476) [NioEventLoop.class:?]
    	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:438) [NioEventLoop.class:?]
    	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) [SingleThreadEventExecutor$5.class:?]
    	at java.lang.Thread.run(Unknown Source) [?:1.8.0_201]

     

  2. 7 minutes ago, diesieben07 said:

    You can't load client-only classes on the server. "Needing to", doesn't change it. You cannot.

    Also: Every class directly referencing client-only classes immediately also becomes client-only.

    Well, I forget to edit that. I changed code, I am only using this class at client. And I changed the SideOnly to EventBusSubscriber but still getting the error.

    Quote

    Caused by: java.lang.NoSuchMethodError: net.minecraft.client.Minecraft.getMinecraft()Lnet/minecraft/client/Minecraft;

    Code
     

    @EventBusSubscriber(modid = Main.MODID, value = Side.CLIENT)
    public class EventsClientSide {
    	

     

  3. Now I am getting different error, and what is with this
     

    Quote

    java.lang.NoSuchFieldError: player

    The Code is as below

    	public IMessage onMessage(MyMessage message, MessageContext ctx) {
    		if(Main.SIDE == Side.SERVER) {
    			if(Main.SHOULD_KICK) {
    				try {
    				ctx.getServerHandler().player.getServerWorld().addScheduledTask(()-> { //Thats where error refers, the player object.

     

    What could be the possible problem here ? Like how the hell is this not getting player?

     

  4. 12 minutes ago, Draco18s said:

    More like "mildly annoying." Packets really aren't that bad.

    Yes, but I want to put more in it. Its not that annoying.

     

    1 hour ago, diesieben07 said:

    Complete BS.

    Hahaha, this really got me.

  5. 22 minutes ago, DavidM said:

    You are still using Minecraft#getMinecraft on the client.

    Adding the @SideOnly will not make your code client-sided; specify the side of your event subscriber in your @EventBusSubscriber annotation.

    	if(SIDE == Side.SERVER) {
        		EventsServerSide eventsServerSide = new EventsServerSide();
        	} else {
        		EventsClientSide eventsClientSide = new EventsClientSide();
        	}

    I am checking that before hand.
    I am getting side in PreInit

     	@EventHandler
        public void preInit(FMLPreInitializationEvent event)
        {
            SIDE = event.getSide();
        }

     

    Edit:

    Quote

    You are still using Minecraft#getMinecraft on the client.

    Wait, can't I use this at client? I thought I can't use it at Server

  6. I am trying to send client only message. The code itself works when I run my client with Eclipse. But when I put my mod in a mod pack, it just doesn't. Also I am calling "getMinecraft()" at client not server. And crashing side is also client.

    The Code

    @SideOnly(Side.CLIENT)
    public class EventsClientSide {
    	
    	public EventsClientSide() {
    		MinecraftForge.EVENT_BUS.register(this);
    	}
    	
    	@SubscribeEvent
    	public void clientTick(ClientTickEvent event) {
    		if(Main.MESSAGE_RECEIVED_CLIENT) {
    			Minecraft.getMinecraft().player.sendMessage(new TextComponentString("You have joined to server!"));
    			Main.MESSAGE_RECEIVED_CLIENT = false;
    		}
    	}
    }


    The error
     

    Quote

    java.lang.NoSuchMethodError: net.minecraft.client.Minecraft.getMinecraft()Lnet/minecraft/client/Minecraft;

     

    I don't know whats wrong. I tried both Forge builds[Recommended and Latest]. It just denies to work.

    I am new to Forge API. It's been 3 days, I am working on it. Everything was fine and working at test phase. Then I put the mod inside a mod pack, it started to give me errors. Solid red pages. Then booom client crashes.

  7. So if anyone needs in the future, below is the way I solved my problem.

    	@SubscribeEvent
    	public static void mouseEvent(MouseEvent event) {
    		if(Main.SIDE == Side.CLIENT && Main.IS_PLAYER_IN_SERVER) {
    			Main.IS_PLAYER_IN_SERVER = false;
    			Minecraft.getMinecraft().addScheduledTask(() -> {
    				Main.network.sendToServer(new MyMessage("Message"));
    			    });
    		}
    	}
    	
    	@SubscribeEvent
    	public static void clientSideJoin(ClientConnectedToServerEvent event) {
    		Main.IS_PLAYER_IN_SERVER = true;
    	}
    	
    	@SubscribeEvent
    	public static void clientSideDisconnect(ClientDisconnectionFromServerEvent event) {
    		Main.IS_PLAYER_IN_SERVER = false;
    	}

     

    If anyone wonders where I get SIDE from, I get "SIDE" in PreInit:
     

    	@EventHandler
    	public static void PreInit(FMLPreInitializationEvent event) {
    		SIDE = event.getSide();
    			
    	}

     

  8. 4 hours ago, Draco18s said:

    Remember:

    The Client is a lying, cheating bastard. Never trust the client for anything. There is no way to insure the integrity of the client, for any message the client sends can be faked.

    What a bitch. Yeah, I have some experience with that.
    You guys are right at that point. But I am thinking this will be the case if I publish the mod publicly. I am running small server, generally kids are playing in. They know how to install the mod but i don't think if they know how to bypass. Well, if they know how to bypass then "You can cheat, but don't get caught!" rule works. Anyway I am still gonna try and make this mod. Thx all of you!

  9. 2 hours ago, diesieben07 said:

    You can't. The client cannot be trusted.

     

    • Packets must always be registered on both sides. The last parameter to registerMessage defines the direction (server to client or client to server) the packet goes. But the call to registerMessage must happen on both sides and the exact same way. 
    • You can't immediately do things in onMessage, as that is running on the network thread. Read the warnings in the packet documentation.
    Quote

    You can't. The client cannot be trusted.

    Yeah.. I know that much, but I wanna do what I can. And if client doesn't send the message or sends inappropriate message,  I am thinking "kick the client" anyway.
    So whole "if else" is unnecessary. Because it has to be registered both sides. 
    And I can't use the "onMessage" becuz Minecraft just doesn't work like that. Also I can't send messages with "ClientConnectedToServerEvent" since its too early for that.
    So I need to use an event like, walking and kind of that things. Hopefully those work. Thx!

  10. First of all, I am new to Forge API(3-4 Hours) but I have some experiences with Java.
    So here is my purpose: I want to make a mod that checks all the mods client has at the folder and sends the list to Server. Than server kicks if anyone changed the mods or added any new the mods.
    My Question is: How do I send message to Server.

    I followed this tutorial and checked this one. They helped quite a lot. But I can't send the data pack to Server. Client receives the pack and according to debug I have done, its also sending the packet but Server is not reading it.

     

    I don't know if I am doing something wrong, is there a way to force Server to read the message?


    Here is the code:

     

    Initialization(in-it)

    @EventHandler
    	public static void init(FMLInitializationEvent event) {
    		if(SIDE == Side.CLIENT) {
    			network.registerMessage(MyMessageHandler.class, MyMessage.class, PACKET_ID, Side.CLIENT);
    			System.out.println("LOOK ITS CLIENT!");
    		}
    		if(SIDE == Side.SERVER) {
    			network.registerMessage(MyMessageHandler.class, MyMessage.class, PACKET_ID, Side.SERVER);
    			System.out.println("LOOK ITS SERVER!");
    		}
    		MinecraftForge.EVENT_BUS.register(ServerSideJoin.class);

     


    My Message.Class

    public class MyMessage implements IMessage {
    	  public MyMessage(){}
    
    	  public CharSequence toSend;
    	  public MyMessage(String toSend) {
    	    this.toSend = toSend;
    	    Main.PACKET_ID++;
    	  }
    
    	  @Override public void toBytes(ByteBuf buf) {
    			System.out.println("TO BYTESS!!!!!!!!!");
    		    buf.writeCharSequence(toSend, Charset.defaultCharset());
    		    registerMessage();
    	  }
    
    	  @Override public void fromBytes(ByteBuf buf) {
    		  System.out.println("FROM BYTESS!!!!!!!!!");
    		  toSend = buf.readCharSequence(buf.readableBytes(), Charset.defaultCharset());
    		  registerMessage();
    	  }
    	  
    	  public void registerMessage() {
    		  if(Main.SIDE == Side.CLIENT) {
    			  	Main.PACKET_ID++;
    		    	Main.network.registerMessage(MyMessageHandler.class, MyMessage.class, Main.PACKET_ID, Side.CLIENT);
    				System.out.println("LOOK ITS CLIENT!");
    			}
    			if(Main.SIDE == Side.SERVER) {
    				Main.PACKET_ID++;
    				Main.network.registerMessage(MyMessageHandler.class, MyMessage.class, Main.PACKET_ID, Side.SERVER);
    				System.out.println("LOOK ITS SERVER!");
    			}
    	  }
    	}


    Handler

    public class MyMessageHandler implements IMessageHandler<MyMessage, IMessage> {
    // Do note that the default constructor is required, but implicitly defined in this case
    	public MyMessageHandler() {
    		// TODO Auto-generated constructor stub
    	}
    	@Override 
    	public IMessage onMessage(MyMessage message, MessageContext ctx) {
    		System.out.println("RECEIVED!!!");
    		System.out.println("THE MESSAGE : " + message.toSend);
    		if(Main.SIDE == Side.CLIENT) {
    			Main.network.sendToServer(new MyMessage("MESSAGE FROM CLIENT!!!!"));
    		}
    	 return null;
    	}
    
    }


    When Player Joins, Server Sends the Packet

    public class ServerSideJoin {
    	@SubscribeEvent
    	public static void onPlayerJoin(EntityJoinWorldEvent event) {
    		if(event.getEntity() instanceof EntityPlayerMP) {
    			Main.network.sendTo(new MyMessage("THE MESSAGE FROM SERVER"), (EntityPlayerMP) event.getEntity());
    		}
    	}
    }


    Thx

×
×
  • Create New...

Important Information

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