use of net.silentchaos512.gear.api.item.GearType in project Silent-Gear by SilentChaos512.
the class TooltipHandler method getSubStatTooltipLine.
private static Optional<MutableComponent> getSubStatTooltipLine(ItemTooltipEvent event, PartType partType, ItemStat stat, GearType gearType, Collection<StatInstance> modifiers) {
if (!modifiers.isEmpty()) {
StatInstance inst = stat.computeForDisplay(0, gearType, modifiers);
if (inst.shouldList(partType, stat, event.getFlags().isAdvanced())) {
boolean isZero = inst.getValue() == 0;
Color color = isZero ? MC_DARK_GRAY : Color.WHITE;
MutableComponent nameStr = TextUtil.withColor(gearType.getDisplayName().copy(), color);
int decimalPlaces = stat.isDisplayAsInt() && inst.getOp() != StatInstance.Operation.MUL1 && inst.getOp() != StatInstance.Operation.MUL2 ? 0 : 2;
MutableComponent statListText = TextUtil.withColor(StatModifierMap.formatText(modifiers, stat, decimalPlaces), color);
// Harvest level hints
MutableComponent textWithAdditions = stat == ItemStats.HARVEST_LEVEL && modifiers.size() == 1 ? harvestLevelWithHint(statListText, inst.getValue()) : statListText;
return Optional.of(new TranslatableComponent("stat.silentgear.displayFormat", nameStr, textWithAdditions));
}
}
return Optional.empty();
}
use of net.silentchaos512.gear.api.item.GearType in project Silent-Gear by SilentChaos512.
the class MaterialDisplay method getMostSpecificKey.
private PartGearKey getMostSpecificKey(GearType gearType, PartType partType) {
PartGearKey key = PartGearKey.of(gearType, partType);
if (map.containsKey(key)) {
return key;
}
PartGearKey parent = key.getParent();
while (parent != null) {
if (map.containsKey(parent)) {
return parent;
}
parent = parent.getParent();
}
// No match
return key;
}
use of net.silentchaos512.gear.api.item.GearType 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()));
}
}
}
use of net.silentchaos512.gear.api.item.GearType in project Silent-Gear by SilentChaos512.
the class PartGearKey method read.
public static PartGearKey read(String key) {
String[] parts = key.split("/");
if (parts.length != 2) {
throw new JsonParseException("invalid key: " + key);
}
PartType partType = PartType.getNonNull(Objects.requireNonNull(SilentGear.getIdWithDefaultNamespace(parts[0])));
if (partType.isInvalid()) {
throw new JsonParseException("Unknown part type: " + parts[0]);
}
GearType gearType = GearType.get(parts[1]);
if (gearType.isInvalid()) {
throw new JsonParseException("Unknown gear type: " + parts[1]);
}
return new PartGearKey(gearType, partType);
}
use of net.silentchaos512.gear.api.item.GearType in project Silent-Gear by SilentChaos512.
the class StatGearKey method read.
@Nullable
public static StatGearKey read(String key) {
String[] parts = key.split("/");
if (parts.length > 2) {
throw new JsonParseException("invalid key: " + key);
}
ItemStat stat = ItemStats.getRegistry().getValue(SilentGear.getIdWithDefaultNamespace(parts[0]));
if (stat == null) {
return null;
}
GearType gearType;
if (parts.length > 1) {
gearType = GearType.get(parts[1]);
if (gearType.isInvalid()) {
throw new JsonParseException("Unknown gear type: " + parts[1]);
}
} else {
gearType = GearType.ALL;
}
return new StatGearKey(stat, gearType);
}
Aggregations