Jump to content

Trouble with Cadiboo's example mod.


DiamondMiner88

Recommended Posts

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() :)

 

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

 

 

Edited by desht
Link to comment
Share on other sites

  • Replies 50
  • Created
  • Last Reply

Top Posters In This Topic

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".

Link to comment
Share on other sites

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

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

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)

Link to comment
Share on other sites

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

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

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)

Link to comment
Share on other sites

Just now, DiamondMiner88 said:

Ummm the 1.13.2 branch has no src folder

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

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

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)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

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)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

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)

Link to comment
Share on other sites

ClientEventSubscriber:

Spoiler

package tk.diamondbuildz.mod.character.client;

import com.google.common.base.Preconditions;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import tk.diamondbuildz.mod.character.init.ModBlocks;
import tk.diamondbuildz.mod.character.init.ModItems;

import javax.annotation.Nonnull;

import static net.minecraftforge.fml.relauncher.Side.CLIENT;
import static tk.diamondbuildz.mod.character.util.Reference.MOD_ID;

/**
 * Subscribe to events that should be handled on the PHYSICAL CLIENT in this class
 *
 * Edited by Diamond made by Cadiboo
 *
 * @author Diamond
 * @author Cadiboo
 */
@EventBusSubscriber(modid = MOD_ID, value = CLIENT)
public final class ClientEventSubscriber {

    private static final Logger LOGGER = LogManager.getLogger();
    private static final String DEFAULT_VARIANT = "normal";

    @SubscribeEvent
    public static void onRegisterModelsEvent(@Nonnull final ModelRegistryEvent event) {

        /*
        registerTileEntitySpecialRenderers();
        LOGGER.debug("Registered tile entity special renderers");

        registerEntityRenderers();
        LOGGER.debug("Registered entity renderers");
        */

        // Registration can be automated like this
        // But when you're learning its better to manually register your objects
        /*
      ForgeRegistries.BLOCKS.getValuesCollection().stream()
            .filter(block -> block.getRegistryName().getNamespace().equals(MOD_ID))
            .forEach(ClientEventSubscriber::registerItemBlockModel);
      */
        registerItemBlockModel(ModBlocks.A_CONCRETE_BLACK);
        registerItemBlockModel(ModBlocks.A_CONCRETE_WHITE);

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

        registerItemModel(ModItems.GLASS_SHARD_BLACK);
        registerItemModel(ModItems.GLASS_SHARD_BLUE);
        registerItemModel(ModItems.GLASS_SHARD_BROWN);
        registerItemModel(ModItems.GLASS_SHARD_CLEAR);
        registerItemModel(ModItems.GLASS_SHARD_CYAN);
        registerItemModel(ModItems.GLASS_SHARD_GRAY);
        registerItemModel(ModItems.GLASS_SHARD_GREEN);
        registerItemModel(ModItems.GLASS_SHARD_LIGHT_BLUE);
        registerItemModel(ModItems.GLASS_SHARD_LIME);
        registerItemModel(ModItems.GLASS_SHARD_MAGENTA);
        registerItemModel(ModItems.GLASS_SHARD_ORANGE);
        registerItemModel(ModItems.GLASS_SHARD_PINK);
        registerItemModel(ModItems.GLASS_SHARD_PURPLE);
        registerItemModel(ModItems.GLASS_SHARD_RED);
        registerItemModel(ModItems.GLASS_SHARD_SILVER);
        registerItemModel(ModItems.GLASS_SHARD_WHITE);
        registerItemModel(ModItems.GLASS_SHARD_YELLOW);

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

        LOGGER.debug("Registered models");

    }

    /*
    private static void registerTileEntitySpecialRenderers() {
        ClientRegistry.bindTileEntitySpecialRenderer(TileEntityExampleTileEntity.class, new RenderExampleTileEntity());
    }

    private static void registerEntityRenderers() {
      RenderingRegistry.registerEntityRenderingHandler(Entity___.class, renderManager -> new Entity___Renderer(renderManager));
    }
    */

