Search in sources :

Example 11 with MaterialInstance

use of net.silentchaos512.gear.gear.material.MaterialInstance in project Silent-Gear by SilentChaos512.

the class CompoundPartModel 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(this.gearType, this.partType, mat).getFirstLayer();
    if (exampleMain != null) {
        builder.addAll(getQuadsForSprite(0, spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, exampleMain.getTexture(this.texturePath, 0))), rotation, exampleMain.getColor()));
    }
    builder.addAll(getQuadsForSprite(0, spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, new StaticLayer(PART_MARKER_TEXTURE).getTexture(this.gearType, 0))), rotation, Color.VALUE_WHITE));
}
Also used : IMaterialDisplay(net.silentchaos512.gear.api.material.IMaterialDisplay) MaterialLayer(net.silentchaos512.gear.api.material.MaterialLayer) IMaterial(net.silentchaos512.gear.api.material.IMaterial) MaterialInstance(net.silentchaos512.gear.gear.material.MaterialInstance) LazyMaterialInstance(net.silentchaos512.gear.gear.material.LazyMaterialInstance) StaticLayer(net.silentchaos512.gear.api.material.StaticLayer)

Example 12 with MaterialInstance

use of net.silentchaos512.gear.gear.material.MaterialInstance in project Silent-Gear by SilentChaos512.

the class CompoundPartModelOverrideList method getOverrideModel.

private BakedModel getOverrideModel(ItemStack stack, @Nullable ClientLevel worldIn, @Nullable LivingEntity entityIn) {
    List<MaterialLayer> layers = new ArrayList<>();
    PartData part = PartData.from(stack);
    MaterialInstance primaryMaterial = CompoundPartItem.getPrimaryMaterial(stack);
    if (part != null && primaryMaterial != null) {
        addWithBlendedColor(layers, part, primaryMaterial, stack);
    }
    return model.bake(layers, "test", owner, bakery, spriteGetter, modelTransform, this, modelLocation);
}
Also used : MaterialLayer(net.silentchaos512.gear.api.material.MaterialLayer) ArrayList(java.util.ArrayList) PartData(net.silentchaos512.gear.gear.part.PartData) MaterialInstance(net.silentchaos512.gear.gear.material.MaterialInstance)

Example 13 with MaterialInstance

use of net.silentchaos512.gear.gear.material.MaterialInstance 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()));
    }
}
Also used : IMaterialDisplay(net.silentchaos512.gear.api.material.IMaterialDisplay) MaterialLayer(net.silentchaos512.gear.api.material.MaterialLayer) IMaterial(net.silentchaos512.gear.api.material.IMaterial) MaterialInstance(net.silentchaos512.gear.gear.material.MaterialInstance) LazyMaterialInstance(net.silentchaos512.gear.gear.material.LazyMaterialInstance)

Example 14 with MaterialInstance

use of net.silentchaos512.gear.gear.material.MaterialInstance in project Silent-Gear by SilentChaos512.

the class CompounderTileEntity method getInputs.

private MaterialList getInputs() {
    boolean allEmpty = true;
    for (int i = 0; i < getInputSlotCount(); ++i) {
        ItemStack stack = getItem(i);
        if (!stack.isEmpty()) {
            allEmpty = false;
            break;
        }
    }
    if (allEmpty) {
        return MaterialList.empty();
    }
    MaterialList ret = MaterialList.empty();
    for (int i = 0; i < getInputSlotCount(); ++i) {
        ItemStack stack = getItem(i);
        if (!stack.isEmpty()) {
            MaterialInstance material = MaterialInstance.from(stack);
            if (material != null && material.get().isSimple()) {
                ret.add(material);
            } else {
                return MaterialList.empty();
            }
        }
    }
    return ret;
}
Also used : MaterialList(net.silentchaos512.gear.api.material.MaterialList) ItemStack(net.minecraft.world.item.ItemStack) MaterialInstance(net.silentchaos512.gear.gear.material.MaterialInstance) IMaterialInstance(net.silentchaos512.gear.api.material.IMaterialInstance)

Example 15 with MaterialInstance

use of net.silentchaos512.gear.gear.material.MaterialInstance in project Silent-Gear by SilentChaos512.

the class GraderTileEntity method tick.

public static void tick(Level level, BlockPos pos, BlockState state, GraderTileEntity blockEntity) {
    // Don't waste time if there is no input or no free output slots
    ItemStack input = blockEntity.getInputStack();
    if (input.isEmpty())
        return;
    int outputSlot = blockEntity.getFreeOutputSlot();
    if (outputSlot < 0)
        return;
    ItemStack catalyst = blockEntity.getCatalystStack();
    int catalystTier = getCatalystTier(catalyst);
    if (catalystTier < 1)
        return;
    MaterialInstance material = MaterialInstance.from(input);
    if (material != null && material.getGrade() != MaterialGrade.getMax()) {
        if (blockEntity.progress < BASE_ANALYZE_TIME) {
            ++blockEntity.progress;
        }
        if (blockEntity.progress >= BASE_ANALYZE_TIME && !level.isClientSide) {
            blockEntity.progress = 0;
            catalyst.shrink(1);
            blockEntity.tryGradeItem(input, catalystTier, material);
        }
    } else {
        blockEntity.progress = 0;
    }
// if (requireClientSync) {
// BlockState state = world.getBlockState(pos);
// world.notifyBlockUpdate(pos, state, state, 3);
// requireClientSync = false;
// }
}
Also used : ItemStack(net.minecraft.world.item.ItemStack) MaterialInstance(net.silentchaos512.gear.gear.material.MaterialInstance) IMaterialInstance(net.silentchaos512.gear.api.material.IMaterialInstance)

Aggregations

MaterialInstance (net.silentchaos512.gear.gear.material.MaterialInstance)25 ItemStack (net.minecraft.world.item.ItemStack)12 IMaterial (net.silentchaos512.gear.api.material.IMaterial)10 IMaterialInstance (net.silentchaos512.gear.api.material.IMaterialInstance)10 PartType (net.silentchaos512.gear.api.part.PartType)9 MaterialLayer (net.silentchaos512.gear.api.material.MaterialLayer)8 PartData (net.silentchaos512.gear.gear.part.PartData)8 Component (net.minecraft.network.chat.Component)7 IMaterialDisplay (net.silentchaos512.gear.api.material.IMaterialDisplay)7 TextComponent (net.minecraft.network.chat.TextComponent)6 ResourceLocation (net.minecraft.resources.ResourceLocation)6 TraitInstance (net.silentchaos512.gear.api.traits.TraitInstance)6 Collectors (java.util.stream.Collectors)5 Nullable (javax.annotation.Nullable)5 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)5 GearType (net.silentchaos512.gear.api.item.GearType)5 ItemStat (net.silentchaos512.gear.api.stats.ItemStat)5 LazyMaterialInstance (net.silentchaos512.gear.gear.material.LazyMaterialInstance)5 java.util (java.util)4 ArrayList (java.util.ArrayList)4