#1275: Add internal ItemType and BlockType, delegate Material methods to them

By: Jishuna <joshl5324@gmail.com>
Also-by: Bjarne Koll <lynxplay101@gmail.com>
Also-by: DerFrZocker <derrieple@gmail.com>
Also-by: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2024-05-05 10:08:54 +10:00
parent b4e6cc4dce
commit 8f55ed539f
14 changed files with 642 additions and 47 deletions

View File

@@ -10,11 +10,13 @@ import net.minecraft.world.entity.EntityTypes;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.block.BlockType;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlockType;
import org.bukkit.craftbukkit.entity.CraftEntityType;
import org.bukkit.craftbukkit.inventory.CraftItemType;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemType;
import org.bukkit.packs.DataPack;
import org.bukkit.packs.DataPackManager;
@@ -89,6 +91,24 @@ public class CraftDataPackManager implements DataPackManager {
return false;
}
@Override
public boolean isEnabledByFeature(ItemType itemType, World world) {
Preconditions.checkArgument(itemType != null, "itemType cannot be null");
Preconditions.checkArgument(world != null, "world cannot be null");
CraftWorld craftWorld = ((CraftWorld) world);
return CraftItemType.bukkitToMinecraftNew(itemType.typed()).isEnabled(craftWorld.getHandle().enabledFeatures());
}
@Override
public boolean isEnabledByFeature(BlockType blockType, World world) {
Preconditions.checkArgument(blockType != null, "blockType cannot be null");
Preconditions.checkArgument(world != null, "world cannot be null");
CraftWorld craftWorld = ((CraftWorld) world);
return CraftBlockType.bukkitToMinecraftNew(blockType.typed()).isEnabled(craftWorld.getHandle().enabledFeatures());
}
@Override
public boolean isEnabledByFeature(EntityType entityType, World world) {
Preconditions.checkArgument(entityType != null, "entityType cannot be null");