    private static void registerItemModel(@Nonnull final Item item) {
        Preconditions.checkNotNull(item, "Item cannot be null!");
        final ResourceLocation registryName = item.getRegistryName();
        Preconditions.checkNotNull(registryName, "Item Registry Name cannot be null!");
        ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), DEFAULT_VARIANT));
    }

    private static void registerItemBlockModel(@Nonnull final Block block) {
        Preconditions.checkNotNull(block, "Block cannot be null!");
        final ResourceLocation registryName = block.getRegistryName();
        Preconditions.checkNotNull(registryName, "Block Registry Name cannot be null!");
        ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), DEFAULT_VARIANT));
    }

    /*
    @SubscribeEvent
    public static void onTextureStitchEvent(@Nonnull final TextureStitchEvent event) {
        // register texture for example tile entity
        final ResourceLocation registryName = ModBlocks.EXAMPLE_TILE_ENTITY.getRegistryName();
        event.getMap().registerSprite(new ResourceLocation(registryName.getNamespace(), "block/" + registryName.getPath()));
    }
    */

}

ModItems:

Spoiler

package tk.diamondbuildz.mod.character.init;

import net.minecraft.item.Item;
import net.minecraftforge.fml.common.registry.GameRegistry;
import tk.diamondbuildz.mod.character.items.ToolGlassCutter;
import tk.diamondbuildz.mod.character.util.Reference;

@GameRegistry.ObjectHolder(Reference.MOD_ID)
public class ModItems {

    // Items
    public static final Item GLASS_SHARD_CLEAR = null;
    public static final Item GLASS_SHARD_BLACK = null;
    public static final Item GLASS_SHARD_BROWN = null;
    public static final Item GLASS_SHARD_CYAN = null;
    public static final Item GLASS_SHARD_GRAY = null;
    public static final Item GLASS_SHARD_GREEN = null;
    public static final Item GLASS_SHARD_BLUE = null;
    public static final Item GLASS_SHARD_LIGHT_BLUE = null;
    public static final Item GLASS_SHARD_LIME = null;
    public static final Item GLASS_SHARD_MAGENTA = null;
    public static final Item GLASS_SHARD_ORANGE = null;
    public static final Item GLASS_SHARD_PINK = null;
    public static final Item GLASS_SHARD_PURPLE = null;
    public static final Item GLASS_SHARD_RED = null;
    public static final Item GLASS_SHARD_SILVER = null;
    public static final Item GLASS_SHARD_WHITE = null;
    public static final Item GLASS_SHARD_YELLOW = null;

    // Tools
    public static ToolGlassCutter DIAMOND_GLASS_CUTTER = null;
    public static ToolGlassCutter IRON_GLASS_CUTTER = null;
}

ModBlocks:

Spoiler

package tk.diamondbuildz.mod.character.init;

import net.minecraft.block.Block;
import net.minecraftforge.fml.common.registry.GameRegistry;
import tk.diamondbuildz.mod.character.util.Reference;

/**
 * {@link Block} Instances class
 * All the blocks in here will be public static final and null as their values will be filled by @ObjectHolder
 *
 * @author Diamond
 * @author Cadiboo
 */
@GameRegistry.ObjectHolder(Reference.MOD_ID)
public class ModBlocks {
    public static final Block A_CONCRETE_BLACK = null;
    public static final Block A_CONCRETE_WHITE = null;

    public static final Block A_GLASS_BLACK = null;
    public static final Block A_GLASS_BLUE = null;
    public static final Block A_GLASS_BROWN = null;
    public static final Block A_GLASS_CLEAR = null;
    public static final Block A_GLASS_CYAN = null;
    public static final Block A_GLASS_GREEN = null;
    public static final Block A_GLASS_GRAY = null;
    public static final Block A_GLASS_LIGHT_BLUE = null;
    public static final Block A_GLASS_LIME = null;
    public static final Block A_GLASS_MAGENTA = null;
    public static final Block A_GLASS_ORANGE = null;
    public static final Block A_GLASS_PINK = null;
    public static final Block A_GLASS_PURPLE = null;
    public static final Block A_GLASS_RED = null;
    public static final Block A_GLASS_SILVER = null;
    public static final Block A_GLASS_WHITE = null;
    public static final Block A_GLASS_YELLOW = null;

    /*
    public static final Block B_CONCRETE_BLACK = null;
    public static final Block B_CONCRETE_BLUE = null;
    public static final Block B_CONCRETE_BROWN = null;
    public static final Block B_CONCRETE_CYAN = null;
    public static final Block B_CONCRETE_GRAY = null;
    public static final Block B_CONCRETE_GREEN = null;
    public static final Block B_CONCRETE_LIGHT_BLUE = null;
    public static final Block B_CONCRETE_LIME = null;
    public static final Block B_CONCRETE_MAGENTA = null;
    public static final Block B_CONCRETE_ORANGE = null;
    public static final Block B_CONCRETE_PINK = null;
    */
}

