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
MythicCosmetics
Commits
ec586611
Commit
ec586611
authored
2 years ago
by
Ticxo
Browse files
Options
Download
Email Patches
Plain Diff
Meg 3
parent
b844ede4
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
48 additions
and
101 deletions
+48
-101
api/.flattened-pom.xml
api/.flattened-pom.xml
+1
-1
plugin/pom.xml
plugin/pom.xml
+1
-1
plugin/src/main/java/io/lumine/cosmetics/MCCosmeticsPlugin.java
.../src/main/java/io/lumine/cosmetics/MCCosmeticsPlugin.java
+1
-1
plugin/src/main/java/io/lumine/cosmetics/managers/modelengine/FakeEntity.java
.../io/lumine/cosmetics/managers/modelengine/FakeEntity.java
+16
-45
plugin/src/main/java/io/lumine/cosmetics/managers/modelengine/MEGAccessory.java
...o/lumine/cosmetics/managers/modelengine/MEGAccessory.java
+3
-5
plugin/src/main/java/io/lumine/cosmetics/managers/modelengine/MEGManager.java
.../io/lumine/cosmetics/managers/modelengine/MEGManager.java
+21
-25
plugin/src/main/java/io/lumine/cosmetics/managers/modelengine/MEGModel.java
...va/io/lumine/cosmetics/managers/modelengine/MEGModel.java
+4
-18
v1_19_R1/src/main/java/io/lumine/cosmetics/nms/v1_19_R1/cosmetic/VolatileHatImpl.java
...mine/cosmetics/nms/v1_19_R1/cosmetic/VolatileHatImpl.java
+1
-5
No files found.
api/.flattened-pom.xml
View file @
ec586611
...
...
@@ -4,7 +4,7 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
io.lumine
</groupId>
<artifactId>
MCCosmetics-API
</artifactId>
<version>
0.
7
.0-SNAPSHOT
</version>
<version>
0.
8
.0-SNAPSHOT
</version>
<dependencies>
<dependency>
<groupId>
io.lumine
</groupId>
...
...
This diff is collapsed.
Click to expand it.
plugin/pom.xml
View file @
ec586611
...
...
@@ -181,7 +181,7 @@
<dependency>
<groupId>
com.ticxo.modelengine
</groupId>
<artifactId>
api
</artifactId>
<version>
R2.5
.0
</version>
<version>
B3.0
.0
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
...
...
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/MCCosmeticsPlugin.java
View file @
ec586611
...
...
@@ -114,7 +114,7 @@ public class MCCosmeticsPlugin extends LuminePlugin {
backManager
=
new
BackManager
(
this
);
sprayManager
=
new
SprayManager
(
this
);
offhandManager
=
new
OffhandManager
(
this
);
if
(
Bukkit
.
getPluginManager
().
getPlugin
(
"ModelEngine"
)
!=
null
)
{
if
(
Bukkit
.
getPluginManager
().
getPlugin
(
"ModelEngine
_Beta
"
)
!=
null
)
{
try
{
megManager
=
new
MEGManager
(
this
);
}
catch
(
Exception
|
Error
ex
)
{
...
...
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/managers/modelengine/FakeEntity.java
View file @
ec586611
package
io.lumine.cosmetics.managers.modelengine
;
import
com.ticxo.modelengine.api.model.ModeledEntity
;
import
com.ticxo.modelengine.api.model.base.BukkitPlayer
;
import
com.ticxo.modelengine.api.model.base.EntityData
;
import
com.ticxo.modelengine.api.util.math.Offset
;
import
io.lumine.cosmetics.MCCosmeticsPlugin
;
import
io.lumine.cosmetics.logging.MCLogger
;
import
com.ticxo.modelengine.api.entity.BukkitPlayer
;
import
com.ticxo.modelengine.api.nms.entity.wrapper.BodyRotationController
;
import
com.ticxo.modelengine.api.utils.math.Offset
;
import
io.lumine.utils.serialize.Orient
;
import
org.bukkit.Location
;
import
org.bukkit.entity.Player
;
import
org.bukkit.util.Vector
;
import
org.jetbrains.annotations.NotNull
;
public
class
FakeEntity
extends
BukkitPlayer
{
private
final
Player
player
;
private
final
Vector
offset
;
private
final
double
yaw
;
private
final
double
pitch
;
private
final
ModelAnchor
anchor
;
private
BodyRotationController
controller
;
public
FakeEntity
(
Player
player
,
Orient
orient
,
ModelAnchor
anchor
)
{
super
(
player
);
this
.
player
=
player
;
public
FakeEntity
(
@NotNull
Player
entity
,
Orient
orient
,
ModelAnchor
anchor
)
{
super
(
entity
);
offset
=
orient
.
getLocus
().
toVector
();
yaw
=
Math
.
toRadians
(
orient
.
getDirection
().
getYaw
());
pitch
=
Math
.
toRadians
(
orient
.
getDirection
().
getPitch
());
...
...
@@ -29,52 +26,26 @@ public class FakeEntity extends BukkitPlayer {
}
@Override
public
void
sendDespawnPacket
(
ModeledEntity
modeledEntity
)
{
}
@Override
public
void
sendSpawnPacket
(
ModeledEntity
modeledEntity
)
{
}
@Override
public
void
saveModelInfo
(
ModeledEntity
model
)
{
}
@Override
public
EntityData
loadModelInfo
()
{
return
null
;
public
BodyRotationController
wrapBodyRotationControl
()
{
controller
=
super
.
wrapBodyRotationControl
();
controller
.
setMaxHeadAngle
(
45
);
controller
.
setMaxBodyAngle
(
45
);
controller
.
setStableAngle
(
5
);
return
controller
;
}
@Override
public
Location
getLocation
()
{
Location
location
=
player
.
getLocation
();
Location
location
=
getOriginal
()
.
getLocation
();
Vector
offset
;
if
(
anchor
==
ModelAnchor
.
HEAD
)
{
double
pYaw
=
Math
.
toRadians
(
location
.
getYaw
());
double
pPitch
=
Math
.
toRadians
(
location
.
getPitch
());
offset
=
Offset
.
rotateYaw
(
Offset
.
rotatePitch
(
this
.
offset
.
clone
(),
pitch
+
pPitch
),
yaw
+
pYaw
);
}
else
{
double
pYaw
=
getBody
Yaw
(
);
}
else
{
double
pYaw
=
Math
.
toRadians
(
controller
==
null
?
get
Y
Body
Rot
()
:
controller
.
getYBodyRot
()
);
offset
=
Offset
.
rotateYaw
(
this
.
offset
.
clone
(),
yaw
+
pYaw
);
}
return
location
.
add
(
offset
);
}
@Override
public
void
setEntitySize
(
float
width
,
float
height
,
float
eye
)
{
}
private
double
getBodyYaw
()
{
Location
location
=
player
.
getLocation
();
Vector
nV
=
new
Vector
(
location
.
getX
()
-
getLastX
(),
0
,
location
.
getZ
()
-
getLastZ
());
if
(
nV
.
getX
()
!=
0
||
nV
.
getZ
()
!=
0
)
MCCosmeticsPlugin
.
inst
().
getVolatileCodeHandler
().
setBodyYaw
(
player
,
location
.
getYaw
());
return
Math
.
toRadians
(
MCCosmeticsPlugin
.
inst
().
getVolatileCodeHandler
().
getBodyYaw
(
player
));
}
}
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/managers/modelengine/MEGAccessory.java
View file @
ec586611
package
io.lumine.cosmetics.managers.modelengine
;
import
com.ticxo.modelengine.api.util.ConfigManager
;
import
com.ticxo.modelengine.api.model.AnimationMode
;
import
io.lumine.cosmetics.api.cosmetics.ColorableCosmetic
;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
import
io.lumine.cosmetics.config.Scope
;
import
io.lumine.cosmetics.constants.CosmeticType
;
import
io.lumine.cosmetics.logging.MCLogger
;
import
io.lumine.cosmetics.managers.AbstractCosmetic
;
import
io.lumine.utils.config.properties.Property
;
import
io.lumine.utils.config.properties.types.EnumProp
;
...
...
@@ -23,13 +21,13 @@ public class MEGAccessory extends AbstractCosmetic implements ColorableCosmetic
private
static
final
StringProp
MODEL
=
Property
.
String
(
Scope
.
NONE
,
"ModelId"
);
private
static
final
StringProp
STATE
=
Property
.
String
(
Scope
.
NONE
,
"State"
);
private
static
final
OrientProp
OFFSET
=
Property
.
Orient
(
Scope
.
NONE
,
"Offset"
);
private
static
final
EnumProp
<
ConfigManager
.
AnimationMode
>
MODELMODE
=
Property
.
Enum
(
Scope
.
NONE
,
ConfigManager
.
AnimationMode
.
class
,
"Mode"
,
ConfigManager
.
AnimationMode
.
B
);
private
static
final
EnumProp
<
AnimationMode
>
MODELMODE
=
Property
.
Enum
(
Scope
.
NONE
,
AnimationMode
.
class
,
"Mode"
,
AnimationMode
.
B
);
private
static
final
EnumProp
<
ModelAnchor
>
MODELANCHOR
=
Property
.
Enum
(
Scope
.
NONE
,
ModelAnchor
.
class
,
"Anchor"
,
ModelAnchor
.
BODY
);
@Getter
private
final
String
modelId
;
@Getter
private
final
String
state
;
@Getter
private
final
Orient
offset
;
@Getter
private
final
ConfigManager
.
AnimationMode
mode
;
@Getter
private
final
AnimationMode
mode
;
@Getter
private
final
ModelAnchor
anchor
;
public
MEGAccessory
(
MEGManager
manager
,
File
file
,
String
key
)
{
...
...
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/managers/modelengine/MEGManager.java
View file @
ec586611
package
io.lumine.cosmetics.managers.modelengine
;
import
com.ticxo.modelengine.api.ModelEngineAPI
;
import
com.ticxo.modelengine.api.animation.StateProperty
;
import
com.ticxo.modelengine.api.animation.AnimationProperty
;
import
com.ticxo.modelengine.api.animation.blueprint.LoopMode
;
import
com.ticxo.modelengine.api.model.ModeledEntity
;
import
com.ticxo.modelengine.api.nms.entity.wrapper.RangeManager
;
import
io.lumine.cosmetics.MCCosmeticsPlugin
;
import
io.lumine.cosmetics.api.players.CosmeticProfile
;
import
io.lumine.cosmetics.logging.MCLogger
;
import
io.lumine.cosmetics.managers.MCCosmeticsManager
;
import
io.lumine.utils.Events
;
import
io.lumine.utils.Schedulers
;
import
org.bukkit.entity.Player
;
import
org.bukkit.event.entity.PlayerDeathEvent
;
import
org.bukkit.event.player.PlayerChangedWorldEvent
;
...
...
@@ -104,33 +104,33 @@ public class MEGManager extends MCCosmeticsManager<MEGAccessory> {
return
;
}
final
var
blueprint
=
ModelEngineAPI
.
get
Model
Blueprint
(
meg
.
getModelId
());
final
var
blueprint
=
ModelEngineAPI
.
getBlueprint
(
meg
.
getModelId
());
if
(
blueprint
==
null
)
return
;
final
var
animation
=
blueprint
.
getAnimation
(
meg
.
getState
());
final
var
animation
=
blueprint
.
getAnimation
s
().
get
(
meg
.
getState
());
if
(
animation
==
null
)
return
;
final
var
player
=
profile
.
getPlayer
();
final
var
activeModel
=
ModelEngineAPI
.
createActiveModel
(
meg
.
getModelId
());
final
var
property
=
new
StateProperty
(
meg
.
getState
(),
animation
,
1
,
0
,
1
);
property
.
setLoop
(
true
);
property
.
setOverride
(
true
);
activeModel
.
addState
(
property
);
activeModel
.
setDamageTint
(
false
);
activeModel
.
setAnimationMode
(
meg
.
getMode
());
final
var
activeModel
=
ModelEngineAPI
.
createActiveModel
(
blueprint
);
final
var
property
=
new
AnimationProperty
(
animation
,
1
,
0
,
1
);
property
.
setForceLoopMode
(
LoopMode
.
LOOP
);
property
.
setForceOverride
(
true
);
activeModel
.
getAnimationHandler
().
playAnimation
(
property
,
true
);
activeModel
.
setCanHurt
(
false
);
ModeledEntity
modeledEntity
=
ModelEngineAPI
.
getModeledEntity
(
player
.
getUniqueId
());
if
(
modeledEntity
!=
null
)
{
modeledEntity
.
clearModels
();
modeledEntity
.
getAllActiveModel
().
clear
();
if
(
modeledEntity
==
null
)
{
modeledEntity
=
ModelEngineAPI
.
createModeledEntity
(
new
FakeEntity
(
player
,
meg
.
getOffset
(),
meg
.
getAnchor
()));
modeledEntity
.
setBaseEntityVisible
(
true
);
ModelEngineAPI
.
getEntityHandler
().
setSelfFakeInvisible
(
player
,
false
);
if
(
modeledEntity
.
getRangeManager
()
instanceof
RangeManager
.
Disguise
disguise
)
disguise
.
setIncludeSelf
(
true
);
}
modeledEntity
=
new
MEGModel
(
player
,
new
FakeEntity
(
player
,
meg
.
getOffset
(),
meg
.
getAnchor
()));
modeledEntity
.
addActiveModel
(
activeModel
);
modeledEntity
.
setInvisible
(
false
);
modeledEntity
.
addPlayerAsync
(
player
);
modeledEntity
.
destroy
();
modeledEntity
.
addModel
(
activeModel
,
false
);
}
public
void
unequip
(
CosmeticProfile
profile
)
{
...
...
@@ -140,16 +140,12 @@ public class MEGManager extends MCCosmeticsManager<MEGAccessory> {
}
var
opt
=
maybeEquipped
.
get
().
getCosmetic
();
if
(!(
opt
instanceof
MEGAccessory
meg
))
{
if
(!(
opt
instanceof
MEGAccessory
))
{
return
;
}
final
var
player
=
profile
.
getPlayer
();
ModeledEntity
modeledEntity
=
ModelEngineAPI
.
getModeledEntity
(
player
.
getUniqueId
());
if
(
modeledEntity
!=
null
)
{
modeledEntity
.
clearModels
();
modeledEntity
.
getAllActiveModel
().
clear
();
}
ModelEngineAPI
.
removeModeledEntity
(
player
.
getUniqueId
());
}
}
This diff is collapsed.
Click to expand it.
plugin/src/main/java/io/lumine/cosmetics/managers/modelengine/MEGModel.java
View file @
ec586611
package
io.lumine.cosmetics.managers.modelengine
;
import
com.ticxo.modelengine.api.animation.Query
;
import
com.ticxo.modelengine.api.model.AbstractModeledEntity
;
import
com.ticxo.modelengine.api.model.ActiveModel
;
import
com.ticxo.modelengine.api.model.base.BaseEntity
;
import
com.ticxo.modelengine.api.model.mount.handler.EmptyMountHandler
;
import
com.ticxo.modelengine.api.model.mount.handler.IMountHandler
;
import
com.ticxo.modelengine.api.model.nametag.EmptyNametagHandler
;
import
com.ticxo.modelengine.api.model.nametag.INametagHandler
;
import
org.bukkit.Location
;
import
org.bukkit.entity.Player
;
import
org.bukkit.util.Vector
;
import
java.util.List
;
public
class
MEGModel
extends
AbstractModeledEntity
{
private
final
Player
player
;
public
class
MEGModel
/*extends AbstractModeledEntity*/
{
/*private final Player player;
private final Query queries = new Query(this);
private final IMountHandler mountHandler;
private final INametagHandler nametagHandler;
...
...
@@ -183,5 +169,5 @@ public class MEGModel extends AbstractModeledEntity {
if(!getEntity().isLivingEntity())
return 0;
return getEntity().getMaxHealth();
}
}
*/
}
This diff is collapsed.
Click to expand it.
v1_19_R1/src/main/java/io/lumine/cosmetics/nms/v1_19_R1/cosmetic/VolatileHatImpl.java
View file @
ec586611
...
...
@@ -120,12 +120,8 @@ public class VolatileHatImpl implements VolatileEquipmentHelper {
final
var
nmsHat
=
CraftItemStack
.
asNMSCopy
(
hat
.
getCosmetic
(
equip
));
ClientboundSetEquipmentPacket
equipmentPacket
=
new
ClientboundSetEquipmentPacket
(
player
.
getEntityId
(),
List
.
of
(
Pair
.
of
(
EquipmentSlot
.
HEAD
,
nmsHat
)));
FriendlyByteBuf
byteBuf
=
new
FriendlyByteBuf
(
Unpooled
.
buffer
());
byteBuf
.
writeByte
(
80
);
equipmentPacket
.
write
(
byteBuf
);
final
var
pipeline
=
((
CraftPlayer
)
player
).
getHandle
().
connection
.
getConnection
().
channel
.
pipeline
();
pipeline
.
writeAndFlush
(
byteBuf
);
pipeline
.
writeAndFlush
(
equipmentPacket
);
}
}
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