Jump to content

Recommended Posts

Posted

I get this error every time I try to open my world. I am using MCAnimator and this is one of the classes. I am using Forge 1.8, Java 1.7 (I tried both 1.7 and 1.8 java they both didn't work).

 

 

  Reveal hidden contents

 

 

AnimTickHandler:

 

  Reveal hidden contents

 

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Posted

Jesus!

 

CMO appears when you are manipulating contents of collection while they are being in use. Example: One thread is iterating through collection while other thread removes entries.

 

Which is literally what you did. You have 2 arrays shared between client and server event. ClientTick is fired by client thread, server, by server.

You need to have separate arrays for each logical side or not allow client to remove stuff.

Also note that you should remember about thing called "dedic" where clients don't have server thread.

  Quote

1.7.10 is no longer supported by forge, you are on your own.

Posted

CME can occur even on a single-threaded application, so it is not necessarily a threading issue; in fact, variables exist separately in Minecraft client vs. server because they are (or effectively are) separate applications, so if you had a List that existed on both sides, you could modify it to your heart's content on one side without the other side ever being affected by it. That's why you need packets to communicate between the two.

 

Anyway, you can safely remove elements using Iterators, but not the standard List methods. A quick search on Google brings up lots of information; e.g. this SO question which should help your specific situation.

 

Other solutions are to make a copy of the collection, but I usually prefer iterators when I wish to remove elements mid-iteration.

Posted

Ok heres what I made with Iterators:

 

 

  Reveal hidden contents

 

 

Would this be correct? And should I put it in both client and server or what? I'm kinda confused on this.

 

So the client runs and starts deleting files that the server is currently iterating through? Is that correct?

 

Thanks

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Posted
  On 12/1/2015 at 2:31 AM, Asweez said:

Ok heres what I made with Iterators:

 

 

  Reveal hidden contents

 

o.0 I don't see any Iterator in there at all, just a foreach loop. Please, if you don't know what something is, search before you ask. There are literally thousands of pages discussing how to use Iterators in Java that you should read rather than wasting our time here.

 

  Quote

So the client runs and starts deleting files that the server is currently iterating through? Is that correct?

  Quote

variables exist separately in Minecraft client vs. server because they are (or effectively are) separate applications, so if you had a List that existed on both sides, you could modify it to your heart's content on one side without the other side ever being affected by it.

How is that not clear? And "files" ?! You're not handling any files at all in the code you posted...

Posted

MCAnimator.  There's your problem.  The animation system exported by MCAnimator is rife with problems.  You will not be able to fix this on your own.

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
  On 12/1/2015 at 2:47 AM, coolAlias said:

o.0 I don't see any Iterator in there at all, just a foreach loop. Please, if you don't know what something is, search before you ask. There are literally thousands of pages discussing how to use Iterators in Java that you should read rather than wasting our time here.

 

Sorry posted the wrong code, here's the correct code:

 

 

  Reveal hidden contents

 

 

  Quote

MCAnimator.  There's your problem.  The animation system exported by MCAnimator is rife with problems.  You will not be able to fix this on your own.

 

MCAnimator is not my go-to modeling program, but I have a Mac so there's no other option :/

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Posted

You are not using the Iterator to remove the element... -.-

 

Please, search 'removing Collection element with Iterator' or some such to learn how to use them to remove entries from a Collection.

 

Also, you won't need a removableEntities list - you can remove the entry directly when found (when using the Iterator correctly).

Posted

I did that:

 

 

  Reveal hidden contents

 

 

And it is in both the client and the server tick methods. However, I still get CME, even when I don't remove anything from the lists (deleting it#remove()). Why?

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Posted

AnimTickHandler:

 

  Reveal hidden contents

 

 

Log:

 

  Reveal hidden contents

 

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Posted

Well, that's pretty bizarre. Using an Iterator to remove elements should generally protect you from CME in this type of scenario - the only other thing I can think of that you can try is to surround your current list traversal with a synchronized block:

synchronized (activeEntities) {
   // iterator code and iterate over list
}

That will prevent any other methods or threads from accessing the activeEntities List until that code block completes.

 

Perhaps someone with more Java knowledge will be able to explain your problem, as I am at the end of mine with respect to CME :\

Posted

1. Using "synchronized" kills purpose of having multi-threading (in Minecraft case it would cause Client tick to "wait" for Server tick or other way around, not to mention that it is totally logic-breaking).

 

2. If you SUPER-NEED to have one Collection for both threads (which is, as alredy mentioned: retarded), you will need... idk... Lock interface (ReentrantReadWriteLock.class). Which again - will break EVERYTHING, since stuff like this is not compatible with Minecraft design. Lock is used to perfom very fast actions while securing from concurrency.

 

3. MC is not designed to handle synchronization - so DON'T do that!

  On 12/1/2015 at 1:08 AM, Ernio said:

You need to have separate arrays for each logical side or not allow client (or server) to remove stuff.

Also note that you should remember about thing called "dedic" where clients don't have server thread.

 

4. Make those 2 arrays or proxify your code :

On MP:

- Dedic runs ServerTickEvent on its own array.

- Client runs ClientTickEvent on its own array.

On SP:

- Only ServerTickEvent manipulates array

*Which I will AGAIN say - is REALLY bad. Server should not manipulate client stuff and other way around.

  Quote

1.7.10 is no longer supported by forge, you are on your own.

Posted

So I need to have a entitiesServer and an entitiesClient list? The MCA help thing said that animations are run both on client and server. Is this right? Is there any way to get around all of this client server tick stuff or is there another solution that I can use to animate my model?

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Posted

@Ernio I don't know where you're getting all this multi-threading stuff from - MC is not really multi-threaded except for the network, and that is, well... not well done. The server and client run as separate applications (unless on single player), not threads, so synchronizing a block (which does the same thing as a lock) in one application has no effect on the other application.

 

Even in single player, having a single array or Collection that operates on both sides, there is already a separate instance of it on each side. Otherwise doing:

List list = new ArrayList();

someMethod(World world) {
  if (world.isRemote) {
    list.add("you won't see this on the server!");
  } else {
    print list to screen; // nothing will ever show up here because the server list is separate from the client list
  }
}

 

Anyway, @OP Animations are usually triggered by the server, but only run on the client. What that means is, for example, an entity performs an attack on the server (the trigger) which sends a notification to the client saying "I (the entity) am attacking now" and the client then starts the animation timer for the attack animation.

 

I don't know how MCAnimator is set up or expects things to be handled, but really you shouldn't need any sort of Collection to handle animating entities - that should be done in the Entity class (for the triggers and possibly a timer) and the entity's Render / Model class (for the actual animations).

 

For a good example of this, check out the Iron Golem, specifically its attack on the server and how that triggers a client-side animation by using World#setEntityState in combination with the entity's #handleHealthUpdate methods, a class field for the timer that gets set on both sides, and a Model class that uses that timer to change the arm position.

Posted
  On 12/2/2015 at 10:33 AM, diesieben07 said:

coolAlias, what you are saying is not always true. Unless there is an underlying mechanism already that separates the two sides into two instances (e.g. with Entities, TileEntities, etc.) fields will not just be magically different between client and server in SinglePlayer.  The two sides run on the same VM, in the same process. If you have an EventHandler somewhere and put a list in it this list will be shared between client & server.

Yeah, you're right. I was thinking in terms of Entity, but if you have an event handler or similar class on single player (which the OP does...), the class fields will be shared (so even if you only add things to the list on 1 side, the other side will have that same data without packets). Thanks for the correction.

 

@OP The above could explain why you are getting CME if you are only getting it in Single Player - both client and server threads (and SP is where MC is actually multi-threaded, as Ernio was saying) are iterating over the list. Adding a synchronized block or any kind of Lock should work but could negatively impact performance on single player (you probably won't notice), or using separate collection instances for each thread (again as Ernio suggested).

 

Still, the best solution is to animate as I described in my previous post, and forget all this tick event business. What you have now is not the best way to animate an entity.

Posted
  On 12/2/2015 at 3:20 PM, coolAlias said:

Still, the best solution is to animate as I described in my previous post, and forget all this tick event business. What you have now is not the best way to animate an entity.

 

Read: MCAnimator is crap. It makes all kinds of assumptions which end up being false. You fix this problem and another will pop up else where. I tried once to fix it and I could not. The animation code is just too complex and too buggy.

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
  On 12/2/2015 at 6:49 PM, Draco18s said:

  Quote

Still, the best solution is to animate as I described in my previous post, and forget all this tick event business. What you have now is not the best way to animate an entity.

 

Read: MCAnimator is crap. It makes all kinds of assumptions which end up being false. You fix this problem and another will pop up else where. I tried once to fix it and I could not. The animation code is just too complex and too buggy.

 

I know MCAnimator is not the best, but do you have any other option for model making and animations for macs?

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Posted

I've heard good things about Tabula, though I've never used it personally and don't know if it's for Mac.

 

Otherwise, use MCAnimator to create the models and then position your model in various intermediate poses, then cycle through them to create an animation. Jabelar has a pretty good tutorial on that floating around somewhere - find one of his posts and click the link in his signature for his blog.

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.