use of net.silentchaos512.gear.gear.part.PartData in project Silent-Gear by SilentChaos512.
the class PartsCommand method partToTsvLine.
private static String partToTsvLine(IGearPart part) {
StringBuilder builder = new StringBuilder();
PartData partData = PartData.of(part);
appendTsv(builder, part.getDisplayName(partData, ItemStack.EMPTY).getString());
appendTsv(builder, part.getId().toString());
appendTsv(builder, part.getType().getName());
appendTsv(builder, partData.getTier());
// Stats
for (ItemStat stat : ItemStats.allStatsOrdered()) {
Collection<StatInstance> statModifiers = partData.getStatModifiers(StatGearKey.of(stat, GearType.ALL), ItemStack.EMPTY);
appendTsv(builder, FORMAT_CODES.matcher(StatModifierMap.formatText(statModifiers, stat, 5).getString()).replaceAll(""));
}
// Traits
appendTsv(builder, partData.getTraits().stream().map(t -> t.getTrait().getDisplayName(t.getLevel()).getString()).collect(Collectors.joining(", ")));
return builder.toString();
}
use of net.silentchaos512.gear.gear.part.PartData in project Silent-Gear by SilentChaos512.
the class GearModelOverrideList method addSimplePartLayers.
private static void addSimplePartLayers(List<MaterialLayer> list, PartData part, ItemStack stack) {
IPartDisplay model = GearDisplayManager.get(part.get());
if (model != null) {
GearType gearType = GearHelper.getType(stack);
List<MaterialLayer> layers = model.getLayers(gearType, part).getLayers();
addColorBlendedLayers(list, part, stack, layers);
}
}
use of net.silentchaos512.gear.gear.part.PartData in project Silent-Gear by SilentChaos512.
the class GearModelOverrideList method getOverrideModel.
private BakedModel getOverrideModel(CacheKey key, ItemStack stack, @Nullable ClientLevel worldIn, @Nullable LivingEntity entityIn, int animationFrame) {
boolean broken = GearHelper.isBroken(stack);
if (isDebugLoggingEnabled()) {
SilentGear.LOGGER.info("getOverrideModel for {} ({})", stack.getHoverName().getString(), broken ? "broken" : "normal");
SilentGear.LOGGER.info("- model key {}", key.data);
}
List<MaterialLayer> layers = new ArrayList<>();
for (PartData part : getPartsInRenderOrder(stack)) {
if (((ICoreItem) stack.getItem()).hasTexturesFor(part.getType())) {
addSimplePartLayers(layers, part, stack);
if (part.get() instanceof CompoundPart) {
MaterialInstance mat = CompoundPart.getPrimaryMaterial(part);
if (mat != null) {
addWithBlendedColor(layers, part, mat, stack);
}
}
}
}
// TODO: Make this not a special case...
if (stack.getItem() instanceof GearCrossbowItem) {
getCrossbowCharge(stack, worldIn, entityIn).ifPresent(layers::add);
}
return model.bake(stack, layers, animationFrame, "test", owner, bakery, spriteGetter, modelTransform, this, modelLocation);
}
use of net.silentchaos512.gear.gear.part.PartData in project Silent-Gear by SilentChaos512.
the class GearModelOverrideList method getPartsInRenderOrder.
private static PartDataList getPartsInRenderOrder(ItemStack stack) {
PartDataList unsorted = GearData.getConstructionParts(stack);
PartDataList ret = PartDataList.of();
ICoreItem item = (ICoreItem) stack.getItem();
for (PartType partType : item.getRenderParts()) {
ret.addAll(unsorted.getPartsOfType(partType));
}
for (PartData part : unsorted) {
if (!ret.contains(part)) {
ret.add(part);
}
}
return ret;
}
use of net.silentchaos512.gear.gear.part.PartData 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);
}
}
}
Aggregations