Jump to content

Recommended Posts

Posted (edited)

 

Hey, I have an event where an animation is triggered after the player attacks or right clicks the entity. When the entity is attacked or right clicked, it is supposed to trigger new AI (which I got working with ease) and set an animation to open the entity's eyes (which I'm struggling with). I accomplished the AI part with a pair of setters and getters for a boolean which returns true when the event happens. I also got a pair of setters and getters for the model class and set the boolean to equal the boolean in the entity class, as well as an if statement in the livinganimations to trigger the animation, which right now is just a simple edit to the model rotations.

 

Here is my model class

  Reveal hidden contents

 

And here is the Entity class

  Reveal hidden contents

Event class:

  Reveal hidden contents

EDIT: So i got the boolean in the model class to set to true, the if statement in setLivingAnimation just isn't working

EDIT2: Yeah, the boolean is set to true and the AwakeAnimation IS being called, but for some reason, it isn't picking up the boolean as true

Edited by GooberGunter
Posted (edited)

Update: So it looks like the boolean is set to true when the setter is called but doesn't remain true

Unfortunately, this is as far as I can figure out. I can't think of a solution for this and I haven't really worked with triggered animations before

Edited by GooberGunter
Posted

You're setting awake on the server.

You're expecting the client to render something.

 

You need to tell the client that the data has changed.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

The magic of packets

  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)

Alright I've Been looking around for a while and I can't find any good tutorials on packets. I mean I understand the whole making a class for the message that has methods to send info to and from bits, but I don't know how it all fits together. Why do I need a message handler? How do I set information to the packet? How do I get the information? The forge documentation didn't give me much insight

 

Edited by GooberGunter
Posted (edited)

So I followed cjminecraft's tutorial, only understanding what I'm doing here and there, and I got myself a promising error:

  Reveal hidden contents

Model Code: Most of the important stuff is the AwakeAnimation

  Reveal hidden contents

Here's just the AwakeAnimation method:

  Reveal hidden contents

Packet Handler:

  Reveal hidden contents

PacketGetAwaken:

  Reveal hidden contents

PacketReturnAwaken:

  Reveal hidden contents

 

Now you'll probably see a lot of weird things, but, like I said, I kinda just tumbled through this.

Usually, I'm able to figure it out, but Networking is something I have never worked with

Edited by GooberGunter
Posted
java.lang.NullPointerException
    at com.ninja3659.explorationexpansion.client.model.ModelBeelzebook.AwakeAnimation(ModelBeelzebook.java:193) ~[ModelBeelzebook.class:?]

Something is null where it shouldn't be. I'm guessing line 193 is probably this one, right?

NeemPacketHandler.INSTANCE.sendToServer(new PacketGetAwaken(entity.getentityAwake(), "com.ninja3659.explorationexpansion.client.model.ModelBeelzebook", "awake", entity.getEntityId()));

 

Where do you call the registerMessages method of your PacketHandler?

Posted (edited)

Yeah...I had no idea what was going on in the tutorial. The class name and field name were supposed to be "java reflection" but I never saw the point in it. But considering the fact that I've never done this before, I figured, what do I know.

I updated the code, it should be a little better but I still don't know when and where to call the sendTo part. 

 

NeemPacketHandler:

  Reveal hidden contents

PacketReturnAwaken:

  Reveal hidden contents

