mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 11:05:40 +00:00
Tests do not run yet. Things of note: Removed the idea of substitutions, just register multiple items with the same name they will override each other like a normal map. Decoupled Forge registries from vanilla classes. They now use bouncer classes. MODDERS SHOULD NEVER USE THESE Introduced more stringent registry locking. As it sits things are only allowed to be registered during the RegistryEvent.Registry phases! This is to force modders to split up their registrations, and pave the way for calling these functions multiple times during a single MC lifecycle. ObjectHolder, Missing Mappings, etc... *should* now work for all registry types, nothing should be special cased to Blocks/Items anymore. Added optional generic dummy factory to registries, to allow registry creators the ability to dummy more then just Blocks. Re-worked the ItemStack transformer and applied it to ItemBlock and ItemBlockSpecial. Allowing us to cleanup reflective hacks in Block callbacks. Registry onAdd callback is now only fired on the ACTIVE registry, fixing any issues of temp registries overriding active objects.
84 lines
3.1 KiB
Java
84 lines
3.1 KiB
Java
package net.minecraftforge.debug;
|
|
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.block.material.Material;
|
|
import net.minecraft.block.state.IBlockState;
|
|
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
import net.minecraft.item.Item;
|
|
import net.minecraft.item.ItemBlock;
|
|
import net.minecraft.util.BlockRenderLayer;
|
|
import net.minecraft.util.ResourceLocation;
|
|
import net.minecraftforge.client.event.ModelRegistryEvent;
|
|
import net.minecraftforge.client.model.ModelLoader;
|
|
import net.minecraftforge.event.RegistryEvent;
|
|
import net.minecraftforge.fml.common.Mod;
|
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|
import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
|
|
|
|
@Mod(modid = MultiLayerModelDebug.MODID, name = "ForgeDebugMultiLayerModel", version = MultiLayerModelDebug.VERSION, acceptableRemoteVersions = "*")
|
|
public class MultiLayerModelDebug
|
|
{
|
|
private static final boolean ENABLED = true;
|
|
public static final String MODID = "forgedebugmultilayermodel";
|
|
public static final String VERSION = "0.0";
|
|
|
|
private static final String blockName = "test_layer_block";
|
|
private static final ResourceLocation blockId = new ResourceLocation(MODID, blockName);
|
|
@ObjectHolder(blockName)
|
|
public static final Block TEST_BLOCK = null;
|
|
|
|
@Mod.EventBusSubscriber(modid = MODID)
|
|
public static class Registration
|
|
{
|
|
@SubscribeEvent
|
|
public static void registerBlocks(RegistryEvent.Register<Block> event)
|
|
{
|
|
if (!ENABLED)
|
|
return;
|
|
event.getRegistry().register(
|
|
new Block(Material.WOOD)
|
|
{
|
|
{
|
|
setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
|
|
setUnlocalizedName(MODID + "." + blockName);
|
|
setRegistryName(blockId);
|
|
}
|
|
|
|
@Override
|
|
public boolean isOpaqueCube(IBlockState state)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean isFullCube(IBlockState state)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean canRenderInLayer(IBlockState state, BlockRenderLayer layer)
|
|
{
|
|
return layer == BlockRenderLayer.SOLID || layer == BlockRenderLayer.TRANSLUCENT;
|
|
}
|
|
}
|
|
);
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public static void registerItems(RegistryEvent.Register<Item> event)
|
|
{
|
|
event.getRegistry().register(new ItemBlock(TEST_BLOCK).setRegistryName(TEST_BLOCK.getRegistryName()));
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public static void registerModels(ModelRegistryEvent event)
|
|
{
|
|
if (!ENABLED)
|
|
return;
|
|
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(TEST_BLOCK), 0, new ModelResourceLocation(blockId, "inventory"));
|
|
}
|
|
}
|
|
}
|