use of net.silentchaos512.gear.api.material.IMaterialInstance in project Silent-Gear by SilentChaos512.
the class CraftedMaterial method getStatModifiers.
@Override
public Collection<StatInstance> getStatModifiers(IMaterialInstance material, PartType partType, StatGearKey key, ItemStack gear) {
Collection<StatInstance> ret = super.getStatModifiers(material, partType, key, gear);
IMaterialInstance base = getBaseMaterial(material);
ret.addAll(base.getStatModifiers(partType, key, gear));
return ret;
}
use of net.silentchaos512.gear.api.material.IMaterialInstance in project Silent-Gear by SilentChaos512.
the class CompoundMaterialDisplay method getLayerColor.
@Override
public int getLayerColor(GearType gearType, IPartData part, IMaterialInstance materialIn, int layer) {
List<MaterialLayer> layers = getLayerList(gearType, part, materialIn).getLayers();
if (layer < layers.size()) {
ItemStack stack = materialIn.getItem();
if (stack.getItem() instanceof CompoundMaterialItem) {
List<IMaterialInstance> subMaterials = CompoundMaterialItem.getSubMaterials(stack);
int color = ColorUtils.getBlendedColor((CompoundMaterialItem) stack.getItem(), subMaterials, layer);
// return layers.get(layer).getColor();
return color;
}
}
return Color.VALUE_WHITE;
}
use of net.silentchaos512.gear.api.material.IMaterialInstance in project Silent-Gear by SilentChaos512.
the class GraderTileEntity method tryGradeItem.
private void tryGradeItem(ItemStack input, int catalystTier, IMaterialInstance material) {
MaterialGrade targetGrade = MaterialGrade.selectWithCatalyst(SilentGear.RANDOM, catalystTier);
this.lastGradeAttempt = targetGrade;
if (targetGrade.ordinal() > material.getGrade().ordinal()) {
// Assign grade, move to output slot
ItemStack stack = input.split(1);
targetGrade.setGradeOnStack(stack);
InventoryUtils.mergeItem(this, 2, 2 + SLOTS_OUTPUT.length, stack);
}
}
use of net.silentchaos512.gear.api.material.IMaterialInstance in project Silent-Gear by SilentChaos512.
the class CompoundMaterialItem method getPrimaryMaterial.
@Nullable
private static IMaterialInstance getPrimaryMaterial(ItemStack stack) {
IMaterialInstance first = MaterialList.deserializeFirst(stack.getOrCreateTag().getList(NBT_MATERIALS, Tag.TAG_COMPOUND));
if (first != null) {
return first;
}
// Read old style
ListTag listNbt = stack.getOrCreateTag().getList(NBT_MATERIALS, Tag.TAG_STRING);
if (!listNbt.isEmpty()) {
Tag nbt = listNbt.get(0);
ResourceLocation id = ResourceLocation.tryParse(nbt.getAsString());
if (id != null) {
IMaterial material = MaterialManager.get(id);
if (material != null) {
return MaterialInstance.of(material);
}
}
}
return null;
}
use of net.silentchaos512.gear.api.material.IMaterialInstance in project Silent-Gear by SilentChaos512.
the class CompoundMaterialItem method getName.
@Override
public Component getName(ItemStack stack) {
IMaterialInstance material = getPrimaryMaterial(stack);
Component text = material != null ? material.getDisplayName(PartType.MAIN) : TextUtil.misc("unknown");
return new TranslatableComponent(this.getDescriptionId(), text);
}
Aggregations