-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyExampleEntity.java
57 lines (46 loc) · 1.61 KB
/
MyExampleEntity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package dev.murad.liteloadlib.examples;
import dev.murad.liteloadlib.api.EnrollableEntity;
import dev.murad.liteloadlib.api.EnrollmentHandler;
import dev.murad.liteloadlib.api.LLLClientAPI;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.protocol.Packet;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.Level;
import java.util.UUID;
public class MyExampleEntity extends Entity implements EnrollableEntity {
private final EnrollmentHandler enrollmentHandler;
public MyExampleEntity(EntityType<?> type, Level level){
super(type, level);
enrollmentHandler = new EnrollmentHandler(this);
}
// if you want to enroll an entity based on a server event - ex. clicked with a specific item
public void serverSideEnrollExample(UUID player){
enrollmentHandler.enroll(player);
}
// if you want to enroll an entity based on a client event - ex. GUI button
public void clientSideEnrollExample(){
if(this.level.isClientSide()) {
LLLClientAPI.sendEntityEnrollmentPacket(this);
}
}
@Override
public EnrollmentHandler getEnrollmentHandler() {
return enrollmentHandler;
}
@Override
protected void defineSynchedData() {
}
@Override
protected void readAdditionalSaveData(CompoundTag tag) {
enrollmentHandler.load(tag);
}
@Override
protected void addAdditionalSaveData(CompoundTag tag) {
enrollmentHandler.save(tag);
}
@Override
public Packet<?> getAddEntityPacket() {
return null;
}
}