package com.thebrokenrail.twine.block; import com.thebrokenrail.twine.util.ItemUtil; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.block.Block; import net.minecraft.block.Material; import net.minecraft.block.MaterialColor; import net.minecraft.client.item.TooltipContext; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.mob.Monster; import net.minecraft.item.ItemStack; import net.minecraft.text.Text; import net.minecraft.util.math.BlockPos; import net.minecraft.world.BlockView; import net.minecraft.world.World; import java.util.List; public class GlowingObsidianBlock extends Block { public GlowingObsidianBlock() { super(Settings.of(Material.STONE, MaterialColor.BLACK).requiresTool().strength(50.0F, 1200.0F).lightLevel(state -> 4)); } @Override public void onSteppedOn(World world, BlockPos pos, Entity entity) { super.onSteppedOn(world, pos, entity); if (entity instanceof LivingEntity && entity.age % 5 == 0) { final float amount = 2f; if (entity instanceof Monster) { ((LivingEntity) entity).heal(amount); } else { entity.damage(DamageSource.MAGIC, amount); } } } @Override @Environment(EnvType.CLIENT) public void buildTooltip(ItemStack stack, BlockView world, List tooltip, TooltipContext options) { super.buildTooltip(stack, world, tooltip, options); ItemUtil.addTooltip("block", "glowing_obsidian", 2, tooltip); } }