proper shovel item
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2025-04-05 16:20:29 -04:00
parent 3338487241
commit ee28d54342
8 changed files with 87 additions and 1 deletions

View File

@ -4,7 +4,8 @@
], ],
"files" : [ "files" : [
"Data/entity/items/weapons.json", "Data/entity/items/weapons.json",
"Data/entity/items/tools.json", "Data/entity/items/debug_tools.json",
"Data/entity/items/hand_tools.json",
"Data/entity/items/clothing.json", "Data/entity/items/clothing.json",
"Data/entity/items/materials.json" "Data/entity/items/materials.json"
] ]

View File

@ -0,0 +1,37 @@
{
"items" : [
{
"id" : "Stone Shovel",
"tokens" : [
"GRAVITY",
"TARGETABLE",
"CURSOR"
],
"equipData": {
"equipClass" : "tool"
},
"graphicsTemplate": {
"model": {
"path" : "Models/items/weapons/shovel1.glb"
}
},
"clientSidePrimary": "DIG",
"collidable": {
"type" : "CUBE",
"dimension1" : 0.1,
"dimension2" : 0.1,
"dimension3" : 0.35,
"rotX": 0,
"rotY": 0,
"rotZ": 0,
"rotW": 1,
"offsetX" : 0,
"offsetY" : 0.05,
"offsetZ" : 0
},
"iconPath" : "Textures/icons/itemIconItemGeneric.png"
}
],
"files" : [
]
}

View File

@ -40,5 +40,11 @@ export const clientHooks: Hook[] = [
callback: (engine: Engine) => { callback: (engine: Engine) => {
engine.classes.voxelUtils.static.spawnWater() engine.classes.voxelUtils.static.spawnWater()
} }
},
{
signal: "DIG",
callback: (engine: Engine) => {
engine.classes.voxelUtils.static.applyEdit()
}
} }
] ]

View File

@ -13,4 +13,9 @@ export interface ClientVoxelUtils {
*/ */
readonly spawnWater: () => void readonly spawnWater: () => void
/**
* Tries to dig with whatever tool is equipped
*/
readonly dig: () => void
} }

View File

@ -1451,6 +1451,7 @@ Static rocks which harvest into rock items that spawn in forest
Stone Axe item Stone Axe item
Fix human data for RH sword slash attack moves Fix human data for RH sword slash attack moves
Cursor only for specific items Cursor only for specific items
Added shovel (works inversely of how you would expect currently)

View File

@ -83,4 +83,27 @@ public class ScriptClientVoxelUtils {
} }
} }
/**
* Tries to dig with whatever tool is equipped
*/
@Export
public static void dig(){
CollisionEngine collisionEngine = Globals.clientSceneWrapper.getCollisionEngine();
Entity camera = Globals.playerCamera;
if(
collisionEngine != null &&
camera != null
){
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(camera));
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(camera));
Vector3d cursorPos = collisionEngine.rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE);
if(cursorPos == null){
cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE));
}
if(Globals.clientSelectedVoxelType != null){
TerrainEditing.removeTerrainGated(cursorPos, 1.1f, Globals.clientSelectedVoxelType.getId(), EDIT_INCREMENT);
}
}
}
} }

View File

@ -66,4 +66,17 @@ public class TerrainEditing {
} }
} }
/**
* Tries to remove terrain with proper game logic checks applied
* @param position The position to perform the edit
* @param editMagnitude The magnitude of the edit to perform
* @param type The type of block to make all edited blocks
* @param weight The weight of the sphere to apply the edit to
*/
public static void removeTerrainGated(Vector3d position, float editMagnitude, int type, float weight){
if(position != null){
Globals.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestUseTerrainPaletteMessage(position.x, position.y, position.z, editMagnitude, weight, type));
}
}
} }