use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.
the class PartMaterialIngredient method test.
@Override
public boolean test(@Nullable ItemStack stack) {
if (stack == null || stack.isEmpty())
return false;
MaterialInstance material = MaterialInstance.from(stack);
if (material == null)
return false;
int tier = material.getTier(this.partType);
return material.get().isCraftingAllowed(material, partType, gearType) && (categories.isEmpty() || material.hasAnyCategory(categories)) && tierMatches(tier);
}
use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.
the class ConversionRecipe method readMaterials.
private static void readMaterials(FriendlyByteBuf buffer, ConversionRecipe recipe) {
int typeCount = buffer.readByte();
for (int i = 0; i < typeCount; ++i) {
PartType partType = PartType.get(buffer.readResourceLocation());
int matCount = buffer.readByte();
List<IMaterialInstance> list = new ArrayList<>(matCount);
for (int j = 0; j < matCount; ++j) {
list.add(LazyMaterialInstance.read(buffer));
}
recipe.resultMaterials.put(partType, list);
}
}
use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.
the class ModKitRemovePartRecipe method getRemainingItems.
@Override
public NonNullList<ItemStack> getRemainingItems(CraftingContainer inv) {
NonNullList<ItemStack> list = NonNullList.withSize(inv.getContainerSize(), ItemStack.EMPTY);
ItemStack gear = StackList.from(inv).uniqueOfType(ICoreItem.class);
ItemStack modKit = StackList.from(inv).uniqueOfType(ModKitItem.class);
PartType type = ModKitItem.getSelectedType(modKit);
PartData part = GearData.getPartOfType(gear, type);
for (int i = 0; i < list.size(); ++i) {
ItemStack stack = inv.getItem(i);
if (stack.getItem() instanceof ICoreItem) {
list.set(i, part != null ? part.getItem() : ItemStack.EMPTY);
} else if (stack.hasContainerItem()) {
list.set(i, stack.getContainerItem());
}
}
return list;
}
use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.
the class ModKitRemovePartRecipe method matches.
@Override
public boolean matches(CraftingContainer inv, Level worldIn) {
ItemStack gear = ItemStack.EMPTY;
boolean foundModKit = false;
PartType type = PartType.NONE;
for (int i = 0; i < inv.getContainerSize(); ++i) {
ItemStack stack = inv.getItem(i);
if (!stack.isEmpty()) {
// noinspection ChainOfInstanceofChecks
if (gear.isEmpty() && stack.getItem() instanceof ICoreItem) {
gear = stack;
} else if (!foundModKit && stack.getItem() instanceof ModKitItem) {
type = ModKitItem.getSelectedType(stack);
if (type == PartType.NONE) {
return false;
}
foundModKit = true;
} else {
return false;
}
}
}
return !gear.isEmpty() && foundModKit && GearData.hasPartOfType(gear, type);
}
use of net.silentchaos512.gear.api.part.PartType in project Silent-Gear by SilentChaos512.
the class GearArmorItem method getArmorTexture.
// endregion
// region Client-side methods and rendering horrors
@Override
public String getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, String type) {
// Empty texture if broken
if (GearHelper.isBroken(stack))
return SilentGear.MOD_ID + ":textures/models/armor/empty.png";
int layer = slot == EquipmentSlot.LEGS ? 2 : 1;
// Overlay - default to a blank texture
if ("overlay".equals(type))
return SilentGear.MOD_ID + ":textures/models/armor/all_layer_" + layer + "_overlay.png";
// New material-based armor
MaterialInstance material = GearData.getPrimaryArmorMaterial(stack);
if (material != null) {
IMaterialDisplay materialModel = material.getDisplayProperties();
PartType partType = GearData.hasPartOfType(stack, PartType.COATING) ? PartType.COATING : PartType.MAIN;
MaterialLayer materialLayer = materialModel.getLayerList(this.getGearType(), partType, material).getFirstLayer();
if (materialLayer != null) {
ResourceLocation tex = materialLayer.getTextureId();
return tex.getNamespace() + ":textures/models/armor/" + tex.getPath() + "_layer_" + layer + (type != null ? "_" + type : "") + ".png";
}
}
return "silentgear:textures/models/armor/main_generic_hc_layer_" + layer + (type != null ? "_" + type : "") + ".png";
}
Aggregations