Jump to content
  • Home
  • Files
  • Docs
Status Updates
  • All Content

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Splashsky

Splashsky

Members
 View Profile  See their activity
  • Content Count

    22
  • Joined

    December 12, 2015
  • Last visited

    October 16, 2017

 Content Type 

  • All Activity

Profiles

  • Status Updates
  • Status Replies

Forums

  • Topics
  • Posts

Calendar

  • Events

Posts posted by Splashsky

  1. [1.12.1] Help with entity code

    in Modder Support

    Posted September 11, 2017 · Edited September 11, 2017 by Splashsky


    What I've ended up doing was create the CommonProxy as an interface.

    public interface CommonProxy
    {
        void preInit();
        void init();
        void postInit();
    
        void registerItemRender(Item item, int meta, String id);
    }

     

    I then proceed to put the client logic into the ClientProxy.

    public class ClientProxy implements CommonProxy
    {
        @Override
        public void preInit()
        {
        }
    
        @Override
        public void init()
        {
        }
    
        @Override
        public void postInit()
        {
        }
    
        @Override
        public void registerItemRender(Item item, int meta, String id)
        {
            ModelLoader.setCustomModelResourceLocation(
                    item,
                    meta,
                    new ModelResourceLocation(Reference.PREFIX + id, "inventory")
            );
        }
    }

     

    And then, finally, server stuff!

    public class ServerProxy implements CommonProxy
    {
        @Override
        public void preInit()
        {
        }
    
        @Override
        public void init()
        {
        }
    
        @Override
        public void postInit()
        {
        }
    
        @Override
        public void registerItemRender(Item item, int meta, String id)
        {
        }
    }

     

    Granted, Draco and jabelar know a lot more than me, but this is my current setup. Not much different then just a ClientProxy and ServerProxy.

     

    Though, I probably should be implementing the FMLInitializationEvent thingies....

  2. [1.12.x] Item Only Showing Placeholder

    in Modder Support

    Posted September 11, 2017


    So I've continued my goofing around with tutorials to try and get the hang of this, and I've come to the next roadblock. I don't know how to assign a model/image to my item! I've created the item class, added a function to it which will allow me to tell the ClientProxy to register the item model with setCustomModelResourceLocation, but it simply shows up as the black and pink boxes. Any help?

     

    ModItem.java

    public class ModItem extends Item
    {
        protected String name;
    
        public ModItem(String name)
        {
            this.name = name;
            setName(this, name);
        }
    
        public static void setName(final Item item, final String name)
        {
            item.setRegistryName(Reference.MODID, name);
            item.setUnlocalizedName(item.getRegistryName().toString());
        }
    
        public void registerModel()
        {
            Venture.proxy.registerItemRender(this, 0, this.name);
        }
    
        @Override
        public ModItem setCreativeTab(CreativeTabs tab)
        {
            super.setCreativeTab(tab);
            return this;
        }
    }

     

    In ClientProxy.java

    @Override
    public void registerItemRender(Item item, int meta, String id)
    {
        ModelLoader.setCustomModelResourceLocation(
                item,
                meta,
                new ModelResourceLocation(Reference.PREFIX + id, "inventory")
        );
    }

     

    ModItems.java

    @GameRegistry.ObjectHolder(Reference.MODID)
    public class ModItems {
        public static ModIngot ObsidianIngot = new ModIngot("obsidian_ingot");
        // ... more items go here
    
        public static void registerModels()
        {
            ObsidianIngot.registerModel();
        }
    
        @Mod.EventBusSubscriber(modid = Reference.MODID)
        public static class RegistrationHandler
        {
            public static final Set<Item> ITEMS = new HashSet<>();
    
            @SubscribeEvent
            public static void registerItems(final RegistryEvent.Register<Item> event)
            {
                final Item[] items = {
                        ObsidianIngot
                };
    
                final IForgeRegistry<Item> registry = event.getRegistry();
    
                for (final Item item : items) {
                    registry.register(item);
                    ITEMS.add(item);
                }
    
                ModItems.registerModels();
            }
        }
    }

     

    obsidian_ingot in resources/assets/csvm/models/item

    {
      "parent": "item/generated",
      "textures": {
        "layer0": "csvm:items/obsidian_ingot"
      }
    }

     

    And yes, I have an obsidian_ingot.png in my assets/csvm/textures/items folder. :D

    And honestly, I don't know what the inventory variant is actually for.

    screenshot.png

  3. [1.12.x] Any Guides for Newbies?

    in Modder Support

    Posted September 10, 2017 · Edited September 10, 2017 by Splashsky


    So basically, merely that class' existence will register the items?

     

    EDIT: Answered my own question. It sure does! That's a nifty lil thing right there. :D

  4. [1.12.x] Any Guides for Newbies?

    in Modder Support

    Posted September 10, 2017


    20 minutes ago, jabelar said:

    The registry method in 1.12.1 actually doesn't need you to register the handler class directly to the bus. Instead you use an @ObjectHolder annotation and another type of subscription. In other words, you don't register the registry rather it registers itself based on annotation. I'm sure Draco's examples are good so look at them more closely.

    I had actually seen some of that from Choonster's test mod repo. It had some init things in there where he used @ObjectHolder to manage items...

    @GameRegistry.ObjectHolder(Reference.MODID)
    public class ModItems {
        public static ModIngot ObsidianIngot = new ModIngot("obsidian_ingot");
        // ... more items go here
    
        @Mod.EventBusSubscriber(modid = Reference.MODID)
        public static class RegistrationHandler
        {
            public static final Set<Item> ITEMS = new HashSet<>();
    
            @SubscribeEvent
            public static void registerItems(final RegistryEvent.Register<Item> event)
            {
                final Item[] items = {
                        ObsidianIngot
                };
    
                final IForgeRegistry<Item> registry = event.getRegistry();
    
                for (final Item item : items) {
                    registry.register(item);
                    ITEMS.add(item);
                }
            }
        }
    }

    but the one thing I couldn't ever figure out is how to make it work, or if things like this worked on their own without having to instantiate the class in the main mod file or something else along those lines.

  5. [1.12.x] Any Guides for Newbies?

    in Modder Support

    Posted September 10, 2017 · Edited September 10, 2017 by Splashsky


    I see! In this, then, I have another question. Given Draco's EasyRegistry class, it looks like he annotates it with SidedProxy... would this work as I expect it to?

    @Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION)
    public class Venture
    {
        @Mod.Instance
        public static Venture instance;
    
        @SidedProxy(clientSide = Reference.CLIENTPROXY, serverSide = Reference.SERVERPROXY)
        public static CommonProxy proxy;
    
        public static ServerRegistry registry;
    
        public static Logger logger;
    
        @Mod.EventHandler
        public static void preInit(FMLPreInitializationEvent event)
        {
            logger = event.getModLog();
            MinecraftForge.EVENT_BUS.register(registry);
            proxy.preInit();
        }
    
        @Mod.EventHandler
        public static void init(FMLInitializationEvent event)
        {
            proxy.init();
        }
    
        @Mod.EventHandler
        public static void postInit(FMLPostInitializationEvent event)
        {
            proxy.postInit();
        }
    }
    public class ServerRegistry
    {
        private List<Block> blocksToRegister = new ArrayList<Block>();
        private List<Item>  itemsToRegister  = new ArrayList<Item>();
        private List<IForgeRegistryEntry> otherItems = new ArrayList<IForgeRegistryEntry>();
    
        public static void registerItem(Item item)
        {
            Venture.registry._registerItem(item);
        }
    
        public void _registerItem(Item item)
        {
            itemsToRegister.add(item);
        }
    
        @SubscribeEvent
        public void registerItems(RegistryEvent.Register<Item> event)
        {
            event.getRegistry().registerAll(itemsToRegister.toArray(new Item[itemsToRegister.size()]));
        }
    }
    public class ModItem extends Item
    {
        protected String name;
    
        public ModItem(String name)
        {
            this.name = name;
            setUnlocalizedName(name);
            setRegistryName(name);
            Venture.registry.registerItem(this);
        }
    
        @Override
        public ModItem setCreativeTab(CreativeTabs tab)
        {
            super.setCreativeTab(tab);
            return this;
        }
    }

     

  6. [1.12.x] Any Guides for Newbies?

    in Modder Support

    Posted September 10, 2017


    Okay, so from what I've extrapolated, I came up with a plan in my head. I can use my common.items package, create a ModItem class to act as a base class and set the Unlocalized and Registry names. When that item is created, I can, from the ModItem class, call ServerRegistry.registerItem(), add it to that list, and simply have the ServerRegistry use registerAll on that list. When I get it all hooked up, I use kind of a ItemHub with a method for instantiating all these items, which ultimately adds them to the list in the ServerRegistry. I then just add the ServerRegistry to the EVENT_BUS and call it a day.

     

    Is that more or less correct? :o

  7. [1.12.x] Any Guides for Newbies?

    in Modder Support

    Posted September 10, 2017


    Awesome! Thank you. More reading is always helpful. I did end up finding some succinct tutorials at Shadowfacts, so all-in-all I'm working towards piecing it all together. ^^

  8. [1.12.x] Any Guides for Newbies?

    in Modder Support

    Posted September 10, 2017


    1 minute ago, Draco18s said:

    The first one is static so I can reference it as EasyRegistry.registerItem, that method then calls Hardlib.proxy._registerItem

    Couldn't you just make _registerItem static instead? O.o

  9. [1.12.x] Any Guides for Newbies?

    in Modder Support

    Posted September 10, 2017


    Additionally, is there any particular reason you make two methods for most actions? Such as registerItem and _registerItem, that is.

  10. [1.12.x] Any Guides for Newbies?

    in Modder Support

    Posted September 10, 2017


    So, effectively - and pardon for being such a newb - I could just write a ServerRegistry class with the same base functionality as your EasyRegistry and register that to the EVENT_BUS separate from the ServerProxy I have?

  11. [1.12.x] Any Guides for Newbies?

    in Modder Support

    Posted September 10, 2017


    21 minutes ago, Draco18s said:

    Otherwise you have to register an instance manually.

    So, gauging from what I read, the EasyRegistry classes could just as easily be the ClientProxy and ServerProxy I have. Just set it up in the same way... okay. Well, thanks, Draco! :D

  12. [1.12.x] Any Guides for Newbies?

    in Modder Support

    Posted September 10, 2017


    So... 

    @Mod.EventHandler

    ... and I just assign that class to a variable in the main mod file? Or do I use that above the registration function after using 

    @SubscribeEvent / @Mod.EventBusSubscriber

    above the Registry class declaration?

     

    Java's metadata is like alienese to me.

  13. [1.12.x] Any Guides for Newbies?

    in Modder Support

    Posted September 10, 2017


    Would it matter too terribly much where I were to put the Registry event? Choonster's puts the class into the ModItems class, and another tutorial puts the class directly into the main mod file. Is there a way I can make a separate Registry class and call the registration somewhere in the main mod class?

  14. [1.12.x] Any Guides for Newbies?

    in Modder Support

    Posted September 9, 2017


    I'm brand new to the modding scene. I know PHP, I've got some C++ experience, and I'm aware of Java. I can figure things out, more or less... but really only when I have examples I can first learn from. What I'm getting at is are there any clean, fully working example mods using all the best practices for 1.12.x? Like, registering and rendering items, how I should set up the proxies, etc? I did look at Choonster's test mod, and it had a pretty neat idea with how he registers items... however, I need a guide or an example mod that steps me through the basics of setting up a registry for items and blocks, and how I should set up my proxies to work with that.

     

    This is basically just what I pulled from Choonster...

    public static ModIngot ObsidianIngot = new ModIngot("obsidian_ingot");
    
    
        public static void init()
        {
    
        }
    
        @Mod.EventBusSubscriber(modid = Reference.MODID)
        public static class RegistrationHandler
        {
            public static final Set<Item> ITEMS = new HashSet<>();
    
            @SubscribeEvent
            public static void registerItems(final RegistryEvent.Register<Item> event)
            {
                final Item[] items = {
                        ObsidianIngot
                };
    
                final IForgeRegistry<Item> registry = event.getRegistry();
    
                for (final Item item : items) {
                    registry.register(item);
                    ITEMS.add(item);
                }
    
                init();
            }
        }

     

    But I don't know where to go from here.

  15. IntelliJ IDEA - how to run the MC client for testing?

    in ForgeGradle

    Posted September 5, 2017 · Edited September 5, 2017 by Splashsky


     

    I'm completely new to modding; I installed IDEA because I know it's a stronger IDE than Eclipse, and so I followed this tutorial on the forum to get it working, but I can't see where to edit the configuration he found, nor does genIntellijRuns do anything rather than set the Gradle task to setupDecompWorkspace. Doesn't ask me to refresh the project or anything.

     

    edit: Switched the project to run the Minecraft Client instead. Worked as expected. :D

     

    My configuration screen for the Gradle project looks like this...

    Spoiler

    screenshot.png

     

  16. [1.8+] Some vanilla textures go blank?

    in Modder Support

    Posted December 14, 2015


    That error is common to testing environments, so just ignore it and show us the real error (which might be found only in the log file, not console output)

    Which log file? I checked all through eclipse/logs/fml-client-latest.log and it doesn't show anything that I'd take as an error or a failure.

     

    Here's a screenshot of the problem

    Here is a pastebin of fml-client-latest.log

  17. [1.8+] Some vanilla textures go blank?

    in Modder Support

    Posted December 14, 2015


    So, I'm like, minding my own business right? I go ahead and add two food items to my mod, and I'm registering the renders like all the tutorials tell me to.

     

    Suddenly, this hideous error appears and a bunch of Minecraft's vanilla textures are replaced by blank white squares! Anyone have experience with this sort of thing?

    [06:49:11] [pool-2-thread-1/WARN]: Couldn't look up profile properties for com.mojang.authlib.GameProfile@5b82e090[id=d978d670-4b07-3a90-bfb6-b4e7c70fe7fc,name=Player412,properties={},legacy=false]
    com.mojang.authlib.exceptions.AuthenticationException: The client has sent too many requests within a certain amount of time
    at com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService.makeRequest(YggdrasilAuthenticationService.java:65) ~[YggdrasilAuthenticationService.class:?]
    at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillGameProfile(YggdrasilMinecraftSessionService.java:158) [YggdrasilMinecraftSessionService.class:?]
    at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:53) [YggdrasilMinecraftSessionService$1.class:?]
    at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:50) [YggdrasilMinecraftSessionService$1.class:?]
    at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524) [guava-17.0.jar:?]
    at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317) [guava-17.0.jar:?]
    at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280) [guava-17.0.jar:?]
    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195) [guava-17.0.jar:?]
    at com.google.common.cache.LocalCache.get(LocalCache.java:3934) [guava-17.0.jar:?]
    at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938) [guava-17.0.jar:?]
    at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821) [guava-17.0.jar:?]
    at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4827) [guava-17.0.jar:?]
    at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillProfileProperties(YggdrasilMinecraftSessionService.java:148) [YggdrasilMinecraftSessionService.class:?]
    at net.minecraft.client.resources.SkinManager$3.run(SkinManager.java:138) [skinManager$3.class:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_60]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_60]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_60]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_60]
    at java.lang.Thread.run(Thread.java:745) [?:1.8.0_60]
    

     

    EDIT

    After commenting out the following line of code (which was in a separate class file) I was able to get rid of the above error, the textures still do not show up, however.

    private static ItemStack cookedPork = new ItemStack(Items.cooked_porkchop);

  18. [1.8+] Localizing item/block names?

    in Modder Support

    Posted December 14, 2015


    You shouldn't need any kind of special Registry at all - registering your Item to the normal GameRegistry and setting its unlocalized name will automatically check your language file for the string "item.unlocalized_name.name".

    The point was to create a class that added localized names via a simple regex process so that I could add items and tabs and the like and not have to manually enter new localizations. It partially works, except my bugged version had been putting en_US.lang in the root directory and made multiple copies of the same line (an issue I am trying to debug :P)

     

    Though, I tested a couple things out while writing this reply, and it seems that manually adding entries is my best bet until I learn some more about Java and Forge.

     

    As for the directory structure, everyone sets it up differently, so it was probably fine where it was before, but the default workspace setup usually has the folder as src/main/resources/assets/mod_id/actual_folders.

    Changed the path that was being passed to LangRegistry to match up with that format; can't find the file that is - to me - clearly there. Not a problem for the time being, but something I want to fix.

     

    RegistryFile.class (sorry for lack of brevity)

    public abstract class RegistryFile {
    protected String filePath;
    protected BufferedWriter writer;
    protected File file;
    protected StringBuilder builder = new StringBuilder();
    
    public RegistryFile(String filePath) {
    	this.filePath = filePath;
    	this.file     = new File(filePath);
    }
    
    public abstract void addNames();
    
    public void localizeName(String prefixOfLine, String unlocalizedName) {
    	String name = unlocalizedName.substring(5);
    	char firstLetter = name.charAt(0);
    	if(Character.isLowerCase(firstLetter)) {
    		firstLetter = Character.toUpperCase(firstLetter);
    	}
    	String inGame = name.substring(1);
    	String temp   = inGame;
    
    	for(int p = 1; p < temp.length(); p++) {
    		char c   = inGame.charAt(p);
    		int code = c;
    
    		if(inGame.charAt(p - 1) != ' ') {
    			for(int n = 65; n < 90; n++) {
    				if(code == n) {
    					inGame = new StringBuffer(inGame).insert(p, "").toString();
    				}
    			}
    		}
    
    		inGame = inGame.replaceAll(" Of ", " of ").replaceAll(" The ", " the ");
    		String finalName = firstLetter + inGame;
    		addToFile(prefixOfLine + "." + name + ".name=" + finalName, name);
    	}
    }
    
    public static String getLocalizedMobName(String str) {
    	int l = str.length();
    	if(str.length() > 1) {
    		for(int i = 1; i < l; i++) {
    			if((Character.isUpperCase(str.charAt(i))) && (str.charAt(i - 1) != ' ')) {
    				str = new StringBuffer(str).insert(i, " ").toString();
    			}
    		}
    	}
    
    	return str.replace("HRPG", "");
    }
    
    public String readFile(String path) {
    	StringBuilder source = new StringBuilder();
    	BufferedReader reader = null;
    	File file = new File(path);
    
    	try {
    		reader = new BufferedReader(new FileReader(file));
    		String line;
    		while((line = reader.readLine()) != null) {
    			source.append(line);
    		}
    		reader.close();
    	} catch(Exception e) {
    		e.printStackTrace();
    	}
    
    	return source.toString();
    }
    
    public void addName(String prefix, String keyName, String inGameName) { addToFile(prefix + "." + keyName + "=" + inGameName, keyName); }
    
    public void addToFile(String inGame, String oldName) {
    	String temp = inGame;
    	Log.dev("Registered new name, " + oldName + " became " + temp.substring(temp.indexOf('=') + 1));
    	this.builder.append(inGame + "\n");
    }
    
    public void addToFile(String text) { this.builder.append(text + "\n"); }
    
    public void write() {
    	try {
    		if(!this.file.exists()) { this.file.createNewFile(); }
    
    		this.writer = new BufferedWriter(new FileWriter(this.file));
    		this.writer.write(this.builder.toString());
    		this.writer.close();
    	} catch(IOException e) {
    		e.printStackTrace();
    	}
    }
    }
    

     

    LangRegistry.class (extends RegistryFile)

    public class LangRegistry extends RegistryFile {
    private static ArrayList<HexTabs> tabs = new ArrayList();
    private static ArrayList<Item> items   = new ArrayList();
    
    public static final RegistryFile instance = new LangRegistry();
    
    public LangRegistry() {
    	super("src/main/resources/assets/cshex/lang/en_US.lang");
    }
    
    public static void registerNames() {
    	instance.addNames();
    }
    
    public void addNames() {
    	for(Item item : items) {
    		localizeName("item", item.getUnlocalizedName());
    	}
    
    	instance.write();
    }
    
    public static void addTab(HexTabs tab) { tabs.add(tab); }
    public static void addItem(Item item) { items.add(item); }
    }
    

  19. [1.8+] Localizing item/block names?

    in Modder Support

    Posted December 13, 2015


    One more quick question; in the event that I'm creating a class to automagically add lines to my en_US.lang file, how would I navigate to said file? Currently, I've got a LangRegistry class that extends a custom RegistryFile class, with a constructor as such;

    RegistryFile Constructor (LangRegistry uses super())

    public RegistryFile(String filePath) {
    this.filePath = filePath;
    this.file     = new File(filePath);
    }
    

     

    I've got "resources/assets/cshex/lang/en_US.lang" passed to my LangRegistry class at the moment, but it doesn't seem to read it, let alone write to it.

     

    NOTE I'm only learning; I'm reverse engineering a well-established mod, so my questions are pretty noobish for the stuff I'm trying to do. However, I've had previous programming experience, only Java itself is new for me :P

  20. [1.8+] Localizing item/block names?

    in Modder Support

    Posted December 13, 2015


    It should be under src/main/resources/assets/your_mod_id/lang

     

    Awesome, thanks! Though, if it requires a folder labelled with your_mod_id, then how's it work that it allows item and block textures to be in folders in assets? Wouldn't it be logical to put such things into the same folder as the lang files?

  21. [1.8+] Localizing item/block names?

    in Modder Support

    Posted December 13, 2015


    I've been trying to work with some pre-1.8 tutorials and examples, but I can't figure out how to get my single item's name localized.

     

    Does anyone have a guide or something on localization in 1.8? I've got a manually-made en_US.lang under src/main/resources/assets/lang in my Eclipse Package Explorer, but when I grab the item in-game it reads item.bacon.name

  22. Function changes?

    in Modder Support

    Posted December 12, 2015


    I'm reverse-engineering a mod that was apparently designed for Minecraft 1.7.10, and in their custom food classes I'm seeing methods like "func_77637_a" and "func_111206_d", the former of which I guessed was the old-school setCreativeTab() method from the Minecraft Item class.

     

    Is there a dictionary that shows the function changes? I'm having difficulty translating the old code.

  • All Activity
  • Home
  • Splashsky
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community