use of com.axanthic.loi.blocks.BlockLeaf in project Lands-of-Icaria by Axanthic-Game-Studios.
the class ClientProxy method registerModels.
@SubscribeEvent
public void registerModels(ModelRegistryEvent event) {
for (ItemBlock block : Resources.blocks) {
if (block.getBlock() instanceof BlockFlower || block.getBlock() instanceof BlockTallGrass || block.getBlock() instanceof BlockHerb) {
for (int i = 0; i < ((IBlockMeta) block.getBlock()).getNames().length; i++) {
ModelLoader.setCustomModelResourceLocation(block, i, new ModelResourceLocation(block.getRegistryName() + "_inv", "type=" + ((IBlockMeta) block.getBlock()).getNames()[i]));
}
} else if (block.getBlock() instanceof BlockLeafOlives) {
// olive leaves are weird
ModelLoader.setCustomModelResourceLocation(block, 0, new ModelResourceLocation(block.getRegistryName(), "check_decay=false,decayable=false,type=" + ((IBlockMeta) block.getBlock()).getNameForMeta(0)));
ModelLoader.setCustomModelResourceLocation(block, 1, new ModelResourceLocation(block.getRegistryName(), "check_decay=false,decayable=false,type=" + ((IBlockMeta) block.getBlock()).getNameForMeta(1)));
} else if (block instanceof ItemBlockMeta) {
ModelLoader.setCustomMeshDefinition(block, new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
return new ModelResourceLocation(block.getRegistryName(), "type=" + ((IBlockMeta) block.getBlock()).getNameForMeta(stack.getMetadata()));
}
});
} else if (block.getBlock() instanceof BlockLeaf || block.getBlock() instanceof BlockSapling || block.getBlock() instanceof BlockCustomWorkbench) {
String[] path = block.getRegistryName().getResourcePath().split("_");
if (block.getBlock() instanceof BlockSapling)
ModelLoader.setCustomModelResourceLocation(block, 0, new ModelResourceLocation(new ResourceLocation(block.getRegistryName().getResourceDomain(), "wood_" + path[1]), "inv_" + path[0]));
else
ModelLoader.setCustomModelResourceLocation(block, 0, new ModelResourceLocation(new ResourceLocation(block.getRegistryName().getResourceDomain(), "wood_" + path[1]), path[0]));
ModelLoader.setCustomStateMapper(block.getBlock(), new StateMapperBase() {
@Override
public ModelResourceLocation getModelResourceLocation(IBlockState state) {
return new ModelResourceLocation(new ResourceLocation(block.getRegistryName().getResourceDomain(), "wood_" + path[1]), path[0]);
}
});
} else if (block.getBlock() instanceof BlockLog) {
String[] path = block.getRegistryName().getResourcePath().split("_");
ResourceLocation loc = new ResourceLocation(block.getRegistryName().getResourceDomain(), "wood_" + path[1]);
ModelLoader.setCustomModelResourceLocation(block, 0, new ModelResourceLocation(loc, path[0] + "_y"));
ModelLoader.setCustomStateMapper(block.getBlock(), new StateMapperBase() {
@Override
public ModelResourceLocation getModelResourceLocation(IBlockState state) {
String axis = "bark";
int meta = ((BlockLog) block.getBlock()).getMetaFromState(state);
if (meta == 0) {
axis = "y";
} else if (meta == 4) {
axis = "x";
} else if (meta == 8) {
axis = "z";
}
return new ModelResourceLocation(loc, path[0] + "_" + axis);
}
});
} else if (block.getBlock() instanceof BlockFluidCustom) {
ModelLoader.setCustomModelResourceLocation(block, 0, new ModelResourceLocation(block.getRegistryName(), "normal"));
ModelLoader.setCustomStateMapper(block.getBlock(), new StateMapperBase() {
@Override
public ModelResourceLocation getModelResourceLocation(IBlockState state) {
return new ModelResourceLocation(block.getRegistryName(), "normal");
}
});
} else
ModelLoader.setCustomModelResourceLocation(block, 0, new ModelResourceLocation(block.getRegistryName(), "inventory"));
}
for (Item item : Resources.items) {
if (item instanceof IItemMeta) {
for (int i = 0; i < ((IItemMeta) item).getNames().length; i++) {
ModelLoader.setCustomModelResourceLocation(item, i, new ModelResourceLocation(item.getRegistryName(), "type=" + ((IItemMeta) item).getNames()[i]));
}
} else if (item instanceof ItemTool || item instanceof ItemSword || item instanceof ItemCustomArmor) {
String[] path = item.getRegistryName().getResourcePath().split("_");
ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(new ResourceLocation(item.getRegistryName().getResourceDomain(), "tool_" + path[1]), path[0]));
} else if (item instanceof ItemSpell) {
ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(new ResourceLocation(item.getRegistryName().getResourceDomain(), "spell"), ((ItemSpell) item).getName()));
} else if (item instanceof ItemScroll) {
ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(new ResourceLocation(item.getRegistryName().getResourceDomain(), "spell_scroll"), ((ItemScroll) item).getName()));
} else if (item instanceof ItemConcoctionFlask) {
ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(new ResourceLocation(item.getRegistryName().getResourceDomain(), "concoction_flask_filled"), "inventory"));
} else
ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
}
// register special item renderers here
Resources.saltedFood.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
Resources.grinder.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
Resources.mobHeadRevenant.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
Resources.mobHeadArachne.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
Resources.mobHeadArachneDrone.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
Resources.mobHeadMyrmeke.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
Resources.mobHeadCerver.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
Resources.mobHeadArganHound.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
Resources.mobHeadForesthagPlane.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
Resources.mobHeadForesthagPopulus.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
Resources.mobHeadForesthagCypress.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
Resources.mobHeadForesthagFir.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
Resources.mobHeadForesthagOlive.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
Resources.mobHeadForesthagLaurel.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
Resources.mobHeadForesthagDroughtroot.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
Resources.mobHeadAeternae.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
Resources.mobHeadCatoblepas.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
Resources.mobHeadSow.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
for (ItemScroll scroll : Resources.scrolls) scroll.setTileEntityItemStackRenderer(LOIItemStackRenderer.LOIInstance);
}
Aggregations