EventSubscriber:

Spoiler

package tk.diamondbuildz.mod.character;

import com.google.common.base.Preconditions;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.registries.IForgeRegistryEntry;
import tk.diamondbuildz.mod.character.blocks.a.glass.*;
import tk.diamondbuildz.mod.character.blocks.blockbases.a.BlockBaseConcreteA;
import tk.diamondbuildz.mod.character.init.ModBlocks;
import tk.diamondbuildz.mod.character.items.ItemBase;
import tk.diamondbuildz.mod.character.items.ToolGlassCutter;
import tk.diamondbuildz.mod.character.util.ModUtil;
import tk.diamondbuildz.mod.character.util.Reference;

import javax.annotation.Nonnull;
import java.util.Arrays;

import static tk.diamondbuildz.mod.character.util.Reference.MOD_ID;

/**
 * Subscribe to events that should be handled on both PHYSICAL sides in this class
 *
 * Edited by Diamond; original author Cadiboo
 *
 * @author Diamond
 * @author Cadiboo -- https://github.com/Cadiboo/Example-Mod
 */
@Mod.EventBusSubscriber(modid = MOD_ID)
public final class EventSubscriber {

    // For Entities
    private static int entityId = 0;

    // Register Blocks
    @SubscribeEvent
    public static void onRegisterBlocksEvent(@Nonnull final RegistryEvent.Register<Block> event) {
        final IForgeRegistry<Block> registry = event.getRegistry();
        setup(new BlockBaseConcreteA(), "a_concrete_black");
        setup(new BlockBaseConcreteA(), "a_concrete_white");

        /*
        registry.register(new BlockBaseConcreteA("a_concrete_black"));
        registry.register(new BlockBaseConcreteA("a_concrete_white"));

        registry.register(new AGlassBlack("a_glass_black"));
        registry.register(new AGlassBlue("a_glass_blue"));
        registry.register(new AGlassBrown("a_glass_brown"));
        registry.register(new AGlassClear("a_glass_clear"));
        registry.register(new AGlassCyan("a_glass_cyan"));
        registry.register(new AGlassGray("a_glass_gray"));
        registry.register(new AGlassGreen("a_glass_green"));
        registry.register(new AGlassLightBlue("a_glass_blue"));
        registry.register(new AGlassLime("a_glass_lime"));
        registry.register(new AGlassOrange("a_glass_orange"));
        registry.register(new AGlassMagenta("a_glass_magenta"));
        registry.register(new AGlassPink("a_glass_orange"));
        registry.register(new AGlassPurple("a_glass_pink"));
        registry.register(new AGlassRed("a_glass_purple"));
        registry.register(new AGlassSilver("a_glass_red"));
        registry.register(new AGlassWhite("a_glass_silver"));
        registry.register(new AGlassYellow("a_glass_yellow"));
        */
        /*
        registry.register(new BlockBaseConcreteB("b_concrete_black"));
        registry.register(new BlockBaseConcreteB("b_concrete_blue"));
        registry.register(new BlockBaseConcreteB("b_concrete_brown"));
        registry.register(new BlockBaseConcreteB("b_concrete_cyan"));
        registry.register(new BlockBaseConcreteB("b_concrete_gray"));
        registry.register(new BlockBaseConcreteB("b_concrete_green"));
        registry.register(new BlockBaseConcreteB("b_concrete_light_blue"));
        registry.register(new BlockBaseConcreteB("b_concrete_lime"));
        registry.register(new BlockBaseConcreteB("b_concrete_magenta"));
        registry.register(new BlockBaseConcreteB("b_concrete_orange"));
        registry.register(new BlockBaseConcreteB("b_concrete_pink"));
        */

        Main.CHARACTER_MOD_LOG.debug("Registered blocks");

        //registerTileEntities();

        //Main.CHARACTER_MOD_LOG.debug("Registered tile entities");

    }

    /*
    private static void registerTileEntities() {
        registerTileEntity(TileEntityExampleTileEntity.class, "example_tile_entity");
    }

    private static void registerTileEntity(@Nonnull final Class<? extends TileEntity> clazz, String name) {
        try {
            GameRegistry.registerTileEntity(clazz, new ResourceLocation(Reference.MOD_ID, name));
        } catch (final Exception exception) {
            CrashReport crashReport = new CrashReport("Error registering Tile Entity " + clazz.getSimpleName(), exception);
            crashReport.makeCategory("Registering Tile Entity");
            throw new ReportedException(crashReport);
        }
    }
    */

