Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
CreatureChat
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
Public
CreatureChat
Commits
0317dbdf
Commit
0317dbdf
authored
Apr 07, 2024
by
Jonathan Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update TextureLoader to only log missing textures a single time in teh log.
parent
453e9f1f
Pipeline
#11958
passed with stage
in 21 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
6 deletions
+18
-6
TextureLoader.java
src/client/java/com/owlmaddie/utils/TextureLoader.java
+18
-6
No files found.
src/client/java/com/owlmaddie/utils/TextureLoader.java
View file @
0317dbdf
...
@@ -6,31 +6,33 @@ import net.minecraft.util.Identifier;
...
@@ -6,31 +6,33 @@ import net.minecraft.util.Identifier;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
java.util.HashSet
;
import
java.util.Optional
;
import
java.util.Optional
;
import
java.util.Set
;
/**
/**
* The {@code TextureLoader} class registers and returns texture identifiers for resources
* The {@code TextureLoader} class registers and returns texture identifiers for resources
* contained for this mod. UI and Entity icons.
* contained for this mod. UI and Entity icons.
Missing textures are logged once.
*/
*/
public
class
TextureLoader
{
public
class
TextureLoader
{
public
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
"mobgpt"
);
public
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
"mobgpt"
);
private
static
final
Set
<
String
>
missingTextures
=
new
HashSet
<>();
public
TextureLoader
()
{
public
TextureLoader
()
{
}
}
public
Identifier
GetUI
(
String
name
)
{
public
Identifier
GetUI
(
String
name
)
{
// Attempt to load texture resource
String
texturePath
=
"textures/ui/"
+
name
+
".png"
;
String
texture_path
=
"textures/ui/"
+
name
+
".png"
;
Identifier
textureId
=
new
Identifier
(
"mobgpt"
,
texturePath
);
Identifier
textureId
=
new
Identifier
(
"mobgpt"
,
texture_path
);
Optional
<
Resource
>
resource
=
MinecraftClient
.
getInstance
().
getResourceManager
().
getResource
(
textureId
);
Optional
<
Resource
>
resource
=
MinecraftClient
.
getInstance
().
getResourceManager
().
getResource
(
textureId
);
if
(
!
resource
.
isEmpty
())
{
if
(
resource
.
isPresent
())
{
// Bind texture, and return Identity
// Bind texture, and return Identity
MinecraftClient
.
getInstance
().
getTextureManager
().
bindTexture
(
textureId
);
MinecraftClient
.
getInstance
().
getTextureManager
().
bindTexture
(
textureId
);
return
textureId
;
return
textureId
;
}
else
{
}
else
{
// Resource not found
// Resource not found
LOGGER
.
info
(
texture_path
+
" was not found"
);
logMissingTextureOnce
(
texturePath
);
return
null
;
return
null
;
}
}
}
}
...
@@ -47,7 +49,16 @@ public class TextureLoader {
...
@@ -47,7 +49,16 @@ public class TextureLoader {
// Texture not found, log a message and return the "not_found" texture Identifier
// Texture not found, log a message and return the "not_found" texture Identifier
Identifier
notFoundTextureId
=
new
Identifier
(
"mobgpt"
,
"textures/entity/not_found.png"
);
Identifier
notFoundTextureId
=
new
Identifier
(
"mobgpt"
,
"textures/entity/not_found.png"
);
MinecraftClient
.
getInstance
().
getTextureManager
().
bindTexture
(
notFoundTextureId
);
MinecraftClient
.
getInstance
().
getTextureManager
().
bindTexture
(
notFoundTextureId
);
logMissingTextureOnce
(
texturePath
);
return
notFoundTextureId
;
return
notFoundTextureId
;
}
}
}
}
private
void
logMissingTextureOnce
(
String
texturePath
)
{
// Check if the missing texture has already been logged
if
(!
missingTextures
.
contains
(
texturePath
))
{
LOGGER
.
info
(
texturePath
+
" was not found"
);
missingTextures
.
add
(
texturePath
);
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment