Fix deleting log block not triggering leaf decay, addresses #576

This commit is contained in:
UnknownShadow200 2021-03-26 23:52:51 +11:00
parent a6a04ec92d
commit fe6b838bb1
4 changed files with 20 additions and 2 deletions

View File

@ -124,6 +124,7 @@ namespace MCGalaxy.Blocks {
case Block.Air: return AirPhysics.DoAir;
case Block.Leaves: return LeafPhysics.DoLeaf;
case Block.Log: return LeafPhysics.DoLog;
case Block.Sapling: return OtherPhysics.DoShrub;
case Block.Fire: return FirePhysics.Do;
case Block.LavaFire: return FirePhysics.Do;

View File

@ -117,6 +117,7 @@ namespace MCGalaxy.Blocks.Physics {
// NOTE: omission of y-1 to match original behaviour
}
// TODO: Stop checking block type and just always call lvl.AddCheck
internal static void CheckAt(Level lvl, ushort x, ushort y, ushort z) {
int index;
BlockID block = lvl.GetBlock(x, y, z, out index);
@ -127,6 +128,7 @@ namespace MCGalaxy.Blocks.Physics {
case Block.Sapling:
case Block.Sand:
case Block.Gravel:
case Block.Log:
case Block.Leaves:
case Block.FloatWood:
/*case Block.lava_fast:

View File

@ -105,5 +105,20 @@ namespace MCGalaxy.Blocks.Physics {
// distances can only propagate through leaf blocks
if (dists[index] == -2) dists[index] = dist;
}
public static void DoLog(Level lvl, ref PhysInfo C) {
ushort x = C.X, y = C.Y, z = C.Z;
for (int xx = -range; xx <= range; xx++)
for (int yy = -range; yy <= range; yy++)
for (int zz = -range; zz <= range; zz++)
{
int index = lvl.PosToInt((ushort)(x + xx), (ushort)(y + yy), (ushort)(z + zz));
if (index < 0 || lvl.blocks[index] != Block.Leaves) continue;
lvl.AddCheck(index);
}
}
}
}

View File

@ -36,11 +36,11 @@ namespace MCGalaxy {
public abstract partial class Plugin {
/// <summary> Hooks into events and initalises states/resources etc </summary>
/// <param name="startup"> True if plugin is being automatically loaded (e.g. on server startup), false if manually. </param>
/// <param name="auto"> True if plugin is being automatically loaded (e.g. on server startup), false if manually. </param>
public abstract void Load(bool auto);
/// <summary> Unhooks from events and disposes of state/resources etc </summary>
/// <param name="shutdown"> True if plugin is being auto unloaded (e.g. on server shutdown), false if manually. </param>
/// <param name="auto"> True if plugin is being auto unloaded (e.g. on server shutdown), false if manually. </param>
public abstract void Unload(bool auto);
/// <summary> Called when a player does /Help on the plugin. Typically tells the player what this plugin is about. </summary>