-
Notifications
You must be signed in to change notification settings - Fork 0
Deployment & Test Environment
This project was designed to be as deployable as possible and to be ready to go right out of the box! That being said, it's important you pay close attention and change the following entries within the WorldEdit.cs class to work around your game or project.
- For the purpose of this test environment, editing these variables is not needed.
| WorldHeights: |
|---|
Two integer values defining the bottom and top Y positions of your world. |
Example: = (-64, 64) The worlds bottom Y value is -64, while the worlds top Y value is 64. |
| ItemIDValues: |
|---|
Two integer values defining the Minimum and Maximum block ids of your game or project. |
Example: = (0, 93) The minimum block id is 0, while the max id is 93. |
| ChunkSize: |
|---|
Two integer values defining the Size or, WidthX & LengthZ, of world chunks. |
Example: = (24, 24) The chunk size is X=24 and Z=24. (Most games keep these equal). |
| AirID: |
|---|
An integer value defining the games Air ID. |
Example: AirID = 0 The games ID for air or empty blocks would be 0. |
| LogID: |
|---|
An integer value defining the games Log ID. |
Example: LogID = 17 The games ID for log blocks would be 17. |
| LeavesID: |
|---|
An integer value defining the games Leaves ID. |
Example: LeavesID = 18 The games ID for leave blocks would be 18. |
| WandItemID: |
|---|
An integer value defining the Wand item ID. |
Example: WandItemID = 39 The wand item ID would be 39 (Compass). |
| IsNetworkSessionActive(): |
|---|
| A boolean value defining whether the current game session is active or not. |
Example: DNA.CastleMinerZ.CastleMinerZGame.Instance.CurrentNetworkSession CastleMinerZ's interpretation. |
| GetUsersCursorLocation(): |
|---|
| A vector3 value defining the games cursor location. This is the in reach block location the user can interact with. |
Example: DNA.CastleMinerZ.UI.InGameHUD.Instance.ConstructionProbe._worldIndex CastleMinerZ's interpretation. |
| GetUsersLocation(): |
|---|
| A vector3 value defining the users location. |
Example: DNA.CastleMinerZ.CastleMinerZGame.Instance.LocalPlayer.LocalPosition CastleMinerZ's interpretation. |
| GetUsersHeldItem(): |
|---|
| An integer value defining the currently held item from the user. |
Example: DNA.CastleMinerZ.CastleMinerZGame.Instance.LocalPlayer.PlayerInventory.ActiveInventoryItem.ItemClass.ID CastleMinerZ's interpretation. |
| GetBlockFromLocation(): |
|---|
| A returned integer value of the block ID from a specified vector3 (XYZ) location. |
Example: DNA.CastleMinerZ.UI.InGameHUD.GetBlock(new DNA.IntVector3(x, y, z)) CastleMinerZ's interpretation. |
| PlaceBlock(): |
|---|
| A method for placing a block ID at a specified vector3 (XYZ) location. |
Example: DNA.CastleMinerZ.Net.AlterBlockMessage.Send(player, location, blockID) CastleMinerZ's interpretation. |
| DropItem(): |
|---|
| A method for dropping an item ID at a specified vector3 (XYZ) location. |
Example: DNA.CastleMinerZ.PickupManager.Instance.CreatePickup(CreateItem(item, 1), location, true, false) CastleMinerZ's interpretation. |
| TeleportUser(): |
|---|
| A method for teleporting the user to a specified vector3 (XYZ) location. |
Example: DNA.CastleMinerZ.CastleMinerZGame.Instance.GameScreen.TeleportToLocation(location, spawnOnTop) CastleMinerZ's interpretation. |
The reason CastleMinerZ was used for this test environment was due a couple of key reasons.
- The first most and also simple reason being the game is extremely lightweight, being only the size of many modern dlls.
- Secondly, the game is built 100% in XNA .NET Framework. This means the entire games code is un-obfuscated and can be edited entirely in a CSharp decompiler such as DnSpy.
By by no means is this post aimed at promoting "modding" or "hacking" to where the online player experiences are effected. This post is rather providing information aimed at giving mod developers, contributors, and enthusiasts of WorldEdit-CSharp an easier environment to test their work and experiment with the project.
- You need to first own the game CastleMinerZ on Steam.
- Download the projects Source Code.
- Download DnSpy.
- Launch DnSpy and open the games executable. (
File > Open)- Games Default Location:_
C:\Program Files (x86)\Steam\steamapps\common\CastleMiner Z
- Games Default Location:_
- Navigate to
CastleMinerZ > DNA.CastleMinerZ.UI > PlainChatInputScreen > _textEditControl_EnterPressed - Right click the code and click Edit Method.
- Paste in all of the contents from
WE_Example.cs. - Click the green
C#(Add Source Code) button from the bottom and uploadWorldEdit.cs. - Remove the following code from the bottom of the window and click compile.
/// <summary>
/// REMOVE THIS IN TESTING!
/// </summary>
// Add constructors to evade compiling errors.
private readonly CastleMinerZGame _game = CastleMinerZGame.Instance;
public TextEditControl _textEditControl = new TextEditControl();
public PlainChatInputScreen(bool drawBehind) : base(drawBehind)
{
}
/// <summary>
/// END OF REMOVAL.
/// </summary>- Finally click the save all icon from the top (or
File > Save All) and click 'ok'.

