use of net.silentchaos512.gear.api.material.IMaterial in project Silent-Gear by SilentChaos512.
the class FragmentModel method buildFakeModel.
private void buildFakeModel(Function<Material, TextureAtlasSprite> spriteGetter, ImmutableList.Builder<BakedQuad> builder, Transformation rotation, IMaterial material) {
// This method will display an example item for items with no data (ie, for advancements)
MaterialInstance mat = MaterialInstance.of(material);
IMaterialDisplay model = mat.getDisplayProperties();
MaterialLayer exampleMain = model.getLayerList(GearType.FRAGMENT, PartType.MAIN, mat).getFirstLayer();
if (exampleMain != null) {
builder.addAll(getQuadsForSprite(0, spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, exampleMain.getTexture(GearType.FRAGMENT, 0))), rotation, exampleMain.getColor()));
}
}
use of net.silentchaos512.gear.api.material.IMaterial 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.IMaterial in project Silent-Gear by SilentChaos512.
the class CustomMaterialItem method getMaterial.
@Nullable
public static MaterialInstance getMaterial(ItemStack stack) {
String str = stack.getOrCreateTag().getString(NBT_MATERIAL);
ResourceLocation id = SilentGear.getIdWithDefaultNamespace(str);
if (id != null) {
IMaterial material = MaterialManager.get(id);
if (material != null) {
return MaterialInstance.of(material);
}
}
return null;
}
use of net.silentchaos512.gear.api.material.IMaterial in project Silent-Gear by SilentChaos512.
the class FillRepairKitRecipe method isRepairMaterial.
private static boolean isRepairMaterial(IMaterialInstance material) {
float durability = material.getStat(PartType.MAIN, ItemStats.DURABILITY);
float armorDurability = material.getStat(PartType.MAIN, ItemStats.ARMOR_DURABILITY);
IMaterial mat = material.get();
return mat != null && mat.allowedInPart(material, PartType.MAIN) && (durability > 0 || armorDurability > 0);
}
use of net.silentchaos512.gear.api.material.IMaterial in project Silent-Gear by SilentChaos512.
the class IGearRecipe method getParts.
default Collection<PartData> getParts(Container inv) {
List<MaterialInstance> materials = new ArrayList<>();
IMaterial first = null;
List<PartData> parts = new ArrayList<>();
for (int i = 0; i < inv.getContainerSize(); ++i) {
ItemStack stack = inv.getItem(i);
if (!stack.isEmpty()) {
MaterialInstance mat = MaterialInstance.from(stack);
if (mat != null) {
// If classic mixing is disabled, all materials must be the same
if (first == null) {
first = mat.get();
} else if (!Config.Common.allowLegacyMaterialMixing.get() && first != mat.get()) {
return Collections.emptyList();
}
materials.add(mat);
} else {
PartData part = PartData.from(stack);
if (part != null) {
parts.add(part);
}
}
}
}
if (!materials.isEmpty()) {
// Construct a tool head
createToolHead(this.getOutputItem().getGearType(), materials).ifPresent(part -> parts.add(0, part));
}
return parts;
}
Aggregations