    // Register Item Blocks/Items
    @SubscribeEvent
    public static void onRegisterItemsEvent(@Nonnull final RegistryEvent.Register<Item> event) {
        final IForgeRegistry<Item> registry = event.getRegistry();

        // Item Blocks
        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())
                    )
            );
        });

        // Items
        setup(new ItemBase(), "glass_shard_black");
        setup(new ItemBase(), "glass_shard_blue");
        setup(new ItemBase(), "glass_shard_brown");
        setup(new ItemBase(), "glass_shard_clear");
        setup(new ItemBase(), "glass_shard_cyan");
        setup(new ItemBase(), "glass_shard_gray");
        setup(new ItemBase(), "glass_shard_green");
        setup(new ItemBase(), "glass_shard_light_blue");
        setup(new ItemBase(), "glass_shard_lime");
        setup(new ItemBase(), "glass_shard_magenta");
        setup(new ItemBase(), "glass_shard_orange");
        setup(new ItemBase(), "glass_shard_pink");
        setup(new ItemBase(), "glass_shard_purple");
        setup(new ItemBase(), "glass_shard_red");
        setup(new ItemBase(), "glass_shard_silver");
        setup(new ItemBase(), "glass_shard_white");
        setup(new ItemBase(), "glass_shard_yellow");
        /*
        registry.register(new ItemBase("glass_shard_black"));
        registry.register(new ItemBase("glass_shard_blue"));
        registry.register(new ItemBase("glass_shard_brown"));
        registry.register(new ItemBase("glass_shard_clear"));
        registry.register(new ItemBase("glass_shard_cyan"));
        registry.register(new ItemBase("glass_shard_gray"));
        registry.register(new ItemBase("glass_shard_green"));
        registry.register(new ItemBase("glass_shard_light_blue"));
        registry.register(new ItemBase("glass_shard_lime"));
        registry.register(new ItemBase("glass_shard_magenta"));
        registry.register(new ItemBase("glass_shard_orange"));
        registry.register(new ItemBase("glass_shard_pink"));
        registry.register(new ItemBase("glass_shard_purple"));
        registry.register(new ItemBase("glass_shard_red"));
        registry.register(new ItemBase("glass_shard_silver"));
        registry.register(new ItemBase("glass_shard_white"));
        registry.register(new ItemBase("glass_shard_yellow"));

        registry.register(new ToolGlassCutter("diamond_glass_cutter", Item.ToolMaterial.DIAMOND));
        registry.register(new ToolGlassCutter("iron_glass_cutter", Item.ToolMaterial.IRON));
        */

        Main.CHARACTER_MOD_LOG.debug("Registered items");
    }
    //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;
    }

    /*
    // Register Entities
    @SubscribeEvent
    public static void onRegisterEntitiesEvent(@Nonnull final RegistryEvent.Register<EntityEntry> event) {
        final IForgeRegistry<EntityEntry> registry = event.getRegistry();

        {
         final Class clazz = Entity____.class;
         final ResourceLocation registryName = new ResourceLocation(MOD_ID, ModUtil.getRegistryNameForClass(clazz, "Entity"));
         registry.register(
               EntityEntryBuilder.create()
                     .entity(clazz)
                     .id(registryName, entityId++)
                     .name(registryName.getPath())
                     .tracker(range, updateFrequency, sendVelocityUpdates)
                     .egg(primaryColor, secondaryColor)
                     .build()
         );
        }

        Main.CHARACTER_MOD_LOG.debug("Registered entities");

    }
    */

}

ItemBase:

Spoiler

package tk.diamondbuildz.mod.character.items;

import net.minecraft.item.Item;
import tk.diamondbuildz.mod.character.util.ModUtil;

public class ItemBase extends Item {

    public ItemBase() {
        ModUtil.setCreativeTab(this);
    }
}

ItemGlassCutter:

Spoiler

package tk.diamondbuildz.mod.character.items;

import com.google.common.collect.Sets;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemTool;
import tk.diamondbuildz.mod.character.init.ModBlocks;

import java.util.Set;