When you make changes to the source code and wish to reupload it into the game, you can either restore a copy of the games executable, or simply click the undo button once within DnSpy (or use ctrl+z).

Block IDs
0 = Empty
1 = Dirt
2 = Grass
3 = Sand
4 = Lantern
5 = FixedLantern
6 = Rock
7 = GoldOre
8 = IronOre
9 = CopperOre
10 = CoalOre
11 = DiamondOre
12 = SurfaceLava
13 = DeepLava
14 = Bedrock
15 = Snow
16 = Ice
17 = Log
18 = Leaves
19 = Wood
20 = BloodStone
21 = SpaceRock
22 = IronWall
23 = CopperWall
24 = GoldenWall
25 = DiamondWall
26 = Torch
27 = TorchPOSX
28 = TorchNEGZ
29 = TorchNEGX
30 = TorchPOSZ
31 = TorchPOSY
32 = TorchNEGY
33 = Crate
34 = NormalLowerDoorClosedZ
35 = NormalLowerDoorClosedX
36 = NormalLowerDoor
37 = NormalUpperDoorClosed
38 = NormalLowerDoorOpenZ
39 = NormalLowerDoorOpenX
40 = NormalUpperDoorOpen
41 = TNT
42 = C4
43 = Slime
44 = SpaceRockInventory
45 = GlassBasic
46 = GlassIron
47 = GlassStrong
48 = GlassMystery
49 = CrateStone
50 = CrateCopper
51 = CrateIron
52 = CrateGold
53 = CrateDiamond
54 = CrateBloodstone
55 = CrateSafe
56 = SpawnPointBasic
57 = SpawnPointBuilder
58 = SpawnPointCombat
59 = SpawnPointExplorer
60 = StrongLowerDoorClosedZ
61 = StrongLowerDoorClosedX
62 = StrongLowerDoor
63 = StrongUpperDoorClosed
64 = StrongLowerDoorOpenZ
65 = StrongLowerDoorOpenX
66 = StrongUpperDoorOpen
67 = LanternFancy
68 = TurretBlock
69 = LootBlock
70 = LuckyLootBlock
71 = BombBlock
72 = EnemySpawnOn
73 = EnemySpawnOff
74 = EnemySpawnRareOn
75 = EnemySpawnRareOff
76 = EnemySpawnAltar
77 = TeleportStation
78 = CraftingStation
79 = HellForge
80 = AlienSpawnOn
81 = AlienSpawnOff
82 = HellSpawnOn
83 = HellSpawnOff
84 = BossSpawnOn
85 = BossSpawnOff
86 = EnemySpawnDim
87 = EnemySpawnRareDim
88 = AlienSpawnDim
89 = HellSpawnDim
90 = BossSpawnDim
91 = AlienHordeOn
92 = AlienHordeOff
93 = AlienHordeDim
94 = NumberOfBlocksSince CastleMinerZ is a 32-bit process, the max memory the game will reference (use) is 2GB. For 64-bit users, you can actually force the process to reference up to 4GB (or 3GB on a 32-bit OS with /3GB enabled) by enabling a flag within the games header file. You cannot go beyond 4GB however since 2^32 is the max byte capacity for 32-bits. To do this you would have to compile the game as 64-bits.
Quick Guide:
- Put your games executable in DnSpy.
- Navigate to PE (portable executable).
- Click the File Header.
- Find the Large Address Aware flag and check it.
- Finally click the save all icon from the top (or
File > Save All) and click 'ok'.
Below are some Tweaks that are aimed at making testing and developing much easier.
| Enable the chat in offline games: | |
|---|---|
| Action: | Remove if statement parameters else if (this._game.IsOnlineGame && !this.IsChatting && controllerMapping.TextChat.Released)
|
| Location: | DNA.CastleMinerZ.UI.InGameHUD.OnPlayerInput() |
| Remove: | this._game.IsOnlineGame && |
| Increase placement range: | |
|---|---|
| Action: | Change float value from 5 -> 420 (any range you want) |
| Location: | DNA.CastleMinerZ.UI.InGameHUD.DoConstructionModeUpdate() |
| Example: | See below: |
this.ConstructionProbe.Init(translation, Vector3.Add(translation, Vector3.Multiply(localToWorld.Forward, 420f)), this.PlayerInventory.ActiveInventoryItem.ItemClass.IsMeleeWeapon);| Display the targeted block name and id: | |
|---|---|
| Action: | Replace if statement contents: if (this.ConstructionProbe.AbleToBuild && this.PlayerInventory.ActiveInventoryItem != null)
|
| Location: | DNA.CastleMinerZ.UI.InGameHUD.OnDraw() |
| Code: | See below: |
DNA.CastleMinerZ.Terrain.BlockType blockType = DNA.CastleMinerZ.Terrain.BlockType.GetType(InGameHUD.GetBlock(this.ConstructionProbe._worldIndex));
spriteBatch.DrawString(this._game._medFont, blockType.Name + " (" + ((int)blockType._type).ToString() + ")", new Vector2((float)rectangle.Right - (this._game._medFont.MeasureString(blockType.Name).X + 45f) * Screen.Adjuster.ScaleFactor.Y, (float)(this._game._medFont.LineSpacing * 4) * Screen.Adjuster.ScaleFactor.Y), CMZColors.MenuAqua * 0.75f, 0f, Vector2.Zero, Screen.Adjuster.ScaleFactor.Y, SpriteEffects.None, 0f);These are some tools that where used for the showcasing of WorldEdit. These commands are more then likely obsolete for your testing purposes and can be removed from your environment.
Commands:
| /cc | |
|---|---|
| Description | Clears the chat. |
| Usage | /cc |
| /brightness | |
|---|---|
| Description | Change the brightness. |
| Usage | /brightness [amount] |
[amount] |
The level of brightness to apply. Use '1' for default. |
/brightness Dependencies
Allow for full brightness: Action: Remove a line within the RefreshPlayer()method.Location: DNA.CastleMinerZ.UI.InGameHUD.RefreshPlayer()Remove: this.PlayerHealth = 1f;
Optional:
Make blocks full brightness: Action: Change the bool this.DrawFullBright = fullBright;tothis.DrawFullBright = true;.Action 2: Do this for all three incidences of BlockType().Location: DNA.CastleMinerZ.Terrain.BlockType.BlockType();
Only used in external plugin deployments.
/fullbright Description Force all tiles to use the max light level. Usage /fullbright
| /teleport (or /tp) | |
|---|---|
| Description | Teleport the player to a new position. |
| Usage | /tp [x] [y] [z] |
[x] [y] [z] |
The new XYZ location to send the player. |
| /time | |
|---|---|
| Description | Change the worlds time. |
| Usage | /time [time] |
[time] |
The time to set. Use 0-100 for time of day. |
| /toggleui | |
|---|---|
| Description | Toggles the HUD and UI visibility. |
| Usage | /toggleui |
/toggleui Dependencies
Allow for toggle HUD and UI: Action: Change a bool field from private bool _hideUItopublic static bool _hideUI.Location: DNA.CastleMinerZ.UI.InGameHUD._hideUI
Allow for toggle HUD and UI: Action: Add code to the first line of a function. Location: DNA.CastleMinerZ.UI.InGameHUD.DoConstructionModeUpdate()Add: if (DNA.CastleMinerZ.UI.InGameHUD._hideUI) return;