W.I.P Partial fixes for crashing tools, faster scythe
This commit is contained in:
parent
7ad0695a7d
commit
2eb3289f8a
9 changed files with 113 additions and 33 deletions
|
|
@ -26,6 +26,7 @@ namespace ElementalTools
|
|||
internal const string hammerAssetKey = @"hammer";
|
||||
internal const string fmaKey = @"fma";
|
||||
internal const string sharpeningStoneAssetKey = @"sharpening_stone";
|
||||
internal const string sharpeningRecipiePrefix = @"steel_sharpening_";
|
||||
|
||||
internal const string pack_carburizationClassKey = @"PackCarburization";
|
||||
internal const string PackCarburizationEntityNameKey = @"PackCarburizationEntity";
|
||||
|
|
@ -146,7 +147,7 @@ namespace ElementalTools
|
|||
Height = 3,
|
||||
Width = 1,
|
||||
Shapeless = false,
|
||||
Name = new AssetLocation(fmaKey, "Steel_sharpening_"),//Automatic ## appended...
|
||||
Name = new AssetLocation(fmaKey, sharpeningRecipiePrefix),//Automatic ## appended...
|
||||
IngredientPattern = "H\tL\tS",
|
||||
Ingredients = new Dictionary<string, CraftingRecipeIngredient>( )
|
||||
{
|
||||
|
|
@ -164,7 +165,7 @@ namespace ElementalTools
|
|||
"L", new CraftingRecipeIngredient()
|
||||
{
|
||||
Type = EnumItemClass.Item,
|
||||
Code = new AssetLocation(GlobalConstants.DefaultDomain,"fat"),//Consider: Lubricants of the Future?
|
||||
Code = new AssetLocation(GlobalConstants.DefaultDomain,"fat"),//Consider; Alternate-Lubricants: Grease, Veg-Oils
|
||||
Quantity = 1,
|
||||
}
|
||||
},
|
||||
|
|
@ -189,7 +190,7 @@ namespace ElementalTools
|
|||
|
||||
};
|
||||
|
||||
var results = SingleVariableToolRecipies(sharpenableThings, sharpeningPattern,'H', "metal");
|
||||
var results = SingleVariableToolRecipies(sharpenableThings, sharpeningPattern,'H', MetalNameKey);
|
||||
Mod.Logger.Event($"Added {results} Sharpening recipes, for {sharpenableThings.Count()} items");
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@
|
|||
<Compile Include="Items\ItemSharpeningStone.cs" />
|
||||
<Compile Include="Items\VariableWearRateTool.cs" />
|
||||
<Compile Include="ColorHelper.cs" />
|
||||
<Compile Include="General\SteelAssist.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Items\" />
|
||||
|
|
|
|||
60
ElementalTools/General/SteelAssist.cs
Normal file
60
ElementalTools/General/SteelAssist.cs
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
using System;
|
||||
|
||||
using Vintagestory.API.Common;
|
||||
|
||||
namespace ElementalTools
|
||||
{
|
||||
/// <summary>
|
||||
/// Item wrapped with some Tool helpers & stuff
|
||||
/// </summary>
|
||||
public abstract class SteelAssistItem : Item
|
||||
{
|
||||
private const string altToolKeyword = @"AltTool";
|
||||
|
||||
protected SteelAssistItem() : base()
|
||||
{
|
||||
}
|
||||
|
||||
protected SteelAssistItem(int itemId) : base (itemId)
|
||||
{
|
||||
}
|
||||
|
||||
public EnumTool? AltTool {
|
||||
get
|
||||
{
|
||||
if (this.Attributes != null && this.Attributes.KeyExists(altToolKeyword))
|
||||
{
|
||||
EnumTool altEnumVal = (EnumTool)(this.Attributes[altToolKeyword].AsInt(0));
|
||||
return altEnumVal;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//HACK: to workaround null tool values...
|
||||
}
|
||||
|
||||
public bool Edged {
|
||||
get
|
||||
{
|
||||
if (this.Tool.HasValue) return this.Tool.EdgedImpliment( );
|
||||
if (this.AltTool.HasValue) return this.AltTool.EdgedImpliment( );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Weapon {
|
||||
get
|
||||
{
|
||||
if (this.Tool.HasValue) return this.Tool.Weapons( );
|
||||
if (this.AltTool.HasValue) return this.AltTool.Weapons( );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool RecomendedUsage(EnumBlockMaterial blockMaterial)
|
||||
{
|
||||
if( this.MiningSpeed != null && this.MiningSpeed.ContainsKey(blockMaterial)) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ namespace ElementalTools
|
|||
/// <param name="what">What.</param>
|
||||
public static bool EdgedImpliment(this EnumTool? what)
|
||||
{
|
||||
if (what.HasValue && (
|
||||
if (what != null || what.HasValue && (
|
||||
what == EnumTool.Axe ||
|
||||
what == EnumTool.Chisel ||
|
||||
what == EnumTool.Hoe ||
|
||||
|
|
@ -126,7 +126,7 @@ namespace ElementalTools
|
|||
/// <param name="what">What.</param>
|
||||
public static bool Weapons(this EnumTool? what)
|
||||
{
|
||||
if (what.HasValue && (
|
||||
if (what != null || what.HasValue && (
|
||||
what == EnumTool.Axe || //Arguable
|
||||
what == EnumTool.Bow ||
|
||||
what == EnumTool.Knife ||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace ElementalTools
|
|||
/// <summary>
|
||||
/// GENERIC Steel item. (Tool / Weapon / Armor...anything) [Possibly: Temperable and/or Hardenable ]
|
||||
/// </summary>
|
||||
public class SteelWrap<T>: Item, IAmSteel where T : Item, new()
|
||||
public class SteelWrap<T>: SteelAssistItem, IAmSteel where T : Item, new()
|
||||
{
|
||||
private const float eutectoid_transition_temperature = 727f;//Celcius
|
||||
private const float quenchTimeConstant = 180f;
|
||||
|
|
@ -107,7 +107,7 @@ namespace ElementalTools
|
|||
WrappedItem.Textures = this.Textures;
|
||||
WrappedItem.Variant = this.Variant;
|
||||
WrappedItem.VariantStrict = this.VariantStrict;
|
||||
WrappedItem.Tool = this.Tool;
|
||||
WrappedItem.Tool = this?.Tool;
|
||||
WrappedItem.Attributes = this?.Attributes?.Clone();
|
||||
WrappedItem.MiningSpeed = this?.MiningSpeed;
|
||||
WrappedItem.Shape = this.Shape;
|
||||
|
|
@ -126,6 +126,7 @@ namespace ElementalTools
|
|||
|
||||
|
||||
WrappedItem.OnLoadedNative(api);//Hacky - but needed?
|
||||
//WrappedItem.OnLoaded(api); // ItemScythe : ItemShears Needs this!
|
||||
}
|
||||
|
||||
#region Static Properties
|
||||
|
|
@ -383,8 +384,8 @@ namespace ElementalTools
|
|||
|
||||
public override void OnAttackingWith(IWorldAccessor world, Entity byEntity, Entity attackedEntity, ItemSlot itemslot)
|
||||
{
|
||||
bool edged = this.Tool.EdgedImpliment( );
|
||||
bool weapon = this.Tool.Weapons( );
|
||||
bool edged = this.Edged;
|
||||
bool weapon = this.Weapon;
|
||||
float targetArmorFactor = 0.0f;
|
||||
|
||||
|
||||
|
|
@ -429,14 +430,17 @@ namespace ElementalTools
|
|||
|
||||
public override bool OnBlockBrokenWith(IWorldAccessor world, Entity byEntity, ItemSlot itemslot, BlockSelection blockSel)
|
||||
{
|
||||
bool edged = this.Tool.EdgedImpliment( );
|
||||
bool weapon = this.Tool.Weapons( );
|
||||
if (api.Side.IsClient()) return true;
|
||||
|
||||
bool edged = this.Edged;
|
||||
bool weapon = this.Weapon;
|
||||
var targetBlock = api.World.BlockAccessor.GetBlock(blockSel.Position);
|
||||
int targetTier = targetBlock.ToolTier;
|
||||
float targetResistance = targetBlock.Resistance;
|
||||
bool recomendedUsage = this.MiningSpeed.ContainsKey(targetBlock.BlockMaterial);
|
||||
bool recomendedUsage = this.RecomendedUsage(targetBlock.BlockMaterial);
|
||||
var hardness = this.Hardness(itemslot.Itemstack);
|
||||
|
||||
|
||||
//ERROR: NullReferenceException !
|
||||
|
||||
//Only called for attacks on BLOCKS / Envrionment. Scen# 5 - 6 here.
|
||||
|
||||
|
|
@ -529,22 +533,22 @@ namespace ElementalTools
|
|||
/// <param name="quantity">Quantity.</param>
|
||||
public override void OnConsumedByCrafting(ItemSlot[ ] allInputSlots, ItemSlot stackInSlot, GridRecipe gridRecipe, CraftingRecipeIngredient fromIngredient, IPlayer byPlayer, int quantity)
|
||||
{
|
||||
if (fromIngredient.IsTool) {
|
||||
|
||||
if (fromIngredient.IsTool) {
|
||||
|
||||
//Edged tool vs. non-edged tool
|
||||
bool edgedTool = this.Tool.EdgedImpliment( );
|
||||
bool edgedTool = this.Edged;
|
||||
|
||||
|
||||
float hardnessMult =((int)HardnessState.Brittle+1) / ((int)this.Hardness(stackInSlot.Itemstack)+1) * 0.25f;
|
||||
float wearMax = 1;
|
||||
if (edgedTool) {
|
||||
wearMax = ( byte )SharpnessState.Razor / ( byte )this.Sharpness(stackInSlot.Itemstack);//5..1
|
||||
wearMax = ( byte )SharpnessState.Razor - ( byte )this.Sharpness(stackInSlot.Itemstack);
|
||||
}
|
||||
|
||||
int actualDmg = ( int )Math.Round(NatFloat.createTri(wearMax, hardnessMult).nextFloat( ), 1);
|
||||
|
||||
#if DEBUG
|
||||
api.World.Logger.VerboseDebug($"[{this.Code}] --> Harndess effect: [ Hardness {hardnessMult} Vs. Rate: {wearMax} apply dmg: {actualDmg}, edged: {edgedTool} ]");
|
||||
api.World.Logger.VerboseDebug($"tooluse [{this.Code}] --> Harndess effect: [ Hardness {hardnessMult} Vs. Rate: {wearMax} apply dmg: {actualDmg}, edged: {edgedTool} ]");
|
||||
#endif
|
||||
|
||||
stackInSlot.Itemstack.Collectible.DamageItem(byPlayer.Entity.World, byPlayer.Entity, stackInSlot, actualDmg);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
{ code: "metal", states: [ "blister_steel", "shear_steel"] },
|
||||
],
|
||||
shape: { base: "game:item/tool/chisel" },
|
||||
tool: "Chisel",
|
||||
tool: "chisel",
|
||||
enabled: true,
|
||||
heldTpHitAnimation: "breaktool",
|
||||
attributesByType: {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
code: "scythe",
|
||||
damagedby: ["blockbreaking"],
|
||||
class: "Steel_ItemScythe",
|
||||
tool: "Scythe",
|
||||
tool: "scythe",
|
||||
variantgroups: [
|
||||
{ code: "metal", states: ["blister_steel", "shear_steel" ] },
|
||||
],
|
||||
|
|
@ -11,15 +11,9 @@
|
|||
metalName:"Blister Steel",
|
||||
sharpenable: true,
|
||||
hardenable: false,
|
||||
},
|
||||
"*-shear_steel": {
|
||||
metalName:"Shear Steel",
|
||||
sharpenable: true,
|
||||
hardenable: false,
|
||||
},
|
||||
"*": {
|
||||
codePrefixes: ["crop", "tallgrass", "frostedtallgrass"],
|
||||
handbook: {
|
||||
AltTool:13,
|
||||
codePrefixes: ["crop", "tallgrass", "frostedtallgrass"],
|
||||
handbook: {
|
||||
groupBy: ["scythe-*"]
|
||||
},
|
||||
toolrackTransform: {
|
||||
|
|
@ -27,7 +21,22 @@
|
|||
translation: { x: -0.35, y: 0.5 },
|
||||
scale: 1,
|
||||
},
|
||||
}
|
||||
},
|
||||
"*-shear_steel": {
|
||||
metalName:"Shear Steel",
|
||||
sharpenable: true,
|
||||
hardenable: false,
|
||||
AltTool:13,
|
||||
codePrefixes: ["crop", "tallgrass", "frostedtallgrass"],
|
||||
handbook: {
|
||||
groupBy: ["scythe-*"]
|
||||
},
|
||||
toolrackTransform: {
|
||||
rotation: { y: 3, z: -1 },
|
||||
translation: { x: -0.35, y: 0.5 },
|
||||
scale: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
shape: { base: "game:item/tool/scythe" },
|
||||
heldTpHitAnimation: "scythe",
|
||||
|
|
@ -38,6 +47,11 @@
|
|||
"*-blister_steel": 1900,
|
||||
"*-shear_steel": 2000,
|
||||
},
|
||||
miningspeed:
|
||||
{
|
||||
"plant": 6,
|
||||
"leaves": 4
|
||||
},
|
||||
creativeinventory: { "general": ["*"], "items": ["*"], "tools": ["*"] },
|
||||
guiTransform: {
|
||||
translation: { x: 0, y: 0, z: 0 },
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
},
|
||||
"textures": {
|
||||
"nails": "game:block/metal/sheet/iron1",
|
||||
"metal": "fma:metal/{metal}",
|
||||
"metal": "fma:metal/blister_steel",
|
||||
"string": "game:item/tool/material/string",
|
||||
"wood": "game:block/wood/debarked/redwood"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@
|
|||
"description" : "Anchient techniques for making STEEL, in your very own forge - today!",
|
||||
"authors": ["Melchior"],
|
||||
"ModID":"eraofsteel",
|
||||
"version": "0.1.1",
|
||||
"version": "0.1.2",
|
||||
"dependencies": {
|
||||
"game": "1.13.0",
|
||||
"game": "1.13.4",
|
||||
"survival": ""
|
||||
},
|
||||
"website": "http://nowebsite.nope"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue