Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
MythicCraft
MEG MoLang Extension
Commits
2ff9eb39
Commit
2ff9eb39
authored
2 years ago
by
Ticxo
Browse files
Options
Download
Email Patches
Plain Diff
lol done
parent
9d3c8a5d
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
195 additions
and
4 deletions
+195
-4
pom.xml
pom.xml
+37
-3
src/main/java/com/ticxo/megml/MegML.java
src/main/java/com/ticxo/megml/MegML.java
+16
-0
src/main/java/com/ticxo/megml/ModelQuery.java
src/main/java/com/ticxo/megml/ModelQuery.java
+59
-0
src/main/java/com/ticxo/megml/QueryData.java
src/main/java/com/ticxo/megml/QueryData.java
+29
-0
src/main/java/com/ticxo/megml/RuntimeManager.java
src/main/java/com/ticxo/megml/RuntimeManager.java
+32
-0
src/main/resources/plugin.yml
src/main/resources/plugin.yml
+1
-1
target/classes/plugin.yml
target/classes/plugin.yml
+7
-0
target/maven-archiver/pom.properties
target/maven-archiver/pom.properties
+5
-0
target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
...-compiler-plugin/compile/default-compile/createdFiles.lst
+5
-0
target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
...en-compiler-plugin/compile/default-compile/inputFiles.lst
+4
-0
target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
...ler-plugin/testCompile/default-testCompile/inputFiles.lst
+0
-0
No files found.
pom.xml
View file @
2ff9eb39
...
...
@@ -6,16 +6,50 @@
<groupId>
com.ticxo.megmolang
</groupId>
<artifactId>
Meg-Molang
</artifactId>
<version>
1.0
-SNAPSHOT
</version>
<version>
R
1.0
.0
</version>
<properties>
<project.version>
R1.0.0
</project.version>
<maven.compiler.source>
16
</maven.compiler.source>
<maven.compiler.target>
16
</maven.compiler.target>
</properties>
<build>
<finalName>
Model-Engine-${project.version}
</finalName>
<finalName>
MEG-MoLang-Extension-${version}
</finalName>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
3.8.0
</version>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-shade-plugin
</artifactId>
<version>
3.3.1-SNAPSHOT
</version>
<executions>
<execution>
<phase>
package
</phase>
<goals>
<goal>
shade
</goal>
</goals>
<configuration>
<minimizeJar>
true
</minimizeJar>
<createDependencyReducedPom>
false
</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-jar-plugin
</artifactId>
<version>
2.3.2
</version>
</plugin>
</plugins>
<resources>
<resource>
<directory>
src/main/resources
</directory>
<filtering>
true
</filtering>
</resource>
</resources>
</build>
<repositories>
...
...
This diff is collapsed.
Click to expand it.
src/main/java/com/ticxo/megml/MegML.java
View file @
2ff9eb39
package
com.ticxo.megml
;
import
com.bedrockk.molang.MoLang
;
import
com.ticxo.modelengine.api.ModelEngineAPI
;
import
com.ticxo.modelengine.api.animation.keyframe.IKeyframeData
;
import
org.bukkit.plugin.java.JavaPlugin
;
public
class
MegML
extends
JavaPlugin
{
private
static
MegML
instance
;
private
RuntimeManager
manager
;
@Override
public
void
onEnable
()
{
instance
=
this
;
manager
=
new
RuntimeManager
();
manager
.
runTaskTimerAsynchronously
(
this
,
0
,
200
);
ModelEngineAPI
.
getKeyframeReaderRegistry
().
register
(
"molang"
,
MegML:
:
parse
);
}
@Override
...
...
@@ -14,4 +26,8 @@ public class MegML extends JavaPlugin {
}
public
static
IKeyframeData
parse
(
String
data
)
{
return
new
QueryData
(
instance
.
manager
,
MoLang
.
parse
(
data
));
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/ticxo/megml/
query/
ModelQuery.java
→
src/main/java/com/ticxo/megml/ModelQuery.java
View file @
2ff9eb39
package
com.ticxo.megml
.query
;
package
com.ticxo.megml
;
import
com.bedrockk.molang.runtime.MoParams
;
import
com.ticxo.modelengine.api.animation.AnimationProperty
;
...
...
@@ -21,21 +21,26 @@ public class ModelQuery {
public
static
final
Map
<
String
,
BiFunction
<
MoParams
,
AnimationProperty
,
Object
>>
MODEL_QUERY
=
new
HashMap
<>()
{
{
put
(
"anim_time"
,
(
params
,
property
)
->
property
.
getTime
());
put
(
"body_y_rotation"
,
(
params
,
property
)
->
getBase
(
property
).
getYBodyRot
());
put
(
"count"
,
(
params
,
property
)
->
params
.
getParams
().
size
());
put
(
"head_x_rotation"
,
(
params
,
property
)
->
getBase
(
property
).
getXHeadRot
());
put
(
"head_y_rotation"
,
(
params
,
property
)
->
getBase
(
property
).
getYHeadRot
());
put
(
"is_on_ground"
,
(
params
,
property
)
->
livingOrZero
(
property
,
living
->
living
.
isOnGround
()
?
1
:
0
));
put
(
"is_in_water"
,
(
params
,
property
)
->
livingOrZero
(
property
,
living
->
living
.
isInWater
()
?
1
:
0
));
put
(
"health"
,
(
params
,
property
)
->
livingOrZero
(
property
,
Damageable:
:
getHealth
));
put
(
"max_health"
,
(
params
,
property
)
->
livingOrZero
(
property
,
living
->
living
.
getAttribute
(
Attribute
.
GENERIC_MAX_HEALTH
).
getValue
()
));
put
(
"is_on_fire"
,
(
params
,
property
)
->
livingOrZero
(
property
,
living
->
Math
.
min
(
1
,
living
.
getFireTicks
())));
put
(
"on_fire_time"
,
(
params
,
property
)
->
livingOrZero
(
property
,
Entity:
:
getMaxFireTicks
));
put
(
"ground_speed"
,
(
params
,
property
)
->
getModel
(
property
).
getMoveController
().
getVelocity
().
distance
(
ZERO
)
*
20
);
put
(
"anim_time"
,
(
params
,
property
)
->
property
.
getTime
());
put
(
"body_y_rotation"
,
(
params
,
property
)
->
getBase
(
property
).
getYBodyRot
());
put
(
"count"
,
(
params
,
property
)
->
params
.
getParams
().
size
());
put
(
"head_x_rotation"
,
(
params
,
property
)
->
getBase
(
property
).
getXHeadRot
());
put
(
"head_y_rotation"
,
(
params
,
property
)
->
getBase
(
property
).
getYHeadRot
());
put
(
"is_on_ground"
,
(
params
,
property
)
->
livingOrZero
(
property
,
living
->
living
.
isOnGround
()
?
1
:
0
));
put
(
"is_in_water"
,
(
params
,
property
)
->
livingOrZero
(
property
,
living
->
living
.
isInWater
()
?
1
:
0
));
put
(
"health"
,
(
params
,
property
)
->
livingOrZero
(
property
,
Damageable:
:
getHealth
));
put
(
"max_health"
,
(
params
,
property
)
->
livingOrZero
(
property
,
ModelQuery:
:
getMaxHealth
));
put
(
"is_on_fire"
,
(
params
,
property
)
->
livingOrZero
(
property
,
living
->
Math
.
min
(
1
,
living
.
getFireTicks
())));
put
(
"on_fire_time"
,
(
params
,
property
)
->
livingOrZero
(
property
,
Entity:
:
getMaxFireTicks
));
put
(
"ground_speed"
,
(
params
,
property
)
->
getModel
(
property
).
getMoveController
().
getVelocity
().
distance
(
ZERO
)
*
20
);
}
};
private
static
double
getMaxHealth
(
LivingEntity
living
)
{
var
attr
=
living
.
getAttribute
(
Attribute
.
GENERIC_MAX_HEALTH
);
return
attr
==
null
?
0
:
attr
.
getValue
();
}
private
static
Object
livingOrZero
(
AnimationProperty
property
,
Function
<
LivingEntity
,
Object
>
function
)
{
if
(
getBase
(
property
).
getOriginal
()
instanceof
LivingEntity
living
)
{
return
function
.
apply
(
living
);
...
...
@@ -48,7 +53,7 @@ public class ModelQuery {
}
private
static
ModeledEntity
getModel
(
AnimationProperty
property
)
{
return
property
.
getModel
();
return
property
.
getModel
()
.
getModeledEntity
()
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/ticxo/megml/QueryData.java
0 → 100644
View file @
2ff9eb39
package
com.ticxo.megml
;
import
com.bedrockk.molang.Expression
;
import
com.ticxo.modelengine.api.animation.AnimationProperty
;
import
com.ticxo.modelengine.api.animation.keyframe.IKeyframeData
;
import
lombok.RequiredArgsConstructor
;
import
java.util.List
;
@RequiredArgsConstructor
public
class
QueryData
implements
IKeyframeData
{
private
final
RuntimeManager
manager
;
private
final
List
<
Expression
>
script
;
@Override
public
double
getValue
(
AnimationProperty
property
)
{
var
runtime
=
manager
.
getOrCreateRuntime
(
property
);
try
{
var
value
=
runtime
.
execute
(
script
);
if
(
value
!=
null
)
return
value
.
asDouble
();
}
catch
(
Throwable
e
)
{
e
.
printStackTrace
();
}
return
0
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/ticxo/megml/RuntimeManager.java
0 → 100644
View file @
2ff9eb39
package
com.ticxo.megml
;
import
com.bedrockk.molang.MoLang
;
import
com.bedrockk.molang.runtime.MoLangRuntime
;
import
com.bedrockk.molang.runtime.struct.QueryStruct
;
import
com.ticxo.modelengine.api.animation.AnimationProperty
;
import
org.bukkit.scheduler.BukkitRunnable
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
public
class
RuntimeManager
extends
BukkitRunnable
{
private
final
Map
<
AnimationProperty
,
MoLangRuntime
>
runtimes
=
new
ConcurrentHashMap
<>();
@Override
public
void
run
()
{
for
(
var
property
:
runtimes
.
keySet
())
{
if
(
property
.
isFinished
())
runtimes
.
remove
(
property
);
}
}
public
MoLangRuntime
getOrCreateRuntime
(
AnimationProperty
property
)
{
return
runtimes
.
computeIfAbsent
(
property
,
p
->
{
var
runtime
=
MoLang
.
createRuntime
();
runtime
.
getEnvironment
().
getStructs
().
put
(
"query"
,
new
QueryStruct
<>(
p
,
ModelQuery
.
MODEL_QUERY
));
return
runtime
;
});
}
}
This diff is collapsed.
Click to expand it.
src/main/resources/plugin.yml
View file @
2ff9eb39
name
:
ModelEngine-MoLang
author
:
Ticxo
main
:
com.ticxo.megml.MegML
version
:
${
project.
version}
version
:
${version}
api-version
:
1.16
depend
:
-
ModelEngine
\ No newline at end of file
This diff is collapsed.
Click to expand it.
target/classes/plugin.yml
0 → 100644
View file @
2ff9eb39
name
:
ModelEngine-MoLang
author
:
Ticxo
main
:
com.ticxo.megml.MegML
version
:
R1.0.0
api-version
:
1.16
depend
:
-
ModelEngine
\ No newline at end of file
This diff is collapsed.
Click to expand it.
target/maven-archiver/pom.properties
0 → 100644
View file @
2ff9eb39
#Generated by Maven
#Wed Dec 07 01:24:15 PST 2022
groupId
=
com.ticxo.megmolang
artifactId
=
Meg-Molang
version
=
R1.0.0
This diff is collapsed.
Click to expand it.
target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
0 → 100644
View file @
2ff9eb39
com\ticxo\megml\MegML.class
com\ticxo\megml\ModelQuery.class
com\ticxo\megml\ModelQuery$1.class
com\ticxo\megml\QueryData.class
com\ticxo\megml\RuntimeManager.class
This diff is collapsed.
Click to expand it.
target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
0 → 100644
View file @
2ff9eb39
C:\Users\shawn\IdeaProjects\MegMolang\src\main\java\com\ticxo\megml\RuntimeManager.java
C:\Users\shawn\IdeaProjects\MegMolang\src\main\java\com\ticxo\megml\QueryData.java
C:\Users\shawn\IdeaProjects\MegMolang\src\main\java\com\ticxo\megml\ModelQuery.java
C:\Users\shawn\IdeaProjects\MegMolang\src\main\java\com\ticxo\megml\MegML.java
This diff is collapsed.
Click to expand it.
target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
0 → 100644
View file @
2ff9eb39
This diff is collapsed.
Click to expand it.
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