Jump to content

Recommended Posts

Posted (edited)

Oh FFS.  I wrote yesterday:

 

  Quote

 In this case, there are only two static methods in EnumFacing which take a single int parameter and return an EnumFacing: byIndex() and byHorizontalIndex().  I'll leave it to you to figure out which one of those replaces getHorizontal() :)

Expand  

 

The updated method name for EnumFacing.getHorizontal() is EnumFacing.byHorizontalIndex().

 

 

Edited by desht
  • Replies 50
  • Created
  • Last Reply

Top Posters In This Topic

Posted

I suspect you're not including your mod name when you register those blocks; your calls in the event handler certainly don't include the mod name, but that goes through a few levels of utility methods which I don't feel like tracing via web browser.  To be certain, debug with your IDE and set a breakpoint in your code where you call Block#setRegistryName() and check what you're passing there.  It should look like "modid:blockid", not just "blockid".

Posted

The registration in the 1.12.2 version in slightly sketchy. I’ve fixed it all up in 1.13.2 and I’m planning on backporting it.

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted (edited)

Right now you can look a the 1.13.2 branch to see how I do the registration.

My old approach was to call a utility method inside all my constructors. This is bad for a number of reasons including passing this out of a constructor and preventing other mods from registering objects that extend your objects. Registration should also be kept separate from the object classes.

Example:

//Registration
event.getRegistry().registerAll(
  new ItemOldApproach("old_approach"),
  new ItemOldApproach("old_approach2")
);

//Item Class Constructor
public ItemOldApproach(@Nonnull final String name) {
  ModUtil.setRegistryNames(this, name);
}

//ModUtil setRegistryNames method

@Nonnull
public static <T extends IForgeRegistryEntry.Impl<?>> T setRegistryNames(@Nonnull final T entry, @Nonnull final String name) {
  entry.setRegistryName(new ResourceLocation(ModReference.MOD_ID, name));
  if (entry instanceof Block) {
    ((Block) entry).setTranslationKey(name);
  }
  if (entry instanceof Item) {
    ((Item) entry).setTranslationKey(name);
  }
  return entry;
}

 

My current approach is to instantiate my objects, call a helper method on them and then register them.

Example:

//Registration
event.getRegistry().registerAll(
  setup(new ItemNewApproach(), "new_approach"),
  setup(new ItemNewApproach(), "new_approach2")
);

//Item Class Constructor
public ItemNewApproach() {
}

//setup method
@Nonnull
public static <T extends IForgeRegistryEntry> T setup(@Nonnull final T entry, @Nonnull final String name) {
  return setup(entry, new ResourceLocation(MOD_ID, name));
}

@Nonnull
public static <T extends IForgeRegistryEntry> T setup(@Nonnull final T entry, @Nonnull final ResourceLocation registryName) {
  entry.setRegistryName(registryName);
  if (entry instanceof Block) {
    ((Block) entry).setTranslationKey(MOD_ID + "." + registryName.getPath());
  }
  if (entry instanceof Item) {
    ((Item) entry).setTranslationKey(MOD_ID + "." + registryName.getPath());
  }
  return entry;
}

 

Edited by Cadiboo

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted
  On 4/6/2019 at 11:09 PM, DiamondMiner88 said:

Ummm the 1.13.2 branch has no src folder

Expand  

Erm yes, Realised that I'm in the middle of rewriting something and I haven't pushed everything for a while. If you look at the second code block in my previous response you'll see the new method that I use and I've added the 1.12.2 stuff for it (thats gone in 1.13.2) too.

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted

Now i get an error like:

