1.12.2 NMS Registering new Item

Discussion in 'Spigot Plugin Development' started by Gimble, Jun 13, 2021.

  1. Hi, I'm trying to registering new item with nms (not custom item with ItemStack).This item already registered on Client (with Mod Coder Pack). But this item not showing in player's hand.

    My NMS Code:
    Code (Java):
    import net.minecraft.server.v1_12_R1.Item;
    import net.minecraft.server.v1_12_R1.MinecraftKey;

    public class ItemManager {
        public static void register(int id, String key, Item item) {
            Item.REGISTRY.a(id, new MinecraftKey(key), item);
        }
    }

    Main Class (I'm registering)
    Code (Java):

    import net.gimbleapp.customitems.utils.ItemManager;
    import net.minecraft.server.v1_12_R1.CreativeModeTab;
    import net.minecraft.server.v1_12_R1.Item;
    import org.bukkit.plugin.java.JavaPlugin;

    public final class CustomItems extends JavaPlugin {

        @Override
        public void onEnable() {
            ItemManager.register(501, "ruby_ore", (new Item()).c("rubyOre").b(CreativeModeTab.l));
        }

        @Override
        public void onDisable() {}
    }

     
    Code (Text):

    [15:27:57] [Server thread/INFO]: Starting minecraft server version 1.12.2
    [15:27:57] [Server thread/INFO]: Loading properties
    [15:27:57] [Server thread/INFO]: Default game type: SURVIVAL
    [15:27:57] [Server thread/INFO]: This server is running CraftBukkit version git-Spigot-79a30d7-acbc348 (MC: 1.12.2) (Implementing API version 1.12.2-R0.1-SNAPSHOT)
    [15:27:57] [Server thread/INFO]: Debug logging is disabled
    [15:27:57] [Server thread/INFO]: Server Ping Player Sample Count: 12
    [15:27:57] [Server thread/INFO]: Using 4 threads for Netty based IO
    [15:27:57] [Server thread/INFO]: Generating keypair
    [15:27:57] [Server thread/INFO]: Starting Minecraft server on *:25565
    [15:27:57] [Server thread/INFO]: Using default channel type
    [15:27:57] [Server thread/INFO]: Set PluginClassLoader as parallel capable
    [15:27:57] [Server thread/INFO]: [CustomItems] Loading CustomItems v1.0-SNAPSHOT
    [15:27:57] [Server thread/WARN]: **** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!
    [15:27:57] [Server thread/WARN]: The server will make no attempt to authenticate usernames. Beware.
    [15:27:57] [Server thread/WARN]: While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose.
    [15:27:57] [Server thread/WARN]: To change this, set "online-mode" to "true" in the server.properties file.
    [15:27:57] [Server thread/INFO]: **** Beginning UUID conversion, this may take A LONG time ****
    [15:27:57] [Server thread/INFO]: Preparing level "world"
    [15:27:57] [Server thread/INFO]: -------- World Settings For [world] --------
    [15:27:57] [Server thread/INFO]: Item Merge Radius: 2.5
    [15:27:57] [Server thread/INFO]: Item Despawn Rate: 6000
    [15:27:57] [Server thread/INFO]: Structure Info Saving: true
    [15:27:57] [Server thread/INFO]: Max TNT Explosions: 100
    [15:27:57] [Server thread/INFO]: Cactus Growth Modifier: 100%
    [15:27:57] [Server thread/INFO]: Cane Growth Modifier: 100%
    [15:27:57] [Server thread/INFO]: Melon Growth Modifier: 100%
    [15:27:57] [Server thread/INFO]: Mushroom Growth Modifier: 100%
    [15:27:57] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
    [15:27:57] [Server thread/INFO]: Sapling Growth Modifier: 100%
    [15:27:57] [Server thread/INFO]: Wheat Growth Modifier: 100%
    [15:27:57] [Server thread/INFO]: NetherWart Growth Modifier: 100%
    [15:27:57] [Server thread/INFO]: Vine Growth Modifier: 100%
    [15:27:57] [Server thread/INFO]: Cocoa Growth Modifier: 100%
    [15:27:57] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
    [15:27:57] [Server thread/INFO]: Mob Spawn Range: 4
    [15:27:57] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Mi 16 / Tiv true
    [15:27:57] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms
    [15:27:57] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 1 Hopper Amount: 1
    [15:27:57] [Server thread/INFO]: Random Lighting Updates: false
    [15:27:57] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
    [15:27:57] [Server thread/INFO]: Arrow Despawn Rate: 1200
    [15:27:57] [Server thread/INFO]: View Distance: 10
    [15:27:57] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
    [15:27:57] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Feature: 14357617 Monument: 10387313 Slime: 987234911
    [15:27:57] [Server thread/INFO]: Experience Merge Radius: 3.0
    [15:27:57] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
    [15:27:58] [Server thread/INFO]: -------- World Settings For [world_nether] --------
    [15:27:58] [Server thread/INFO]: Item Merge Radius: 2.5
    [15:27:58] [Server thread/INFO]: Item Despawn Rate: 6000
    [15:27:58] [Server thread/INFO]: Structure Info Saving: true
    [15:27:58] [Server thread/INFO]: Max TNT Explosions: 100
    [15:27:58] [Server thread/INFO]: Cactus Growth Modifier: 100%
    [15:27:58] [Server thread/INFO]: Cane Growth Modifier: 100%
    [15:27:58] [Server thread/INFO]: Melon Growth Modifier: 100%
    [15:27:58] [Server thread/INFO]: Mushroom Growth Modifier: 100%
    [15:27:58] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
    [15:27:58] [Server thread/INFO]: Sapling Growth Modifier: 100%
    [15:27:58] [Server thread/INFO]: Wheat Growth Modifier: 100%
    [15:27:58] [Server thread/INFO]: NetherWart Growth Modifier: 100%
    [15:27:58] [Server thread/INFO]: Vine Growth Modifier: 100%
    [15:27:58] [Server thread/INFO]: Cocoa Growth Modifier: 100%
    [15:27:58] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
    [15:27:58] [Server thread/INFO]: Mob Spawn Range: 4
    [15:27:58] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Mi 16 / Tiv true
    [15:27:58] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms
    [15:27:58] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 1 Hopper Amount: 1
    [15:27:58] [Server thread/INFO]: Random Lighting Updates: false
    [15:27:58] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
    [15:27:58] [Server thread/INFO]: Arrow Despawn Rate: 1200
    [15:27:58] [Server thread/INFO]: View Distance: 10
    [15:27:58] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
    [15:27:58] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Feature: 14357617 Monument: 10387313 Slime: 987234911
    [15:27:58] [Server thread/INFO]: Experience Merge Radius: 3.0
    [15:27:58] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
    [15:27:58] [Server thread/INFO]: -------- World Settings For [world_the_end] --------
    [15:27:58] [Server thread/INFO]: Item Merge Radius: 2.5
    [15:27:58] [Server thread/INFO]: Item Despawn Rate: 6000
    [15:27:58] [Server thread/INFO]: Structure Info Saving: true
    [15:27:58] [Server thread/INFO]: Max TNT Explosions: 100
    [15:27:58] [Server thread/INFO]: Cactus Growth Modifier: 100%
    [15:27:58] [Server thread/INFO]: Cane Growth Modifier: 100%
    [15:27:58] [Server thread/INFO]: Melon Growth Modifier: 100%
    [15:27:58] [Server thread/INFO]: Mushroom Growth Modifier: 100%
    [15:27:58] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
    [15:27:58] [Server thread/INFO]: Sapling Growth Modifier: 100%
    [15:27:58] [Server thread/INFO]: Wheat Growth Modifier: 100%
    [15:27:58] [Server thread/INFO]: NetherWart Growth Modifier: 100%
    [15:27:58] [Server thread/INFO]: Vine Growth Modifier: 100%
    [15:27:58] [Server thread/INFO]: Cocoa Growth Modifier: 100%
    [15:27:58] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
    [15:27:58] [Server thread/INFO]: Mob Spawn Range: 4
    [15:27:58] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Mi 16 / Tiv true
    [15:27:58] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms
    [15:27:58] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 1 Hopper Amount: 1
    [15:27:58] [Server thread/INFO]: Random Lighting Updates: false
    [15:27:58] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
    [15:27:58] [Server thread/INFO]: Arrow Despawn Rate: 1200
    [15:27:58] [Server thread/INFO]: View Distance: 10
    [15:27:58] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
    [15:27:58] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Feature: 14357617 Monument: 10387313 Slime: 987234911
    [15:27:58] [Server thread/INFO]: Experience Merge Radius: 3.0
    [15:27:58] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
    [15:27:58] [Server thread/INFO]: Preparing start region for level 0 (Seed: 3917750685739533355)
    [15:27:58] [Server thread/INFO]: Preparing start region for level 1 (Seed: 3917750685739533355)
    [15:27:59] [Server thread/INFO]: Preparing start region for level 2 (Seed: 3917750685739533355)
    [15:27:59] [Server thread/INFO]: [CustomItems] Enabling CustomItems v1.0-SNAPSHOT
    [15:27:59] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
    [15:27:59] [Server thread/INFO]: Done (1,843s)! For help, type "help" or "?"
    [15:28:06] [User Authenticator #1/INFO]: UUID of player Player858 is 651bbe0e-980e-38d7-8fbb-83ebfec85347
    [15:28:06] [Server thread/INFO]: Player858[/127.0.0.1:55521] logged in with entity id 137 at ([world]-92.5, 70.0, 253.5)
    [15:28:11] [Server thread/INFO]: Opped Player858
    [15:28:15] [User Authenticator #2/INFO]: UUID of player Player451 is efe2ab2d-072a-337a-9d65-10da4f48c969
    [15:28:15] [Server thread/INFO]: Player451[/127.0.0.1:55527] logged in with entity id 138 at ([world]-78.5, 78.0, 247.5)
    [15:28:18] [Server thread/INFO]: Opped Player451
    [15:28:21] [Server thread/INFO]: Player858 issued server command: /gamemode 1
    [15:28:21] [Server thread/INFO]: [Player858: Set own game mode to Creative Mode]
    [15:28:25] [Server thread/INFO]: Player451 issued server command: /gamemode 1
    [15:28:25] [Server thread/INFO]: [Player451: Set own game mode to Creative Mode]
    [15:28:29] [Server thread/INFO]: Player451 issued server command: /tp Player858
    [15:28:29] [Server thread/INFO]: [Player451: Teleported Player451 to Player858]
     

    [​IMG]
     
  2. Can I ask why you wouldn't just use Forge/SpongeForge if you're modifying the client as well? This seems like a complicated way to go about things.
     
  3. I don't want to use forge because it affects performance (boot times etc.)

    also i solved problem. i registered item in spigot source (Item class) and it seems now.
     
  4. changing in the spigot source is not a good way AT all, since you'll need a specified version of spigot everytime ur running that feature, also it'll be useless, as AWEChess1 said, use Forge, it's more flexible and easier.
     
  5. You'd probably be better off with something like Magma: https://github.com/magmafoundation/Magma

    That way you can just write a Forge mod and still run it on a Spigot-like server. Since you're not using any major mods it's likely that you won't encounter any compatibility issues.