Also, I register the messages through the common proxy (which may or may not be a bad idea; which I don't doubt) in a method called preInit() which is called in the preInit message in the main core mod class. But naturally, when I ran that code, I forgot to call the proxy method. 

Edited by GooberGunter
Posted

Your packet doesn't do anything when it arrives. 

		void proccessMessage(PacketReturnAwaken message) {
			try {
				
			}catch(Exception e) {
				Utils.getLogger().catching(e);
			}
		}

So blank, much void, many noop. Wow.

 

Additionally, your packet doesn't have any way of finding the entity it needs to awaken. 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)

So I figured it could find the entity via entityid through this line, 

EntityBeelzebook eb = (EntityBeelzebook) ctx.getServerHandler().playerEntity.getServerWorld().getEntityByID(id);

so I created another variable int entityid and wrote the code to and from bytes, I just don't know where I should go from here

  Reveal hidden contents

What code belongs in the handler and how do I connect the variables in the constructor of the message to the variables in my entity class?

EDIT: Ok so I think I'm good storing the boolean from the entity to the packet. I just don't know how to update the other boolean in my model class to the packet one

 

Also I know that send to all is a very bad idea for this, but I can't get the entity tracker working right now and since I'm the only one testing, I'll just put it in for now and fix it later when the actual packet works

Edited by GooberGunter
Posted (edited)

Wait, would I set the boolean in the model class to the packet boolean in the message handler?

EDIT: I looked back at the forge documentation and I got an idea, I'm about to test this

PacketReturnAwake:

  Reveal hidden contents

And the Method in EntityBeelzebook:

  Reveal hidden contents

it gave me an error about casting NetHandlerPlayClient to NetHanlderPlayServer at the declaration of eb

 

 

Edited by GooberGunter
Posted

Random question: why do uou pass both message (which you use to pull message.awake) and message.id?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)

I pass the message. id to put in the entityid for the initialization of the eb variable so that I could use the getModel() method in my EntityBeelzebook class and have access from there. Without the id i can't initialize it. Why? is there a better way?

 

Initialization is my weakness

Edited by GooberGunter
Posted (edited)

If you're passing the message itself as a parameter, then you can access the message's entityid field locally in the method - by passing it separately you're basically passing the same information to the method twice.

  On 7/18/2017 at 4:28 PM, GooberGunter said:

it gave me an error about casting NetHandlerPlayClient to NetHanlderPlayServer at the declaration of eb

Expand  

Post the error.

Edited by Jay Avery
Posted (edited)

Here's the error

  Reveal hidden contents

 

And I got rid of int id in processMessage and replaced it with message.entityid

Edited by GooberGunter
Posted (edited)

So I have it all set up, but the boolean awake in the model class is Not being set to true for some reason

PacketReturnAwaken:

  Reveal hidden contents

Model:

  Reveal hidden contents

Here is the method in the entity class:

  Reveal hidden contents

Everything Looks to be in good shape, i don't know what could be the problem

 

on the flip side, I feel like I'm getting a better understanding of packets

Edited by GooberGunter

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hi! I've been running a server on Minecraft using the Prodigium Reforged pack on curse forge using the site exaroton. It was working fine until randomly encountering this error every time anyone tries to connect to the server, I've already reloaded backups and deleted json files  Here is the crash report https://mclo.gs/EwKw51q. Thanks for the help in advance
    • nevermind i figured out the issue  
    • I was trying to host a server with the 1.21.1 cobbleverse forge mod, but when I tried starting it, it kept giving me this error. Crash report here: https://pastebin.com/AsE1X5QY   Thanks
    • This mod lets you choose an element power, Earth, Wind, Fire, or Water. Also two secret element powers Light and Darkness. Each power gives good a bad things, Earth lets you dig through anything but ores and bedrock, Wind lets you jump high in the air every three seconds, Fir lets you throw fire balls and you are immune to any flame/lava but you can't go into water or else you take damage, Water you swim and break blocks under water quicker and you can get rid of water like a sponge but you take more damage when in fire/lava, Light makes you faster at day but slower at night you are able to throw light spears that do four hearts and can go through any armor, Darkness let's you be faster at night but slower at day mobs don't harm you but peaceful mobs run away from you you are able to spawn ink creatures around you that are like dogs but are stronger. another thing in the mod is that there are other dimensions that can get you ores to make better armor and weapons, each dimensions are are good for a certain element though each dimension has a boss depending on which dimension one dimension has more than one boss, each elements are required to defeat the bosses with each others help.
    • Read the posts above yours, it tells you exactly how to do it, instructions are the same if it's making a forge installation or a vanilla one, just make a new folder for the game directory.
  • Topics

×
×
  • Create New...

Important Information

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