Jump to content

Recommended Posts

Posted

Hey so I'm working on a Survival Games mod right now and I'm using the PlayerInteractEvent for some things. However, it is called multiple times and I have no clue why. It is only registered once but gets called more than once, when aiming on something that isn't air. Can someone help me please :D

Posted

First, if you need help show the full mod on Github or Gitlab. Second: are you working on a weapon or what else? Third: Are you use it on the on both sides or Client or Server side?

New in Modding? == Still learning!

Posted
  On 2/27/2020 at 3:34 PM, DragonITA said:

First, if you need help show the full mod on Github or Gitlab. Second: are you working on a weapon or what else? Third: Are you use it on the on both sides or Client or Server side?

Expand  

First: I don't have it on github, but I can do it if necessary
Second: I'm just using a piece of paper to vote for a map. 

Third: I have a check if it's serverside

 

It gets called twice when aiming on a block and I found out that there is PlayerInteractEvent.RightClickEmpty but that only works Clientside, though the mod is completely serverside

Posted
  On 2/27/2020 at 4:15 PM, diesieben07 said:

Need more info.

How many times? Show your code.

Expand  

	@SubscribeEvent
	public void onInteract(PlayerInteractEvent.RightClickEmpty event) {
		if (event.getWorld() instanceof ServerWorld) {
			if (event.getSide() == LogicalSide.SERVER) {
				if (event.getHand() == Hand.MAIN_HAND) {
					if (event.getPlayer().getHeldItem(Hand.MAIN_HAND) != null) {
						ItemStack item = event.getPlayer().getHeldItem(Hand.MAIN_HAND);
						ServerPlayerEntity player = (ServerPlayerEntity) event.getPlayer();
						String displayName = item.getDisplayName().getFormattedText();
						if (item.getItem() == Items.PAPER) {
							if (HungerGames.getInstance().getMapManager().maps.contains(displayName)) {
								HungerGames.getInstance().getVoteManager().vote(displayName, player);
							}
						} else if (item.getItem() == Items.ANVIL) {
							boolean selecting = HungerGames.getInstance().getKitManager().kitSelecting.get(player);

							if (selecting) {
								HungerGames.getInstance().getVoteManager().addItems(player);
								HungerGames.getInstance().getTeamManager().addItems(player);
								HungerGames.getInstance().getKitManager().addItems(player);

								ChatUtil.sendMessage(player, HungerGames.getInstance().getMessageManager().messages
										.get("kitChosen").replaceAll("%kit%", displayName));
								HungerGames.getInstance().getKitManager().chosenKits.put(player, displayName);

							} else {
								HungerGames.getInstance().getKitManager().addKitItems(player);
							}
							HungerGames.getInstance().getKitManager().kitSelecting.put(player, !selecting);
						} else if (item.getItem() == Items.BOOK) {
							if (HungerGames.getInstance().getMapManager().maps.contains(displayName)) {
								HungerGames.getInstance().getAdminManager().selectMap(displayName, player);
							}
						}
					}
				}
			}
		}
	}

This is the code. It gets executed once when looking in the air and twice when aiming on a block

Posted
  On 2/27/2020 at 4:50 PM, diesieben07 said:

RightClickEmpty is fired when aiming at nothing ("looking in the air"). It is not fired when aiming at a block.

It is not possible for this event handler to fire when right-clicking a block.

Expand  

oh, yea, sorry. I only had PlayerInteractEvent in there before, I tried it out with RightClickEmpty, then it wasn't fired at all. Looks like it is a client-side event. 

This was my actual code

