Skip to content

Commit

Permalink
Updated to Version 1.20.0-pre.6
Browse files Browse the repository at this point in the history
  • Loading branch information
VintageStory CI committed Oct 14, 2024
1 parent 4e178b8 commit dbaccbc
Show file tree
Hide file tree
Showing 227 changed files with 3,330 additions and 6,136 deletions.
1 change: 1 addition & 0 deletions Client/API/IAmbientManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public interface IAmbientManager
/// The blended cloud density, calculated every frame from the list of modifiers
/// </summary>
float BlendedCloudDensity { get; }
float BlendedSceneBrightness { get; }

/// <summary>
/// The update loop for this manager. Runs every frame.
Expand Down
32 changes: 30 additions & 2 deletions Client/API/IClientNetworkAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,26 @@ public interface INetworkAPI
/// <param name="channelName">Unique channel identifier</param>
/// <returns></returns>
INetworkChannel RegisterChannel(string channelName);
/// <summary>
/// Supplies you with your very own and personal network channel with which you can send packets to the server. Use the same channelName on the client and server to have them link up.
/// </summary>
/// <param name="channelName">Unique channel identifier</param>
/// <returns></returns>
INetworkChannel RegisterUdpChannel(string channelName);

/// <summary>
/// Returns a previoulsy registered channeled, null otherwise
/// Returns a previously registered channeled, null otherwise
/// </summary>
/// <param name="channelName"></param>
/// <returns></returns>
INetworkChannel GetChannel(string channelName);

/// <summary>
/// Returns a previously registered channeled, null otherwise
/// </summary>
/// <param name="channelName"></param>
/// <returns></returns>
INetworkChannel GetUdpChannel(string channelName);
}
}

Expand Down Expand Up @@ -63,7 +76,7 @@ public interface IClientNetworkAPI : INetworkAPI
new IClientNetworkChannel RegisterChannel(string channelName);

/// <summary>
/// Returns a previoulsy registered channeled, null otherwise
/// Returns a previously registered channel, null otherwise
/// </summary>
/// <param name="channelName"></param>
/// <returns></returns>
Expand All @@ -76,6 +89,21 @@ public interface IClientNetworkAPI : INetworkAPI
/// <returns></returns>
EnumChannelState GetChannelState(string channelName);


/// <summary>
/// Supplies you with your very own and personal network channel with which you can send packets to the server. Use the same channelName on the client and server to have them link up.
/// </summary>
/// <param name="channelName">Unique channel identifier</param>
/// <returns></returns>
new IClientNetworkChannel RegisterUdpChannel(string channelName);

/// <summary>
/// Returns a previously registered channel, null otherwise
/// </summary>
/// <param name="channelName"></param>
/// <returns></returns>
new IClientNetworkChannel GetUdpChannel(string channelName);

/// <summary>
/// Sends a blockentity interaction packet to the server. For quick an easy blockentity network communication without setting up a channel first.
/// </summary>
Expand Down
3 changes: 3 additions & 0 deletions Client/Render/DefaultShaderUniforms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ public void Update(float dt, ICoreClientAPI capi)
// updated by RenderPlayerEffects.cs:
// DamageVignetting, PointLights*

// updated by AmbientManager
// Contrast and Sepia

}
}
}
2 changes: 2 additions & 0 deletions Client/Render/PerceptionEffects/DrunkPerceptionEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public override void OnBeforeGameRender(float dt)
hc.yawOffset = (float)(Math.Cos(accum / 1.12) + Math.Cos(accum / 1.2f) + Math.Cos(accum / 4f) * 0.2f) * f * 60f;
accum /= 2;
hc.pitchOffset = (float)(Math.Sin(accum / 1.12) + Math.Sin(accum / 1.2f) + Math.Sin(accum / 4f) * 0.2f) * f * 30f;

hc.pitchOffset = (float)(Math.Sin(accum / 1.12) + Math.Sin(accum / 1.2f) + Math.Sin(accum / 4f) * 0.2f) * f * 30f;
}

