Skip to content

Commit

Permalink
Use proper adapter for EntityType.END_CRYSTAL
Browse files Browse the repository at this point in the history
  • Loading branch information
Intelli committed Jun 18, 2024
1 parent 49eb176 commit fa1de08
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
10 changes: 10 additions & 0 deletions src/main/java/net/coreprotect/bukkit/BukkitAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,14 @@ public ItemStack getArrowMeta(Arrow arrow, ItemStack itemStack) {
return itemStack;
}

@Override
public EntityType getEntityType(Material material) {
switch (material) {
case END_CRYSTAL:
return EntityType.valueOf("ENDER_CRYSTAL");
default:
return EntityType.UNKNOWN;
}
}

}
2 changes: 2 additions & 0 deletions src/main/java/net/coreprotect/bukkit/BukkitInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,6 @@ public interface BukkitInterface {

public ItemStack getArrowMeta(Arrow arrow, ItemStack itemStack);

public EntityType getEntityType(Material material);

}
11 changes: 11 additions & 0 deletions src/main/java/net/coreprotect/bukkit/Bukkit_v1_21.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.entity.EntityType;

import net.coreprotect.model.BlockGroup;

Expand All @@ -22,4 +23,14 @@ public Bukkit_v1_21() {
}
}

@Override
public EntityType getEntityType(Material material) {
switch (material) {
case END_CRYSTAL:
return EntityType.valueOf("END_CRYSTAL");
default:
return EntityType.UNKNOWN;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -649,14 +649,7 @@ else if ((rowType == Material.END_CRYSTAL)) {
}

if (!exists) {
EntityType END_CRYSTAL = null;
try {
END_CRYSTAL = EntityType.valueOf("END_CRYSTAL"); // 1.21+
}
catch (Exception e) {
END_CRYSTAL = EntityType.valueOf("ENDER_CRYSTAL"); // <= 1.20
}
Entity entity = block.getLocation().getWorld().spawnEntity(location1, END_CRYSTAL);
Entity entity = block.getLocation().getWorld().spawnEntity(location1, BukkitAdapter.ADAPTER.getEntityType(Material.END_CRYSTAL));
EnderCrystal enderCrystal = (EnderCrystal) entity;
enderCrystal.setShowingBottom((rowData != 0));
PaperAdapter.ADAPTER.teleportAsync(entity, location1);
Expand Down

0 comments on commit fa1de08

Please sign in to comment.