-
-
Notifications
You must be signed in to change notification settings - Fork 104
/
PacketOutEntityMetadata_v1_14_R1.java
53 lines (44 loc) · 1.68 KB
/
PacketOutEntityMetadata_v1_14_R1.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
package net.aufdemrand.denizen.nms.impl.packets;
import net.aufdemrand.denizen.nms.interfaces.packets.PacketOutEntityMetadata;
import net.aufdemrand.denizen.nms.util.ReflectionHelper;
import com.denizenscript.denizencore.utilities.debugging.dB;
import net.minecraft.server.v1_14_R1.DataWatcher;
import net.minecraft.server.v1_14_R1.PacketPlayOutEntityMetadata;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Map;
public class PacketOutEntityMetadata_v1_14_R1 implements PacketOutEntityMetadata {
private PacketPlayOutEntityMetadata internal;
private int entityId;
private List<DataWatcher.Item<?>> metadata;
public PacketOutEntityMetadata_v1_14_R1(PacketPlayOutEntityMetadata internal) {
this.internal = internal;
try {
entityId = ENTITY_ID.getInt(internal);
metadata = (List<DataWatcher.Item<?>>) METADATA.get(internal);
}
catch (Exception e) {
dB.echoError(e);
}
}
@Override
public int getEntityId() {
return entityId;
}
@Override
public boolean checkForGlow() {
for (DataWatcher.Item<?> data : metadata) {
if (data.a().a() == 0) {
// TODO: Instead of cancelling, casually strip out the 0x40 "Glowing" metadata rather than cancelling entirely?
return true;
}
}
return false;
}
private static final Field ENTITY_ID, METADATA;
static {
Map<String, Field> fields = ReflectionHelper.getFields(PacketPlayOutEntityMetadata.class);
ENTITY_ID = fields.get("a");
METADATA = fields.get("b");
}
}