FPS Gun Game

Hi there, I’m @frogocomics and I create plugins for my private server. I am planning to add a FPS game, based on World War 1. I have a few questions and if you would be so kind to answer them.

    1. Many shooter games, such as Minestrike use custom resource packs. I find hard to code plugins like this because the code will be messy and the game will not be of good quality. How to I use Sponge to communicate with Forge?

    2. How would I let my plugin know where the battlefield is? How could I set each team’s spawnpoint?

    3. How could I put all of this together? Is Sponge 100% compatible with Forge?

    4. Is it possible to make this piece of code below: (Excuse the Persudo-Code)

    
    public class Example {
        //Blah blah blah
        @Subscribe
        public void onGunShot(ShotFiredEvent event) {
            Player player = event.getPlayer();
            Gun gun = player.getGun();
            Target target = gun.getTarger();
            if (target instanceof player) {
                player.damage(gun.getDamage());
            }
        } 
    }
    
  1. Custom resource packs is the way to to to be honest. I don’t see any other way. Also, resource packs, while if they are not accepted by the client can make your server look weird does not affect your code quality. Also you can detect if the client has accepted the pack or not by detecting packets.
  2. This is for you to decide, learn java, learn how to use a database, learn how to spawn players.
  3. You would put it together like any other plugin. Code It I really don’t know what you mean by 100% compatible. You can’t use the Forge API without making it so a client has to download a mod if that is what you are asking. You can use the Forge API though I believe.
  4. Most certainly, it would be a bit more complicated than what is depicted in your pseudo-code but it is 100% possible.
1 Like

I almost finished my post, and RoboDude has beaten me. Darn!

3 Likes

Another question, could Sponge work with modded items, could Sponge manipulate mod objects?

The specific’s will probably need to be worked out on your own but the official implementation of the SpongeAPI is a forge coremod. So yes it is 100% compatible. You may however need two different projects and have one rely on the other as a dependency in order to have them work together

I don’t think so, a Forge mod can make use of the Sponge API, but to manipulate mod items I believe you must use the Forge API.

You can, but you have to be eeeeextra careful. And it’s probably not worth it, as Sponge offers a great accessor to these things and makes sure that you don’t rely on clientside stuff by accident.

1 Like

Yeah I mean cmon, just use sponge, thats what its for :stuck_out_tongue:

I suddenly thought of another idea. To set a team’s spawnpoint, the player’s cursor has to be pointing at a block and use the command /ww1:setalliespawn. The plugin will find out what coordinates the player is pointing at and save the position.
The question is, how do I get the block the player is pointing at? I would like to thank the Sponge community for their help. :smile:

1 Like

There’s a reason that Sponge has JavaDocs.
Look for its link on the read me of the SpongeAPI Github project.

I actually want to make a SIMPLE mod with non-functional items such as guns. How to a implement a modded item in a PlayerInteractEvent?


@Subscribe(order = Order.POST)
    public void onInteract(PlayerInteractEvent event) {
        Player player = event.getPlayer();
        Optional option = player.getItemInHand();

        if (option.isPresent()) {
            ItemType itemType = option.get().getItem();
            if (itemType.equals(WHAT DO I DO WITH A MODDED ITEM?)) {
            
            }   
        }
    } 

You should really be using generics for this. For potential casting issues, if nothing else.