@SubscribeEvent
	public void onInteract(PlayerInteractEvent event) {
		if (event.getWorld() instanceof ServerWorld) {
			if (event.getSide() == LogicalSide.SERVER) {
				if (event.getHand() == Hand.MAIN_HAND) {
					if (event.getPlayer().getHeldItem(Hand.MAIN_HAND) != null) {
						ItemStack item = event.getPlayer().getHeldItem(Hand.MAIN_HAND);
						ServerPlayerEntity player = (ServerPlayerEntity) event.getPlayer();
						String displayName = item.getDisplayName().getFormattedText();
						if (item.getItem() == Items.PAPER) {
							if (HungerGames.getInstance().getMapManager().maps.contains(displayName)) {
								HungerGames.getInstance().getVoteManager().vote(displayName, player);
							}
						} else if (item.getItem() == Items.ANVIL) {
							boolean selecting = HungerGames.getInstance().getKitManager().kitSelecting.get(player);

							if (selecting) {
								HungerGames.getInstance().getVoteManager().addItems(player);
								HungerGames.getInstance().getTeamManager().addItems(player);
								HungerGames.getInstance().getKitManager().addItems(player);

								ChatUtil.sendMessage(player, HungerGames.getInstance().getMessageManager().messages
										.get("kitChosen").replaceAll("%kit%", displayName));
								HungerGames.getInstance().getKitManager().chosenKits.put(player, displayName);

							} else {
								HungerGames.getInstance().getKitManager().addKitItems(player);
							}
							HungerGames.getInstance().getKitManager().kitSelecting.put(player, !selecting);
						} else if (item.getItem() == Items.BOOK) {
							if (HungerGames.getInstance().getMapManager().maps.contains(displayName)) {
								HungerGames.getInstance().getAdminManager().selectMap(displayName, player);
							}
						}
					}
				}
			}
		}
	}

 

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

    • There is an issue with Modular Force Field System (mffs) Remove it or try other builds
    • I never imagined I would be writing this kind of testimony, but I feel it’s important to share my experience with Malice Cyber Recovery and how they helped me recover $230,000 I lost to crypto scammers. A few months ago, I got involved in a crypto investment opportunity that seemed legitimate at first. The scammers were incredibly convincing. They showed me impressive returns, sent regular updates, and even gave me access to what looked like a real trading platform. I was initially cautious, but after seeing the returns, I began to invest more, ultimately transferring over $230,000. Unfortunately, after a few weeks, when I tried to withdraw my funds, I found that the platform had disappeared, and I could no longer contact anyone involved. It was clear I had been scammed, and I felt completely helpless. For weeks, I tried everything to get my money back—contacting the authorities, reaching out to the platform’s so-called support team (who of course were unreachable), and trying to trace the transactions myself. But everything led to dead ends. The more I researched, the more I realized just how hard it was to recover stolen crypto. I began to lose hope. That’s when I came across Malice Cyber Recovery. At first, I was skeptical. Could they really help me recover my funds after everything I had been through? I decided to reach out anyway, just to see if they could offer any guidance. From the very first conversation, their team was not only professional but also deeply empathetic. They understood exactly how I was feeling and immediately made it clear that they were dedicated to helping me recover my lost funds. Malice Cyber Recovery’s team got to work quickly. They walked me through every step of the process, explaining the methods they would use to track down my stolen crypto. Their knowledge of blockchain technology and how to trace crypto transactions was incredibly impressive. They didn’t just give me vague promises they showed me the action they were taking and the progress they were making, which gave me hope that my money wasn’t gone forever. One of the most reassuring aspects of working with Malice Cyber Recovery was their transparency. They kept me updated regularly, letting me know what they were doing, what obstacles they encountered, and how they were overcoming them. It wasn’t an easy process; tracing funds through blockchain and dealing with scammers who hide behind fake identities and complex networks is incredibly difficult. But Malice Cyber Recovery’s team was relentless. They used advanced tools and techniques to trace the flow of my funds, and within just a few weeks, they managed to locate a significant portion of my lost funds. I couldn’t believe it when they informed me that they had successfully recovered a large chunk of my money. I never thought I’d see that $230,000 again. The recovery process wasn’t instantaneous it  took time, patience, and persistence but Malice Cyber Recovery delivered on their promise.  
    • Almost, just the java -server -Xmx4G -Xms4G -Dlog4j.configurationFile=log4jformattingfix.xml -jar forge-1.12.2-14.23.5.2860.jar nogui and if that doesn't work, try java --version
    • What so just copy and paste " java -server -Xmx4G -Xms4G -Dlog4j.configurationFile=log4jformattingfix.xml -jar forge-1.12.2-14.23.5.2860.jar nogui Pause >nul " into a cmd terminal? If that's what you mean, nothing happens
    • The networking has been far simplified in 1.20.5+ The docs could be old, as Ash has said feel free to submit a PR updating the community docs. However the only real up-to-date reference would be the code itself. So your best bet is to just read the code and give it want it wants.
  • Topics

×
×
  • Create New...

Important Information

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