This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
Twine/src/main/java/com/thebrokenrail/twine/block/GlowingObsidianBlock.java

31 lines
1.0 KiB
Java
Raw Normal View History

2020-06-14 03:04:21 +00:00
package com.thebrokenrail.twine.block;
import net.minecraft.block.Block;
import net.minecraft.block.Material;
import net.minecraft.block.MaterialColor;
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.util.math.BlockPos;
import net.minecraft.world.World;
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;
2020-06-14 03:04:21 +00:00
if (entity instanceof Monster) {
((LivingEntity) entity).heal(amount);
} else {
entity.damage(DamageSource.MAGIC, amount);
}
}
}
}