我在Minecraft 1 11中遇到纹理问题 我用子项目创建了Hammer类:
public Hammer(Hammers hammers){
this(hammers.name, hammers.size, hammers.material);
}
public Hammer(String name, Size range, Item.ToolMaterial material){
super(name, material);
this._range = range;
this.name = name;
setUnlocalizedName(name);
setRegistryName(name);
setCreativeTab(BookCraft.toolTab);
hasSubtypes = true;
this.efficiencyOnProperMaterial /= MathHelper.sqrt(_range.width*_range.height);
}
@Override
public void getSubItems(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> subItems) {
for (Hammers h : Hammers.values()){
subItems.add(new ItemStack(new Hammer(h)));
}
}
public static enum Hammers{
BUILDER_HAMMER("BuilderHammer", new Size(2,1), ToolMaterial.STONE),
LIGHT_HAMMER("LightHammer", new Size(2,2), ToolMaterial.IRON),
MJÖLLNIR("Mjöllnir", new Size(3,2), ToolMaterial.DIAMOND),
WAR_HAMMER("WarHammer", new Size(2,1), ToolMaterial.DIAMOND),
LEGENDARY_HAMMER("LegendaryHammer", new Size(5,3), ToolMaterial.DIAMOND);
public final String name;
public final Size size;
public final ToolMaterial material;
public final float damage;
Hammers(String name, Size size, ToolMaterial material){
this.name = name;
this.size = size;
this.material = material;
this.damage = material.getDamageVsEntity();
}
}
这是ItemInit
类,我在其中注册带纹理的项目:
//region Fields
public static Hammer hammes;
//public static Boers boer;
//public static BkAxe axe;
//endregion
//
public static void init(){
hammes = register(new Hammer(Hammer.Hammers.BUILDER_HAMMER));
//boer = register(new Boers("boer", new Size(5,3), Item.ToolMaterial.DIAMOND));
//axe = register(new BkAxe("axe", Item.ToolMaterial.DIAMOND, 7, 7,1000,20));
}
//region Helping Method
private static <T extends Item> T register(T item) {
GameRegistry.register(item);
if (item instanceof IBkBase) {
if (item.getHasSubtypes()){
item = registerWithSubtypes(item);
}
else
((IBkBase) item).registerItemModel();
}
return item;
}
public static <T extends Item> T registerWithSubtypes(T item){
NonNullList<ItemStack> items = NonNullList.create();
item.getSubItems(item, item.getCreativeTab(), items);
for (int i = 0; i < items.size(); i++){
Item tempItem = items.get(i).getItem();
String name = tempItem.getUnlocalizedName().substring(5);
ModelLoader.setCustomModelResourceLocation(tempItem, i,
new ModelResourceLocation(BookCraft.MOD_ID + ":" + name, "inventory"));
}
return item;
}
//endregion
所有文件夹都已正确命名,在整个互联网上搜索,无法找到任何帮助
以下是一些截图:
model
文件夹
所有三个* .json都有相同的文字:
{
"parent": "item/handheld",
"textures": {
"layer0": "bk:items/Hammer1"
}
}
你能建议任何解决方案吗?
答案 0 :(得分:1)
资源路径&#34; bk:items / Hammer1&#34;与实际路径不符,&#34; bk / models / item / baseHammer&#34;
项
项目
项目
项目
此外,您的资源文件名称必须全部为小写(&#34; hammer1&#34;或&#34; basehammer&#34;),因为游戏会自动接受您提供的任何内容(例如&#34; Hammer1&#34;)并在其上调用gcloud
,如果无法找到具有该确切名称的文件,则会抛出错误(例如&#34; Hammer1.json&#34;不匹配)。< / p>
你需要使用&#34; bk:items / hammer1&#34;并重命名你的&#34;项目&#34;目录到&#34;项目&#34;以及将json文件重命名为&#34; hammer1.json&#34;或&#34; builderhammer&#34; (无论您在注册时实际给出的名称)。