33import galena .oreganized .content .block .ICrystalGlass ;
44import galena .oreganized .index .OBlocks ;
55import net .minecraft .core .BlockPos ;
6- import net .minecraft .core .particles .BlockParticleOption ;
7- import net .minecraft .core .particles .ParticleTypes ;
86import net .minecraft .sounds .SoundEvents ;
97import net .minecraft .world .InteractionResult ;
108import net .minecraft .world .entity .EquipmentSlot ;
1614import net .minecraft .world .item .enchantment .Enchantment ;
1715import net .minecraft .world .item .enchantment .EnchantmentCategory ;
1816import net .minecraft .world .level .Level ;
17+ import net .minecraft .world .level .block .AmethystClusterBlock ;
1918import net .minecraft .world .level .block .Block ;
2019import net .minecraft .world .level .block .Blocks ;
2120import net .minecraft .world .level .block .state .BlockState ;
2221import net .minecraft .world .level .gameevent .GameEvent ;
23- import net .minecraft .world .phys .Vec3 ;
2422
2523import java .util .HashMap ;
2624import java .util .Map ;
@@ -89,17 +87,17 @@ public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantmen
8987 return super .canApplyAtEnchantingTable (stack , enchantment );
9088 }
9189
92- private InteractionResult replaceBlock (UseOnContext context , BlockState to ) {
90+ private InteractionResult replaceBlock (UseOnContext context , BlockState to , boolean particles ) {
9391 var level = context .getLevel ();
9492 var pos = context .getClickedPos ();
9593 var from = level .getBlockState (pos );
9694
9795 level .setBlockAndUpdate (pos , to );
9896 level .gameEvent (GameEvent .BLOCK_CHANGE , pos , GameEvent .Context .of (context .getPlayer (), from ));
99- level .addDestroyBlockEffect (pos , from );
10097
101- var vec = Vec3 .atCenterOf (pos );
102- level .addParticle (new BlockParticleOption (ParticleTypes .BLOCK , from ), vec .x , vec .y + 1 , vec .z , 0.0 , 0.0 , 0.0 );
98+ if (particles ) {
99+ level .addDestroyBlockEffect (pos , from );
100+ }
103101
104102 if (context .getPlayer () != null ) {
105103 context .getPlayer ().playSound (SoundEvents .GRINDSTONE_USE , 1F , 1.5F );
@@ -118,12 +116,17 @@ public InteractionResult useOn(UseOnContext context) {
118116
119117 if (state .hasProperty (ICrystalGlass .TYPE )) {
120118 var type = state .getValue (ICrystalGlass .TYPE );
121- return replaceBlock (context , state .setValue (ICrystalGlass .TYPE , (type + 1 ) % (ICrystalGlass .MAX_TYPE + 1 )));
119+ return replaceBlock (context , state .setValue (ICrystalGlass .TYPE , (type + 1 ) % (ICrystalGlass .MAX_TYPE + 1 )), true );
122120 }
123121
124122 var grooved = GROOVED_BLOCKS .get (state .getBlock ());
125123 if (grooved != null ) {
126- return replaceBlock (context , grooved .get ().defaultBlockState ());
124+ return replaceBlock (context , grooved .get ().defaultBlockState (), true );
125+ }
126+
127+ if (state .getBlock () instanceof AmethystClusterBlock && !state .is (Blocks .SMALL_AMETHYST_BUD )) {
128+ Block .dropResources (state , context .getLevel (), context .getClickedPos (), null , context .getPlayer (), new ItemStack (Items .IRON_PICKAXE ));
129+ return replaceBlock (context , Blocks .SMALL_AMETHYST_BUD .withPropertiesOf (state ), false );
127130 }
128131
129132 return super .useOn (context );
0 commit comments