mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-05 02:22:12 +01:00
#1131: Added methods to get translation keys for materials, itemstacks and more
By: mfnalex <mfnalex@gmail.com>
This commit is contained in:
parent
b9bf523b80
commit
abeb7e6d0c
2 changed files with 31 additions and 0 deletions
|
@ -642,4 +642,9 @@ public class CraftBlock implements Block {
|
|||
|
||||
return iblockdata.canSurvive(world, this.position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTranslationKey() {
|
||||
return getNMS().getBlock().getDescriptionId();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import net.minecraft.server.MinecraftServer;
|
|||
import net.minecraft.util.ChatDeserializer;
|
||||
import net.minecraft.util.datafix.DataConverterRegistry;
|
||||
import net.minecraft.util.datafix.fixes.DataConverterTypes;
|
||||
import net.minecraft.world.entity.EntityTypes;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeBase;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
@ -54,9 +55,11 @@ import org.bukkit.block.data.BlockData;
|
|||
import org.bukkit.craftbukkit.CraftEquipmentSlot;
|
||||
import org.bukkit.craftbukkit.attribute.CraftAttributeInstance;
|
||||
import org.bukkit.craftbukkit.attribute.CraftAttributeMap;
|
||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.legacy.CraftLegacy;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.CreativeCategory;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
@ -361,6 +364,29 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
|||
return CreativeCategory.BUILDING_BLOCKS; // TODO: Figure out what to do with this
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlockTranslationKey(Material material) {
|
||||
Block block = getBlock(material);
|
||||
return (block != null) ? block.getDescriptionId() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemTranslationKey(Material material) {
|
||||
Item item = getItem(material);
|
||||
return (item != null) ? item.getDescriptionId() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTranslationKey(EntityType entityType) {
|
||||
return EntityTypes.byString(entityType.name()).map(EntityTypes::getDescriptionId).orElseThrow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTranslationKey(ItemStack itemStack) {
|
||||
net.minecraft.world.item.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(itemStack);
|
||||
return nmsItemStack.getItem().getDescriptionId(nmsItemStack);
|
||||
}
|
||||
|
||||
/**
|
||||
* This helper class represents the different NBT Tags.
|
||||
* <p>
|
||||
|
|
Loading…
Reference in a new issue