use of net.silentchaos512.gear.gear.part.CompoundPart in project Silent-Gear by SilentChaos512.
the class SalvagingRecipe method salvage.
/**
* Salvages parts into their respective material items, or fragments if appropriate. This does
* not necessarily give back the original item used for the material, but an item that matches
* it.
*
* @param part The part
* @return The list of items to return
*/
public static List<ItemStack> salvage(PartData part) {
if (part.get() instanceof CompoundPart && part.getItem().getItem() instanceof CompoundPartItem) {
int craftedCount = ((CompoundPartItem) part.getItem().getItem()).getCraftedCount(part.getItem());
if (craftedCount < 1) {
SilentGear.LOGGER.warn("Compound part's crafted count is less than 1? {}", part.getItem());
return Collections.singletonList(part.getItem());
}
List<IMaterialInstance> materials = part.getMaterials();
Map<IMaterialInstance, Integer> fragments = new LinkedHashMap<>();
for (IMaterialInstance material : materials) {
int fragmentCount = 8 / craftedCount;
fragments.merge(material.onSalvage(), fragmentCount, Integer::sum);
}
List<ItemStack> ret = new ArrayList<>();
for (Map.Entry<IMaterialInstance, Integer> entry : fragments.entrySet()) {
IMaterialInstance material = entry.getKey();
int count = entry.getValue();
int fulls = count / 8;
int frags = count % 8;
if (fulls > 0) {
ret.add(material.getItem());
}
if (frags > 0) {
ret.add(ModItems.FRAGMENT.get().create(material, frags));
}
}
return ret;
}
return Collections.singletonList(part.getItem());
}
use of net.silentchaos512.gear.gear.part.CompoundPart in project Silent-Gear by SilentChaos512.
the class GearClientHelper method tooltipListParts.
public static void tooltipListParts(ItemStack gear, List<Component> tooltip, Collection<PartData> parts, GearTooltipFlag flag) {
TextListBuilder builder = new TextListBuilder();
for (PartData part : parts) {
if (part.get().isVisible()) {
int partNameColor = Color.blend(part.getColor(gear), Color.VALUE_WHITE, 0.25f) & 0xFFFFFF;
MutableComponent partNameText = TextUtil.withColor(part.getDisplayName(gear).copy(), partNameColor);
builder.add(flag.isAdvanced() ? partNameText.append(TextUtil.misc("spaceBrackets", part.getType().getName()).withStyle(ChatFormatting.DARK_GRAY)) : partNameText);
// List materials for compound parts
if (part.get() instanceof CompoundPart) {
builder.indent();
for (IMaterialInstance material : CompoundPartItem.getMaterials(part.getItem())) {
int nameColor = material.getNameColor(part.getType(), GearType.ALL);
builder.add(TextUtil.withColor(material.getDisplayNameWithModifiers(part.getType(), ItemStack.EMPTY), nameColor));
}
builder.unindent();
}
}
}
tooltip.addAll(builder.build());
}
use of net.silentchaos512.gear.gear.part.CompoundPart 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);
}
Aggregations