public override void ApplyToFpHand(Matrixf modelMat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ public override void RenderInteractiveElements(float deltaTime)

api.Render.Render2DTexturePremultipliedAlpha(waterTexture.TextureId, Bounds.renderX + padding, Bounds.renderY + padding, (int)(handlePosition + 5), (int)insetHeight);

api.Render.Render2DTexturePremultipliedAlpha(handleTexture.TextureId, Bounds.renderX + handlePosition, Bounds.renderY - dy, (int)handleWidth + 4, (int)handleHeight + 4);
if (Enabled)
{
api.Render.Render2DTexturePremultipliedAlpha(handleTexture.TextureId, Bounds.renderX + handlePosition, Bounds.renderY - dy, (int)handleWidth + 4, (int)handleHeight + 4);
}


if (mouseDownOnSlider || mouseOnSlider)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class SlideshowGridRecipeTextComponent : ItemstackComponentBase

public GridRecipeAndUnnamedIngredients CurrentVisibleRecipe;

static int[][,] variantDisplaySequence = new int[30][,];


/// <summary>
Expand All @@ -65,6 +66,14 @@ public SlideshowGridRecipeTextComponent(ICoreClientAPI capi, GridRecipe[] gridre

Random fixedRand = new Random(123);

for (int i = 0; i < 30; i++)
{
var sq = variantDisplaySequence[i] = new int[3, 3];
for (int x = 0; x < 3; x++)
for (int y = 0; y < 3; y++)
sq[x, y] = capi.World.Rand.Next(99999);
};

// Expand wild cards
List<GridRecipeAndUnnamedIngredients> resolvedGridRecipes = new List<GridRecipeAndUnnamedIngredients>();
Queue<GridRecipe> halfResolvedRecipes = new Queue<GridRecipe>(gridrecipes);
Expand Down Expand Up @@ -271,15 +280,15 @@ public override void RenderInteractiveElements(float deltaTime, double renderX,
int rely = (int)(api.Input.MouseY - renderY);
bool mouseover = bounds.PointInside(relx, rely);

GridRecipeAndUnnamedIngredients recipeunin = CurrentVisibleRecipe = GridRecipesAndUnIn[curItemIndex];

if (!mouseover && (secondsVisible -= deltaTime) <= 0)
{
secondsVisible = 1;
curItemIndex = (curItemIndex + 1) % GridRecipesAndUnIn.Length;
secondCounter++;
}

GridRecipeAndUnnamedIngredients recipeunin = CurrentVisibleRecipe = GridRecipesAndUnIn[curItemIndex];

LoadedTexture extraTextTexture;
if (extraTexts.TryGetValue(curItemIndex, out extraTextTexture))
{
Expand Down Expand Up @@ -316,7 +325,7 @@ public override void RenderInteractiveElements(float deltaTime, double renderX,
ItemStack[] unnamedWildcardStacklist = null;
if (recipeunin.unnamedIngredients?.TryGetValue(index, out unnamedWildcardStacklist) == true && unnamedWildcardStacklist.Length > 0)
{
dummyslot.Itemstack = unnamedWildcardStacklist[secondCounter % unnamedWildcardStacklist.Length];
dummyslot.Itemstack = unnamedWildcardStacklist[variantDisplaySequence[secondCounter % 30][x,y] % unnamedWildcardStacklist.Length];
dummyslot.Itemstack.StackSize = ingred.Quantity;
} else
{
Expand Down Expand Up @@ -364,7 +373,7 @@ public override void OnMouseDown(MouseEvent args)
ItemStack[] unnamedWildcardStacklist = null;
if (recipeunin.unnamedIngredients?.TryGetValue(index, out unnamedWildcardStacklist) == true)
{
onStackClicked?.Invoke(unnamedWildcardStacklist[secondCounter % unnamedWildcardStacklist.Length]);
onStackClicked?.Invoke(unnamedWildcardStacklist[variantDisplaySequence[secondCounter % 30][x, y] % unnamedWildcardStacklist.Length]);
}
else
{
Expand Down
16 changes: 16 additions & 0 deletions Common/API/IBlockAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,22 @@ public interface IBlockAccessor
/// <returns></returns>
Block GetBlock(BlockPos pos);

/// <summary>
/// Get the block type of the block below the given world coordinate. Will never return null. For air blocks or invalid coordinates you'll get a block instance with block code "air" and id 0
/// <br/>Specify a negative dy for a block above!
/// </summary>
/// <param name="pos"></param>
/// <returns></returns>
Block GetBlockBelow(BlockPos pos, int dy = 1);


/// <summary>
/// Get the block type of the block above the given world coordinate. Will never return null. For air blocks or invalid coordinates you'll get a block instance with block code "air" and id 0
/// </summary>
/// <param name="pos"></param>
/// <returns></returns>
Block GetBlockAbove(BlockPos pos, int dy = 1);

/// <summary>
/// Get the block type of the block at the given world coordinate. Will never return null. For airblocks or invalid coordinates you'll get a block instance with block code "air" and id 0
/// <br/>Reads the block from the specified layer(s), see <see cref="BlockLayersAccess"/> documentation for details.
Expand Down
5 changes: 4 additions & 1 deletion Common/Assets/AssetLocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -504,14 +504,17 @@ public int CompareTo(AssetLocation other)
return ToString().CompareOrdinal(other.ToString());
}

internal bool WildCardMatch(AssetLocation other, string pathAsRegex)
public bool WildCardMatch(AssetLocation other, string pathAsRegex)
{
if (Domain == other.Domain)
{
return WildcardUtil.fastMatch(path, other.path, pathAsRegex);
}
return false;
}

public static implicit operator string(AssetLocation loc) => loc.ToString();
public static explicit operator AssetLocation(string code) => new AssetLocation(code);
}

class StringAssetLocationConverter : TypeConverter
Expand Down
16 changes: 14 additions & 2 deletions Common/Collectible/Block/Block.cs
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,7 @@ public virtual bool CanCreatureSpawnOn(IBlockAccessor blockAccessor, BlockPos po
/// <param name="worldgenRandom"></param>
/// <param name="attributes"></param>
/// <returns></returns>
public virtual bool TryPlaceBlockForWorldGen(IBlockAccessor blockAccessor, BlockPos pos, BlockFacing onBlockFace, IRandom worldgenRandom,
BlockPatchAttributes attributes = null)
public virtual bool TryPlaceBlockForWorldGen(IBlockAccessor blockAccessor, BlockPos pos, BlockFacing onBlockFace, IRandom worldgenRandom, BlockPatchAttributes attributes = null)
{
Block block = blockAccessor.GetBlock(pos);

Expand Down Expand Up @@ -1952,6 +1951,19 @@ public virtual bool IsClimbable(BlockPos pos)
return Climbable;
}

/// <summary>
/// The cost of traversing this block as part of the AI pathfinding system.
/// Return a negative value to prefer traversal of a block, return a positive value to avoid traversal of this block. A value over 10000f is considered impassable.
/// Default value is 0
/// </summary>
/// <param name="pos"></param>
/// <param name="creatureType"></param>
/// <returns></returns>
public virtual float GetTraversalCost(BlockPos pos, EnumAICreatureType creatureType)
{
return (1 - WalkSpeedMultiplier) * (creatureType == EnumAICreatureType.Humanoid ? 5 : 2);
}


/// <summary>
/// For any block that can be rotated, this method should be implemented to return the correct rotated block code. It is used by the world edit tool for allowing block data rotations
Expand Down
4 changes: 2 additions & 2 deletions Common/Collectible/Collectible.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2788,10 +2788,10 @@ public virtual float GetTemperature(IWorldAccessor world, ItemStack itemstack)
ITreeAttribute attr = (ITreeAttribute)itemstack.Attributes["temperature"];

double nowHours = world.Calendar.TotalHours;
double lastUpdateHours = attr.GetDouble("temperatureLastUpdate");
double lastUpdateHours = attr.GetDecimal("temperatureLastUpdate");

double hourDiff = nowHours - lastUpdateHours;
float temp = attr.GetFloat("temperature", 20);
float temp = (float)attr.GetDecimal("temperature", 20);
// 1.5 deg per irl second
// 1 game hour = irl 60 seconds
if (hourDiff > 1/85f && temp > 0f)
Expand Down
7 changes: 5 additions & 2 deletions Common/Entity/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,10 @@ public bool IsOnFire
}
set
{
WatchedAttributes.SetBool("onFire", value);
if (value != WatchedAttributes.GetBool("onFire"))
{
WatchedAttributes.SetBool("onFire", value);
}
}
}
protected bool resetLightHsv;
Expand Down Expand Up @@ -958,7 +961,7 @@ public virtual void OnGameTick(float dt)
if (IsOnFire)
{
Block fluidBlock = World.BlockAccessor.GetBlock(Pos.AsBlockPos, BlockLayersAccess.Fluid);
if (fluidBlock.IsLiquid() && fluidBlock.LiquidCode != "lava" || World.ElapsedMilliseconds - OnFireBeginTotalMs > 12000)
if (((fluidBlock.IsLiquid() && fluidBlock.LiquidCode != "lava") || World.ElapsedMilliseconds - OnFireBeginTotalMs > 12000) && !InLava)
{
IsOnFire = false;
}
Expand Down
11 changes: 7 additions & 4 deletions Common/Entity/EntityAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public virtual bool TryMount(IMountableSeat onmount)
// load current controls when mounting onto the mountable
onmount.Controls.FromInt(Controls.ToInt());

if (MountedOn != onmount)
if (MountedOn != null && MountedOn != onmount)
{
if (!TryUnmount()) return false;
}
Expand All @@ -182,7 +182,10 @@ public virtual bool TryMount(IMountableSeat onmount)
onmount?.MountableToTreeAttributes(mountableTree);
WatchedAttributes["mountedOn"] = mountableTree;
doMount(onmount);
WatchedAttributes.MarkPathDirty("mountedOn");
if (World.Side == EnumAppSide.Server)
{
WatchedAttributes.MarkPathDirty("mountedOn");
}
return true;
}

Expand Down Expand Up @@ -642,8 +645,8 @@ protected virtual void HandleHandAnimations(float dt)
/// <param name="groundDragFactor">The amount of drag provided by the current ground. (Default: 0.3)</param>
public virtual double GetWalkSpeedMultiplier(double groundDragFactor = 0.3)
{
int y1 = (int)(SidedPos.Y - 0.05f);
int y2 = (int)(SidedPos.Y + 0.01f);
int y1 = (int)(SidedPos.InternalY - 0.05f);
int y2 = (int)(SidedPos.InternalY + 0.01f);

Block belowBlock = World.BlockAccessor.GetBlock((int)SidedPos.X, y1, (int)SidedPos.Z);

Expand Down
Loading

0 comments on commit dbaccbc

Please sign in to comment.