public class ItemGlassCutter extends ItemTool {
    private static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(
            ModBlocks.A_GLASS_CLEAR, ModBlocks.A_GLASS_BLACK, ModBlocks.A_GLASS_BLUE, ModBlocks.A_GLASS_BROWN, ModBlocks.A_GLASS_CYAN, ModBlocks.A_GLASS_GREEN, ModBlocks.A_GLASS_GRAY, 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_SILVER, ModBlocks.A_GLASS_WHITE, ModBlocks.A_GLASS_YELLOW,
            Blocks.GLASS, Blocks.STAINED_GLASS, Blocks.STAINED_GLASS_PANE, Blocks.GLASS_PANE);
    public ItemGlassCutter(Item.ToolMaterial material) {
        super(6.0F, -2.0F, material, EFFECTIVE_ON);
    }

    @Override
    public boolean canHarvestBlock(IBlockState blockIn) {
        boolean TF = false;
        Material material = blockIn.getMaterial();
        if (material == Material.GLASS) {
            TF = true;
        }
        return TF;
    }

    public float getDestroySpeed(ItemStack stack, IBlockState state) {
        Material material = state.getMaterial();
        return material != Material.GLASS ? super.getDestroySpeed(stack, state) : this.efficiency;
    }
}

ToolGlassCutter:

Spoiler

package tk.diamondbuildz.mod.character.items;

import com.google.common.collect.Sets;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemTool;
import tk.diamondbuildz.mod.character.init.ModBlocks;

import java.util.Set;

public class ItemGlassCutter extends ItemTool {
    private static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(
            ModBlocks.A_GLASS_CLEAR, ModBlocks.A_GLASS_BLACK, ModBlocks.A_GLASS_BLUE, ModBlocks.A_GLASS_BROWN, ModBlocks.A_GLASS_CYAN, ModBlocks.A_GLASS_GREEN, ModBlocks.A_GLASS_GRAY, 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_SILVER, ModBlocks.A_GLASS_WHITE, ModBlocks.A_GLASS_YELLOW,
            Blocks.GLASS, Blocks.STAINED_GLASS, Blocks.STAINED_GLASS_PANE, Blocks.GLASS_PANE);
    public ItemGlassCutter(Item.ToolMaterial material) {
        super(6.0F, -2.0F, material, EFFECTIVE_ON);
    }

    @Override
    public boolean canHarvestBlock(IBlockState blockIn) {
        boolean TF = false;
        Material material = blockIn.getMaterial();
        if (material == Material.GLASS) {
            TF = true;
        }
        return TF;
    }

    public float getDestroySpeed(ItemStack stack, IBlockState state) {
        Material material = state.getMaterial();
        return material != Material.GLASS ? super.getDestroySpeed(stack, state) : this.efficiency;
    }
}

BlockBaseConcreteA:

Spoiler

package tk.diamondbuildz.mod.character.blocks.blockbases.a;

import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public class BlockBaseConcreteA extends Block {

    private static final AxisAlignedBB BOUNDING_BOX_1 = new AxisAlignedBB(0.0625 * 3, 0 , 0.0625 * 7, 0.0625 * 13, 0.0625 * 13, 0.0625 * 9);
    private static final AxisAlignedBB BOUNDING_BOX_2 = new AxisAlignedBB(0.0625 * 7, 0 , 0.0625 * 3, 0.0625 * 9, 0.0625 * 13, 0.0625 * 13);
    private static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
    public EntityPlayer entityPlayer;

    public BlockBaseConcreteA() {
        super(Material.ROCK);
        this.setSoundType(SoundType.STONE);
        this.setHardness(0.3F);
        this.setSoundType(SoundType.STONE);
        this.setDefaultState(blockState.getBaseState().withProperty(FACING, EnumFacing.SOUTH));
    }
    @Override
    public boolean isFullCube(IBlockState state) { return false; }
    @Override
    public boolean isOpaqueCube(IBlockState state) { return false; }
    @Override
    public boolean canPlaceTorchOnTop(IBlockState state, IBlockAccess world, BlockPos pos) { return false; }
    @Override
    public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { return state; }
    @Override
    public BlockRenderLayer getRenderLayer() {
        return BlockRenderLayer.TRANSLUCENT;
    }
    @Override
    protected BlockStateContainer createBlockState()
    {
        return new BlockStateContainer(this, FACING);
    }

    @Override
    @Nonnull
    public IBlockState getStateForPlacement(@Nullable World world, @Nullable BlockPos pos, @Nullable EnumFacing facing, float hitX, float hitY, float hitZ, int meta, @Nullable EntityLivingBase placer, EnumHand hand) {
        assert placer != null;
        return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
    }
    @Override
    public IBlockState getStateFromMeta(int meta) {
        EnumFacing facing = EnumFacing.byHorizontalIndex(meta);
        return this.getDefaultState().withProperty(FACING, facing);
    }

    @Override
    public int getMetaFromState(IBlockState state) {
        EnumFacing facing = state.getValue(FACING);
        return facing.getHorizontalIndex();
    }

    @Override
    public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing blockFaceClickedOn, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
        EnumFacing enumfacing = (placer == null) ? EnumFacing.NORTH : placer.getHorizontalFacing().getOpposite();

        return this.getDefaultState().withProperty(FACING, enumfacing);
    }

    @Override
    public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
        state = state.getActualState(source, pos);
        EnumFacing enumfacing = state.getValue(FACING);

        switch (enumfacing)
        {
            case SOUTH:
            default:
                return BOUNDING_BOX_1;
            case WEST:
                return BOUNDING_BOX_2;
            case NORTH:
                return BOUNDING_BOX_1;
            case EAST:
                return BOUNDING_BOX_2;
        }
    }
}

 

