Skip to content

Commit 2780a9a

Browse files
committed
Fixed NotSerializableException when sacrificing entities (fixes #666)
1 parent ad4b0dd commit 2780a9a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/main/java/net/coreprotect/listener/entity/EntityDeathListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ else if (entity instanceof Player) {
289289
if (attributeInstance != null) {
290290
List<Object> attributeData = new ArrayList<>();
291291
List<Object> attributeModifiers = new ArrayList<>();
292-
attributeData.add(attributeInstance.getAttribute());
292+
attributeData.add(BukkitAdapter.ADAPTER.getRegistryKey(attributeInstance.getAttribute()));
293293
attributeData.add(attributeInstance.getBaseValue());
294294

295295
for (AttributeModifier modifier : attributeInstance.getModifiers()) {

src/main/java/net/coreprotect/utility/entity/EntityUtil.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,13 @@ else if (count == 1) {
166166
for (Object value : attributes) {
167167
@SuppressWarnings("unchecked")
168168
List<Object> attributeData = (List<Object>) value;
169-
Attribute attribute = (Attribute) attributeData.get(0);
169+
Attribute attribute = null;
170+
if (attributeData.get(0) instanceof Attribute) {
171+
attribute = (Attribute) attributeData.get(0);
172+
}
173+
else {
174+
attribute = (Attribute) BukkitAdapter.ADAPTER.getRegistryValue((String) attributeData.get(0), Attribute.class);
175+
}
170176
Double baseValue = (Double) attributeData.get(1);
171177
@SuppressWarnings("unchecked")
172178
List<Object> attributeModifiers = (List<Object>) attributeData.get(2);

0 commit comments

Comments
 (0)