Search in sources :

Example 1 with EnumBasicStructureName

use of com.wuest.prefab.Config.Structures.BasicStructureConfiguration.EnumBasicStructureName in project MC-Prefab by Brian-Wuest.

the class ItemRenderRegister method regItem.

/**
 * Registers an item to be rendered. This is needed for textures.
 * @param item The item to register.
 * @param metaData The meta data for the item to register.
 * @param blockName the name of the block.
 */
public static void regItem(Item item, int metaData, String blockName) {
    ModelResourceLocation location = new ModelResourceLocation(blockName, "inventory");
    if (!(item instanceof ItemBasicStructure)) {
        ModelLoader.setCustomModelResourceLocation(item, metaData, location);
    } else {
        ArrayList<ResourceLocation> names = new ArrayList<ResourceLocation>();
        for (EnumBasicStructureName value : EnumBasicStructureName.values()) {
            if (value.getResourceLocation() != null) {
                names.add(value.getResourceLocation());
            }
        }
        ResourceLocation[] resources = new ResourceLocation[names.size()];
        resources = names.toArray(resources);
        ModelLoader.registerItemVariants(item, resources);
    }
}
Also used : EnumBasicStructureName(com.wuest.prefab.Config.Structures.BasicStructureConfiguration.EnumBasicStructureName) ItemBasicStructure(com.wuest.prefab.Items.Structures.ItemBasicStructure) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) ArrayList(java.util.ArrayList) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation)

Example 2 with EnumBasicStructureName

use of com.wuest.prefab.Config.Structures.BasicStructureConfiguration.EnumBasicStructureName in project MC-Prefab by Brian-Wuest.

the class ItemBasicStructure method getSubItems.

/**
 * returns a list of items with the same ID, but different meta (eg: dye
 * returns 16 items)
 */
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems) {
    if (this.isInCreativeTab(tab)) {
        for (EnumBasicStructureName value : EnumBasicStructureName.values()) {
            if (value.getResourceLocation() != null) {
                ItemStack stack = new ItemStack(this);
                IStructureConfigurationCapability capability = stack.getCapability(ModRegistry.StructureConfiguration, EnumFacing.NORTH);
                capability.getConfiguration().basicStructureName = value;
                subItems.add(stack);
            }
        }
    }
}
Also used : EnumBasicStructureName(com.wuest.prefab.Config.Structures.BasicStructureConfiguration.EnumBasicStructureName) IStructureConfigurationCapability(com.wuest.prefab.Capabilities.IStructureConfigurationCapability) ItemStack(net.minecraft.item.ItemStack) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 3 with EnumBasicStructureName

use of com.wuest.prefab.Config.Structures.BasicStructureConfiguration.EnumBasicStructureName in project MC-Prefab by Brian-Wuest.

the class ClientEventHandler method regItem.

/**
 * Registers an item to be rendered. This is needed for textures.
 * @param item The item to register.
 * @param metaData The meta data for the item to register.
 * @param blockName the name of the block.
 */
public static void regItem(Item item, int metaData, String blockName) {
    ModelResourceLocation location = new ModelResourceLocation(blockName, "inventory");
    if (!(item instanceof ItemBasicStructure)) {
        ModelLoader.setCustomModelResourceLocation(item, metaData, location);
    } else {
        ArrayList<ResourceLocation> names = new ArrayList<ResourceLocation>();
        for (EnumBasicStructureName value : EnumBasicStructureName.values()) {
            if (value.getResourceLocation() != null) {
                names.add(value.getResourceLocation());
            }
        }
        ResourceLocation[] resources = new ResourceLocation[names.size()];
        resources = names.toArray(resources);
        ModelLoader.registerItemVariants(item, resources);
    }
}
Also used : EnumBasicStructureName(com.wuest.prefab.Config.Structures.BasicStructureConfiguration.EnumBasicStructureName) ItemBasicStructure(com.wuest.prefab.Items.Structures.ItemBasicStructure) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) ArrayList(java.util.ArrayList) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation)

Aggregations

EnumBasicStructureName (com.wuest.prefab.Config.Structures.BasicStructureConfiguration.EnumBasicStructureName)3 ItemBasicStructure (com.wuest.prefab.Items.Structures.ItemBasicStructure)2 ArrayList (java.util.ArrayList)2 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 IStructureConfigurationCapability (com.wuest.prefab.Capabilities.IStructureConfigurationCapability)1 ItemStack (net.minecraft.item.ItemStack)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1