Update to Techblox and new API

This commit is contained in:
Norbi Peti 2021-05-17 23:26:19 +02:00
parent bfedf5d2bb
commit bba56a1967
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
5 changed files with 87 additions and 72 deletions

View file

@ -1,4 +1,4 @@
using GamecraftModdingAPI.Blocks; using TechbloxModdingAPI.Blocks;
namespace GCMC namespace GCMC
{ {

View file

@ -1,16 +1,19 @@
[Dirt] [Dirt]
type=DirtCube type=Cube
color=Orange
darkness=5
[Grass] [Grass]
type=GrassCube type=Cube
color=Green
[Stone,Coal_ore,Iron_ore] [Stone,Coal_ore,Iron_ore]
type=ConcreteCube type=Cube
color=White color=White
darkness=5 darkness=5
[Leaves] [Leaves]
type=AluminiumCube type=Cube
color=Green color=Green
darkness=5 darkness=5
@ -18,14 +21,16 @@ darkness=5
ignore=true ignore=true
[Log] [Log]
type=WoodCube type=Cube
color=Orange
darkness=8
[Water] [Water]
type=GlassCube type=Cube
color=Blue color=Blue
[Sand] [Sand]
type=AluminiumCube type=Cube
color=Yellow color=Yellow
[Long_grass] [Long_grass]
@ -35,11 +40,11 @@ type=Flower1
type=Flower2 type=Flower2
[Gravel] [Gravel]
type=ConcreteCube type=Cube
color=White color=White
darkness=7 darkness=7
[Clay] [Clay]
type=ConcreteCube type=Cube
color=White color=White
darkness=4 darkness=4

View file

@ -6,69 +6,69 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ILMerge" Version="3.0.29" /> <PackageReference Include="ILMerge" Version="3.0.41" />
<PackageReference Include="ini-parser" Version="2.5.2" /> <PackageReference Include="ini-parser" Version="2.5.2" />
<PackageReference Include="Lib.Harmony" Version="2.0.1" /> <PackageReference Include="Lib.Harmony" Version="2.0.4" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="BlockEntityFactory, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\BlockEntityFactory.dll</HintPath>
</Reference>
<Reference Include="CommandLine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="CommandLine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\CommandLine.dll</HintPath> <HintPath>..\..\ref\TechbloxPreview_Data\Managed\CommandLine.dll</HintPath>
</Reference> </Reference>
<Reference Include="DataLoader, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="DataLoader, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\DataLoader.dll</HintPath> <HintPath>..\..\ref\TechbloxPreview_Data\Managed\DataLoader.dll</HintPath>
</Reference> </Reference>
<Reference Include="GamecraftModdingAPI"> <Reference Include="Svelto.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\GamecraftModdingAPI\GamecraftModdingAPI\bin\Debug\net472\GamecraftModdingAPI.dll</HintPath> <HintPath>..\..\ref\TechbloxPreview_Data\Managed\Svelto.Common.dll</HintPath>
</Reference> </Reference>
<Reference Include="IllusionPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="Svelto.Tasks, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>IllusionPlugin.dll</HintPath> <HintPath>..\..\ref\TechbloxPreview_Data\Managed\Svelto.Tasks.dll</HintPath>
</Reference>
<Reference Include="TechbloxModdingAPI">
<HintPath>..\..\ref\Plugins\TechbloxModdingAPI.dll</HintPath>
</Reference>
<Reference Include="IllusionPlugin">
<HintPath>..\..\ref\TechbloxPreview_Data\Managed\IllusionPlugin.dll</HintPath>
<!-- <Private>False</Private> Need to copy for ILMerge --> <!-- <Private>False</Private> Need to copy for ILMerge -->
</Reference> </Reference>
<Reference Include="Newtonsoft.Json"> <Reference Include="Newtonsoft.Json">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Newtonsoft.Json.dll</HintPath> <HintPath>..\..\ref\TechbloxPreview_Data\Managed\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
<Reference Include="RobocraftX.Blocks, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="RobocraftX.Blocks, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.Blocks.dll</HintPath> <HintPath>..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Blocks.dll</HintPath>
</Reference> </Reference>
<Reference Include="RobocraftX.Character, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="RobocraftX.Character, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.Character.dll</HintPath> <HintPath>..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Character.dll</HintPath>
</Reference> </Reference>
<Reference Include="RobocraftX.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="RobocraftX.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.Common.dll</HintPath> <HintPath>..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Common.dll</HintPath>
</Reference> </Reference>
<Reference Include="RobocraftX.GUI, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="RobocraftX.GUI, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.dll</HintPath> <HintPath>..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.dll</HintPath>
</Reference> </Reference>
<Reference Include="RobocraftX.Input, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="RobocraftX.Input, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.Input.dll</HintPath> <HintPath>..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Input.dll</HintPath>
</Reference> </Reference>
<Reference Include="RobocraftX.MachineEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="RobocraftX.MachineEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.MachineEditor.dll</HintPath> <HintPath>..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.MachineEditor.dll</HintPath>
</Reference> </Reference>
<Reference Include="RobocraftX.StateSync, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="RobocraftX.StateSync, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.StateSync.dll</HintPath> <HintPath>..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.StateSync.dll</HintPath>
</Reference>
<Reference Include="Svelto.Common_3, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>D:\Games\SteamLibrary\steamapps\common\RobocraftX\Gamecraft_Data\Managed\Svelto.Common_3.dll</HintPath>
</Reference> </Reference>
<Reference Include="Svelto.ECS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="Svelto.ECS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Svelto.ECS.dll</HintPath> <HintPath>..\..\ref\TechbloxPreview_Data\Managed\Svelto.ECS.dll</HintPath>
</Reference> </Reference>
<Reference Include="Unity.Entities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="Unity.Entities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Unity.Entities.dll</HintPath> <HintPath>..\..\ref\TechbloxPreview_Data\Managed\Unity.Entities.dll</HintPath>
</Reference> </Reference>
<Reference Include="Unity.Mathematics, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="Unity.Mathematics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Unity.Mathematics.dll</HintPath> <HintPath>..\..\ref\TechbloxPreview_Data\Managed\Unity.Mathematics.dll</HintPath>
</Reference> </Reference>
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\UnityEngine.CoreModule.dll</HintPath> <HintPath>..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference> </Reference>
<Reference Include="uREPL, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"> <Reference Include="uREPL, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\uREPL.dll</HintPath> <HintPath>..\..\ref\TechbloxPreview_Data\Managed\uREPL.dll</HintPath>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
@ -79,9 +79,9 @@
</ItemGroup> </ItemGroup>
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" /> <Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
<Target Name="AfterBuild"> <!-- <Target Name="AfterBuild">
<!-- the ILMergePath property points to the location of ILMerge.exe console application --> <!- the ILMergePath property points to the location of ILMerge.exe console application ->
<Exec Command="$(ILMergeConsolePath) /ndebug /out:bin\Debug\net472\GCMC.dll bin\$(Configuration)\net472\GCMC.dll bin\$(Configuration)\net472\INIFileParser.dll" /> <Exec Command="$(ILMergeConsolePath) /ndebug /out:bin\Debug\net472\GCMC.dll bin\$(Configuration)\net472\GCMC.dll bin\$(Configuration)\net472\INIFileParser.dll" />
</Target> </Target> -->
</Project> </Project>

View file

@ -1,23 +1,27 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using GamecraftModdingAPI;
using GamecraftModdingAPI.Blocks;
using GamecraftModdingAPI.Commands;
using IllusionPlugin; using IllusionPlugin;
using Newtonsoft.Json; using Newtonsoft.Json;
using Svelto.Tasks.ExtraLean;
using TechbloxModdingAPI;
using TechbloxModdingAPI.App;
using TechbloxModdingAPI.Blocks;
using TechbloxModdingAPI.Commands;
using TechbloxModdingAPI.Tasks;
using Unity.Mathematics; using Unity.Mathematics;
using UnityEngine; using UnityEngine;
using uREPL; using uREPL;
namespace GCMC namespace GCMC
{ {
public class GCMCPlugin : IPlugin public class GCMCPlugin : IEnhancedPlugin
{ {
public string Name { get; } = Assembly.GetExecutingAssembly().GetName().Name; public override string Name { get; } = Assembly.GetExecutingAssembly().GetName().Name;
public string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version.ToString(); public override string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version.ToString();
private readonly Dictionary<string, BlockType> mapping = new Dictionary<string, BlockType>(10); private readonly Dictionary<string, BlockType> mapping = new Dictionary<string, BlockType>(10);
private JsonSerializer _serializer = JsonSerializer.Create(); private JsonSerializer _serializer = JsonSerializer.Create();
@ -76,7 +80,7 @@ namespace GCMC
{ {
Material = mcblock.ToUpper(), Material = mcblock.ToUpper(),
Type = type, Type = type,
Color = new BlockColor {Color = color, Darkness = darkness} Color = new BlockColor(color, darkness)
}); });
} }
} }
@ -91,6 +95,7 @@ namespace GCMC
}); });
Log.Output("Placing blocks..."); Log.Output("Placing blocks...");
int i; int i;
Block lastBlock = null;
for (i = 0; i < blocksArray.Length; i++) for (i = 0; i < blocksArray.Length; i++)
{ {
var blocks = blocksArray[i]; var blocks = blocksArray[i];
@ -102,11 +107,18 @@ namespace GCMC
if (type.Type == BlockIDs.Invalid) continue; if (type.Type == BlockIDs.Invalid) continue;
Block.PlaceNew(type.Type, (blocks.Start + blocks.End) / 10 * 3, color: type.Color.Color, var block = new Block(type.Type, (blocks.Start + blocks.End) / 10 * 3 + new float3(5000, 0, 5000))
darkness: type.Color.Darkness, scale: (blocks.End - blocks.Start + 1) * 3, {
rotation: float3.zero); Color = type.Color,
//Scale = (blocks.End - blocks.Start + 1) * 3
};
Console.WriteLine("Placed block at " + block.Position);
lastBlock = block;
} }
if (lastBlock != null)
Game.Simulate += (sender, args) => OnSimulationStarted(lastBlock).RunOn(Scheduler.extraLeanRunner);
Log.Output(i + " blocks placed."); Log.Output(i + " blocks placed.");
} }
catch (Exception e) catch (Exception e)
@ -115,35 +127,33 @@ namespace GCMC
Log.Error(e.Message); Log.Error(e.Message);
} }
} }
public void OnApplicationStart() private IEnumerator OnSimulationStarted(Block lastBlock)
{ {
GamecraftModdingAPI.Main.Init(); SimBody body;
int C = 0;
while ((body = lastBlock.GetSimBody()) == null)
{
C++;
yield return null;
}
Console.WriteLine($"Body position: {body.Position} ({C})");
}
public override void OnApplicationStart()
{
TechbloxModdingAPI.Main.Init();
CommandBuilder.Builder("importWorld", "Imports a Minecraft world.") CommandBuilder.Builder("importWorld", "Imports a Minecraft world.")
.Action<string>(ImportWorld).Build(); .Action<string>(ImportWorld).Build();
_serializer.TraceWriter = _traceWriter; //_serializer.TraceWriter = _traceWriter;
Debug.Log("GCMC loaded"); Debug.Log("GCMC loaded");
} }
public void OnApplicationQuit() public override void OnApplicationQuit()
{
}
public void OnLevelWasLoaded(int level)
{
}
public void OnLevelWasInitialized(int level)
{
}
public void OnUpdate()
{
}
public void OnFixedUpdate()
{ {
TechbloxModdingAPI.Main.Shutdown();
} }
} }
} }

Binary file not shown.