use of net.silentchaos512.lib.registry.IRegistryObject in project SilentGems by SilentChaos512.
the class ToolHelper method createToolName.
public static String createToolName(Item item, List<ItemStack> materials) {
ToolPart part;
LocalizationHelper loc = SilentGems.localizationHelper;
Set<String> prefixSet = Sets.newLinkedHashSet();
Set<String> materialSet = Sets.newLinkedHashSet();
for (ItemStack stack : materials) {
part = ToolPartRegistry.fromStack(stack);
if (part != null) {
String prefix = part.getDisplayNamePrefix(stack);
if (prefix != null && !prefix.isEmpty())
prefixSet.add(prefix);
materialSet.add(part.getDisplayName(stack));
}
}
String prefix = String.join(" ", prefixSet);
if (!prefix.isEmpty())
prefix += " ";
String delimiter = loc.getLocalizedString("tool.silentgems:delimiter");
String materialName = String.join(delimiter, materialSet);
String toolName = ((IRegistryObject) item).getName();
String name = loc.getLocalizedString("tool", toolName, materialName);
return prefix + name;
}
use of net.silentchaos512.lib.registry.IRegistryObject in project SilentGems by SilentChaos512.
the class ToolPartGem method getModel.
@Override
public ModelResourceLocation getModel(ItemStack tool, ToolPartPosition pos, int frame) {
String name = ((IRegistryObject) tool.getItem()).getName();
name = SilentGems.RESOURCE_PREFIX + name + "/" + name;
String gemNum = tool.getItem() instanceof ItemGemBow ? "" : "" + gem.ordinal();
String frameNum = frame == 3 ? "_3" : "";
switch(pos) {
case HEAD:
name += gemNum + frameNum;
break;
case ROD_DECO:
name += "_deco";
break;
default:
return null;
}
if (modelMap.containsKey(name)) {
return modelMap.get(name);
}
name = name.toLowerCase();
ModelResourceLocation model = new ModelResourceLocation(name, "inventory");
modelMap.put(name, model);
return model;
}
use of net.silentchaos512.lib.registry.IRegistryObject in project SilentGems by SilentChaos512.
the class ToolPartRodGems method getModel.
@Override
public ModelResourceLocation getModel(ItemStack tool, ToolPartPosition pos, int frame) {
String name = ((IRegistryObject) tool.getItem()).getName();
name = SilentGems.RESOURCE_PREFIX + name.toLowerCase() + "/" + name + "_" + rodName;
if (modelMap.containsKey(name)) {
return modelMap.get(name);
}
name = name.toLowerCase();
ModelResourceLocation model = new ModelResourceLocation(name, "inventory");
modelMap.put(name, model);
return model;
}
use of net.silentchaos512.lib.registry.IRegistryObject in project SilentGems by SilentChaos512.
the class ToolPartTipGems method getModel.
@Override
public ModelResourceLocation getModel(ItemStack tool, ToolPartPosition pos, int frame) {
String name = ((IRegistryObject) tool.getItem()).getName();
name = SilentGems.MODID + ":" + name.toLowerCase() + "/" + name + "_" + tipName + (frame == 3 ? "_3" : "");
if (modelMap.containsKey(name)) {
return modelMap.get(name);
}
name = name.toLowerCase();
ModelResourceLocation model = new ModelResourceLocation(name, "inventory");
modelMap.put(name, model);
return model;
}
use of net.silentchaos512.lib.registry.IRegistryObject in project SilentGems by SilentChaos512.
the class ToolModel method getQuads.
@Override
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
LogHelper log = SilentGems.logHelper;
if (tool == null) {
return new ArrayList<BakedQuad>();
}
if (modelManager == null) {
modelManager = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager();
}
List<BakedQuad> quads = Lists.newArrayList();
ModelResourceLocation location;
IBakedModel model;
IBakedModel rodModel = null;
Item item = tool.getItem();
// Invalid tools models.
if (ToolHelper.getMaxDamage(tool) <= 0 && tool.getItem() instanceof IRegistryObject) {
String name = ((IRegistryObject) tool.getItem()).getName();
location = new ModelResourceLocation(SilentGems.MODID + ":" + name.toLowerCase() + "/_error", "inventory");
model = modelManager.getModel(location);
if (model != null) {
quads.addAll(model.getQuads(state, side, rand));
}
return quads;
}
for (ToolPartPosition partPos : ToolPartPosition.values()) {
// Scepter rods on top of head.
if (tool.getItem() instanceof ItemGemScepter) {
if (partPos == ToolPartPosition.ROD) {
location = ToolRenderHelper.getInstance().getModel(tool, partPos);
rodModel = modelManager.getModel(location);
continue;
} else if (partPos == ToolPartPosition.ROD_DECO) {
quads.addAll(rodModel.getQuads(state, side, rand));
}
}
// Normal logic.
location = ToolRenderHelper.getInstance().getModel(tool, partPos);
// debug += partPos + ": " + (location == null ? "null" : location.toString()) + "\n";
if (location != null) {
model = modelManager.getModel(location);
if (model != null) {
quads.addAll(model.getQuads(state, side, rand));
}
}
}
if (ModuleAprilTricks.instance.isEnabled() && ModuleAprilTricks.instance.isRightDay()) {
model = modelManager.getModel(ToolRenderHelper.getInstance().modelGooglyEyes);
quads.addAll(model.getQuads(state, side, rand));
}
return quads;
}
Aggregations