Skip to content

Commit

Permalink
Skip metadata of entities which aren't spawned (yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Jun 27, 2024
1 parent f57ac05 commit 43c3bb1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,8 @@ public enum EntityDataIndex1_7_6_10 {
}

private static Optional<EntityDataIndex1_7_6_10> getIndex(EntityType type, int index) {
Pair<EntityType, Integer> pair = new Pair<>(type, index);
if (ENTITY_DATA_REWRITES.containsKey(pair)) {
return Optional.of(ENTITY_DATA_REWRITES.get(pair));
}

return Optional.empty();
final Pair<EntityType, Integer> pair = new Pair<>(type, index);
return Optional.ofNullable(ENTITY_DATA_REWRITES.get(pair));
}

public EntityTypes1_8.EntityType getClazz() {
Expand All @@ -203,6 +199,10 @@ public int getIndex() {
}

public static EntityDataIndex1_7_6_10 searchIndex(EntityType type, int index) {
if (type == null) {
// Plugins sending metadata before an entity is spawned, causing exceptions while the game ignores them.
return null;
}
EntityType currentType = type;
do {
Optional<EntityDataIndex1_7_6_10> optMeta = getIndex(currentType, index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ private static Optional<EntityDataIndex1_9> getIndex(final EntityType type, fina
}

public static EntityDataIndex1_9 searchIndex(final EntityType type, final int index) {
if (type == null) {
// Plugins sending metadata before an entity is spawned, causing exceptions while the game ignores them.
return null;
}
EntityType currentType = type;
do {
final Optional<EntityDataIndex1_9> optMeta = getIndex(currentType, index);
Expand Down

0 comments on commit 43c3bb1

Please sign in to comment.