Jump to content

SeptemberBlue

Members
  • Posts

    49
  • Joined

  • Last visited

Posts posted by SeptemberBlue

  1. 40 minutes ago, Draco18s said:

    The model is cube_all, which is specified by vanilla.

    The item model is this one which is used for all blocks.

    EDIT: Alright, modified the code for my block, reverted back to my old json files (I needed them since the textures stopped working) and now I've finally create a block that drops xp. Thanks for all the help!

     

    Still though, I appear to be getting a lot of these

    Quote

    [15:45:25] [Server thread/WARN] [minecraft/MinecraftServer]: Can't keep up! Did the system time change, or is the server overloaded? Running 46131ms behind, skipping 922 tick(s)

    I'm certain it's to do with these for loops, but if they're fine, then I'm assuming that I'm just imagining these issues.

    	@SubscribeEvent
    	public static void onModelRegister(ModelRegistryEvent event) {
    		for (Item item:ModItems.ITEMS) {
    			Main.proxy.registerItemRenderer(item, 0, "inventory");
    		}
    		for (Block block:ModBlocks.BLOCKS) {
    			Main.proxy.registerItemRenderer(Item.getItemFromBlock(block), 0, "inventory");
    		}
    	}

     

  2. 15 minutes ago, Draco18s said:

    EDIT: Alright, fixed blockstates. I'll just tweak it a bit, since I currently find it too cluttered.

    EDIT 2: Maybe it's just me, but when I run client, it feels like it's running more slowly than before. Should this concern me or no? If so, I think it has something to do with how I'm registering stuff.

     

    Speaking of which, do you just have 1 json per block? Because the 3 jsons I posted above were 3 seperate jsons.

  3. 2 minutes ago, Draco18s said:

    Look under this, see if there's another error starting with Caused By:

     

    Also post your json files.

    all json files are named "amethyst_ore.json"

    blockstates:

    {
        "variants": {
            "normal": { "model": "geg:amethyst_ore" }
        }
    }

    block model:

    {
       "parent": "block/cube_all",
       "textures": {
           "all": "geg:blocks/amethyst_ore"
       }
    }

    item model:

    {
       "parent": "geg:block/amethyst_ore"
    }

     

    also, here's this:

    Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException

     

  4. 17 minutes ago, Draco18s said:

    Look at (and/or post) your logs.

    Logs being the text in the console, right?

     

    EDIT:

    [13:29:09] [main/ERROR] [FML]: Exception loading model for variant geg:amethyst_ore#inventory for item "geg:amethyst_ore", blockstate location exception: 
    net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model geg:amethyst_ore#inventory with loader VariantLoader.INSTANCE, skipping
    	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:161) ~[ModelLoaderRegistry.class:?]
    	at net.minecraftforge.client.model.ModelLoader.loadItemModels(ModelLoader.java:296) ~[ModelLoader.class:?]
    	at net.minecraft.client.renderer.block.model.ModelBakery.loadVariantItemModels(ModelBakery.java:175) ~[ModelBakery.class:?]
    	at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:151) ~[ModelLoader.class:?]
    	at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?]
    	at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:121) [SimpleReloadableResourceManager.class:?]
    	at net.minecraft.client.Minecraft.init(Minecraft.java:559) [Minecraft.class:?]
    	at net.minecraft.client.Minecraft.run(Minecraft.java:421) [Minecraft.class:?]
    	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_222]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_222]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_222]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_222]
    	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
    	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_222]
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_222]
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_222]
    	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_222]
    	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
    	at GradleStart.main(GradleStart.java:25) [start/:?]

     

    EDIT:

    @EventBusSubscriber
    public class RegistryHandler {
    	
    	@SubscribeEvent
    	public static void onItemRegister(RegistryEvent.Register<Item> event) {
    		event.getRegistry().registerAll(ModItems.ITEMS.toArray(new Item[0]));
    	}
    	
    	@SubscribeEvent
    	public static void onBlockRegister(RegistryEvent.Register<Block> event) {
    		event.getRegistry().registerAll(ModBlocks.BLOCKS.toArray(new Block[0]));
    	}
    	
    	@SubscribeEvent
    	public static void onModelRegister(ModelRegistryEvent event) {
    		for (Item item:ModItems.ITEMS) {
    			Main.proxy.registerItemRenderer(item, 0, "inventory");
    		}
    		for (Block block:ModBlocks.BLOCKS) {
    			Main.proxy.registerItemRenderer(Item.getItemFromBlock(block), 0, "inventory");
    		}
    	}
    }

    Here's my registry class, if this is any help.

  5. So I've gone and redone my code again, and I'm looking at the code for my registryhandler class.

    @SubscribeEvent
    	public static void onModelRegister(ModelRegistryEvent event) {
    		for (Item item:ModItems.ITEMS) {
    			Main.proxy.registerItemRenderer(item, 0, "inventory");
    		}
    		for (Block block:ModBlocks.BLOCKS) {
    			Main.proxy.registerItemRenderer(Item.getItemFromBlock(block), 0, "inventory");
    		}
    	}

    Is there a better way to rewrite this code or is this fine?

     

    EDIT: So I was working on my block, and while it does appear in the creative inventory, it's missing an inventory texture and its texture when dropped as an item (which I'm assuming is the same texture for the item when its held, as that is also missing). The block has the correct texture though when placed. I'm certain the json files are correct, so I'm not too sure at the moment what the issue would be.

  6. 6 minutes ago, Animefan8888 said:

    Is your mod loading check the mods list on the main menu.

    Two things. First off, the mod doesn't seem to have anything set. It's still called example mod, despite the name, version, modid and whatnot set in the Main class.

     

    The other thing is that the mod's disabled.

     

    EDIT: I'll wait and see if I get this resolved, but if not, I'll just go back to the tutorial I used first and use the code from that to create functional items, as whatever code I have now clearly does not work, and I don't really know why either.

  7. Just now, Animefan8888 said:

    Yes at the top of it.

    	@SubscribeEvent
    	public static void onItemRegister(RegistryEvent.Register<Item> event) {
    		ModItems.init();
    		event.getRegistry().registerAll(ModItems.ITEMS.toArray(new Item[0]));
    	}

    I tried this but the item didn't show up. Unless you wanted it outside the method, like above the @SubscribeEvent thing.

     

    I also thought I'd mention that I also have the item lang, textures and json set up in the res folder.

  8. Just now, Animefan8888 said:

    What?

    To be more specific, I'm wondering what java class would be responsible for why the items aren't showing up. To make it easier though, I'll just paste the code for these.

     

    ModItem:

    package goocraft4evr.expand_goocraft.items;
    
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.item.Item;
    
    public class ModItem extends Item {
    
    	public ModItem(String name) {
    		this.setRegistryName(name);
    		this.setUnlocalizedName(name);
    		this.setCreativeTab(CreativeTabs.MATERIALS);
    		ModItems.ITEMS.add(this);
    	}
    }

    ModItems:

    package goocraft4evr.expand_goocraft.items;
    
    import java.util.ArrayList;
    import java.util.List;
    import net.minecraft.item.Item;
    
    public class ModItems {
    	
    	public static final List<Item> ITEMS = new ArrayList<Item>();
    	
    	public static void init() {
    		new ModItem("Amethyst");
    	}
    }

    RegistryHandler:

    package goocraft4evr.expand_goocraft;
    
    import goocraft4evr.expand_goocraft.items.ModItems;
    import net.minecraft.client.renderer.block.model.ModelResourceLocation;
    import net.minecraft.item.Item;
    import net.minecraftforge.client.event.ModelRegistryEvent;
    import net.minecraftforge.client.model.ModelLoader;
    import net.minecraftforge.event.RegistryEvent;
    import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
    import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
    
    @EventBusSubscriber
    public class RegistryHandler {
    	@SubscribeEvent
    	public static void onItemRegister(RegistryEvent.Register<Item> event) {
    		event.getRegistry().registerAll(ModItems.ITEMS.toArray(new Item[0]));
    	}
    	
    	@SubscribeEvent
    	public static void onModelRegister(ModelRegistryEvent event) {
    		for (Item item:ModItems.ITEMS) {
    			ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(),null));
    		}
    	}
    }

    The Main method might also be relevant, but I've already posted that and it hasn't been changed.

  9. I'm getting a bit of a strange error now.

    package goocraft4evr.expand_goocraft;
    
    import net.minecraftforge.fml.common.Mod;
    import net.minecraftforge.fml.common.Mod.EventHandler;
    import net.minecraftforge.fml.common.Mod.Instance;
    import net.minecraftforge.fml.common.SidedProxy;
    import net.minecraftforge.fml.common.event.FMLInitializationEvent;
    import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
    import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
    
    import com.goocraft.mod.items.ModItems;
    import com.goocraft.mod.proxy.ServerProxy;
    
    @Mod(modid=Main.MODID,version=Main.VERSION,name=Main.NAME,acceptedMinecraftVersions="[1.12.2]")
    public class Main {
    	public static final String MODID = "goocraft_mod";
    	public static final String VERSION = "1.0";
    	public static final String NAME = "Goocraft4Evr's Expansionary Goodstuffs";
    	
    	@Instance(MODID)
    	public Main instance;
    	
    	@SidedProxy(clientSide = "goocraft4evr.expand_goocraft.proxy.Client_Proxy",serverSide = "goocraft4evr.expand_goocraft.proxy.Server_Proxy")
    	public static ServerProxy proxy;
    	
    	@EventHandler
    	public void preInit(FMLPreInitializationEvent event) {
    		ModItems.init();
    		proxy.preInit(event);
    	}
    	
    	@EventHandler
    	public void init(FMLInitializationEvent event) {
    		proxy.init(event);
    	}
    	
    	@EventHandler
    	public void postInit(FMLPostInitializationEvent event) {
    		proxy.postInit(event);
    	}
    }

    this is the entirety of my Main class. For some reason, classes like ModItems and ServyProxy are undefined.

    299683055_weirderror.png.110b1f424089b7fc6feeb999cfd4b5d5.png

    There's my hierarchy above.

  10. 5 minutes ago, Draco18s said:

    There is a lot of code there, and I don't need to use all of it.

    I was using this so far.

    @EventBusSubscriber
    public class RegistryHandler {
    	@SubscribeEvent
    	public static void onItemRegister(RegistryEvent.Register<Item> event) {
    		event.getRegistry().registerAll(ModItems.ITEMS.toArray(new Item[0]));
    	}
    	
    	@SubscribeEvent
    	public static void onModelRegister(ModelRegistryEvent event) {
    		for (Item item:ModItems.ITEMS) {
    			if (item instanceOf )
    		}
    	}
    }

    However, I stopped by the for loop, since it was going to check if "item instanceOf IHasModel", and I'm pretty sure that was something you shouldn't do.

    Is there a specific chunk from that code that I can use in place of what I currently have? I don't want to just copy and paste the entire thing because that seems like a hassle.

  11. Ok, so I've followed the tutorial to a point, since its outdated. Now I'm a little stuck for my ModItems class.

     

    public class ModItems {
    	
    	public static final List<Item> ITEMS = new ArrayList<Item>();
    	
    	public static void init() {
    		new ModItem("Amethyst");
    		register();
    	}
    	
    	public static void register() {
    		for (Item item:ITEMS) {
    			Main.proxy.registerItemRenderer(item, 0, "inventory");
    		}
    	}
    }

    I'm not even sure if this would work. My problem with it now though is that I don't have a registerItemRenderer method. The tutorial I was following put it in a common proxy class, but I don't have that class (instead use server proxy). So where should I define the method?

     

    EDIT: Alright, defined it. Only issue is that my item doesn't show up at all. Any idea why?

  12. 23 minutes ago, Animefan8888 said:

    You should have a ModelRegistryEvent and you need to do it there.

    Where do I find an example of this?

     

    On another note, I was having trouble with this code (for items, wanted to add the ore item):

    public class ModItems {
    	public static final List<Item> ITEMS = new ArrayList<Item>();
    	public static final Item AMETHYST = new Item().setUnlocalizedName("amethyst").setRegistryName("amethyst").setCreativeTab(CreativeTabs.MATERIALS);
    	ITEMS.add(AMETHYST);
    }

    ITEMS doesn't need to be final, does it? Because I'm trying to add the amethyst item to it, but it won't compile.

     

    EDIT: Almost forgot my current code for the ore:

    public class AmethystOre extends Block {
    
    	public AmethystOre(String name, Material material) {
    		super(material);
    		setUnlocalizedName(name);
    		setRegistryName(name);
    		setCreativeTab(CreativeTabs.BUILDING_BLOCKS);	
    		ModBlocks.BLOCKS.add(this);
    		ModItems.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName()));
    		setHardness(3.0f);
    		setResistance(15.0f);
    		setHarvestLevel("pickaxe",1);
    		setLightLevel(0.0f);
    		//setLightOpacity(1); for glass blocks
    		//setBlockUnbreakable();
    	}
    	
    	@Override
    	public Item getItemDropped(IBlockState state, Random rand, int fortune) {
    		return ModItems.AMETHYST;
    	}
    	
    	@Override
    	public int quantityDropped(Random rand) {
    		int max = 5;
    		int min = 2;
    		return rand.nextInt(max)+min;
    	}
    	
    	@Override
    	public int quantityDroppedWithBonus(int fortune, Random random)
        {
            if (fortune > 0 && Item.getItemFromBlock(this) != this.getItemDropped((IBlockState)this.getBlockState().getValidStates().iterator().next(), random, fortune))
            {
                int i = random.nextInt(fortune + 2) - 1;
    
                if (i < 0)
                {
                    i = 0;
                }
    
                return this.quantityDropped(random) * (i + 1);
            }
            else
            {
                return this.quantityDropped(random);
            }
        }
    
    }

     

  13. Just now, Animefan8888 said:

    That's a different issue. Do you have a item model file for it? Do you register the models for it. 

    So remember when you said to delete the IHasModel implementation? There was a method connected to that implementation, and that was where the model was registered. I'm not sure where else I'm supposed to register it.

  14. Alright, so I've found those files, that's good. I just don't know what to do with those methods. Do I override them or do I call them? If the latter is true, where?

    Also, while my block appears to render just fine when placed, is missing its item texture. What am I supposed to do about that?

  15. 1 minute ago, Animefan8888 said:

    You could look at these I made these 2 years ago for 1.10. Not much of the basic stuff changed between 1.10 and 1.12.

     

    It's the idea of composition over inheritance. You don't need to make a new class for each Block. You can just do

    
    new Block(Material.ROCK).setUnlocalizedName("modid:name").setRegistryName("modid:name");

    But in your case you can make a class for your ores. Like vanilla's BlockOre class.

    Block is the class and the # means that the following thing after it requires a field of the class type. IE Blocks.DIAMOND_ORE.getItem(...) instead of Block.getItem(...).

    Go to the BlockOre class. Which you can find by typing BlockOre and ctrl+left clicking on the name. Or by looking in the forge source file in the eclipse file explorer. Then find the methods with the names I gave you.

    (I'm not really sure how to quote certain sections of a comment, but for reference, I'm referring to the latter portion)

     

    In my eclipse project, I only see the resources for my mod, so where am I supposed to find the forge source file?

    So my mod is in a folder. Assuming that all mod folders are the same, where would I have to go to find the forge source file?

    Or is it not included in the mod folder?

  16. 16 minutes ago, Animefan8888 said:

    Ok first thing after looking over your code I have determined that it isn't a good tutorial. So I don't recommend you keep using it.

    Remove this entirely from your workspace. And instead replace wherever you have <variable>.registerModels(); With Main.proxy.registerItemRenderer(item, 0, "inventory");

    If you have any custom item models later do that manually.

    This is also bad remove it. Also if you have an ItemBase remove that too.

    The math for fortune is in BlockOre#quantityDroppedWithBonus this is also the method you should use to apply fortune.

    The method to use is Block#getExpDrop and once again you can find an example in BlockOre#getExpDrop

     

    So I have two more questions.

     

    First off, why is having a class like block base bad? Personally, I think it'd be easier to modify it so that instead of having to create a new class for each block, I would just give the base class some values and it would set the block. Or is it because you couldn't give those blocks any special events? My point is that I fail to see the issue.

     

    Second, I don't get the Block# thing. I'm not sure what I'm supposed to do to find it (I've also barely used eclipse, which is what I'm using to make this mod). What does it mean, and how do I find it?

     

    EDIT: Anyway, since the tutorial I've used isn't any good, is there a good tutorial that I could follow in order to improve my current code?

     

    EDIT 2: So I deleted the "implements IHasModel" portion, alongside the registerModels method. However, I think that was the only portion of code that actually registered the model, because I don't see any other area in which " <variable>.registerModels() " would be called. With that said, where should I call it?

  17. So I've been using this tutorial to start creating a mod. I want to create an ore, but there's two issues that I have. The main issue I have is that I don't know what method to override so I can have the block drop xp. Other than that, I have a method so that the ore drops a random amount of items. However, it's not affected by fortune enchantments, and I'm don't know exactly how fortune enchantments work (like if they multiply the quantity, add onto the quantity, etc).

     

    Here is the code for my ore so far:

    public class AmethystOre extends BlockBase {
    
    	public AmethystOre(String name, Material material) {
    		super(name, material);
    		
    		setSoundType(SoundType.STONE);
    		setHardness(3.0f);
    		setResistance(15.0f);
    		setHarvestLevel("pickaxe",1);
    		setLightLevel(0.0f);
    		//setLightOpacity(1); for glass blocks
    		//setBlockUnbreakable();
    	}
    	
    	@Override
    	public Item getItemDropped(IBlockState state, Random rand, int fortune) {
    		return ModItems.AMETHYST;
    	}
    	
    	@Override
    	public int quantityDropped(Random rand) {
    		int max = 5;
    		int min = 2;
    		return rand.nextInt(max)+min;
    	}
    
    }

     

    Here is the code for BlockBase:

    public class BlockBase extends Block implements IHasModel {
    	public BlockBase(String name, Material material) {
    		super(material);
    		setUnlocalizedName(name);
    		setRegistryName(name);
    		setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
    		
    		ModBlocks.BLOCKS.add(this);
    		ModItems.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName()));
    	}
    
    	@Override
    	public void registerModels() {
    		Main.proxy.registerItemRenderer(Item.getItemFromBlock(this), 0, "inventory");
    	}
    }

     

    I've omitted imports because the only things imported so far seem to be the main method and the random class. Are there any additional things I should import?

×
×
  • Create New...

Important Information

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