Jump to content

Recommended Posts

Posted (edited)

Hello, I am making a mod that uses the commands from another mod to create portals. That mod is in a state of disrepair environment wise, so I'm not able to use its code, that's why I have to use commands. So essentially what I'm trying to make is a glorified command stick. I have a few question regarding the design. The relevant code snippets can be find below. This code works in a single player world, but, while I haven't tested it there yet, I don't think it would work in a multiplayer one, even if I tweak the whole "!worldIn.isRemote" part.

1. You can see I create a PortalManager when the item is used. Obviously this is not ideal. For example, if I reload a world where I've created portals, I am creating a new PM that doesn't know about them. The problem is I need the "playerIn" object provided by "onItemRightClick" to create the CommandSource and Commands objects. I've tried using "Minecract.getInstance().getServer()", but that returns "null". Ideally, I would want to make PM outside of all this so I can initialize it with stuff from an existing world with portals in it. So basically, how can I get a CommandSource and a Commands object without the "playerIn" from "onItemRightClick"? 

2. Sort of related to 1. What tweaks would I have to make in order for this to work on a dedicated server as well as single player world? I don't think I have to worry about packets as the commands from the mod I'm using already take care of spawning entities and what not. Should the commands be executed on the server instead of the client? I don't have a good understanding of which side should execute what.

PortalGunItem

  Reveal hidden contents

PortalManager

  Reveal hidden contents

Thank you very much for the help, it is greatly appreciated. Please let me know if you need to see more code in order to help me. I have a pretty functional od already, but didn't want to flood this post with all the code obviously.

Edited by link182
Posted (edited)
  On 8/9/2021 at 7:15 AM, diesieben07 said:

Re 1: Use a World capability.

Re 2: If you coded things correctly, nothing. Single player has basically the same architecture as playing on a MP server, as it runs an integrated server.

 

Expand  

How do I use World capability? Could you give me a short example?

Edited by link182
Posted
  On 8/10/2021 at 6:48 AM, diesieben07 said:

This is what using a World capability will fix. It allows you to attach additional data to a world, optionally even persisting it through world unloads.

Expand  

Still not sure I understand. How can I get the world and player without it coming through itemRightClicked? Again, I would appreciate an actual example of this stuff working.

Posted
  On 8/11/2021 at 6:43 AM, diesieben07 said:

Which player and which world? There is not just one.

Expand  

The player using the item and the world he's playing in. No offense and I'm really not trying to be rude here, but I feel like this a pretty good question that deserves some better answers and engagement than what it's been given. I think you can intuit which world and which player I'm talking about. You don't need to try to hit me with a gotcha question. I would really appreciate some help on this with some actual examples that I can use. Considering there is almost no documentation on this stuff, I don't think that's too much to ask. 

Posted
  On 8/9/2021 at 6:08 AM, link182 said:

Ideally, I would want to make PM outside of all this so I can initialize it with stuff from an existing world with portals in it. So basically, how can I get a CommandSource and a Commands object without the "playerIn" from "onItemRightClick"? 

Expand  

The Portal Manager takes in a CommandSource and a Commands object. How do I get these without the Item method? I can't use world and player from the item method because then the player would first have to use the item before the portal manager knows anything about the world.  I think it's made pretty clear in my question. 

Posted
  On 8/11/2021 at 6:37 PM, diesieben07 said:

Exactly... Dude what do you want from me?

Expand  

That was before you said you had no idea what I was talking about...so clearly you still didn't understand and yet you didn't ask for more clarification so you could actually help. 

Posted
  On 8/11/2021 at 6:44 PM, diesieben07 said:

Originally I thought I knew exactly what you wanted. Then you asked about how to get the player and then I no longer knew, so I asked.

Expand  

I'll ask the question again. Differently this time. I would like to initialize the PM outside of the item method. It requires a CommandSource, a Commands object, and the player. Right now, these are gotten from the player in the item method. How can I accomplish this without using the item method? 

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

    • I've been attempting to trouble shoot performance issues with this version of forge - I've been getting 10 - 14 FPS on a fresh install while the same settings on vanilla will net me ~ 250 FPS  I've tried setting ram to 2, 4, 6, 8, 16 GB, making sure that the GPU is being used - although i cant confirm other than the F3 screen - I've cleared out my .Minecraft folder and done a fresh install of forge multiple times, I even reinstalled Java 17 - from what i read this is the recommended for this version of MC, - Graphics drivers are fully up to date and I've tried it on both studio and game ready drivers. I have a spark report but I dont know what to do with it https://spark.lucko.me/BrrJ5vzX6k Would love some help for this as Ive spent three days on this
    • One fateful day, my life took an unexpected turn when I received a phone call that would change everything. The voice on the other end claimed to be from my bank, delivering alarming news: my account had been frozen due to suspicious activity. Panic surged through me as I listened, my heart racing at the thought of losing my hard-earned savings. At that moment, I had about 130,000 USD in my bank, equivalent to around 2 BTC. The caller spoke with such authority and urgency that I felt compelled to act immediately. They insisted that the only way to protect my funds was to transfer Bitcoin BTC to them for "safekeeping. In my fear and confusion, I believed I was making a wise decision to secure my finances. Without fully grasping the implications, I complied and transferred the equivalent of my savings in Bitcoin, convinced I was safeguarding my money. It wasn’t until later that the reality of my situation hit me like a ton of bricks. I had been duped, and the weight of my mistake was unbearable. Shame and disbelief washed over me as I realized how easily I had been manipulated. How could I have let this happen? The feeling of vulnerability was overwhelming, and I was left grappling with the consequences of my actions. I learned about a recovery expert named RAPID DIGITAL RECOVERY. Desperate to reclaim what I had lost, I reached out for help. RAPID DIGITAL RECOVERY was knowledgeable and reassuring, explaining that there was a chance to trace the Bitcoin I had sent. With their expertise, they tracked the stolen funds to a peer-to-peer (P2P) exchanger based in the United Kingdom. This revelation sparked a glimmer of hope within me, a sense that perhaps justice could be served. RAPID DIGITAL RECOVERY collaborated with Action Fraud, the UK's national reporting center for fraud and cybercrime, to take decisive action against the scammers. Knowing that law enforcement was involved provided me with a sense of relief. The thought that the culprits behind my suffering could be brought to justice was comforting. In an incredible turn of events, RAPID DIGITAL RECOVERY successfully recovered all my funds, restoring my faith in the possibility of justice and recovery.
    • My game crashed in 1.12.2 here is the crash log https://pastebin.com/6MYu4mGy
    • I created a Modpack Forge in 1.20.1 for my friend and I. There are 135 mods including "Essential". I was able to play an 8 hour session without problem but when I relaunch my world, I crashed when I opened the menu of the game "ESC" or after about 15 minutes of session. I can't find the source of the problem. Latest.log and Debug.log : https://paste.ee/p/B0npvlRw
    • Hello! Faced with the same problem. Can you please describe in more detail how you rewrote the toNetwork and fromNetwork methods?
  • Topics

×
×
  • Create New...

Important Information

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