Jump to content

neogoo123

Vintarian
  • Posts

    10
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by neogoo123

  1. Update:

    Hello! This mod was quite old and I had to update it to the current version of the game. Everything works as it should. The only actual change to the functionality of the mod was the change of composting dry grass to be 3 days instead of two. Please let me know of any suggestions you may have!

     

    EDIT: Fixed issue with scythe not being able to trim grass instead of only cutting.

  2. Fixed! Let me know if anything else is screwy. Thanks for letting me know!

     

    *Thought it was fixed, then I done screwed it up trying to get the fix out quick... Accidentally uploaded a zip of the mod folder, not the actual mod itself... This is why I'm not a professional lol

  3. Hello! It's been a bit! I created this mod a while back in March of 2021, but have recently had some time over winter break from my studies and got back into it.

    After playing it a bit, I found that there were a few things I would want to have in the game, so I went about adding them myself! This mod is small right now, but I plan on working on it and additional mods that will cater to as many as possible.

    In this version of the mod, there are only a few additions/modifications to the game:

    1. Scythes now swipe twice as fast and cut more grass at once - I found it really quite aggravating to cut grass with a scythe and most of the time just ended up using a knife to cut it because it ended up being faster. I want going through the ages to save me time and effort, not just give me more tools that don't do much.
    2. Thatched Grass - Combining 9 Dry Grass in the crafting grid (one grass in each box) will give you a piece of Thatched Grass.
    3. Thatched Grass Clothing - Combining Thatched Grass in the crafting grid as you would for getting armor in MineCraft will give you either Thatched Grass Pants or a Thatched Grass Shirt. These clothes come with a low Max Warmth, but with the ability to remake them when the conditions get low.
    4. 64x Dry Grass can be added to a barrel in order to create one compost. This process takes 3 days, so it doesn't take forever to get a single piece of compost, nor does it take 64 wasted foodstuffs.

    Mod page link: https://mods.vintagestory.at/show/mod/4900

    Dry Grass in Barrel:

    Spoiler

    2021-03-15_21-51-43.thumb.png.c12681029037983cf5a85f29e2b66f60.png

    Thatched Grass Recipe:

    Spoiler

    2021-03-15_22-30-06.png.f71e4160dcf7f560b7d5ea7e1522132c.png

    Thatched Grass Shirt Recipe:

    Spoiler

    2021-03-15_21-52-27.png.27b5f90218e458d48968e2b443a2a558.png

    Thatched Grass Pants Recipe:

    Spoiler

    2021-03-15_21-53-00.png.cd62b8a02b49799e6a15e4d3705e1b56.png

    Thatched Grass Shirt and Pants being worn:

    Spoiler

    image.png.087d21912707bfd34ed13b2216e131ec.png

    If you'd like to take a look at all of this in action (Note that this version puts the time to compost at 3 days instead of the 1 day seen in the video):

     

     

    • Like 5
  4. Alright, so, I think I've fixed my issue but I'm left with some questions still. I'm going to put this as solved for now incase others who are in my situation come across this. What I had to do was replace all of the sections in the code that used "(byPlayer as EntityPlayer)?.Player;" with 

    Spoiler
    
    
    
    EntityPlayer e = byEntity as EntityPlayer;
    
    IPlayer byPlayer = null;
    
    if(e != null)
    {
    	byPlayer = e.Player;
    }

     

    This has fixed my issue, and I'm now able to modify the class at my leisure. My main issue here is if that operator, the "?", in this specific context, is part of a different CS version and I'm just not up-to-date? I've only ever seen the question mark operator used as a ternary operator. Also I'm going to change the bubble to "Solved!".

  5. Thanks for the reply, Quentin!

    Update: I seem to have narrowed down the issue to specifically lines 59, 118, and 126, which are the places where there are "(byEntity as EntityPlayer)?.Player;"s. I happened to look into the log files (I had been, but didn't really notice anything weird in the client and server debug logs) and found that in server-event file there was this:

    Spoiler
    
    
    15.3.2021 16:12:08 [Error] [mymod] Compiler errors during compilation:
    15.3.2021 16:12:08 [Error] [mymod]     src\items\ItemScytheModded.cs(59): Invalid expression term '.' [CS1525]
    15.3.2021 16:12:08 [Error] [mymod]     src\items\ItemScytheModded.cs(59): Syntax error, ':' expected [CS1003]
    15.3.2021 16:12:08 [Error] [mymod]     src\items\ItemScytheModded.cs(118): Invalid expression term '.' [CS1525]
    15.3.2021 16:12:08 [Error] [mymod]     src\items\ItemScytheModded.cs(118): Syntax error, ':' expected [CS1003]
    15.3.2021 16:12:08 [Error] [mymod]     src\items\ItemScytheModded.cs(118): ; expected [CS1002]
    15.3.2021 16:12:08 [Error] [mymod]     src\items\ItemScytheModded.cs(118): Invalid expression term ',' [CS1525]
    15.3.2021 16:12:08 [Error] [mymod]     src\items\ItemScytheModded.cs(118): ; expected [CS1002]
    15.3.2021 16:12:08 [Error] [mymod]     src\items\ItemScytheModded.cs(118): ; expected [CS1002]
    15.3.2021 16:12:08 [Error] [mymod]     src\items\ItemScytheModded.cs(118): Invalid expression term ',' [CS1525]
    15.3.2021 16:12:08 [Error] [mymod]     src\items\ItemScytheModded.cs(118): ; expected [CS1002]
    15.3.2021 16:12:08 [Error] [mymod]     src\items\ItemScytheModded.cs(118): ; expected [CS1002]
    15.3.2021 16:12:08 [Error] [mymod]     src\items\ItemScytheModded.cs(118): Invalid expression term ')' [CS1525]
    15.3.2021 16:12:08 [Error] [mymod]     src\items\ItemScytheModded.cs(126): Invalid expression term '.' [CS1525]
    15.3.2021 16:12:08 [Error] [mymod]     src\items\ItemScytheModded.cs(126): Syntax error, ':' expected [CS1003]

     

     By removing the question marks (I'd never seen question marks used like this myself so I figured that might have been it) I successfully got it to load the mod albeit with other issues but hey at least I'm actually loading the mod.

     

  6. Hello! I'm fairly new to the Vintage Story scene, and its modding in general, but have had some good successes. After getting used to everything and starting to add stuff that I actually wanted modded in, I started work on another part which has to do with modifying the scythe code. This would be the first coding work I'd done in it, so I figured I'd start out by making my own version of the scythe and then replace the vanilla one when I was done. I went about this by essentially just copying the ItemScythe code from the survival github to a new CS file called ItemScytheModded. This is where I intended to play with the tool. After adding the file and adding the code from the ItemScythe file, trying to run the game through Visual studio leads to it not loading my mod. It had been working before adding the code, and seems to load the mod when I remove most of the ItemScythe code. Note that I've tried both having the item registered and not, and both ways the mod still won't load. I've gone about trying to remove all json that included the file (as at first I figured I'd try just patching the scythe to use my class rather than the vanilla), as well as making an entirely different item in my assets folder, but regardless the game won't even load the mod to see those json files. Am I misunderstanding something here or is this weird?

    Here's the ItemScytheModded code, so you can see it's the same as in the original file:

    Spoiler
    
    
    
    
    using System;
    using Vintagestory.API.Common;
    using Vintagestory.API.MathTools;
    using Vintagestory.GameContent;
    
    namespace VSMods.src.items
    {
        public class ItemScytheModded : ItemShears
        {
            string[] allowedPrefixes;
            string[] disallowedSuffixes;
    
            public override int MultiBreakQuantity { get { return 5; } }
    
            public override void OnLoaded(ICoreAPI api)
            {
                base.OnLoaded(api);
                allowedPrefixes = Attributes["codePrefixes"].AsArray<string>();
                disallowedSuffixes = Attributes["disallowedSuffixes"].AsArray<string>();
            }
    
            public override bool CanMultiBreak(Block block)
            {
                for (int i = 0; i < allowedPrefixes.Length; i++)
                {
                    if (block.Code.Path.StartsWith(allowedPrefixes[i]))
                    {
                        // Disable scything on thick snow variants (-snow2, -snow3 etc.)
                        if (disallowedSuffixes != null)
                        {
                            for (int j = 0; j < disallowedSuffixes.Length; j++)
                            {
                                if (block.Code.Path.EndsWith(disallowedSuffixes[j])) return false;
                            }
                        }
    
                        return true;
                    }
                }
    
                return false;
            }
    
            public override void OnHeldAttackStart(ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, ref EnumHandHandling handling)
            {
                base.OnHeldAttackStart(slot, byEntity, blockSel, entitySel, ref handling);
                if (blockSel == null) return;
    
                IPlayer byPlayer = (byEntity as EntityPlayer)?.Player;
                if (!byEntity.World.Claims.TryAccess(byPlayer, blockSel.Position, EnumBlockAccessFlags.BuildOrBreak))
                {
                    return;
                }
    
                if (CanMultiBreak(api.World.BlockAccessor.GetBlock(blockSel.Position)))
                {
                    handling = EnumHandHandling.PreventDefault;
                    byEntity.Attributes.SetBool("didBreakBlocks", false);
                    byEntity.Attributes.SetBool("didPlaySound", false);
                }
                else
                {
                    handling = EnumHandHandling.PreventDefault;
                    byEntity.Attributes.SetBool("didBreakBlocks", false);
                }
            }
    
            public override bool OnHeldAttackStep(float secondsPassed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSelection, EntitySelection entitySel)
            {
                if (blockSelection == null) return false;
                if (!CanMultiBreak(api.World.BlockAccessor.GetBlock(blockSelection.Position)) && byEntity.Attributes.GetBool("didBreakBlocks") == false) return false;
    
                if (byEntity.World.Side == EnumAppSide.Client)
                {
                    ModelTransform tf = new ModelTransform();
                    tf.EnsureDefaultValues();
    
                    float t = secondsPassed / 1.35f;
    
                    float f = (float)Easings.EaseOutBack(Math.Min(t * 2f, 1));
                    float f2 = (float)Math.Sin(GameMath.Clamp(Math.PI * 1.4f * (t - 0.5f), 0, 3));
    
                    tf.Translation.X += Math.Min(0.2f, t * 3);
                    tf.Translation.Y -= Math.Min(0.75f, t * 3);
                    tf.Translation.Z -= Math.Min(1, t * 3);
                    tf.ScaleXYZ += Math.Min(1, t * 3);
                    tf.Origin.X -= Math.Min(0.75f, t * 3);
                    tf.Rotation.X = -Math.Min(30, t * 30) + f * 30 + (float)f2 * 120f;
                    tf.Rotation.Z = -f * 110;
    
                    if (secondsPassed > 1.75f)
                    {
                        float b = 2 * (secondsPassed - 1.75f);
                        tf.Rotation.Z += b * 140;
                        tf.Rotation.X /= (1 + b * 10);
                        tf.Translation.X -= b * 0.4f;
                        tf.Translation.Y += b * 2 / 0.75f;
                        tf.Translation.Z += b * 2;
                        //tf.Origin.X += b * 2 / 0.75f;
                        //tf.ScaleXYZ -= b * 2;
                    }
    
                    byEntity.Controls.UsingHeldItemTransformBefore = tf;
                }
    
                if (secondsPassed > 0.75f && byEntity.Attributes.GetBool("didPlaySound") == false)
                {
                    api.World.PlaySoundAt(new AssetLocation("sounds/tool/scythe1"), byEntity, (byEntity as EntityPlayer)?.Player, true, 16);
                    byEntity.Attributes.SetBool("didPlaySound", true);
                }
    
                if (secondsPassed > 1.45f && byEntity.Attributes.GetBool("didBreakBlocks") == false)
                {
                    if (byEntity.World.Side == EnumAppSide.Server)
                    {
                        IPlayer byPlayer = (byEntity as EntityPlayer)?.Player;
                        if (!byEntity.World.Claims.TryAccess(byPlayer, blockSelection.Position, EnumBlockAccessFlags.BuildOrBreak))
                        {
                            return false;
                        }
    
                        OnBlockBrokenWith(byEntity.World, byEntity, slot, blockSelection);
                    }
                    byEntity.Attributes.SetBool("didBreakBlocks", true);
                }
    
                // Crappy fix to make harvesting not buggy T_T
                if (api.Side == EnumAppSide.Server) return true;
    
                return secondsPassed < 2f;
            }
    
            public override void OnHeldAttackStop(float secondsPassed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSelection, EntitySelection entitySel)
            {
    
            }
        }
    }

     

    The odd thing about this to me is that even with the file not being used in any json and not being called anywhere, it just stops the game from loading the mod, but does load the mod if I remove parts of the code, specifically all of the overrides.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.