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
0
Merge Requests
0
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
3d98dbfa
Commit
3d98dbfa
authored
Apr 06, 2024
by
Jonathan Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change random name generation to include random letter + random # of syllables
parent
58518b45
Pipeline
#11954
passed with stage
in 21 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
1 deletion
+16
-1
ModInit.java
src/main/java/com/owlmaddie/ModInit.java
+16
-1
No files found.
src/main/java/com/owlmaddie/ModInit.java
View file @
3d98dbfa
...
...
@@ -8,7 +8,6 @@ import net.fabricmc.api.ModInitializer;
import
net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents
;
import
net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents
;
import
net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking
;
import
net.minecraft.entity.Entity
;
import
net.minecraft.entity.mob.MobEntity
;
import
net.minecraft.network.PacketByteBuf
;
import
net.minecraft.server.MinecraftServer
;
...
...
@@ -20,6 +19,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
java.util.Locale
;
import
java.util.Random
;
import
java.util.UUID
;
/**
...
...
@@ -65,6 +65,9 @@ public class ModInit implements ModInitializer {
userMessageBuilder
.
append
(
"Please generate a new character "
);
if
(
entity
.
getCustomName
()
!=
null
)
{
userMessageBuilder
.
append
(
"named '"
).
append
(
entity
.
getCustomName
().
getLiteralString
()).
append
(
"' "
);
}
else
{
userMessageBuilder
.
append
(
"whose name starts with the letter '"
).
append
(
this
.
RandomLetter
()).
append
(
"' "
);
userMessageBuilder
.
append
(
"and which uses "
).
append
(
this
.
RandomNumber
(
4
)
+
1
).
append
(
" syllables "
);
}
userMessageBuilder
.
append
(
"of type '"
).
append
(
entity
.
getType
().
getUntranslatedName
().
toLowerCase
(
Locale
.
ROOT
)).
append
(
"' "
);
userMessageBuilder
.
append
(
"who lives near the "
).
append
(
player_biome
).
append
(
"."
);
...
...
@@ -170,6 +173,18 @@ public class ModInit implements ModInitializer {
LOGGER
.
info
(
"MobGPT Initialized!"
);
}
public
static
String
RandomLetter
()
{
// Return random letter between 'A' and 'Z'
int
randomNumber
=
RandomNumber
(
26
);
return
String
.
valueOf
((
char
)
(
'A'
+
randomNumber
));
}
public
static
int
RandomNumber
(
int
max
)
{
// Generate a random integer between 0 and max (inclusive)
Random
random
=
new
Random
();
return
random
.
nextInt
(
max
);
}
// Send new message to all connected players
public
static
void
BroadcastPacketMessage
(
ChatDataManager
.
EntityChatData
chatData
)
{
for
(
ServerWorld
world
:
serverInstance
.
getWorlds
())
{
...
...
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