版本信息
你使用的IDE:IntelliJ IDEA
你使用的IDE版本:2019.1.3
Forge版本: 14.23.5.2768
Minecraft版本: 1.12
**相关代码**
「public class ObsidianBlock extends Block implements IHasModel {
public ObsidianBlock(String name) {
super(Material.IRON);
setRegistryName(name);
setUnlocalizedName(name);
setHardness(3.0F);
setHarvestLevel("iceaxe",3);
setCreativeTab(Util.creativeTabs);
ModBlocks.BLOCKS.add(this);
}
@Override
public void registryItemRender() {
InitHelper.itemModelRegistry(Item.getItemFromBlock(this));
}
}
」
public class ObsidianIceaxe extends ItemTool implements IHasModel {
private static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(Blocks.PLANKS, Blocks.BOOKSHELF, Blocks.LOG, Blocks.LOG2, Blocks.CHEST, Blocks.PUMPKIN, Blocks.LIT_PUMPKIN, Blocks.MELON_BLOCK, Blocks.LADDER, Blocks.WOODEN_BUTTON, Blocks.WOODEN_PRESSURE_PLATE,Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE, Blocks.DOUBLE_STONE_SLAB, Blocks.GOLDEN_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.LIT_REDSTONE_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE, Blocks.SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.STONE_SLAB, Blocks.STONE_BUTTON, Blocks.STONE_PRESSURE_PLATE);
public ObsidianIceaxe(String name,ToolMaterial materialIn) {
super(materialIn,EFFECTIVE_ON);
InitHelper.itemInit(this,name, Util.creativeTabs);
}
@Override
public Set<String> getToolClasses(ItemStack stack) {
return Collections.singleton("iceaxe");
}