From 3e3fd0c7671698859a34fa19d0c2e842b540d30f Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Tue, 19 May 2020 01:16:40 +0200 Subject: [PATCH] Cleanup, added INI file and parser lib (merged) Updated plugin and removed commands that don't really belong here Using ILMerge to merge the parser into the DLL --- GCMC/BlockType.cs | 11 ++++++++ GCMC/BlockTypes.ini | 45 +++++++++++++++++++++++++++++++ GCMC/CubePlacerEngine.cs | 54 +++---------------------------------- GCMC/GCMC.csproj | 57 ++++++++++++++++++++++------------------ GCMC/GCMCPlugin.cs | 6 ++--- GCMC/PlaceBlockPatch.cs | 4 +-- GCMCTest/GCMCTest.csproj | 4 --- GCMCTest/Program.cs | 1 - 8 files changed, 97 insertions(+), 85 deletions(-) create mode 100644 GCMC/BlockType.cs create mode 100644 GCMC/BlockTypes.ini diff --git a/GCMC/BlockType.cs b/GCMC/BlockType.cs new file mode 100644 index 0000000..86caadf --- /dev/null +++ b/GCMC/BlockType.cs @@ -0,0 +1,11 @@ +using GamecraftModdingAPI.Blocks; + +namespace GCMC +{ + public struct BlockType + { + public string Material; + public BlockIDs Type; + public BlockColor Color; + } +} \ No newline at end of file diff --git a/GCMC/BlockTypes.ini b/GCMC/BlockTypes.ini new file mode 100644 index 0000000..effc81f --- /dev/null +++ b/GCMC/BlockTypes.ini @@ -0,0 +1,45 @@ +[Dirt] +type=DirtCube + +[Grass] +type=GrassCube + +[Stone,Coal_ore,Iron_ore] +type=ConcreteCube +color=White +darkness=5 + +[Leaves] +type=AluminiumCube +color=Green +darkness=5 + +[Air,Double_plant] +ignore=true + +[Log] +type=WoodCube + +[Water] +type=AluminiumCube +color=Blue + +[Sand] +type=AluminiumCube +color=Yellow + +[Long_grass] +type=Flower1 + +[Yellow_flower] +type=Flower2 + +[Gravel] +type=ConcreteCube +color=White +darkness=7 + +[Clay] +type=ConcreteCube +color=White +darkness=4 diff --git a/GCMC/CubePlacerEngine.cs b/GCMC/CubePlacerEngine.cs index e2db938..45e7c55 100644 --- a/GCMC/CubePlacerEngine.cs +++ b/GCMC/CubePlacerEngine.cs @@ -1,6 +1,7 @@ using System; using System.IO; using DataLoader; +using GamecraftModdingAPI; using GamecraftModdingAPI.Blocks; using Newtonsoft.Json; using RobocraftX.Blocks; @@ -21,30 +22,11 @@ using uREPL; namespace GCMC { - public class CubePlacerEngine : IQueryingEntitiesEngine, IDeterministicSim + public class CubePlacerEngine : IQueryingEntitiesEngine, IDeterministicTimeStopped { public void Ready() { RuntimeCommands.Register("importWorld", ImportWorld, "Imports a Minecraft world."); - RuntimeCommands.Register("placeCube", PlaceBlock, "Places a cube."); - RuntimeCommands.Register("placedBy", GetPlacedBy, "Gets who placed a block."); - } - - private void GetPlacedBy() - { - try - { - var placementInfo = - entitiesDB.QueryEntity(new EGID(BlockIdentifiers.LatestBlockID, - BlockIdentifiers.OWNED_BLOCKS)); - Log.Output("Placed by: " + placementInfo.placedBy); - Log.Output("Loaded from disk: " + placementInfo.loadedFromDisk); - } - catch (Exception e) - { - Log.Error("Failed to get who placed the block."); - Console.WriteLine("Error getting who placed the block:\n" + e); - } } public EntitiesDB entitiesDB { get; set; } @@ -122,7 +104,7 @@ namespace GCMC continue; } - Placement.PlaceBlock(id, (blocks.Start + blocks.End) / 10 * 3, color: color, darkness: darkness, + Block.PlaceNew(id, (blocks.Start + blocks.End) / 10 * 3, color: color, darkness: darkness, scale: (blocks.End - blocks.Start + 1) * 3, rotation: float3.zero); C++; } @@ -136,35 +118,7 @@ namespace GCMC } } - private void PlaceBlock(string args) - { - try - { - var s = args.Split(' '); - ushort block = ushort.Parse(s[0]); - byte color = byte.Parse(s[1]); - byte darkness = byte.Parse(s[2]); - float x = float.Parse(s[3]), y = float.Parse(s[4]), z = float.Parse(s[5]); - int scale = int.Parse(s[6]); - float scaleX = float.Parse(s[7]); - float scaleY = float.Parse(s[8]); - float scaleZ = float.Parse(s[9]); - float rotX = float.Parse(s[10]); - float rotY = float.Parse(s[11]); - float rotZ = float.Parse(s[12]); - uint playerId = 0; - Placement.PlaceBlock((BlockIDs) block, new float3(x, y, z), new float3(rotX, rotY, rotZ), - (BlockColors) color, darkness, scale, new float3(scaleX, scaleY, scaleZ), playerId); - } - catch (Exception e) - { - Console.WriteLine(e); - Log.Error(e.Message); - } - } - - public JobHandle SimulatePhysicsStep(in float deltaTime, in PhysicsUtility utility, - in PlayerInput[] playerInputs) + public JobHandle SimulatePhysicsStep(in float deltaTime, in PhysicsUtility utility, in PlayerInput[] playerInputs) { return new JobHandle(); } diff --git a/GCMC/GCMC.csproj b/GCMC/GCMC.csproj index 7588c54..f9b1095 100644 --- a/GCMC/GCMC.csproj +++ b/GCMC/GCMC.csproj @@ -1,74 +1,81 @@ - - + + + - netstandard2.0 + net472 - + + + - - bin\Debug\netstandard2.0\0Harmony.dll - - ..\ref\BlockEntityFactory.dll + ..\..\ref\Gamecraft_Data\Managed\BlockEntityFactory.dll - ..\ref\CommandLine.dll + ..\..\ref\Gamecraft_Data\Managed\CommandLine.dll - ..\ref\DataLoader.dll + ..\..\ref\Gamecraft_Data\Managed\DataLoader.dll - + ..\..\GamecraftModdingAPI\GamecraftModdingAPI\bin\Debug\net472\GamecraftModdingAPI.dll IllusionPlugin.dll + ..\..\GamecraftModdingAPI\GamecraftModdingAPI\bin\Debug\net472\Newtonsoft.Json.dll - ..\ref\RobocraftX.Blocks.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Blocks.dll - ..\ref\RobocraftX.Character.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Character.dll - ..\ref\RobocraftX.Common.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Common.dll - ..\ref\RobocraftX.GUI.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.dll - ..\ref\RobocraftX.Input.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Input.dll - ..\ref\RobocraftX.MachineEditor.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.MachineEditor.dll - ..\ref\RobocraftX.StateSync.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.StateSync.dll - - ..\ref\Svelto.Common.dll + + D:\Games\SteamLibrary\steamapps\common\RobocraftX\Gamecraft_Data\Managed\Svelto.Common_3.dll - ..\ref\Svelto.ECS.dll + ..\..\ref\Gamecraft_Data\Managed\Svelto.ECS.dll - ..\ref\Unity.Entities.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Entities.dll - ..\ref\Unity.Mathematics.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Mathematics.dll - ..\ref\UnityEngine.CoreModule.dll + ..\..\ref\Gamecraft_Data\Managed\UnityEngine.CoreModule.dll - ..\ref\uREPL.dll + ..\..\ref\Gamecraft_Data\Managed\uREPL.dll + + + + + + diff --git a/GCMC/GCMCPlugin.cs b/GCMC/GCMCPlugin.cs index e748ca2..78fad5f 100644 --- a/GCMC/GCMCPlugin.cs +++ b/GCMC/GCMCPlugin.cs @@ -1,5 +1,5 @@ using System.Reflection; -using Harmony; +using HarmonyLib; using IllusionPlugin; using UnityEngine; @@ -9,14 +9,14 @@ namespace GCMC { public string Name { get; } = "GCMC"; public string Version { get; } = "v0.0.1"; - public static HarmonyInstance harmony { get; protected set; } + public static Harmony harmony { get; protected set; } public const string HarmonyID = "io.github.norbipeti.GCMC"; public void OnApplicationStart() { if (harmony == null) { - harmony = HarmonyInstance.Create(HarmonyID); + harmony = new Harmony(HarmonyID); harmony.PatchAll(Assembly.GetExecutingAssembly()); } diff --git a/GCMC/PlaceBlockPatch.cs b/GCMC/PlaceBlockPatch.cs index 69fd431..bcc6e0e 100644 --- a/GCMC/PlaceBlockPatch.cs +++ b/GCMC/PlaceBlockPatch.cs @@ -1,6 +1,6 @@ using System.Reflection; using DataLoader; -using Harmony; +using HarmonyLib; using JetBrains.Annotations; using RobocraftX.Common; using RobocraftX.CR.MachineEditing; @@ -26,7 +26,7 @@ namespace GCMC Debug.Log("Not authoritative, not adding MC engine"); } - static MethodBase TargetMethod(HarmonyInstance instance) + static MethodBase TargetMethod() { return typeof(MainEditingCompositionRoot).GetMethod("Compose", BindingFlags.Public | BindingFlags.Static); diff --git a/GCMCTest/GCMCTest.csproj b/GCMCTest/GCMCTest.csproj index eb25fae..614bf96 100644 --- a/GCMCTest/GCMCTest.csproj +++ b/GCMCTest/GCMCTest.csproj @@ -5,10 +5,6 @@ netcoreapp3.0 - - - - diff --git a/GCMCTest/Program.cs b/GCMCTest/Program.cs index fb73854..7bdb04d 100644 --- a/GCMCTest/Program.cs +++ b/GCMCTest/Program.cs @@ -1,6 +1,5 @@ using System; using System.Threading.Channels; -using fNbt; using GCMC; namespace GCMCTest