Jump to content

MSpace-Dev

Members
  • Posts

    180
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by MSpace-Dev

  1. I have a class called FileManager that manages many things to do with my custom mod files. I'm trying to create a static constant that allows me to reference an array of files whenever I want. However, my program throws an ExceptionInInitializerError.

     

    I took a similar test to a basic static void main program, and the program compiled fine. I can't see what I'm doing wrong in my main program below. Here are the relevant files:

     

    Log:

    [11:26:14] [Client thread/ERROR] [ne.mi.fm.ja.FMLModContainer/]: Exception caught during firing event: null
    	Index: 1
    	Listeners:
    		0: NORMAL
    		1: ASM: class com.mspacedev.ModEventSubscriber onRegisterBlocks(Lnet/minecraftforge/event/RegistryEvent$Register;)V
    		2: ASM: class com.mspacedev.ModEventSubscriber onRegisterItems(Lnet/minecraftforge/event/RegistryEvent$Register;)V
    java.lang.ExceptionInInitializerError
    	at com.mspacedev.util.Data$Chests.getChestProperties(Data.java:16)
    	at com.mspacedev.ModEventSubscriber.onRegisterBlocks(ModEventSubscriber.java:28)
    	at net.minecraftforge.eventbus.ASMEventHandler_0_ModEventSubscriber_onRegisterBlocks_Register.invoke(.dynamic)
    	at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:80)

     

    FileManager:

    // Files
    public static final ArrayList<File> chestFiles = getFilesInPath("customchests/chests/");
    
    private static ArrayList<File> getFilesInPath(final String pathName)
    {
    	ArrayList<File> files = new ArrayList<>();
    
    	File folder = new File(pathName);
    
    	for (final File fileEntry : folder.listFiles())
    	{
    		if (fileEntry.isDirectory())
    			continue;
    
    		files.add(new File(fileEntry.getName()));
    	}
    
    	return files;
    }

     

    I call this in my RegistryEvent.Register<Block> function:

    if (!FileManager.chestFiles.isEmpty())

    And it returns a NullReferenceException because of the earlier ExceptionInInitializerError

  2. I want to expand my mod's features lots in 1.14.4. I want users to be able to specify mobIDs from other mods in JSON to initialise a new item, block and entity for the specified id. To do this, I need to be able to dynamically create these objects.

     

    It would be perfect for my mod. You will be able to see that at a quick glance I think:

    https://www.curseforge.com/minecraft/mc-mods/monster-totems

     

  3. I've been doing some research. What are your thoughts on this method?

    	@SubscribeEvent
    	public static void onRegisterEntities(final RegistryEvent.Register<EntityType<?>> event)
    	{
    		DeferredWorkQueue.runLater(() -> {
    			entityBuilder(event);
    		});
    	}
    
    	private static void entityBuilder(final RegistryEvent.Register<EntityType<?>> event)
    	{
    		ArrayList<EntityType<?>> all_entities;
    		all_entities = (ArrayList<EntityType<?>>) event.getRegistry().getValues();
    
    		Main.LOGGER.debug("ALL LOADED ENTITIES:");
    		all_entities.forEach(p -> Main.LOGGER.debug(p));
    	}

     

    And will I be able to register new entities under new IDs using the methods within EntityType and ForgeRegistries.ENTITIES? (If I don't go with this method ^)

  4. In FG 2.3, there was a function called replace. It has now been removed / changed in 1.14.4. Here is the function in FG 2.3.

        /**
         * Add a source replacement mapping
         *
         * @param token       The token to replace
         * @param replacement The value to replace with
         */
        public void replace(Object token, Object replacement)
        {
            replacements.put(token.toString(), replacement);
        }
    
        /**
         * Add a map of source replacement mappings
         *
         * @param map A map of tokens -&gt; replacements
         */
        public void replace(Map<Object, Object> map)
        {
            for (Entry<Object, Object> e : map.entrySet())
            {
                replace(e.getKey(), e.getValue());
            }
        }

     

    This was useful as it allowed me to edit my version in only gradle.properties

    replace "@VERSION@", project.version
    replaceIn "utils.Reference.java"

     

  5. I've set TileEntity#shouldRefresh to false so that I can update the blockstate without it resetting its values. However, this makes the tile entity persist when its block is broken.

    I've added world.removeTileEntity(pos) in theBlock#blockBreak override function. However, the TE still persists. I can verify it is getting called. Am I missing something here?

     

    @Override
    public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
    {
        if (!worldIn.isRemote)
        {
            if (worldIn.getTileEntity(pos) != null)
            {
                if (worldIn.getTileEntity(pos) instanceof TileEntityTotemBase)
                {
                    TileEntityTotemBase totemBase = (TileEntityTotemBase) worldIn.getTileEntity(pos);
            
                    // Update totem on Client
                    totemBase.setTotemProperties();
                    totemBase.sendUpdates();
                }
            }
        }
    
        worldIn.removeTileEntity(pos); // Redundant as super() calls it anyways. Probably need some other calls to remove TE!
    
        super.breakBlock(worldIn, pos, state);
    }
  6. I have a custom tile entity that can switch between 2 states, simply with bool = !bool

     

    When this switch happens, I would like to change one of the texture references in the model.JSON to switch to another texture. How can I achieve this.
    (There are multiple textures in the single model)

     

    I noticed the furnace DOES NOT use blockstates for this. So, interested in how that was done. If not, I will end up using blockstates.

     

    Thanks

  7. Now that my project is updated. Where can I find info on the changes to all the function names? I've migrated the namespaces using the MCP XML. However, it only goes up to 1.13-to-1.13.1.xml

    These are the resources I've found so far:

    https://mcforge.readthedocs.io/en/1.13.x/

    https://gist.github.com/williewillus/353c872bcf1a6ace9921189f6100d09a

     

    Got things like this happening

    image.png.89bf675547565c96411a57d8daf4ccd2.png

    Just not sure where to begin finding what these have changed to.

  8. Alright, so I've downloaded a completely fresh 1.14.3 MDK and moved it into an empty folder. IMported with IntelliJ. Didn't even put my src in. So bare bones project.

    1. Downloaded and extracted 1.14.4 Forge MDK to new folder
    2. Imported Gradle project using build.gradle in IntelliJ 2019
    3. Ran "gradlew genIntelliJRuns" using terminal.
    4. Ran "gradlew genIntelliJRuns --no-daemon" using terminal.
    5. Ran "gradlew --refresh-dependencies" using terminal.
    
    Note: Steps 3-5 ran without any errors.
    Note2: I refreshed Gradle multiple times. Auto-import is also enabled.

     

    I get this error now when I refresh Gradle

    Spoiler

    Caused by: java.lang.IllegalStateException: ProjectScopeServices has been closed.

    image.png.caecdf713b9fffe10a2ffde03bd2a820.png

    And this error:

    Spoiler

    Unable to resolve net.minecraftforge:forge:1.14.4-28.1.90_mapped_snapshot_20190719-1.14.3

    image.png.a367ccc369b5d8fdc26419ba59dddaf7.png

     

    Project structure:

    image.png.6955a0d882d011a6cbf2aae7d0c8e5ff.png

  9. Hey all,

     

    Trying to update my 1.12.2 project here TO 1.13.2. I've done the following steps exactly in this order:

    1. Downloaded and extracted 1.13.2 Forge MDK to new folder
    2. Moved over my 'src' and 'run' folder into MDK folder
    3. Imported Gradle project using build.gradle in IntelliJ 2019
    4. Ran "gradlew genIntelliJRuns" using terminal.
    5. Ran "gradlew --refresh-dependencies" using terminal.
    
    Note: Both steps 4-5 ran WITHOUT any build errors.
    Note2: I refreshed Gradle multiple times throughout. Auto-import is also enabled, so the project has been refreshed multiple times at least. No question.
      
     Error: "Unable to resolve net.minecraftforge.forge:1.13.2-25.0.219"

     

    Though, some commands produced this output. Not sure if I can safely ignore it or not.

    Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
    Use '--warning-mode all' to show the individual deprecation warnings.
    See https://docs.gradle.org/4.9/userguide/command_line_interface.html#sec:command_line_warnings
    

    image.png.6d6b637d703437a55e01c9b6ca3d193d.png

     

    build.gradle (Just generic one from the zip file)

    buildscript {
        repositories {
            maven { url = 'https://files.minecraftforge.net/maven' }
            jcenter()
            mavenCentral()
        }
        dependencies {
            classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
        }
    }
    apply plugin: 'net.minecraftforge.gradle'
    // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
    apply plugin: 'eclipse'
    apply plugin: 'maven-publish'
    
    version = '1.0'
    group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
    archivesBaseName = 'modid'
    
    sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
    
    minecraft {
        // The mappings can be changed at any time, and must be in the following format.
        // snapshot_YYYYMMDD   Snapshot are built nightly.
        // stable_#            Stables are built at the discretion of the MCP team.
        // Use non-default mappings at your own risk. they may not always work.
        // Simply re-run your setup task after changing the mappings to update your workspace.
        mappings channel: 'snapshot', version: '20180921-1.13'
        // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
        
        // accessTransformer = file('build/resources/main/META-INF/accesstransformer.cfg')
    
        // Default run configurations.
        // These can be tweaked, removed, or duplicated as needed.
        runs {
            client {
                workingDirectory project.file('run')
    
                // Recommended logging data for a userdev environment
                property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
    
                // Recommended logging level for the console
                property 'forge.logging.console.level', 'debug'
    
                mods {
                    examplemod {
                        source sourceSets.main
                    }
                }
            }
    
            server {
                workingDirectory project.file('run')
    
                // Recommended logging data for a userdev environment
                property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
    
                // Recommended logging level for the console
                property 'forge.logging.console.level', 'debug'
    
                mods {
                    examplemod {
                        source sourceSets.main
                    }
                }
            }
        }
    }
    
    dependencies {
        // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
        // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
        // The userdev artifact is a special name and will get all sorts of transformations applied to it.
        minecraft 'net.minecraftforge:forge:1.13.2-25.0.219'
    
        // You may put jars on which you depend on in ./libs or you may define them like so..
        // compile "some.group:artifact:version:classifier"
        // compile "some.group:artifact:version"
    
        // Real examples
        // compile 'com.mod-buildcraft:buildcraft:6.0.8:dev'  // adds buildcraft to the dev env
        // compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
    
        // The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
        // provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
    
        // These dependencies get remapped to your current MCP mappings
        // deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev'
    
        // For more info...
        // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
        // http://www.gradle.org/docs/current/userguide/dependency_management.html
    
    }
    
    // Example for how to get properties into the manifest for reading by the runtime..
    jar {
        manifest {
            attributes([
                "Specification-Title": "examplemod",
                "Specification-Vendor": "examplemodsareus",
                "Specification-Version": "1", // We are version 1 of ourselves
                "Implementation-Title": project.name,
                "Implementation-Version": "${version}",
                "Implementation-Vendor" :"examplemodsareus",
                "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
            ])
        }
    }
    
    // Example configuration to allow publishing using the maven-publish task
    // we define a custom artifact that is sourced from the reobfJar output task
    // and then declare that to be published
    // Note you'll need to add a repository here
    def reobfFile = file("$buildDir/reobfJar/output.jar")
    def reobfArtifact = artifacts.add('default', reobfFile) {
        type 'jar'
        builtBy 'reobfJar'
    }
    publishing {
        publications {
            mavenJava(MavenPublication) {
                artifact reobfArtifact
            }
        }
        repositories {
            maven {
                url "file:///${project.projectDir}/mcmodsrepo"
            }
        }
    }

     

  10. Alright, I've moved everything to being registered through the registry event and EntityEntryBuilder.

     

    My entities are exactly the same in world, so it's working. The lang file is still not working for them though.

     

    RegistryEventHandler

    @SubscribeEvent
    public static void registerEntities(RegistryEvent.Register<EntityEntry> event)
      {
      final IForgeRegistry<EntityEntry> registry = event.getRegistry();
    
      for (final EntityEntry entityEntry : ModEntities.ENTITIES)
      {
      	registry.register(entityEntry);
      }
    }

     

    ModEntities

    public class ModEntities
    {
    	private static int id = 1500;
    
    	public static final EntityEntry[] ENTITIES = {
    			getEntityEntry("mob_name", "Mob Name", EntityMob.class, 16167425, 16775294)
    	};
    
    	private static EntityEntry getEntityEntry(String nameId, String entityName, Class<? extends Entity> entityClass, int eggPrimary, int eggSecondary)
    	{
    		return EntityEntryBuilder.create()
    				.entity(entityClass)
    				.id(new ResourceLocation(Reference.MODID, nameId),++id)
    				.name(entityName)
    				.tracker(64, 1, false)
    				.egg(eggPrimary, eggSecondary)
    				.spawn(EnumCreatureType.MONSTER, 0, 0, 0, Biomes.VOID)
    				.build();
    	}
    }

     

    en_us

    #### Entities ####
    entity.mod_id.mob_name.name=Mob Name
    
    entity.mob_name.name=Mob Name

     

    Am I missing something?

  11. Hey all,

     

    I'm trying to get my spawn eggs to not display as "entity.mob_name.name", but rather as "Spawn mob_name" like Vanilla's spawn eggs. Here is the necessary information.

     

    InitEntities.class

    public class InitEntities
    {
    
    	private static int id = 1500;
    
    	public static void register()
    	{
    		registerEntity("mob_id", "Mob Name", EntityMob.class, 16167425, 16775294);
    
    		Utils.getLogger().info("Entities Registered");
    	}
    
    	private static void registerEntity(String nameId, String entityName, Class<? extends Entity> entityClass, int eggPrimary, int eggSecondary)
    	{
    		EntityRegistry.registerModEntity(new ResourceLocation(Reference.MODID, nameId), entityClass, entityName, ++id, Reference.MODID, 64, 1, false, eggPrimary, eggSecondary);
    	}
    }

     

    Main class

    public static final CreativeTabs creativeTab = new CreativeTabs(CreativeTabs.getNextID(), "modid")
    {
        @Override
        @SideOnly(Side.CLIENT)
        public void displayAllRelevantItems(NonNullList<ItemStack> itemList)
      {
    		super.displayAllRelevantItems(itemList);
    		itemList.add(getSpawnEgg("mob_id"));
    	}
    };

     

    en_us.lang (I've tried both of these separately. No luck.) [All other translations are working fine]

    #### Entities ####
    entity.mod_id.mob_id.name=Mob Name
    
    entity.mob_id.name=Mob Name

     

    Thanks.

×
×
  • Create New...

Important Information

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