Search in sources :

Example 1 with ICustomBlock

use of com.skelril.nitro.registry.block.ICustomBlock in project Skree by Skelril.

the class CustomBlockSystem method register.

// Invoked via reflection
@SuppressWarnings("unused")
private void register(Object block) {
    if (block instanceof Block && block instanceof ICustomBlock) {
        ((Block) block).setUnlocalizedName("skree_" + ((ICustomBlock) block).__getID());
        ((Block) block).setRegistryName("skree:" + ((ICustomBlock) block).__getID());
        GameRegistry.register((Block) block);
        ItemBlock itemBlock = new ItemBlock((Block) block);
        itemBlock.setUnlocalizedName("skree_" + ((ICustomBlock) block).__getID());
        itemBlock.setRegistryName("skree:" + ((ICustomBlock) block).__getID());
        GameRegistry.register(itemBlock);
        // Add selective hooks
        if (block instanceof EventAwareContent) {
            Sponge.getEventManager().registerListeners(SkreePlugin.inst(), block);
        }
        if (block instanceof GraveStone) {
            GameRegistry.registerTileEntity(GraveStoneTileEntity.class, "skree:grave_stone_ent");
        }
    } else {
        throw new IllegalArgumentException("Invalid custom item!");
    }
}
Also used : ICustomBlock(com.skelril.nitro.registry.block.ICustomBlock) ICustomBlock(com.skelril.nitro.registry.block.ICustomBlock) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) EventAwareContent(com.skelril.nitro.selector.EventAwareContent) GraveStone(com.skelril.skree.content.registry.block.container.GraveStone) ItemBlock(net.minecraft.item.ItemBlock)

Example 2 with ICustomBlock

use of com.skelril.nitro.registry.block.ICustomBlock in project Skree by Skelril.

the class CustomBlockSystem method render.

// Invoked via reflection
@SuppressWarnings("unused")
private void render(Object block) {
    if (block instanceof Block && block instanceof ICustomBlock) {
        if (Sponge.getPlatform().getExecutionType().isClient()) {
            RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
            renderItem.getItemModelMesher().register(Item.getItemFromBlock((Block) block), 0, new ModelResourceLocation("skree:" + ((ICustomBlock) block).__getID(), "inventory"));
        }
    } else {
        throw new IllegalArgumentException("Invalid custom item!");
    }
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) ICustomBlock(com.skelril.nitro.registry.block.ICustomBlock) ICustomBlock(com.skelril.nitro.registry.block.ICustomBlock) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation)

Aggregations

ICustomBlock (com.skelril.nitro.registry.block.ICustomBlock)2 Block (net.minecraft.block.Block)2 ItemBlock (net.minecraft.item.ItemBlock)2 EventAwareContent (com.skelril.nitro.selector.EventAwareContent)1 GraveStone (com.skelril.skree.content.registry.block.container.GraveStone)1 RenderItem (net.minecraft.client.renderer.RenderItem)1 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)1