public override void FromTreeAttributes(ITreeAttribute tree, IWorldAccessor worldAccessForResolve) { base.FromTreeAttributes(tree, worldAccessForResolve); this.IsCrafted = tree.GetBool(BlockCompass.ATTR_BOOL_CRAFTED); this.CraftedByPlayerUID = tree.GetString(BlockCompass.ATTR_STR_CRAFTED_BY_PLAYER_UID); var x = tree.TryGetInt(BlockCompass.ATTR_INT_TARGET_POS_X); var y = tree.TryGetInt(BlockCompass.ATTR_INT_TARGET_POS_Y); var z = tree.TryGetInt(BlockCompass.ATTR_INT_TARGET_POS_Z); if (x == null || y == null || z == null) { this.TargetPos = null; } else { this.TargetPos = new BlockPos((int)x, (int)y, (int)z); } this.AngleRad = tree.TryGetFloat("AngleRad"); if (worldAccessForResolve.Api.Side == EnumAppSide.Client) { if (compassBaseMesh == null) { GenMesh("base"); MarkDirty(true); } if (compassNeedleMesh == null) { GenMesh("needle"); MarkDirty(true); } } }
public void FromTreeAttributes(ITreeAttribute tree, IWorldAccessor worldForResolving) { if (tree == null) { return; } Byte[] bytes = tree.GetBytes("wiring"); if (bytes != null) { wiring = VoxelWiring.deserialize(bytes); } AvailableWireVoxels = tree.TryGetInt("availableWireVoxels").GetValueOrDefault(0); ComponentsFromTree(ref components, tree.GetTreeAttribute("components"), worldForResolving); selectionBoxesDidChanged = true; }
public static void Postfix(BlockEntityChisel __instance, ref ITreeAttribute tree, ref IWorldAccessor worldAccessForResolve) { ChiselPlusPropertyAccessor accessor = new ChiselPlusPropertyAccessor(worldAccessForResolve.Api); if (!accessor.Properties.ContainsKey(__instance.Pos)) { accessor.Properties[__instance.Pos] = new ChiselPlusProperties(); } accessor.Properties[__instance.Pos].Mesh = (EnumChiselPlusMesh)(tree.TryGetInt("chiselplusmesh") ?? -1); accessor.Properties[__instance.Pos].Rotation.X = tree.TryGetFloat("chiselplusRotX") ?? 0.0f; accessor.Properties[__instance.Pos].Rotation.Y = tree.TryGetFloat("chiselplusRotY") ?? 0.0f; accessor.Properties[__instance.Pos].Rotation.Z = tree.TryGetFloat("chiselplusRotZ") ?? 0.0f; if (__instance.Api?.Side.IsClient() ?? false) { __instance.MarkDirty(true); } }
public override void FromTreeAttributes(ITreeAttribute tree, IWorldAccessor worldAccessForResolve) { index = (uint)tree.TryGetInt("roadindex"); base.FromTreeAttributes(tree, worldAccessForResolve); }