From 3173f1f2e9e2997629c23599f198756995b95beb Mon Sep 17 00:00:00 2001 From: austin Date: Sat, 26 Apr 2025 17:50:37 -0400 Subject: [PATCH] block cursor custom textures --- docs/src/progress/renderertodo.md | 1 + .../client/interact/ClientInteractionEngine.java | 3 ++- .../electrosphere/controls/cursor/CursorState.java | 12 +++++++----- .../engine/assetmanager/AssetDataStrings.java | 1 + .../entity/state/equip/ClientToolbarState.java | 3 ++- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index 93eabf5c..1c9ab5a7 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -1553,6 +1553,7 @@ Align voxel lookups for movement audio and interaction targeting Align block lookups for interaction targeting Cursor logic around blocks Block destruction work +Block cursor custom textures diff --git a/src/main/java/electrosphere/client/interact/ClientInteractionEngine.java b/src/main/java/electrosphere/client/interact/ClientInteractionEngine.java index 9a5320e5..578e87ba 100644 --- a/src/main/java/electrosphere/client/interact/ClientInteractionEngine.java +++ b/src/main/java/electrosphere/client/interact/ClientInteractionEngine.java @@ -20,6 +20,7 @@ import electrosphere.collision.PhysicsUtils; import electrosphere.collision.collidable.Collidable; import electrosphere.controls.cursor.CursorState; import electrosphere.engine.Globals; +import electrosphere.engine.assetmanager.AssetDataStrings; import electrosphere.entity.Entity; import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityUtils; @@ -278,7 +279,7 @@ public class ClientInteractionEngine { short type = blockChunkData.getType(blockPos.x, blockPos.y, blockPos.z); String text = Globals.gameConfigCurrent.getBlockData().getTypeFromId(type).getName(); InteractionTargetMenu.setInteractionTargetString(text); - CursorState.makeBlockVisible(); + CursorState.makeBlockVisible(AssetDataStrings.TEXTURE_RED_TRANSPARENT); Globals.cursorState.hintClampToExistingBlock(); set = true; } diff --git a/src/main/java/electrosphere/controls/cursor/CursorState.java b/src/main/java/electrosphere/controls/cursor/CursorState.java index e40652d0..820ea593 100644 --- a/src/main/java/electrosphere/controls/cursor/CursorState.java +++ b/src/main/java/electrosphere/controls/cursor/CursorState.java @@ -94,7 +94,7 @@ public class CursorState { Globals.playerCursor = EntityCreationUtils.createClientSpatialEntity(); EntityCreationUtils.makeEntityDrawable(Globals.playerCursor, AssetDataStrings.UNITSPHERE); Actor cursorActor = EntityUtils.getActor(Globals.playerCursor); - cursorActor.addTextureMask(new ActorTextureMask("sphere", Arrays.asList(new String[]{"Textures/transparent_red.png"}))); + cursorActor.addTextureMask(new ActorTextureMask("sphere", Arrays.asList(new String[]{AssetDataStrings.TEXTURE_RED_TRANSPARENT}))); DrawableUtils.makeEntityTransparent(Globals.playerCursor); EntityUtils.getScale(Globals.playerCursor).set(0.2f); Globals.clientSceneWrapper.getScene().removeEntityFromTag(Globals.playerCursor, EntityTags.DRAWABLE); @@ -103,7 +103,7 @@ public class CursorState { Globals.playerBlockCursor = EntityCreationUtils.createClientSpatialEntity(); EntityCreationUtils.makeEntityDrawable(Globals.playerBlockCursor, AssetDataStrings.UNITCUBE); Actor blockCursorActor = EntityUtils.getActor(Globals.playerBlockCursor); - blockCursorActor.addTextureMask(new ActorTextureMask("cube", Arrays.asList(new String[]{"Textures/transparent_red.png"}))); + blockCursorActor.addTextureMask(new ActorTextureMask("cube", Arrays.asList(new String[]{AssetDataStrings.TEXTURE_RED_TRANSPARENT}))); DrawableUtils.makeEntityTransparent(Globals.playerBlockCursor); EntityUtils.getScale(Globals.playerBlockCursor).set(BLOCK_CURSOR_SCALE_MULTIPLIER); Globals.clientSceneWrapper.getScene().removeEntityFromTag(Globals.playerBlockCursor, EntityTags.DRAWABLE); @@ -112,7 +112,7 @@ public class CursorState { Globals.playerAreaCursor = EntityCreationUtils.createClientSpatialEntity(); EntityCreationUtils.makeEntityDrawable(Globals.playerAreaCursor, AssetDataStrings.UNITCUBE); Actor areaCursorActor = EntityUtils.getActor(Globals.playerAreaCursor); - areaCursorActor.addTextureMask(new ActorTextureMask("cube", Arrays.asList(new String[]{"Textures/transparent_red.png"}))); + areaCursorActor.addTextureMask(new ActorTextureMask("cube", Arrays.asList(new String[]{AssetDataStrings.TEXTURE_RED_TRANSPARENT}))); DrawableUtils.makeEntityTransparent(Globals.playerAreaCursor); EntityUtils.getScale(Globals.playerAreaCursor).set(BLOCK_CURSOR_SCALE_MULTIPLIER); Globals.clientSceneWrapper.getScene().removeEntityFromTag(Globals.playerAreaCursor, EntityTags.DRAWABLE); @@ -121,7 +121,7 @@ public class CursorState { playerFabCursor = EntityCreationUtils.createClientSpatialEntity(); EntityCreationUtils.makeEntityDrawable(playerFabCursor, AssetDataStrings.UNITCUBE); Actor fabCursorActor = EntityUtils.getActor(playerFabCursor); - fabCursorActor.addTextureMask(new ActorTextureMask("cube", Arrays.asList(new String[]{"Textures/transparent_red.png"}))); + fabCursorActor.addTextureMask(new ActorTextureMask("cube", Arrays.asList(new String[]{AssetDataStrings.TEXTURE_RED_TRANSPARENT}))); DrawableUtils.makeEntityTransparent(playerFabCursor); Globals.clientSceneWrapper.getScene().removeEntityFromTag(playerFabCursor, EntityTags.DRAWABLE); } @@ -166,8 +166,10 @@ public class CursorState { /** * Makes the block position cursor visible */ - public static void makeBlockVisible(){ + public static void makeBlockVisible(String texture){ CursorState.hide(); + Actor blockCursorActor = EntityUtils.getActor(Globals.playerBlockCursor); + blockCursorActor.addTextureMask(new ActorTextureMask("cube", Arrays.asList(new String[]{texture}))); Globals.clientSceneWrapper.getScene().registerEntityToTag(Globals.playerBlockCursor, EntityTags.DRAWABLE); } diff --git a/src/main/java/electrosphere/engine/assetmanager/AssetDataStrings.java b/src/main/java/electrosphere/engine/assetmanager/AssetDataStrings.java index 08313ffc..07789589 100644 --- a/src/main/java/electrosphere/engine/assetmanager/AssetDataStrings.java +++ b/src/main/java/electrosphere/engine/assetmanager/AssetDataStrings.java @@ -32,6 +32,7 @@ public class AssetDataStrings { * Fundamental textures of the engine */ public static final String TEXTURE_TEAL_TRANSPARENT = "Textures/color/transparent_teal.png"; + public static final String TEXTURE_RED_TRANSPARENT = "Textures/transparent_red.png"; public static final String TEXTURE_DEFAULT = "Textures/color/Testing1.png"; /** diff --git a/src/main/java/electrosphere/entity/state/equip/ClientToolbarState.java b/src/main/java/electrosphere/entity/state/equip/ClientToolbarState.java index 7c8df681..75082dbb 100644 --- a/src/main/java/electrosphere/entity/state/equip/ClientToolbarState.java +++ b/src/main/java/electrosphere/entity/state/equip/ClientToolbarState.java @@ -20,6 +20,7 @@ import java.util.List; import electrosphere.collision.PhysicsEntityUtils; import electrosphere.controls.cursor.CursorState; import electrosphere.engine.Globals; +import electrosphere.engine.assetmanager.AssetDataStrings; import electrosphere.entity.ClientEntityUtils; import electrosphere.entity.Entity; import electrosphere.entity.EntityCreationUtils; @@ -183,7 +184,7 @@ public class ClientToolbarState implements BehaviorTree { CursorState.makeRealVisible(); } else if(itemData.getTokens().contains(CursorState.CURSOR_BLOCK_TOKEN)) { Globals.cursorState.setClampToExistingBlock(true); - CursorState.makeBlockVisible(); + CursorState.makeBlockVisible(AssetDataStrings.TEXTURE_RED_TRANSPARENT); } } }