Jump to content

AMRAAM

Members
  • Posts

    22
  • Joined

  • Last visited

Posts posted by AMRAAM

  1. Hello!

    I have been working on a server only mod for the past while but now with the team who is working on the server we are shifting into a mod that also has a client side.
    But I havent used client side things before, and the small description on the docs outlines the things pretty well but I have a few questions.

    If I have a custom GUI for example do I need to look into packets to sync things up?
    I want to replace the normal inventory with an inventory that doesnt have the armor and crafting slots, but has different slots instead for example, or furnace like things where you put in some items and a progress bar moves and something happens, but I want it to be instanced by player (so that other players cant interact with your thing).

    Or if there is custom information about the player and I want to display it client side in a menu. Like the cold resistance of the player (custom combat/rpg system is mostly in place on the server), do I need a custom packet handler for this, or is there some built in mechanism to facilitate syncing values?

    Also, very curious about anti cheat methods, how can I ensure that all items remain un-changed and only come from my item factory, and the client has no way of changing them?
    I already serialize the items with a UUID and store their state on the server, but that uuid is stored in item NBT not sure how safe is that, but also any other anti cheat catches I should be aware of?

    Thank you!

  2. Continuing this topic I still want to prevent a lot of inventory interaction, is it possible to mess with the itemstack held by the cursor from the server?
    Only the client appears to know about that, how is that possible, the inventory actually changes when the client picks up an item from their inventory, the server has to know about the new empty slot, or is that it, just a new empty slot that appears? As far as the server is concerned, where is the itemstack that is being held?

  3. Hello!

    Is there a good way to detect if a player is trying to open their inventory? I want to open some other container is some cases when they do that.
    This is only server side. I also want to make sure that in the case where I want to open a different container instead they are 100% unable to take their armor off. I think that may not be possible tho, because it might just be up to the client to modify its inventory and send the changes to the server (like it can say "hey I moved my helmet to slot 35, cool?") But not sure on that, if this is not possible it's not that big of deal, but I will need another solution to make sure they can't move their armor into their inventory (thinking of tagging their armor with something like "disallowed" and then periodically checking if they somehow managed to get a disallowed item).

    Thanks

  4. Hello!

    I want to be able to close the player's opened container (like they hit escape) from the server.
    So send a packet or invoke some function that would close the container without the need for writing client code.
    I tried

    PlayerEntity#closeContainer();

    But this just introduced desync with the client, but it actually seemed to close the container as far the server was concerned.

    Thanks

  5. I was hoping there was some method to catch when the client is looking for the description and instead of going through the standard way of getting it from the NBT I could supply it with different data, but then the whole NBT is passed to the client, and it decides on how to display it if I understand correctly so yeah out of luck, I will look into regenerating the item Lore some way when something changes

  6. Hello!

    I have been working on a custom item system where a lot of item properties exist, like vitality, dexterity and many others.
    This works fine by adding to the NBT of the ItemStack and I can also query the values just fine, however I have a problem displaying these to the user.
    My mod runs exclusively on the server side, so I can't use ItemTooltipEvent sadly, but that is exactly what I would have needed.
    I assume I could change the lore and do tricks with that to have it show, but I couldn't get the lore to show properly, I was trying to put my data into the NBT tag.
    And I also can't remove the default information thing that items display, like armors have "+x Armor" which is awful for my use case as I implement my own armor system.

    I also need to be able to generate these descriptions on the fly, real time, because I want to be able to change how attributes work/are displayed.
    So as an example if I put +1 Vitality on an item, and want to display it as "+2 To Life" not as vitality, but then I change my mind, and want to update how item information is displayed.
    This may sound dumb, but I want to be able to patch items and their properties and if their description is just a static string, even if I change how the underlying data works, I can't change the description.
    Take that example, what if I decide to change vitality to give +3 life per point not 2, I wouldn't need to change the item's data at all, just the description.

    I hope I was clear, I'll be around if I need to clear anything up,
    Thanks

  7. So essentially I create a new class, extend from Container maybe and start implementing things, and maybe go off the implementation of ChestContainer.
    Will this approach not break the server side only criteria? Does the client not need to know about the custom container?

  8. So, I will populate the slots of the opened "chest" with items that I dont want to be in game items, rather option in a menu, so when a player tries to take one of them I can run some logic because they clicked an "option", instead of the taking the item I want to run a function to do something.

    Example, the player opens a virtual chest they see their level by the size of the green wool stack, if they try to take the stack, instead of taking 13 green wool, they would get taken to another "chest" with more detailed information about their character.

    Or a shop interface, where them clicking an item would buy it, put it into their inventory and remove some balance from their account.

    So I need a mechanism to detect them trying to take an item, and to know what item it is, and one mechanism to prevent them from actually taking the item.

    I hope it makes sense

  9. This is what I am trying currently, but this doesnt work, it fails to compile.

    		IInventory inv = new Inventory(18);
                    
                    InvWrapper wrapper = new InvWrapper(inv);
                    wrapper.insertItem(0, new ItemStack(Blocks.DIRT), false);
    
                    ChestContainer c = new ChestContainer(ContainerType.GENERIC_9X2, event.getPlayer().inventory, inv, 2);
    'ChestContainer(net.minecraft.inventory.container.ContainerType<?>, int, net.minecraft.entity.player.PlayerInventory, int)' has private access in 'net.minecraft.inventory.container.ChestContainer'

     

  10. Okay I'm lost now, I want to use IInventory because that is what ChestContainer uses, but how do I create one for it, if I understand correctly, right now you are saying I use IInventory of the chest and manage it with an IItemHandler, provided by InvWrapper right?
    But how do I provide the chest container with an IInventory in the first place?
    Can you give an example on how I create the ChestContainer from start to finish? Or I need to implement a custom IInventory?

  11. I see, why does it have to be a ChestContainer, the inventory still opens like this, I just cant put items in from my code, but wouldnt that be fixed if were to put an inventory behind it and use that? ChestContainer has a constructor that takes in a PlayerInventory an IInventory and the number of rows(?). Do I need some sort of wrapper around my IItemHandler to pass it into that IInventory param?

  12. Hello!

    I've been playing around with the idea of creating a "plugin like" chest based menu system, implemented on the server side ONLY, so no code runs on the client. I have gotten so far as to create a generic container and have the player open it, but several issues remain that I can't solve on my own, #1 Is setting the contents of said generic container, so the player sees items and can interact with the menu, and then #2 is actually interacting with the container, how do I detect when a player picks up an item from the container (and cancel that, so they can't take items from it) and then do some other action, like opening another more different container or running some logic or things of that nature.

    This is what is running currently in my mod:
     

            INamedContainerProvider provider = new INamedContainerProvider() {
                @Override
                public ITextComponent getDisplayName() {
                    return new TextComponent() {
                        @Override
                        public String getUnformattedComponentText() {
                            return "name";
                        }
    
                        @Override
                        public ITextComponent shallowCopy() {
                            return null;
                        }
                    };
                }
    
                @Nullable
                @Override
                public Container createMenu(int p_createMenu_1_, PlayerInventory p_createMenu_2_, PlayerEntity p_createMenu_3_) {
                    Container c = new Container(ContainerType.GENERIC_9X2, 1) {
                        @Override
                        public boolean canInteractWith(PlayerEntity playerIn) {
                            return true;
                        }
                    };
    
    				// Both of these line straight up crash the game when they are ran
                    //c.getSlot(0).inventory.setInventorySlotContents(0, new ItemStack(Blocks.DIRT));
                    //c.getInventory().set(0, new ItemStack(Blocks.DIRT)); 
    
                    return c;
                }
            };
    
            event.getPlayer().openContainer(provider);


    Thanks for the help!

  13. Hi,

    I'm looking to change where the output file of building the project gets put, but I'm not familiar with gradle and i cant really find an option for this, as i want to change the output from ${ProjectDir}/build/libs to whatev/whatev/forgetestserver/mods and also clean the mods directory(maybe even with an ignore list, to keep certain mods, but delete the old versions of mine) to streamline testing, as my mod is server side only.

    Thanks!

  14. Hi,

    I've created a small server side mod, to detect XP drop events and cancel them, which works like a charm, but now i want to migrate more of my .mcfunction code to a forge mod, the first thing i cont figure out is, detecting when a player right clicks with, a certain item (a default minecraft item with custom NBT,  i would probably only check for the name), and the execute some code, and the other thing, is to execute some default minecraft .mcfunctions/commands from my mod's code, all topics I could find on that concerned older versions, and didn't seem to work anymore.
    Oh and also on that note is/how is it possible to modify a players tag-s and scoreboard values from a mod's code?

    Tank you for the help I've got excellent answers on my previous post, thanks in advance!

  15. Hi

    recently i had a post about making a small server side only mod to control xp drops, and i more or less understand how that works no, but that made me think, how powerful can server side mods get?
    Can I do anything that a bukkit plugin would be able to do with a server side only forge mod?
    I have a more or less complete RPG system with minecraft command blocks, but it is really performance heavy, so i was thinking if i could move it to a mod without having to have it client side, so the question really is, if i can do something purely with vaniall commands, can it be done with a forge mod too, and i would assume yes, the project is ~3.5-4k lines of minecraft commands, it has right click to use abilities custom weapons, custom mobs, and mob spawning, classes etc... but since it doesn't add any new assets it should be able to be implemented with a server side only mod right?
    So, what is the client side mod required for, what are the limitations of being server side only?

    Thanks! 

  16. Hi,

    I'm looking to create the tiniest of server side mods, which would just remove XP drops from all mobs, but I've never created a forge mod before, but this seems to be a mostly simple task, but i have no experience in Java either, but i have quite a bit of C/++ experience, so i don't think i'm hopeless.
    Also, a more philosophical question, how powerful can server side mods get, to me it seems, as long as they only perform logic and don't add custom item/blocks they should be able to be run server side only.

    Thanks!

×
×
  • Create New...

Important Information

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