2020-08-11 19:20:44 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: MeFisto94 <MeFisto94@users.noreply.github.com>
|
|
|
|
Date: Tue, 11 Aug 2020 19:16:09 +0200
|
|
|
|
Subject: [PATCH] Add a way to get translation keys for blocks, entities and
|
|
|
|
materials
|
|
|
|
|
|
|
|
|
2021-03-16 07:19:45 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/EntityTypes.java b/src/main/java/net/minecraft/world/entity/EntityTypes.java
|
2021-03-16 13:04:28 +00:00
|
|
|
index 9d2955f05aadd4bbc6dcfec068a55d7fe6950ba0..f2cf33d42839710a3bbdf0c8ea0be28af6fcb19d 100644
|
2021-03-16 07:19:45 +00:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/EntityTypes.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/EntityTypes.java
|
2021-03-16 13:04:28 +00:00
|
|
|
@@ -278,6 +278,7 @@ public class EntityTypes<T extends Entity> {
|
2020-08-11 19:20:44 +00:00
|
|
|
return IRegistry.ENTITY_TYPE.getKey(entitytypes);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ public static Optional<EntityTypes<?>> getByName(String name) { return a(name); } // Paper - OBFHELPER
|
|
|
|
public static Optional<EntityTypes<?>> a(String s) {
|
|
|
|
return IRegistry.ENTITY_TYPE.getOptional(MinecraftKey.a(s));
|
|
|
|
}
|
2021-03-16 13:04:28 +00:00
|
|
|
@@ -431,6 +432,7 @@ public class EntityTypes<T extends Entity> {
|
2020-08-11 19:20:44 +00:00
|
|
|
return this.bg;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ public String getDescriptionId() { return f(); } // Paper - OBFHELPER
|
|
|
|
public String f() {
|
|
|
|
if (this.bo == null) {
|
|
|
|
this.bo = SystemUtils.a("entity", IRegistry.ENTITY_TYPE.getKey(this));
|
2021-03-16 07:19:45 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/Item.java b/src/main/java/net/minecraft/world/item/Item.java
|
|
|
|
index ca513e7b0a416860aba89e41de6a7c5ff42baa69..5d7c44a53fb98532057b09176677ce0d719b055b 100644
|
|
|
|
--- a/src/main/java/net/minecraft/world/item/Item.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/item/Item.java
|
|
|
|
@@ -56,7 +56,7 @@ public class Item implements IMaterial {
|
2020-08-11 19:20:44 +00:00
|
|
|
private final FoodInfo foodInfo;
|
|
|
|
|
|
|
|
public static int getId(Item item) {
|
|
|
|
- return item == null ? 0 : IRegistry.ITEM.a((Object) item);
|
|
|
|
+ return item == null ? 0 : IRegistry.ITEM.a(item); // Paper - Fix Decompiler Issue
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Item getById(int i) {
|
2021-03-16 07:19:45 +00:00
|
|
|
@@ -152,6 +152,7 @@ public class Item implements IMaterial {
|
2020-08-11 19:20:44 +00:00
|
|
|
return IRegistry.ITEM.getKey(this).getKey();
|
|
|
|
}
|
|
|
|
|
|
|
|
+ public String getOrCreateDescriptionId() { return m(); } // Paper - OBFHELPER
|
|
|
|
protected String m() {
|
|
|
|
if (this.name == null) {
|
|
|
|
this.name = SystemUtils.a("item", IRegistry.ITEM.getKey(this));
|
2021-03-16 07:19:45 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java
|
|
|
|
index cc512bd2e89382e7fdbc59b41640e95ccafbbfe9..768934fa4158a9773d06f5b23bfb19db75f6d179 100644
|
|
|
|
--- a/src/main/java/net/minecraft/world/level/block/Block.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
|
|
|
|
@@ -318,6 +318,7 @@ public class Block extends BlockBase implements IMaterial {
|
|
|
|
return !this.material.isBuildable() && !this.material.isLiquid();
|
|
|
|
}
|
|
|
|
|
|
|
|
+ public String getDescriptionId() { return i(); } // Paper - OBFHELPER
|
|
|
|
public String i() {
|
|
|
|
if (this.name == null) {
|
|
|
|
this.name = SystemUtils.a("block", IRegistry.BLOCK.getKey(this));
|
2020-08-11 19:20:44 +00:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
2021-03-16 07:19:45 +00:00
|
|
|
index ffa94d23675c6c7b6b005860c99c730aacb94924..c0238ba202b9f6c215788671652c768948acf753 100644
|
2020-08-11 19:20:44 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
|
|
|
@@ -752,5 +752,10 @@ public class CraftBlock implements Block {
|
|
|
|
public com.destroystokyo.paper.block.BlockSoundGroup getSoundGroup() {
|
|
|
|
return new com.destroystokyo.paper.block.CraftBlockSoundGroup(getNMSBlock().getBlockData().getStepSound());
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public String getTranslationKey() {
|
|
|
|
+ return org.bukkit.Bukkit.getUnsafe().getTranslationKey(this);
|
|
|
|
+ }
|
|
|
|
// Paper end
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
2021-03-16 07:19:45 +00:00
|
|
|
index 51aa0c37df947a229eddaa3c4e3372f64575617e..6fbface979f6f9ed97bb39ca91a29bffe05fddda 100644
|
2020-08-11 19:20:44 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
2020-09-14 09:57:06 +00:00
|
|
|
@@ -45,6 +45,7 @@ import org.bukkit.Registry;
|
2020-08-11 19:20:44 +00:00
|
|
|
import org.bukkit.UnsafeValues;
|
|
|
|
import org.bukkit.advancement.Advancement;
|
|
|
|
import org.bukkit.block.data.BlockData;
|
|
|
|
+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;
|
2021-03-09 01:11:17 +00:00
|
|
|
@@ -400,6 +401,25 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
2020-08-11 19:20:44 +00:00
|
|
|
throw new RuntimeException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public String getTranslationKey(Material mat) {
|
2021-03-03 00:27:34 +00:00
|
|
|
+ if (mat.isBlock()) {
|
|
|
|
+ return getBlock(mat).getDescriptionId();
|
|
|
|
+ }
|
2020-08-11 19:20:44 +00:00
|
|
|
+ return getItem(mat).getOrCreateDescriptionId();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public String getTranslationKey(org.bukkit.block.Block block) {
|
|
|
|
+ return ((org.bukkit.craftbukkit.block.CraftBlock)block).getNMS().getBlock().getDescriptionId();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public String getTranslationKey(org.bukkit.entity.EntityType type) {
|
2021-03-16 07:19:45 +00:00
|
|
|
+ return net.minecraft.world.entity.EntityTypes.getByName(type.getName()).map(net.minecraft.world.entity.EntityTypes::getDescriptionId).orElse(null);
|
2020-08-11 19:20:44 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
// Paper end
|
|
|
|
|
|
|
|
/**
|