Posted August 17, 20214 yr public class BlazeAndSteel extends FlintAndSteelItem { public BlazeAndSteel(Properties properties) { super(properties.fireResistant().stacksTo(1).durability(128)); } @Override public ActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) { ItemStack item = player.getItemInHand(hand); if (!world.isClientSide()) { ActionResultType result = fireEntity(item, player, player, hand); return new ActionResult<>(result, item); } return super.use(world, player, hand); } @Override public ActionResultType interactLivingEntity(ItemStack item, PlayerEntity player, LivingEntity target, Hand hand) { if (!target.level.isClientSide()) { return fireEntity(item, player, target, hand); } return super.interactLivingEntity(item, player, target, hand); } protected ActionResultType fireEntity(ItemStack item, PlayerEntity player, LivingEntity target, Hand hand) { if (!target.fireImmune()) { item.hurtAndBreak(1, player, p -> p.broadcastBreakEvent(hand)); player.playSound(SoundEvents.FLINTANDSTEEL_USE, 1.0f, random.nextFloat() * 0.4f + 0.8f); int fireTick = random.nextInt(10 * 20 + 1) + 20; if (fireTick > target.getRemainingFireTicks()) { target.setSecondsOnFire(fireTick); } target.hurt(DamageSource.ON_FIRE, random.nextInt(4)); return ActionResultType.CONSUME; } return ActionResultType.FAIL; } } It has three actions 1. use on block -> act like flint and steel (useOn in FlintAndSteelItem.class) 2. use on entity -> light entity on fire (interactLivingEntity) 3. use on air -> light player on fire (use) When I use it on entity (case 2), it light both entity and player on fire. But I want to make it light only entity on fire. Give me help please. Edited August 18, 20214 yr by reasure
August 18, 20214 yr Author 20 hours ago, diesieben07 said: That is strange, I can't see why it would do that. I would recommend using the debugger. I solved this problem by using return ActionResultType.CONSUME; in interactLivingEntity instead of using super.interactLivingEntity()
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.