use of net.silentchaos512.gear.gear.material.MaterialInstance in project Silent-Gear by SilentChaos512.
the class CompoundPartModelOverrideList method addWithBlendedColor.
@SuppressWarnings("TypeMayBeWeakened")
private void addWithBlendedColor(List<MaterialLayer> list, PartData part, MaterialInstance material, ItemStack stack) {
IMaterialDisplay materialModel = material.getDisplayProperties();
List<MaterialLayer> layers = materialModel.getLayerList(this.model.gearType, part, material).getLayers();
for (int i = 0; i < layers.size(); i++) {
MaterialLayer layer = layers.get(i);
if ((layer.getColor() & 0xFFFFFF) < 0xFFFFFF) {
int blendedColor = part.getColor(stack, i, 0);
list.add(new MaterialLayer(layer.getTextureId(), part.getType(), blendedColor, false));
} else {
list.add(layer);
}
}
}
use of net.silentchaos512.gear.gear.material.MaterialInstance in project Silent-Gear by SilentChaos512.
the class TooltipHandler method getMaterialStatLines.
private static void getMaterialStatLines(ItemTooltipEvent event, PartType partType, MaterialInstance material) {
TextListBuilder builder = new TextListBuilder();
for (ItemStat stat : ItemStats.allStatsOrdered()) {
if (stat.isVisible()) {
getMaterialStatModLines(event, partType, material, builder, stat);
}
}
event.getToolTip().addAll(builder.build());
}
use of net.silentchaos512.gear.gear.material.MaterialInstance in project Silent-Gear by SilentChaos512.
the class TooltipHandler method getMaterialStatModLines.
private static void getMaterialStatModLines(ItemTooltipEvent event, PartType partType, MaterialInstance material, TextListBuilder builder, ItemStat stat) {
Collection<StatInstance> modsAll = material.getStatModifiers(partType, StatGearKey.of(stat, GearType.ALL));
Optional<MutableComponent> head = getStatTooltipLine(event, partType, stat, modsAll);
builder.add(head.orElseGet(() -> TextUtil.withColor(stat.getDisplayName(), stat.getNameColor())));
builder.indent();
int subCount = 0;
List<StatGearKey> keysForStat = material.get().getStatKeys(material, partType).stream().filter(key -> key.getStat().equals(stat)).collect(Collectors.toList());
for (StatGearKey key : keysForStat) {
if (key.getGearType() != GearType.ALL) {
ItemStat stat1 = ItemStats.get(key.getStat());
if (stat1 != null) {
Collection<StatInstance> mods = material.getStatModifiers(partType, key);
Optional<MutableComponent> line = getSubStatTooltipLine(event, partType, stat1, key.getGearType(), mods);
if (line.isPresent()) {
builder.add(line.get());
++subCount;
}
}
}
}
if (subCount == 0 && !head.isPresent()) {
builder.removeLast();
}
builder.unindent();
}
use of net.silentchaos512.gear.gear.material.MaterialInstance in project Silent-Gear by SilentChaos512.
the class TooltipHandler method onTooltip.
@SubscribeEvent(receiveCanceled = true)
public void onTooltip(ItemTooltipEvent event) {
/*
LoaderState state = Loader.instance().getLoaderState();
if (state == LoaderState.INITIALIZATION || state == LoaderState.SERVER_ABOUT_TO_START || state == LoaderState.SERVER_STOPPING) {
// Skip tooltips during block/item remapping
// JEI tooltip caches are done in AVAILABLE, in-game is SERVER_STARTED
return;
}
*/
ItemStack stack = event.getItemStack();
if (TagUtils.contains(ModTags.Items.GRADER_CATALYSTS, stack)) {
onGraderCatalystTooltip(event);
}
if (TagUtils.contains(ModTags.Items.STARLIGHT_CHARGER_CATALYSTS, stack)) {
onStarlightChargerCatalystTooltip(event);
}
MaterialInstance material = MaterialInstance.from(stack);
if (material != null) {
onMaterialTooltip(event, stack, material);
return;
}
PartData part = PartData.from(stack);
if (part != null) /*&& !part.isBlacklisted(stack)*/
{
onPartTooltip(event, stack, part);
return;
}
// Nerfed gear?
if (Config.Common.isNerfedItem(stack.getItem())) {
List<Component> toolTip = event.getToolTip();
toolTip.add(Math.min(1, toolTip.size()), new TranslatableComponent("misc.silentgear.poorlyMade").withStyle(ChatFormatting.RED));
}
}
use of net.silentchaos512.gear.gear.material.MaterialInstance in project Silent-Gear by SilentChaos512.
the class GearModel method buildFakeModel.
private void buildFakeModel(Function<Material, TextureAtlasSprite> spriteGetter, ImmutableList.Builder<BakedQuad> builder, Transformation rotation, IMaterial material) {
// This method will display an example tool for items with no data (ie, for advancements)
MaterialInstance mat = MaterialInstance.of(material);
IMaterialDisplay model = mat.getDisplayProperties();
if (!gearType.isArmor()) {
MaterialLayer exampleRod = model.getLayerList(this.gearType, PartType.ROD, mat).getFirstLayer();
if (exampleRod != null) {
builder.addAll(getQuadsForSprite(0, spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, exampleRod.getTexture(gearType, 0))), rotation, exampleRod.getColor()));
}
}
MaterialLayer exampleMain = model.getLayerList(this.gearType, PartType.MAIN, mat).getFirstLayer();
if (exampleMain != null) {
builder.addAll(getQuadsForSprite(0, spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, exampleMain.getTexture(gearType, 0))), rotation, exampleMain.getColor()));
}
if (gearType.matches(GearType.RANGED_WEAPON)) {
MaterialLayer exampleBowstring = model.getLayerList(this.gearType, PartType.CORD, mat).getFirstLayer();
if (exampleBowstring != null) {
builder.addAll(getQuadsForSprite(0, spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, exampleBowstring.getTexture(gearType, 0))), rotation, exampleBowstring.getColor()));
}
}
}
Aggregations