Link to comment
Share on other sites

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

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

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)

Link to comment
Share on other sites

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:

Spoiler

package tk.diamondbuildz.mod.character.client;

import com.google.common.base.Preconditions;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import tk.diamondbuildz.mod.character.init.ModBlocks;
import tk.diamondbuildz.mod.character.init.ModItems;

import javax.annotation.Nonnull;

import static net.minecraftforge.fml.relauncher.Side.CLIENT;
import static tk.diamondbuildz.mod.character.util.Reference.MOD_ID;

/**
 * Subscribe to events that should be handled on the PHYSICAL CLIENT in this class
 *
 * Edited by Diamond made by Cadiboo
 *
 * @author Diamond
 * @author Cadiboo
 */
@EventBusSubscriber(modid = MOD_ID, value = CLIENT)
public final class ClientEventSubscriber {

    private static final Logger LOGGER = LogManager.getLogger();
    private static final String DEFAULT_VARIANT = "normal";

    @SubscribeEvent
    public static void onRegisterModelsEvent(@Nonnull final ModelRegistryEvent event) {
        registerItemBlockModel(ModBlocks.A_CONCRETE_BLACK);
        registerItemBlockModel(ModBlocks.A_CONCRETE_WHITE);

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

        registerItemModel(ModItems.GLASS_SHARD_BLACK);
        registerItemModel(ModItems.GLASS_SHARD_BLUE);
        registerItemModel(ModItems.GLASS_SHARD_BROWN);
        registerItemModel(ModItems.GLASS_SHARD_CLEAR);
        registerItemModel(ModItems.GLASS_SHARD_CYAN);
        registerItemModel(ModItems.GLASS_SHARD_GRAY);
        registerItemModel(ModItems.GLASS_SHARD_GREEN);
        registerItemModel(ModItems.GLASS_SHARD_LIGHT_BLUE);
        registerItemModel(ModItems.GLASS_SHARD_LIME);
        registerItemModel(ModItems.GLASS_SHARD_MAGENTA);
        registerItemModel(ModItems.GLASS_SHARD_ORANGE);
        registerItemModel(ModItems.GLASS_SHARD_PINK);
        registerItemModel(ModItems.GLASS_SHARD_PURPLE);
        registerItemModel(ModItems.GLASS_SHARD_RED);
        registerItemModel(ModItems.GLASS_SHARD_SILVER);
        registerItemModel(ModItems.GLASS_SHARD_WHITE);
        registerItemModel(ModItems.GLASS_SHARD_YELLOW);

        //HERE-- The DiamondGlassCutter/Iron
        registerItemModel(ModItems.DIAMOND_GLASS_CUTTER);
        registerItemModel(ModItems.IRON_GLASS_CUTTER);

        LOGGER.debug("Registered models");
    }

    private static void registerItemModel(@Nonnull final Item item) {
        Preconditions.checkNotNull(item, "Item cannot be null!");
        final ResourceLocation registryName = item.getRegistryName();
        Preconditions.checkNotNull(registryName, "Item Registry Name cannot be null!");
        ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), DEFAULT_VARIANT));
    }

    private static void registerItemBlockModel(@Nonnull final Block block) {
        Preconditions.checkNotNull(block, "Block cannot be null!");
        final ResourceLocation registryName = block.getRegistryName();
        Preconditions.checkNotNull(registryName, "Block Registry Name cannot be null!");
        ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), DEFAULT_VARIANT));
    }

    /*
    @SubscribeEvent
    public static void onTextureStitchEvent(@Nonnull final TextureStitchEvent event) {
        // register texture for example tile entity
        final ResourceLocation registryName = ModBlocks.EXAMPLE_TILE_ENTITY.getRegistryName();
        event.getMap().registerSprite(new ResourceLocation(registryName.getNamespace(), "block/" + registryName.getPath()));
    }
    */

}

