- 1,031
- 19
- 87
Как сделать предмет на подобии молота из индастриала, ти добавить предмету прочность, которая уменьшается при использовании его в крафтах?
public class PointedStone extends ItemTool {
private static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(Blocks.GRASS);
private static final float[] ATTACK_DAMAGES = new float[] {6.0F, 8.0F, 8.0F, 8.0F, 6.0F};
private static final float[] ATTACK_SPEEDS = new float[] { -3.2F, -3.2F, -3.1F, -3.0F, -3.0F};
public PointedStone(String name, Item.ToolMaterial material, int maxDamage) {
super(material, EFFECTIVE_ON);
this.maxStackSize = 1;
this.setMaxDamage(maxDamage);
this.setRegistryName(name);
this.setCreativeTab(Realism.tabMain);
this.setUnlocalizedName(name);
this.attackDamage = ATTACK_DAMAGES[material.ordinal()]...
Ну я встречал вот такой зис но не пробовал его пока this.setItemDamage(damage);Есть несколько вариантов. Например:
Пишем свой IRecipe (какой там у него аналог на 1.12.2), в котором ищем слот с молоточком и дамажем его.
Вроде есть ещё какой-то трюк с containerItem и doesItemLeavesCraftingGreed (названия от руки), но я его не помню
public class PointedStone extends ItemTool {
private static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(Blocks.GRASS);
private static final float[] ATTACK_DAMAGES = new float[] {6.0F, 8.0F, 8.0F, 8.0F, 6.0F};
private static final float[] ATTACK_SPEEDS = new float[] { -3.2F, -3.2F, -3.1F, -3.0F, -3.0F};
public PointedStone(String name, Item.ToolMaterial material, int maxDamage) {
super(material, EFFECTIVE_ON);
this.maxStackSize = 1;
this.setMaxDamage(maxDamage);
this.setRegistryName(name);
this.setCreativeTab(Realism.tabMain);
this.setUnlocalizedName(name);
this.attackDamage = ATTACK_DAMAGES[material.ordinal()];
this.attackSpeed = ATTACK_SPEEDS[material.ordinal()];
}
public PointedStone(Item.ToolMaterial material, float damage, float speed) {
super(material, EFFECTIVE_ON);
this.attackDamage = damage;
this.attackSpeed = speed;
}
public float getDestroySpeed(ItemStack stack, IBlockState state) {
Material material = state.getMaterial();
return material != Material.GRASS ? super.getDestroySpeed(stack, state) : this.efficiency;
}
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
if (world.getBlockState(pos).getBlock() == Blocks.GRASS) {
world.setBlockState(pos,Blocks.DIRT.getDefaultState());
player.inventory.addItemStackToInventory(new ItemStack(RegItems.turf));
player.getHeldItem(EnumHand.MAIN_HAND).damageItem(1, player);
}
return EnumActionResult.PASS;
}
@Override
public ItemStack getContainerItem(ItemStack stack) {
stack.attemptDamageItem(1, new Random(), null);
return stack.copy();
}
@Override
public boolean hasContainerItem(ItemStack stack) {
return true;
}
}