[16:55:51] [main/ERROR] [FML]: Exception caught during firing event net.minecraftforge.client.event.ModelRegistryEvent@34260b5e:
java.lang.NullPointerException: Block cannot be null!
	at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:787) ~[guava-21.0.jar:?]
	at tk.diamondbuildz.mod.character.client.ClientEventSubscriber.registerItemBlockModel(ClientEventSubscriber.java:132) ~[ClientEventSubscriber.class:?]
	at tk.diamondbuildz.mod.character.client.ClientEventSubscriber.onRegisterModelsEvent(ClientEventSubscriber.java:54) ~[ClientEventSubscriber.class:?]
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_5_ClientEventSubscriber_onRegisterModelsEvent_ModelRegistryEvent.invoke(.dynamic) ~[?:?]
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?]
	at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144) ~[EventBus$1.class:?]
	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) [EventBus.class:?]
	at net.minecraftforge.fml.client.FMLClientHandler.fireSidedRegistryEvents(FMLClientHandler.java:1062) [FMLClientHandler.class:?]
	at net.minecraftforge.fml.common.FMLCommonHandler.fireSidedRegistryEvents(FMLCommonHandler.java:764) [FMLCommonHandler.class:?]
	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:629) [Loader.class:?]
	at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252) [FMLClientHandler.class:?]
	at net.minecraft.client.Minecraft.init(Minecraft.java:513) [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_202]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_202]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_202]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_202]
	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_202]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_202]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_202]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_202]
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
	at GradleStart.main(GradleStart.java:25) [start/:?]
[16:55:51] [main/ERROR] [FML]: Index: 1 Listeners:
[16:55:51] [main/ERROR] [FML]: 0: NORMAL
[16:55:51] [main/ERROR] [FML]: 1: net.minecraftforge.fml.common.eventhandler.EventBus$1@5a5183ed
[16:55:51] [main/ERROR] [FML]: 2: net.minecraftforge.fml.common.eventhandler.EventBus$1@68bfaa16

For client models

Posted

That means that you're registering a null Block or ItemBlock somewhere

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted

What about this?

Arrays.stream(new Block[]{

                ModBlocks.A_CONCRETE_BLACK,
                ModBlocks.A_CONCRETE_WHITE,

                /*
                ModBlocks.A_GLASS_BLACK,
                ModBlocks.A_GLASS_BLUE,
                ModBlocks.A_GLASS_BROWN,
                ModBlocks.A_GLASS_CLEAR,
                ModBlocks.A_GLASS_CYAN,
                ModBlocks.A_GLASS_GRAY,
                ModBlocks.A_GLASS_GREEN,
                ModBlocks.A_GLASS_LIGHT_BLUE,
                ModBlocks.A_GLASS_LIME,
                ModBlocks.A_GLASS_MAGENTA,
                ModBlocks.A_GLASS_ORANGE,
                ModBlocks.A_GLASS_PINK,
                ModBlocks.A_GLASS_PURPLE,
                ModBlocks.A_GLASS_RED,
                ModBlocks.A_GLASS_SILVER,
                ModBlocks.A_GLASS_WHITE,
                ModBlocks.A_GLASS_YELLOW,
                */
                /*
                ModBlocks.B_CONCRETE_BLACK,
                ModBlocks.B_CONCRETE_BLUE,
                ModBlocks.B_CONCRETE_BROWN,
                ModBlocks.B_CONCRETE_CYAN,
                ModBlocks.B_CONCRETE_GRAY,
                ModBlocks.B_CONCRETE_GREEN,
                ModBlocks.B_CONCRETE_LIGHT_BLUE,
                ModBlocks.B_CONCRETE_LIME,
                ModBlocks.B_CONCRETE_MAGENTA,
                ModBlocks.B_CONCRETE_ORANGE,
                ModBlocks.B_CONCRETE_PINK,
                */

        }).forEach(block -> {
            Preconditions.checkNotNull(block.getRegistryName(), "Registry name cannot be null!");
            registry.register(
                    ModUtil.setCreativeTab(
                            ModUtil.setRegistryNames(
                                    new ItemBlock(block),
                                    block.getRegistryName())
                    )
            );
        });

Think thats the problem

Posted

Are those fields being properly filled by @ObjectHolder? They need to have the same name as the registry name of the object they aren’t going to hold. Please post your ModBlocks class and your block registration method

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted

ClientEventSubscriber:

  Reveal hidden contents

ModItems:

  Reveal hidden contents

ModBlocks:

  Reveal hidden contents

EventSubscriber:

  Reveal hidden contents

ItemBase:

  Reveal hidden contents

ItemGlassCutter:

  Reveal hidden contents

ToolGlassCutter:

  Reveal hidden contents

BlockBaseConcreteA:

  Reveal hidden contents

 

