Skip to content

Commit 5c967f9

Browse files
committed
scribe can shear of shards from amethyst clusters
1 parent 63ae8b8 commit 5c967f9

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/main/java/galena/oreganized/content/item/ScribeItem.java

+12-9
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import galena.oreganized.content.block.ICrystalGlass;
44
import galena.oreganized.index.OBlocks;
55
import net.minecraft.core.BlockPos;
6-
import net.minecraft.core.particles.BlockParticleOption;
7-
import net.minecraft.core.particles.ParticleTypes;
86
import net.minecraft.sounds.SoundEvents;
97
import net.minecraft.world.InteractionResult;
108
import net.minecraft.world.entity.EquipmentSlot;
@@ -16,11 +14,11 @@
1614
import net.minecraft.world.item.enchantment.Enchantment;
1715
import net.minecraft.world.item.enchantment.EnchantmentCategory;
1816
import net.minecraft.world.level.Level;
17+
import net.minecraft.world.level.block.AmethystClusterBlock;
1918
import net.minecraft.world.level.block.Block;
2019
import net.minecraft.world.level.block.Blocks;
2120
import net.minecraft.world.level.block.state.BlockState;
2221
import net.minecraft.world.level.gameevent.GameEvent;
23-
import net.minecraft.world.phys.Vec3;
2422

2523
import java.util.HashMap;
2624
import 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

Comments
 (0)