Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

So after a long break off modding, I decided to remake my old mod from 1.11.2. So far, it's been going well except that I can't seem to figure out how to make an ItemSlab for my slab. Nor can I even begin to implement a way to register it using my registry handler. If anyone has some ideas on how I can do this, please explain.

 

My Registry Handler

package emerald.emeraldsores.Util.Handlers;

import emerald.emeraldsores.Init.ModBlocks;
import emerald.emeraldsores.Init.ModItems;
import emerald.emeraldsores.Util.ModelInterface;
import net.minecraft.block.Block;
import net.minecraft.block.BlockSlab;
import net.minecraft.item.Item;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

@EventBusSubscriber

public class RegistryHandler {
	
	@SubscribeEvent
	public static void onItemRegister(RegistryEvent.Register<Item> event) {
		
		event.getRegistry().registerAll(ModItems.ITEMS.toArray(new Item[0]));
		
	}
	
	@SubscribeEvent
	public static void onBlockRegister(RegistryEvent.Register<Block> event) {
		
		event.getRegistry().registerAll(ModBlocks.BLOCKS.toArray(new Block[0]));
		
	}
	
	@SubscribeEvent
	public static void onModelRegister(ModelRegistryEvent event) {
		
		for(Item item : ModItems.ITEMS) {
			
			if(item instanceof ModelInterface) {
				
				((ModelInterface)item).registerModels();
				
			}
			
		}
		
		for(Block block : ModBlocks.BLOCKS) {
			
			if(block instanceof ModelInterface) {
				
				((ModelInterface)block).registerModels();
				
			}
			
		}
		
	}

}

 

Edited by Emerald_Galaxy
Problem Solved

When I made slabs, I ended up extending ItemSlab to create my own item class for the slabs. I needed to do that because I needed custom behavior in onItemUse, but you might be able to make an ItemSlab directly by passing in a block, half slab, and double slab. ItemSlab extends ItemBlock, so you would then register an instance of your ItemSlab instead of making a generic ItemBlock. You'll probably have to do something custom in your registry to detect when your ItemSlab is being registered.

  • Author
11 hours ago, Daeruin said:

When I made slabs, I ended up extending ItemSlab to create my own item class for the slabs. I needed to do that because I needed custom behavior in onItemUse, but you might be able to make an ItemSlab directly by passing in a block, half slab, and double slab. ItemSlab extends ItemBlock, so you would then register an instance of your ItemSlab instead of making a generic ItemBlock. You'll probably have to do something custom in your registry to detect when your ItemSlab is being registered.

Ok I see what your saying. But my problem is I don't know what to put in for the Block parameter. I have both the BlockSlabs in there (My slab and doubleslab) but what do I put for the Block. :/

Edited by Emerald_Galaxy

I have made my own slabs too and i have a registryHandler class with the @EventBusSubscriber annotiation, where i have for example these 2 methods:

 

    	@SubscribeEvent
	public static void onItemRegister(RegistryEvent.Register<Item> event ) {
		
		event.getRegistry().registerAll(ItemInit.ITEMS.toArray(new Item[0]));
		
		ItemBlock item = new ItemSlab(BlockInit.TERRACOTTA_SLABS_HALF_A, (BlockSlab)BlockInit.TERRACOTTA_SLABS_HALF_A, (BlockSlab)BlockInit.TERRACOTTA_SLABS_DOUBLE_A);
		item.setRegistryName(BlockInit.TERRACOTTA_SLABS_HALF_A.getRegistryName());
		event.getRegistry().register(item);
	}
	
	@SubscribeEvent
	public static void onBlockRegister(RegistryEvent.Register<Block> event ) {
		
		event.getRegistry().registerAll(BlockInit.BLOCKS.toArray(new Block[0]));
		registerTileEntities();
	}

You also have to register the block ofcourse.

No.

Does vanilla have a double-slab item? No it does not. You don't need one either.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • 5 months later...

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.