Posted

You don't actually register any of your objects.

What I'm doing

//Registration
event.getRegistry().registerAll(
  setup(new ItemNewApproach(), "new_approach"),
  setup(new ItemNewApproach(), "new_approach2")
);

What you're doing

setup(new ItemNewApproach(), "new_approach");
setup(new ItemNewApproach(), "new_approach2");

 

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted (edited)

I'm guessing i do that to the items too, but i have another problem it says this is null in my ClientEventSubscriber:

registerItemModel(ModItems.DIAMOND_GLASS_CUTTER);
registerItemModel(ModItems.IRON_GLASS_CUTTER);

ClientEventSubscriber:

  Reveal hidden contents

ToolGlassCutter: Merged with ItemGlassCutter

ItemGlassCutter:

  Reveal hidden contents

EventSubscriber:

  Reveal hidden contents

I tested without the glass_cutter s and everything was fine, everything rendered fine and worked, its just the glasscutter's,

IDK whats wrong

Edited by DiamondMiner88
Posted (edited)

Just going to put it in all one post:

Any1 know why my GlassCutters don't work want to register properly?

AIs it possible to shorten my ClientEventSubscriber and EventSubcriber? I have like ~400 blocks and want to shorten because IntelliJ is really slow error-checking 1000 lines of stuff. More than 1/2 is just entering blocks from my ModBlocks so i thought there's some way to just enter all in like a for-loop or something.

  On 4/8/2019 at 4:45 PM, DiamondMiner88 said:

What does this mean in my Console? Open AL error as i understand.

AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80004005
Expand  
  On 4/7/2019 at 11:05 PM, DiamondMiner88 said:

Updated my GitHub

Expand  
Edited by DiamondMiner88
Posted (edited)

Will this work?

for (String color : Reference.colors) {
            event.getRegistry().registerAll(
                    setup(new ConcreteA(), "a_concrete_" + color),
                    setup(new ConcreteB(), "b_concrete_" + color),
                    setup(new ConcreteC(), "c_concrete_" + color),
                    setup(new ConcreteD(), "d_concrete_" + color),
                    setup(new ConcreteE(), "e_concrete_" + color),
                    setup(new ConcreteF(), "f_concrete_" + color),
                    setup(new ConcreteG(), "g_concrete_" + color),
                    setup(new ConcreteH(), "h_concrete_" + color),
                    setup(new ConcreteI(), "i_concrete_" + color),
                    setup(new ConcreteJ(), "j_concrete_" + color),
                    setup(new ConcreteK(), "k_concrete_" + color),
                    setup(new ConcreteL(), "l_concrete_" + color),
                    setup(new ConcreteM(), "m_concrete_" + color),
                    setup(new ConcreteN(), "n_concrete_" + color),
                    setup(new ConcreteO(), "o_concrete_" + color),
                    setup(new ConcreteP(), "p_concrete_" + color),
                    setup(new ConcreteQ(), "q_concrete_" + color),
                    setup(new ConcreteR(), "r_concrete_" + color),
                    setup(new ConcreteS(), "s_concrete_" + color),
                    setup(new ConcreteT(), "t_concrete_" + color),
                    setup(new ConcreteU(), "u_concrete_" + color),
                    setup(new ConcreteV(), "v_concrete_" + color),
                    setup(new ConcreteW(), "w_concrete_" + color),
                    setup(new ConcreteX(), "x_concrete_" + color),
                    setup(new ConcreteY(), "y_concrete_" + color),
                    setup(new ConcreteZ(), "z_concrete_" + color)
            );

Reference.color:

public static final String[] colors = new String[] {
            "black",
            "blue",
            "brown",
            "cyan",
            "gray",
            "green",
            "light_blue",
            "lime",
            "magenta",
            "orange",
            "pink",
            "purple",
            "red",
            "silver",
            "white",
            "yellow"
    };

Also what about my GlassCutter s? i cant call registerItemModel with it without my game crashing due to a null error

Edited by DiamondMiner88
Posted

I explicitly left automating itemblock and model registration out of my 1.12.2 example mod, it’s still in there though just commented out in one of the registration loops (the models IIRC)

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements




×
×
  • Create New...

Important Information

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