3
3
import galena .oreganized .content .block .ICrystalGlass ;
4
4
import galena .oreganized .index .OBlocks ;
5
5
import net .minecraft .core .BlockPos ;
6
- import net .minecraft .core .particles .BlockParticleOption ;
7
- import net .minecraft .core .particles .ParticleTypes ;
8
6
import net .minecraft .sounds .SoundEvents ;
9
7
import net .minecraft .world .InteractionResult ;
10
8
import net .minecraft .world .entity .EquipmentSlot ;
16
14
import net .minecraft .world .item .enchantment .Enchantment ;
17
15
import net .minecraft .world .item .enchantment .EnchantmentCategory ;
18
16
import net .minecraft .world .level .Level ;
17
+ import net .minecraft .world .level .block .AmethystClusterBlock ;
19
18
import net .minecraft .world .level .block .Block ;
20
19
import net .minecraft .world .level .block .Blocks ;
21
20
import net .minecraft .world .level .block .state .BlockState ;
22
21
import net .minecraft .world .level .gameevent .GameEvent ;
23
- import net .minecraft .world .phys .Vec3 ;
24
22
25
23
import java .util .HashMap ;
26
24
import java .util .Map ;
@@ -89,17 +87,17 @@ public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantmen
89
87
return super .canApplyAtEnchantingTable (stack , enchantment );
90
88
}
91
89
92
- private InteractionResult replaceBlock (UseOnContext context , BlockState to ) {
90
+ private InteractionResult replaceBlock (UseOnContext context , BlockState to , boolean particles ) {
93
91
var level = context .getLevel ();
94
92
var pos = context .getClickedPos ();
95
93
var from = level .getBlockState (pos );
96
94
97
95
level .setBlockAndUpdate (pos , to );
98
96
level .gameEvent (GameEvent .BLOCK_CHANGE , pos , GameEvent .Context .of (context .getPlayer (), from ));
99
- level .addDestroyBlockEffect (pos , from );
100
97
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
+ }
103
101
104
102
if (context .getPlayer () != null ) {
105
103
context .getPlayer ().playSound (SoundEvents .GRINDSTONE_USE , 1F , 1.5F );
@@ -118,12 +116,17 @@ public InteractionResult useOn(UseOnContext context) {
118
116
119
117
if (state .hasProperty (ICrystalGlass .TYPE )) {
120
118
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 );
122
120
}
123
121
124
122
var grooved = GROOVED_BLOCKS .get (state .getBlock ());
125
123
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 );
127
130
}
128
131
129
132
return super .useOn (context );
0 commit comments