This repository has been archived on 2024-07-25. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
Thresholds/src/main/java/dev/zontreck/otemod/items/UnstableSingularity.java
2024-01-17 02:25:27 -07:00

39 lines
1.4 KiB
Java

package dev.zontreck.otemod.items;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.item.SimpleFoiledItem;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraftforge.event.world.ExplosionEvent;
public class UnstableSingularity extends SimpleFoiledItem
{
public UnstableSingularity(Properties pProperties) {
super(pProperties);
}
@Override
public InteractionResult useOn(UseOnContext pContext) {
BlockState block = pContext.getLevel().getBlockState(pContext.getClickedPos());
if(block.getBlock().defaultDestroyTime() < 0)
{
pContext.getLevel().explode(pContext.getPlayer(), pContext.getClickedPos().getX(), pContext.getClickedPos().getY(), pContext.getClickedPos().getZ(), 16, true, Explosion.BlockInteraction.DESTROY);
pContext.getLevel().setBlock(pContext.getClickedPos(), Blocks.AIR.defaultBlockState(), 0, 0);
pContext.getItemInHand().shrink(1);
}
return InteractionResult.CONSUME;
}
}