VolcanicGlassRing addded right click logic, Added Curios

This commit is contained in:
Steven 2023-10-01 22:39:26 -04:00
parent 4cf84cea1e
commit c2d3d991b1
4 changed files with 36 additions and 5 deletions

View file

@ -1,9 +1,15 @@
package com.skdevstudios.util_rings.items; package com.skdevstudios.util_rings.items;
import net.minecraft.core.BlockPos;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import top.theillusivec4.curios.api.SlotContext; import top.theillusivec4.curios.api.SlotContext;
import top.theillusivec4.curios.api.type.capability.ICurioItem; import top.theillusivec4.curios.api.type.capability.ICurioItem;
@ -14,8 +20,23 @@ public class VolcanicGlassRing extends Item implements ICurioItem {
@Override @Override
public InteractionResult useOn(UseOnContext context) { public InteractionResult useOn(UseOnContext context) {
return null; Level world = context.getLevel();
//TODO: Add right click spawns obsidian block BlockPos pos = context.getClickedPos().relative(context.getClickedFace());
BlockState targetState = world.getBlockState(pos);
if (targetState.isAir() && !world.isClientSide()) {
// Check if the target block is air and place obsidian
BlockState obsidian = Blocks.OBSIDIAN.defaultBlockState();
world.setBlockAndUpdate(pos, obsidian);
// Play a sound effect at the placed block position
world.playSound(null, pos, SoundEvents.STONE_PLACE, SoundSource.BLOCKS, 1.0F, 1.0F);
return InteractionResult.SUCCESS;
}
return InteractionResult.FAIL;
} }
@Override @Override
public void curioTick(SlotContext slotContext, ItemStack stack) { public void curioTick(SlotContext slotContext, ItemStack stack) {

View file

@ -0,0 +1,4 @@
{
"entities": ["player"],
"slots": ["ring"]
}

View file

@ -0,0 +1,3 @@
{
"size": 2
}

View file

@ -1,12 +1,15 @@
{ {
"type": "minecraft:crafting_shaped", "type": "minecraft:crafting_shaped",
"pattern": [ "pattern": [
" # ", "@#@",
"# #", "# #",
" # " "@#@"
], ],
"key": { "key": {
"#": { "#": {
"item": "minecraft:iron_ingot"
},
"@": {
"item": "minecraft:iron_nugget" "item": "minecraft:iron_nugget"
} }
}, },