Jump to content

[1.15.2] Something wrong with my WorldSavedData [Solved]


_HungTeen_

Recommended Posts

I am making a WorldEventData class to save my world event set.

private HashSet<Events> events = new HashSet<>(Events.values().length);

When I add event to the set ,it seems ok.

public void addEvent(Events ev) {
		events.add(ev);
//		System.out.println(events.contains(ev));
		this.markDirty();
	}

If I use code below to check wheather it add correctly,it output nothing (means the event did't add correctly)

@SuppressWarnings("resource")
	@SubscribeEvent
	public static void onPlayerRightClick(RightClickItem ev){
//	    System.out.println(ev.getWorld().getDayTime());
		if(!ev.getWorld().isRemote) {
		    WorldEventData data = WorldEventData.getOverWorldEventData(ev.getWorld());
		    for(Events event:Events.values()) {
			    System.out.println(data.hasEvent(event));
		    }
		}
	}

 

Codes which maybe related.

WorldEventData https://github.com/HungTeen/pvzmod/blob/dev/src/main/java/com/hungteen/pvz/world/data/WorldEventData.java

RightClickEvent : https://github.com/HungTeen/pvzmod/blob/dev/src/main/java/com/hungteen/pvz/event/PVZPlayerEvent.java#L83

The place I add event https://github.com/HungTeen/pvzmod/blob/dev/src/main/java/com/hungteen/pvz/event/OverWorldEvent.java#L64

 

 

Edited by _HungTeen_
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.