ToolGlassCutter: Merged with ItemGlassCutter

ItemGlassCutter:

Spoiler

package tk.diamondbuildz.mod.character.items;

import com.google.common.collect.Sets;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemTool;
import tk.diamondbuildz.mod.character.init.ModBlocks;
import tk.diamondbuildz.mod.character.util.ModUtil;

import javax.annotation.Nonnull;
import java.util.Set;

public class ItemGlassCutter extends ItemTool {
    private static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(
            ModBlocks.A_GLASS_CLEAR, ModBlocks.A_GLASS_BLACK, ModBlocks.A_GLASS_BLUE, ModBlocks.A_GLASS_BROWN, ModBlocks.A_GLASS_CYAN, ModBlocks.A_GLASS_GREEN, ModBlocks.A_GLASS_GRAY, 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_SILVER, ModBlocks.A_GLASS_WHITE, ModBlocks.A_GLASS_YELLOW,
            Blocks.GLASS, Blocks.STAINED_GLASS, Blocks.STAINED_GLASS_PANE, Blocks.GLASS_PANE);

    public ItemGlassCutter(@Nonnull ToolMaterial material) {
        super(6.0F, -2.0F, material, EFFECTIVE_ON);
        ModUtil.setCreativeTab(this);
    }

    @Override
    public boolean canHarvestBlock(IBlockState blockIn) {
        boolean TF = false;
        Material material = blockIn.getMaterial();
        if (material == Material.GLASS) {
            TF = true;
        }
        return TF;
    }

    public float getDestroySpeed(ItemStack stack, IBlockState state) {
        Material material = state.getMaterial();
        return material != Material.GLASS ? super.getDestroySpeed(stack, state) : this.efficiency;
    }
}

EventSubscriber:

Spoiler

package tk.diamondbuildz.mod.character;

import com.google.common.base.Preconditions;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.registries.IForgeRegistryEntry;
import tk.diamondbuildz.mod.character.blocks.blockbases.a.BlockBaseConcreteA;
import tk.diamondbuildz.mod.character.init.ModBlocks;
import tk.diamondbuildz.mod.character.items.ItemBase;
import tk.diamondbuildz.mod.character.items.ItemGlassCutter;
import tk.diamondbuildz.mod.character.util.ModUtil;

import javax.annotation.Nonnull;
import java.util.Arrays;

import static tk.diamondbuildz.mod.character.util.Reference.MOD_ID;

/**
 * Subscribe to events that should be handled on both PHYSICAL sides in this class
 *
 * Edited by Diamond; original author Cadiboo
 *
 * @author Diamond
 * @author Cadiboo -- https://github.com/Cadiboo/Example-Mod
 */
@Mod.EventBusSubscriber(modid = MOD_ID)
public final class EventSubscriber {

    // For Entities
    private static int entityId = 0;

    // Register Blocks
    @SubscribeEvent
    public static void onRegisterBlocksEvent(@Nonnull final RegistryEvent.Register<Block> event) {
        final IForgeRegistry<Block> registry = event.getRegistry();
        event.getRegistry().registerAll(
                setup(new BlockBaseConcreteA(), "a_concrete_black"),
                setup(new BlockBaseConcreteA(), "a_concrete_white")
        );

        /*
        registry.register(new BlockBaseConcreteA("a_concrete_black"));
        registry.register(new BlockBaseConcreteA("a_concrete_white"));

        registry.register(new AGlassBlack("a_glass_black"));
        registry.register(new AGlassBlue("a_glass_blue"));
        registry.register(new AGlassBrown("a_glass_brown"));
        registry.register(new AGlassClear("a_glass_clear"));
        registry.register(new AGlassCyan("a_glass_cyan"));
        registry.register(new AGlassGray("a_glass_gray"));
        registry.register(new AGlassGreen("a_glass_green"));
        registry.register(new AGlassLightBlue("a_glass_blue"));
        registry.register(new AGlassLime("a_glass_lime"));
        registry.register(new AGlassOrange("a_glass_orange"));
        registry.register(new AGlassMagenta("a_glass_magenta"));
        registry.register(new AGlassPink("a_glass_orange"));
        registry.register(new AGlassPurple("a_glass_pink"));
        registry.register(new AGlassRed("a_glass_purple"));
        registry.register(new AGlassSilver("a_glass_red"));
        registry.register(new AGlassWhite("a_glass_silver"));
        registry.register(new AGlassYellow("a_glass_yellow"));

        registry.register(new BlockBaseConcreteB("b_concrete_black"));
        registry.register(new BlockBaseConcreteB("b_concrete_blue"));
        registry.register(new BlockBaseConcreteB("b_concrete_brown"));
        registry.register(new BlockBaseConcreteB("b_concrete_cyan"));
        registry.register(new BlockBaseConcreteB("b_concrete_gray"));
        registry.register(new BlockBaseConcreteB("b_concrete_green"));
        registry.register(new BlockBaseConcreteB("b_concrete_light_blue"));
        registry.register(new BlockBaseConcreteB("b_concrete_lime"));
        registry.register(new BlockBaseConcreteB("b_concrete_magenta"));
        registry.register(new BlockBaseConcreteB("b_concrete_orange"));
        registry.register(new BlockBaseConcreteB("b_concrete_pink"));
        */

        Main.CHARACTER_MOD_LOG.debug("Registered blocks");
    }

