- 1,031
- 19
- 87
Для предметов работает, но название блока обычным белым шрифтом. Как прикрутить редкость к блоку?
Код:
@SuppressWarnings("deprecation")
public class RustySword extends Item {
public RustySword() {
this.setCreativeTab(ExcaliburCraftTabs.EXCALIBUR_CRAFT);
this.setMaxStackSize(1);
this.setRegistryName("rusty_sword");
this.setUnlocalizedName("sword.rusty");
}
@SideOnly(Side.CLIENT)
public EnumRarity getRarity(ItemStack stack) {
return ExcaliburCraftItems.RARE;
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
if(!world.isRemote) {
player.sendMessage(new TextComponentString(TextFormatting.DARK_PURPLE + I18n.translateToLocal("messenge.make.excalibur.name").replace("%p", player.getName())));
}
else world.playSound(player.posX, player.posY, player.posZ, SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE, SoundCategory.PLAYERS, 1.0F, 1.0F, false);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, new ItemStack(ExcaliburCraftItems.EXCALIBUR));
}
}
Код:
public static EnumRarity EPIC = EnumHelper.addRarity("epic", TextFormatting.AQUA, "");
Код:
public class SacredPlate extends Block {
public SacredPlate() {
super(Material.IRON);
this.setCreativeTab(ExcaliburCraftTabs.EXCALIBUR_CRAFT);
this.setHardness(5.0F);
this.setHarvestLevel("pickaxe", 3);
this.setLightLevel(5.0F);
this.setRegistryName("sacred_plate");
this.setResistance(50.0F);
this.setSoundType(SoundType.METAL);
this.setUnlocalizedName("plate.sacred");
}
@SideOnly(Side.CLIENT)
public EnumRarity getRarity(ItemStack stack) {
return ExcaliburCraftItems.EPIC;
}
@Override
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
return this == ExcaliburCraftBlocks.SACRED_PLATE ? ExcaliburCraftItems.RUSTY_SWORD : Item.getItemFromBlock(this);
}
@Override
public int getExpDrop(IBlockState state, IBlockAccess world, BlockPos pos, int fortune) {
Random rand = world instanceof World ? ((World)world).rand : new Random();
if (this.getItemDropped(state, rand, fortune) != Item.getItemFromBlock(this)) {
int i = 0;
if (this == ExcaliburCraftBlocks.SACRED_PLATE) {
i = MathHelper.getInt(rand, 16, 64);
}
return i;
}
return 0;
}
}