Skip to content

Commit

Permalink
Fixed NotSerializableException when sacrificing entities (fixes #666)
Browse files Browse the repository at this point in the history
  • Loading branch information
Intelli committed Nov 4, 2024
1 parent ad4b0dd commit 2780a9a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ else if (entity instanceof Player) {
if (attributeInstance != null) {
List<Object> attributeData = new ArrayList<>();
List<Object> attributeModifiers = new ArrayList<>();
attributeData.add(attributeInstance.getAttribute());
attributeData.add(BukkitAdapter.ADAPTER.getRegistryKey(attributeInstance.getAttribute()));
attributeData.add(attributeInstance.getBaseValue());

for (AttributeModifier modifier : attributeInstance.getModifiers()) {
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/net/coreprotect/utility/entity/EntityUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,13 @@ else if (count == 1) {
for (Object value : attributes) {
@SuppressWarnings("unchecked")
List<Object> attributeData = (List<Object>) value;
Attribute attribute = (Attribute) attributeData.get(0);
Attribute attribute = null;
if (attributeData.get(0) instanceof Attribute) {
attribute = (Attribute) attributeData.get(0);
}
else {
attribute = (Attribute) BukkitAdapter.ADAPTER.getRegistryValue((String) attributeData.get(0), Attribute.class);
}
Double baseValue = (Double) attributeData.get(1);
@SuppressWarnings("unchecked")
List<Object> attributeModifiers = (List<Object>) attributeData.get(2);
Expand Down

0 comments on commit 2780a9a

Please sign in to comment.