    // Register Item Blocks/Items
    @SubscribeEvent
    public static void onRegisterItemsEvent(@Nonnull final RegistryEvent.Register<Item> event) {
        final IForgeRegistry<Item> registry = event.getRegistry();

        // Item Blocks
        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())
                    )
            );
        });

        // Items
        event.getRegistry().registerAll(
                setup(new ItemBase(), "glass_shard_black"),
                setup(new ItemBase(), "glass_shard_blue"),
                setup(new ItemBase(), "glass_shard_brown"),
                setup(new ItemBase(), "glass_shard_clear"),
                setup(new ItemBase(), "glass_shard_cyan"),
                setup(new ItemBase(), "glass_shard_gray"),
                setup(new ItemBase(), "glass_shard_green"),
                setup(new ItemBase(), "glass_shard_light_blue"),
                setup(new ItemBase(), "glass_shard_lime"),
                setup(new ItemBase(), "glass_shard_magenta"),
                setup(new ItemBase(), "glass_shard_orange"),
                setup(new ItemBase(), "glass_shard_pink"),
                setup(new ItemBase(), "glass_shard_purple"),
                setup(new ItemBase(), "glass_shard_red"),
                setup(new ItemBase(), "glass_shard_silver"),
                setup(new ItemBase(), "glass_shard_white"),
                setup(new ItemBase(), "glass_shard_yellow"),

                setup(new ItemGlassCutter(Item.ToolMaterial.DIAMOND), "diamond_glass_cutter"),
                setup(new ItemGlassCutter(Item.ToolMaterial.IRON), "iron_glass_cutter")
        );
        /*
        registry.register(new ItemBase("glass_shard_black"));
        registry.register(new ItemBase("glass_shard_blue"));
        registry.register(new ItemBase("glass_shard_brown"));
        registry.register(new ItemBase("glass_shard_clear"));
        registry.register(new ItemBase("glass_shard_cyan"));
        registry.register(new ItemBase("glass_shard_gray"));
        registry.register(new ItemBase("glass_shard_green"));
        registry.register(new ItemBase("glass_shard_light_blue"));
        registry.register(new ItemBase("glass_shard_lime"));
        registry.register(new ItemBase("glass_shard_magenta"));
        registry.register(new ItemBase("glass_shard_orange"));
        registry.register(new ItemBase("glass_shard_pink"));
        registry.register(new ItemBase("glass_shard_purple"));
        registry.register(new ItemBase("glass_shard_red"));
        registry.register(new ItemBase("glass_shard_silver"));
        registry.register(new ItemBase("glass_shard_white"));
        registry.register(new ItemBase("glass_shard_yellow"));

        registry.register(new ToolGlassCutter("diamond_glass_cutter", Item.ToolMaterial.DIAMOND));
        registry.register(new ToolGlassCutter("iron_glass_cutter", Item.ToolMaterial.IRON));
        */

        Main.CHARACTER_MOD_LOG.debug("Registered items");
    }
    //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;
    }
}

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
Link to comment
Share on other sites

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.

23 hours ago, DiamondMiner88 said:

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


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

Updated my GitHub

Edited by DiamondMiner88
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

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)

Link to comment
Share on other sites

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.