public static bool Prefix(ItemWorkItem __instance, ref EnumHelveWorkableMode __result, ref BlockEntityAnvil beAnvil)
        {
            bool workable = beAnvil.SelectedRecipe.Output.Attributes?["helvehammerworkable"]?.AsBool() ?? Config.Current.DefaultWorkable;

            if ((workable || Config.Current.AllWorkable) && beAnvil.OwnMetalTier >= Config.Current.AnvilTier)
            {
                __result = EnumHelveWorkableMode.TestSufficientVoxelsWorkable;
                return(false);
            }

            return(true);
        }
Exemple #2
0
    void RegenMesh()
    {
        if (workItemMeshRef != null)
        {
            workItemMeshRef.Dispose();
        }
        workItemMeshRef = null;
        if (stack == null)
        {
            return;
        }

        Shape shape;

        tmpMetal = stack.Collectible.LastCodePart();
        MeshData mesh = null;

        string firstCodePart = stack.Collectible.FirstCodePart();

        if (firstCodePart == "metalplate")
        {
            tmpTextureSource = capi.Tesselator.GetTexSource(capi.World.GetBlock(new AssetLocation("platepile")));
            shape            = capi.Assets.TryGet("shapes/block/stone/forge/platepile.json").ToObject <Shape>();
            textureId        = tmpTextureSource[tmpMetal].atlasTextureId;
            capi.Tesselator.TesselateShape("block-fcr", shape, out mesh, this, null, 0, 0, 0, stack.StackSize);
        }
        else if (firstCodePart == "workitem")
        {
            MeshData workItemMesh = ItemWorkItem.GenMesh(capi, stack, ItemWorkItem.GetVoxels(stack), out textureId);
            workItemMesh.Scale(new Vec3f(0.5f, 0.5f, 0.5f), 0.75f, 0.75f, 0.75f);
            workItemMesh.Translate(0, -9f / 16f, 0);
            workItemMeshRef = capi.Render.UploadMesh(workItemMesh);
        }
        else if (firstCodePart == "ingot")
        {
            tmpTextureSource = capi.Tesselator.GetTexSource(capi.World.GetBlock(new AssetLocation("ingotpile")));
            shape            = capi.Assets.TryGet("shapes/block/stone/forge/ingotpile.json").ToObject <Shape>();
            textureId        = tmpTextureSource[tmpMetal].atlasTextureId;
            capi.Tesselator.TesselateShape("block-fcr", shape, out mesh, this, null, 0, 0, 0, stack.StackSize);
        }
        else if (stack.Collectible.Attributes != null && stack.Collectible.Attributes.IsTrue("forgable") == true)
        {
            if (stack.Class == EnumItemClass.Block)
            {
                mesh      = capi.TesselatorManager.GetDefaultBlockMesh(stack.Block).Clone();
                textureId = capi.BlockTextureAtlas.AtlasTextureIds[0];
            }
            else
            {
                capi.Tesselator.TesselateItem(stack.Item, out mesh);
                textureId = capi.ItemTextureAtlas.AtlasTextureIds[0];
            }

            ModelTransform tf = stack.Collectible.Attributes["inForgeTransform"].AsObject <ModelTransform>();
            if (tf != null)
            {
                tf.EnsureDefaultValues();
                mesh.ModelTransform(tf);
            }
        }

        if (mesh != null)
        {
            workItemMeshRef = capi.Render.UploadMesh(mesh);
        }
    }