-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModifyBlockEntityClayFormFromClient.cs
More file actions
54 lines (47 loc) · 1.54 KB
/
ModifyBlockEntityClayFormFromClient.cs
File metadata and controls
54 lines (47 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using HarmonyLib;
using Vintagestory.API.Common;
using Vintagestory.GameContent;
namespace ZinkModAutoClay;
[HarmonyPatch(typeof(BlockEntityClayForm), "OnCopyLayer")]
public class ModifyBlockEntityClayFormFromClient
{
public static bool Prefix(ref BlockEntityClayForm __instance, ref bool __result, int layer)
{
try
{
if (layer < 0 || layer > 15)
{
__result = false;
return false;
}
bool changed = false;
int remaining = 4;
bool[,,] voxels = ((LayeredVoxelRecipe)(object)__instance.SelectedRecipe).Voxels;
for (int i = 0; i < 16; i++)
{
for (int j = 0; j < 16; j++)
{
if (voxels[i, layer, j] != __instance.Voxels[i, layer, j])
{
remaining--;
__instance.Voxels[i, layer, j] = voxels[i, layer, j];
__instance.AvailableVoxels += (!voxels[i, layer, j]) ? 1 : -1;
changed = true;
}
if (remaining == 0)
{
__result = changed;
return false;
}
}
}
__result = changed;
return false;
}
catch
{
((BlockEntity)__instance).Api.Logger.Chat("(Auto Layer Clay Forming) Error_2: Something went wrong! Try Again...");
}
return true;
}
}