Compare commits

..

No commits in common. "master" and "v1.0" have entirely different histories.
master ... v1.0

6 changed files with 83 additions and 122 deletions

View file

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

View file

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

View file

@ -6,69 +6,69 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ILMerge" Version="3.0.41" />
<PackageReference Include="ILMerge" Version="3.0.29" />
<PackageReference Include="ini-parser" Version="2.5.2" />
<PackageReference Include="Lib.Harmony" Version="2.0.4" />
<PackageReference Include="Lib.Harmony" Version="2.0.1" />
</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">
<HintPath>..\..\ref\TechbloxPreview_Data\Managed\CommandLine.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\CommandLine.dll</HintPath>
</Reference>
<Reference Include="DataLoader, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\TechbloxPreview_Data\Managed\DataLoader.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\DataLoader.dll</HintPath>
</Reference>
<Reference Include="Svelto.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\TechbloxPreview_Data\Managed\Svelto.Common.dll</HintPath>
<Reference Include="GamecraftModdingAPI">
<HintPath>..\..\GamecraftModdingAPI\GamecraftModdingAPI\bin\Debug\net472\GamecraftModdingAPI.dll</HintPath>
</Reference>
<Reference Include="Svelto.Tasks, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<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>
<Reference Include="IllusionPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>IllusionPlugin.dll</HintPath>
<!-- <Private>False</Private> Need to copy for ILMerge -->
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\ref\TechbloxPreview_Data\Managed\Newtonsoft.Json.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.Blocks, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Blocks.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.Blocks.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.Character, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Character.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.Character.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Common.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.Common.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.GUI, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.Input, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Input.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.Input.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.MachineEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.MachineEditor.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\RobocraftX.MachineEditor.dll</HintPath>
</Reference>
<Reference Include="RobocraftX.StateSync, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.StateSync.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_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 Include="Svelto.ECS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\TechbloxPreview_Data\Managed\Svelto.ECS.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\Svelto.ECS.dll</HintPath>
</Reference>
<Reference Include="Unity.Entities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\TechbloxPreview_Data\Managed\Unity.Entities.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\Unity.Entities.dll</HintPath>
</Reference>
<Reference Include="Unity.Mathematics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\TechbloxPreview_Data\Managed\Unity.Mathematics.dll</HintPath>
<Reference Include="Unity.Mathematics, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\Gamecraft_Data\Managed\Unity.Mathematics.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="uREPL, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\..\ref\TechbloxPreview_Data\Managed\uREPL.dll</HintPath>
<HintPath>..\..\ref\Gamecraft_Data\Managed\uREPL.dll</HintPath>
</Reference>
</ItemGroup>
@ -79,13 +79,9 @@
</ItemGroup>
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
<!-- <Target Name="AfterBuild">
<!- the ILMergePath property points to the location of ILMerge.exe console application ->
<Target Name="AfterBuild">
<!-- 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" />
</Target> -->
<Target Name="CopyToPlugins" AfterTargets="AfterBuild">
<Copy SourceFiles="$(MSBuildProjectDirectory)\$(OutputPath)\GCMC.dll" DestinationFolder="$(MSBuildProjectDirectory)\..\..\ref\Plugins" />
</Target>
</Project>

View file

