use of net.silentchaos512.gear.api.item.GearType 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.item.GearType in project Silent-Gear by SilentChaos512.
the class GearModelLoader method read.
@Override
public GearModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents) {
ItemTransforms cameraTransforms = deserializationContext.deserialize(modelContents.get("display"), ItemTransforms.class);
if (cameraTransforms == null) {
cameraTransforms = ItemTransforms.NO_TRANSFORMS;
}
String gearTypeStr = GsonHelper.getAsString(modelContents, "gear_type");
GearType gearType = GearType.get(gearTypeStr);
if (gearType.isInvalid()) {
throw new NullPointerException("Unknown gear type: " + gearTypeStr);
}
String texturePath = GsonHelper.getAsString(modelContents, "texture_path", gearType.getName());
String brokenTexturePath = GsonHelper.getAsString(modelContents, "broken_texture_path", gearType.getName());
Collection<PartType> brokenTextureTypes = new ArrayList<>();
JsonArray brokenTypesJson = GsonHelper.getAsJsonArray(modelContents, "broken_texture_types", null);
if (brokenTypesJson != null) {
for (JsonElement element : brokenTypesJson) {
ResourceLocation id = SilentGear.getIdWithDefaultNamespace(element.getAsString());
if (id != null) {
PartType type = PartType.get(id);
if (type != null) {
brokenTextureTypes.add(type);
} else {
SilentGear.LOGGER.error("Unknown part type '{}' in model {}", id, this.getName());
}
}
}
}
GearModel model = new GearModel(cameraTransforms, gearType, texturePath, brokenTexturePath, brokenTextureTypes);
MODELS.add(model);
return model;
}
use of net.silentchaos512.gear.api.item.GearType in project Silent-Gear by SilentChaos512.
the class GearModelOverrideList method addWithBlendedColor.
private static void addWithBlendedColor(List<MaterialLayer> list, PartData part, MaterialInstance material, ItemStack stack) {
IMaterialDisplay model = material.getDisplayProperties();
GearType gearType = GearHelper.getType(stack);
List<MaterialLayer> layers = model.getLayerList(gearType, part, material).getLayers();
addColorBlendedLayers(list, part, stack, layers);
}
use of net.silentchaos512.gear.api.item.GearType in project Silent-Gear by SilentChaos512.
the class CompoundPartModelLoader method read.
@Override
public CompoundPartModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents) {
ItemTransforms cameraTransforms = deserializationContext.deserialize(modelContents.get("display"), ItemTransforms.class);
if (cameraTransforms == null) {
cameraTransforms = ItemTransforms.NO_TRANSFORMS;
}
GearType gearType = GearType.fromJson(modelContents, "gear_type");
PartType partType = PartType.fromJson(modelContents, "part_type");
String subPath = GsonHelper.getAsString(modelContents, "texture_path", gearType.getName());
List<ResourceLocation> extras = new ArrayList<>();
if (modelContents.has("extra_layers") && modelContents.get("extra_layers").isJsonArray()) {
JsonArray array = modelContents.getAsJsonArray("extra_layers");
array.forEach(e -> extras.add(new ResourceLocation(e.getAsString())));
}
CompoundPartModel model = new CompoundPartModel(cameraTransforms, gearType, partType, subPath, extras);
MODELS.add(model);
return model;
}
use of net.silentchaos512.gear.api.item.GearType in project Silent-Gear by SilentChaos512.
the class GearModel method getTextures.
@SuppressWarnings("OverlyComplexMethod")
@Override
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, UnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
Set<Material> ret = new HashSet<>();
ret.add(new Material(InventoryMenu.BLOCK_ATLAS, SilentGear.getId("item/error")));
// Generic built-in textures
for (PartTextures tex : PartTextures.getTextures(this.gearType)) {
int animationFrames = tex.isAnimated() ? item.getAnimationFrames() : 1;
for (int i = 0; i < animationFrames; ++i) {
MaterialLayer layer = new MaterialLayer(tex, Color.VALUE_WHITE);
ret.add(getTexture(layer, i, false));
ret.add(getTexture(layer, 0, true));
}
}
// Custom textures
for (IMaterialDisplay materialDisplay : GearDisplayManager.getMaterials()) {
for (PartType partType : PartType.getValues()) {
if (item.hasTexturesFor(partType)) {
for (MaterialLayer layer : materialDisplay.getLayerList(gearType, partType, LazyMaterialInstance.of(materialDisplay.getMaterialId()))) {
int animationFrames = layer.isAnimated() ? item.getAnimationFrames() : 1;
ret.addAll(this.getTexturesForAllFrames(layer, animationFrames, false));
ret.addAll(this.getTexturesForAllFrames(layer, 1, true));
}
}
}
}
for (IPartDisplay partDisplay : GearDisplayManager.getParts()) {
for (MaterialLayer layer : partDisplay.getLayers(gearType, FakePartData.of(PartType.NONE))) {
int animationFrames = layer.isAnimated() ? item.getAnimationFrames() : 1;
ret.addAll(this.getTexturesForAllFrames(layer, animationFrames, false));
ret.addAll(this.getTexturesForAllFrames(layer, animationFrames, true));
}
}
if (GearModelOverrideList.isDebugLoggingEnabled()) {
SilentGear.LOGGER.info("Textures for gear model '{}' ({})", getTexturePath(false), this.gearType.getName());
for (Material mat : ret) {
SilentGear.LOGGER.info("- {}", mat.texture());
}
}
return ret;
}
Aggregations