@ -1,34 +1,26 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using GamecraftModdingAPI;
using GamecraftModdingAPI.Blocks;
using GamecraftModdingAPI.Commands;
using IllusionPlugin;
using Newtonsoft.Json;
using Svelto.Tasks;
using Svelto.Tasks.ExtraLean;
using TechbloxModdingAPI;
using TechbloxModdingAPI.App;
using TechbloxModdingAPI.Blocks;
using TechbloxModdingAPI.Commands;
using TechbloxModdingAPI.Tasks;
using TechbloxModdingAPI.Utility;
using Unity.Mathematics;
using UnityEngine;
using uREPL;
namespace GCMC
{
public class GCMCPlugin : IEnhancedPlugin
public class GCMCPlugin : IPlugin
{
public override string Name { get; } = Assembly.GetExecutingAssembly().GetName().Name;
public override string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version.ToString();
public string Name { get; } = "GCMC";
public string Version { get; } = "v0.0.1";
private readonly Dictionary<string, BlockType> _mapping = new Dictionary<string, BlockType>(10);
private readonly List<(Block, SimBody, float3)> _simulationBlocks = new List<(Block, SimBody, float3)>();
private readonly JsonSerializer _serializer = JsonSerializer.Create();
private readonly JsonTraceWriter _traceWriter = new JsonTraceWriter();
private readonly Dictionary<string, BlockType> mapping = new Dictionary<string, BlockType>(10);
private JsonSerializer _serializer = JsonSerializer.Create();
private JsonTraceWriter _traceWriter = new JsonTraceWriter();
private async void ImportWorld(string name)
{
@ -37,7 +29,7 @@ namespace GCMC
Log.Output("Reading block mappings...");
var parser = new IniParser.FileIniDataParser();
var ini = parser.ReadFile("BlockTypes.ini");
_mapping.Clear();
mapping.Clear();
foreach (var section in ini.Sections)
{
var mcblocks = section.SectionName.Split(',');
@ -79,11 +71,11 @@ namespace GCMC
foreach (var mcblock in mcblocks)
{
_mapping.Add(mcblock.ToUpper(), new BlockType
mapping.Add(mcblock.ToUpper(), new BlockType
{
Material = mcblock.ToUpper(),
Type = type,
Color = new BlockColor(color, darkness)
Color = new BlockColor {Color = color, Darkness = darkness}
});
}
}
@ -101,7 +93,7 @@ namespace GCMC
for (i = 0; i < blocksArray.Length; i++)
{
var blocks = blocksArray[i];
if (!_mapping.TryGetValue(blocks.Material, out var type))
if (!mapping.TryGetValue(blocks.Material, out var type))
{
Console.WriteLine("Unknown block: " + blocks.Material);
continue;
@ -109,15 +101,10 @@ namespace GCMC
if (type.Type == BlockIDs.Invalid) continue;
var block = new Block(type.Type, (blocks.Start + blocks.End) / 10 * 3 + new float3(5000, 0, 5000))
{
Color = type.Color,
Scale = (blocks.End - blocks.Start + 1) * 3,
//Static = true - Doesn't seem to work
};
_simulationBlocks.Add((block, null, default));
Block.PlaceNew(type.Type, (blocks.Start + blocks.End) / 10 * 3, color: type.Color.Color,
darkness: type.Color.Darkness, scale: (blocks.End - blocks.Start + 1) * 3,
rotation: float3.zero);
}
Game.Simulate += GameOnSimulate;
Log.Output(i + " blocks placed.");
}
@ -127,52 +114,35 @@ namespace GCMC
Log.Error(e.Message);
}
}
private void GameOnSimulate(object sender, GameEventArgs e)
public void OnApplicationStart()
{
Game.Simulate -= GameOnSimulate;
GameWhileSimulating().RunOn(Scheduler.extraLeanRunner);
}
private IEnumerator GameWhileSimulating()
{
while (!GameState.IsSimulationMode())
yield return Yield.It;
for (var i = 0; i < _simulationBlocks.Count; i++)
{
var (block, body, _) = _simulationBlocks[i];
if (body is null) body = block.GetSimBody();
_simulationBlocks[i] = (block, body, body.Position);
}
while (GameState.IsSimulationMode())
{
foreach (var (_, body, pos) in _simulationBlocks)
{
body.Velocity = 0;
body.AngularVelocity = 0;
body.Position = pos;
body.Rotation = float3.zero;
}
yield return Yield.It;
}
}
public override void OnApplicationStart()
{
TechbloxModdingAPI.Main.Init();
GamecraftModdingAPI.Main.Init();
CommandBuilder.Builder("importWorld", "Imports a Minecraft world.")
.Action<string>(ImportWorld).Build();
//_serializer.TraceWriter = _traceWriter;
_serializer.TraceWriter = _traceWriter;
Debug.Log("GCMC loaded");
}
public override void OnApplicationQuit()
public void OnApplicationQuit()
{
}
public void OnLevelWasLoaded(int level)
{
}
public void OnLevelWasInitialized(int level)
{
}
public void OnUpdate()
{
}
public void OnFixedUpdate()
{
TechbloxModdingAPI.Main.Shutdown();
}
}
}

BIN
GCMC/IllusionPlugin.dll Normal file

Binary file not shown.

View file

@ -1,18 +1,18 @@
# TBMC
# GCMC
Minecraft world importer for Techblox.
Minecraft world importer for Gamecraft.
## Usage
You'll need a Bukkit/Spigot/Paper server first. Download the Bukkit plugin from [releases](https://git.exmods.org/NorbiPeti/GCMC/releases) and put it in the server's plugins directory.
Then run `/export <x1> <y1> <z1> <x2> <y2> <z2>` on the server with the starting and ending coordinates of the area you want to export.
Make sure to not select a large area as it can make Techblox lag.
Make sure to not select a large area as it can make Gamecraft lag.
After that, copy the `result.json` from the server folder into Techblox's folder.
Then, using the Techblox mod, do `importWorld "result.json"` in the GC console (opened by pressing the button near right shift by default) to import the Minecraft blocks.
After that, copy the `result.json` from the server folder into Gamecraft's folder.
Then, using the Gamecraft mod, do `importWorld "result.json"` in the GC console (opened by pressing the button near right shift by default) to import the Minecraft blocks.
It can take a while to load the file and place the blocks, depending on how many are there to place.
Open the game log (and scroll to the end) to see the blocks that the mod doesn't know how to place in GC. You can add block mappings to the BlockTypes.ini file in Techblox's folder following the format (Minecraft block goes in brackets, the rest are Techblox block settings, color darkness goes 0-9).
Open the game log (and scroll to the end) to see the blocks that the mod doesn't know how to place in GC. You can add block mappings to the BlockTypes.ini file in Gamecraft's folder following the format (Minecraft block goes in brackets, the rest are Gamecraft block settings, color darkness goes 0-9).
If you're up to contributing to this mod, please send this file to me (NorbiPeti) after adding more block types.
I have big plans for this project. One day...