Skip to content

Commit 0304300

Browse files
committed
allow scribe to silk-touch blocks that are broken at normal speed
1 parent 5c2d5e4 commit 0304300

File tree

9 files changed

+225
-10
lines changed

9 files changed

+225
-10
lines changed

src/generated/resources/.cache/5bb646c3cee204f41a1b59a2c0d9083b5f7155b0

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// 1.20.1 2024-08-28T12:35:31.5287616 Oreganized Block Tags
1+
// 1.20.1 2024-09-05T19:34:00.0189291 Oreganized Block Tags
22
7a2d68d81bc5ee59f9a2f4ba68ddb39bfd9c875d data/forge/tags/blocks/glass.json
33
d96b4f83e03abe39a1b97d92b7818c8f6b2e5c68 data/forge/tags/blocks/glass_panes.json
44
d062c23ad5308b7de0b2e86f6531ea724530f898 data/forge/tags/blocks/melts_lead.json
@@ -30,5 +30,6 @@ a4acb3623320f801e89e3451f8b7d9e2246f99d0 data/minecraft/tags/blocks/walls.json
3030
81fb1b18afaa14ae90800b23c32de565d1389bb3 data/oreganized/tags/blocks/crystal_glass.json
3131
f1dfddab1e3f2dec1e7ed1c3fbf9f6a7f261cf08 data/oreganized/tags/blocks/crystal_glass_panes.json
3232
6b73bb0ce38222c428d54ee64e82ffa1d96c64d7 data/oreganized/tags/blocks/fire_source.json
33-
81e3d74d8e9abfe57f1388c75a381dd419a44695 data/oreganized/tags/blocks/mineable/scribe.json
33+
9844c422f9aee3bd87aa2008ccbe179ee652c60b data/oreganized/tags/blocks/mineable/scribe.json
34+
73d66f372d8c4d1b45f3aa477fbb0a97cfa88b10 data/oreganized/tags/blocks/silktouch_using_scribe.json
3435
3112fb4a1df2953e2c3572fa47f886bf8e5bd679 data/oreganized/tags/blocks/stone_types/glance.json

src/generated/resources/data/oreganized/tags/blocks/mineable/scribe.json

+159-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,164 @@
33
"#forge:glass",
44
"#forge:obsidian",
55
"#minecraft:ice",
6-
"#forge:storage_blocks/amethyst"
6+
"#minecraft:crystal_sound_blocks",
7+
"#forge:storage_blocks/amethyst",
8+
"minecraft:budding_amethyst",
9+
"minecraft:large_amethyst_bud",
10+
"minecraft:medium_amethyst_bud",
11+
"minecraft:small_amethyst_bud",
12+
"#forge:storage_blocks/quartz",
13+
"minecraft:quartz_bricks",
14+
"minecraft:quartz_pillar",
15+
"minecraft:quartz_slab",
16+
"minecraft:quartz_stairs",
17+
"minecraft:chiseled_quartz_block",
18+
"minecraft:smooth_quartz",
19+
"minecraft:smooth_quartz_slab",
20+
"minecraft:smooth_quartz_stairs",
21+
{
22+
"id": "quark:red_corundum",
23+
"required": false
24+
},
25+
{
26+
"id": "quark:orange_corundum",
27+
"required": false
28+
},
29+
{
30+
"id": "quark:yellow_corundum",
31+
"required": false
32+
},
33+
{
34+
"id": "quark:green_corundum",
35+
"required": false
36+
},
37+
{
38+
"id": "quark:blue_corundum",
39+
"required": false
40+
},
41+
{
42+
"id": "quark:indigo_corundum",
43+
"required": false
44+
},
45+
{
46+
"id": "quark:violet_corundum",
47+
"required": false
48+
},
49+
{
50+
"id": "quark:white_corundum",
51+
"required": false
52+
},
53+
{
54+
"id": "quark:black_corundum",
55+
"required": false
56+
},
57+
{
58+
"id": "quark:waxed_red_corundum",
59+
"required": false
60+
},
61+
{
62+
"id": "quark:waxed_orange_corundum",
63+
"required": false
64+
},
65+
{
66+
"id": "quark:waxed_yellow_corundum",
67+
"required": false
68+
},
69+
{
70+
"id": "quark:waxed_green_corundum",
71+
"required": false
72+
},
73+
{
74+
"id": "quark:waxed_blue_corundum",
75+
"required": false
76+
},
77+
{
78+
"id": "quark:waxed_indigo_corundum",
79+
"required": false
80+
},
81+
{
82+
"id": "quark:waxed_violet_corundum",
83+
"required": false
84+
},
85+
{
86+
"id": "quark:waxed_white_corundum",
87+
"required": false
88+
},
89+
{
90+
"id": "quark:waxed_black_corundum",
91+
"required": false
92+
},
93+
{
94+
"id": "quark:red_corundum_cluster",
95+
"required": false
96+
},
97+
{
98+
"id": "quark:orange_corundum_cluster",
99+
"required": false
100+
},
101+
{
102+
"id": "quark:yellow_corundum_cluster",
103+
"required": false
104+
},
105+
{
106+
"id": "quark:green_corundum_cluster",
107+
"required": false
108+
},
109+
{
110+
"id": "quark:blue_corundum_cluster",
111+
"required": false
112+
},
113+
{
114+
"id": "quark:indigo_corundum_cluster",
115+
"required": false
116+
},
117+
{
118+
"id": "quark:violet_corundum_cluster",
119+
"required": false
120+
},
121+
{
122+
"id": "quark:white_corundum_cluster",
123+
"required": false
124+
},
125+
{
126+
"id": "quark:black_corundum_cluster",
127+
"required": false
128+
},
129+
{
130+
"id": "quark:red_corundum_pane",
131+
"required": false
132+
},
133+
{
134+
"id": "quark:orange_corundum_pane",
135+
"required": false
136+
},
137+
{
138+
"id": "quark:yellow_corundum_pane",
139+
"required": false
140+
},
141+
{
142+
"id": "quark:green_corundum_pane",
143+
"required": false
144+
},
145+
{
146+
"id": "quark:blue_corundum_pane",
147+
"required": false
148+
},
149+
{
150+
"id": "quark:indigo_corundum_pane",
151+
"required": false
152+
},
153+
{
154+
"id": "quark:violet_corundum_pane",
155+
"required": false
156+
},
157+
{
158+
"id": "quark:white_corundum_pane",
159+
"required": false
160+
},
161+
{
162+
"id": "quark:black_corundum_pane",
163+
"required": false
164+
}
7165
]
8166
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"values": [
3+
"#minecraft:mineable/pickaxe"
4+
]
5+
}

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

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
package galena.oreganized.content.item;
22

3+
import galena.oreganized.index.OTags;
34
import net.minecraft.core.BlockPos;
45
import net.minecraft.world.entity.EquipmentSlot;
56
import net.minecraft.world.entity.LivingEntity;
67
import net.minecraft.world.item.Item;
78
import net.minecraft.world.item.ItemStack;
89
import net.minecraft.world.level.Level;
10+
import net.minecraft.world.level.block.Block;
911
import net.minecraft.world.level.block.state.BlockState;
1012

1113
import static galena.oreganized.index.OTags.Blocks.MINEABLE_WITH_SCRIBE;
14+
import static galena.oreganized.index.OTags.Blocks.SILKTOUCH_WITH_SCRIBE;
1215

1316
public class ScribeItem extends Item {
1417

@@ -28,12 +31,22 @@ public boolean mineBlock(ItemStack stack, Level level, BlockState state, BlockPo
2831

2932
@Override
3033
public float getDestroySpeed(ItemStack stack, BlockState state) {
31-
return isCorrectToolForDrops(stack, state) ? 32F : 3F;
34+
if (state.is(MINEABLE_WITH_SCRIBE)) return 32F;
35+
else if (isCorrectToolForDrops(stack, state)) return 0.3F;
36+
return super.getDestroySpeed(stack, state);
37+
}
38+
39+
public boolean dropsLikeSilktouch(ItemStack stack, BlockState state) {
40+
return isCorrectToolForDrops(state);
3241
}
3342

3443
@Override
3544
public boolean isCorrectToolForDrops(BlockState state) {
36-
return state.is(MINEABLE_WITH_SCRIBE);
45+
return state.is(SILKTOUCH_WITH_SCRIBE);
3746
}
3847

48+
@Override
49+
public boolean isValidRepairItem(ItemStack stack, ItemStack repairStack) {
50+
return repairStack.is(OTags.Items.INGOTS_SILVER);
51+
}
3952
}

src/main/java/galena/oreganized/data/OBlockTags.java

+39-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import net.minecraft.core.registries.Registries;
77
import net.minecraft.data.PackOutput;
88
import net.minecraft.data.tags.IntrinsicHolderTagsProvider;
9+
import net.minecraft.resources.ResourceLocation;
910
import net.minecraft.tags.BlockTags;
1011
import net.minecraft.world.level.block.Block;
1112
import net.minecraft.world.level.block.Blocks;
@@ -15,6 +16,7 @@
1516

1617
import javax.annotation.Nullable;
1718
import java.util.concurrent.CompletableFuture;
19+
import java.util.stream.Stream;
1820

1921
import static galena.oreganized.index.OTags.Blocks.CRYSTAL_GLASS;
2022
import static galena.oreganized.index.OTags.Blocks.CRYSTAL_GLASS_PANES;
@@ -23,6 +25,7 @@
2325
import static galena.oreganized.index.OTags.Blocks.MINEABLE_WITH_SCRIBE;
2426
import static galena.oreganized.index.OTags.Blocks.ORES_LEAD;
2527
import static galena.oreganized.index.OTags.Blocks.ORES_SILVER;
28+
import static galena.oreganized.index.OTags.Blocks.SILKTOUCH_WITH_SCRIBE;
2629
import static galena.oreganized.index.OTags.Blocks.STONE_TYPES_GLANCE;
2730
import static galena.oreganized.index.OTags.Blocks.STORAGE_BLOCKS_ELECTRUM;
2831
import static galena.oreganized.index.OTags.Blocks.STORAGE_BLOCKS_LEAD;
@@ -166,10 +169,44 @@ protected void addTags(HolderLookup.Provider provider) {
166169
.addTags(BlockTags.CAMPFIRES)
167170
.addTags(BlockTags.FIRE);
168171

169-
tag(MINEABLE_WITH_SCRIBE)
172+
var scribeMineable = tag(MINEABLE_WITH_SCRIBE)
170173
.addTags(Tags.Blocks.GLASS)
171174
.addTags(Tags.Blocks.OBSIDIAN)
172175
.addTags(BlockTags.ICE)
173-
.addTags(Tags.Blocks.STORAGE_BLOCKS_AMETHYST);
176+
.addTags(BlockTags.CRYSTAL_SOUND_BLOCKS)
177+
.addTags(Tags.Blocks.STORAGE_BLOCKS_AMETHYST)
178+
.add(Blocks.AMETHYST_CLUSTER)
179+
.add(Blocks.LARGE_AMETHYST_BUD)
180+
.add(Blocks.MEDIUM_AMETHYST_BUD)
181+
.add(Blocks.SMALL_AMETHYST_BUD);
182+
183+
scribeMineable
184+
.addTags(Tags.Blocks.STORAGE_BLOCKS_QUARTZ)
185+
.add(Blocks.QUARTZ_BRICKS)
186+
.add(Blocks.QUARTZ_PILLAR)
187+
.add(Blocks.QUARTZ_SLAB)
188+
.add(Blocks.QUARTZ_STAIRS)
189+
.add(Blocks.CHISELED_QUARTZ_BLOCK)
190+
.add(Blocks.SMOOTH_QUARTZ)
191+
.add(Blocks.SMOOTH_QUARTZ_SLAB)
192+
.add(Blocks.SMOOTH_QUARTZ_STAIRS);
193+
194+
Stream.of("%s", "waxed_%s", "%s_cluster", "%s_pane").forEach(pattern -> {
195+
scribeMineable
196+
.addOptional(new ResourceLocation("quark", pattern.formatted("red_corundum")))
197+
.addOptional(new ResourceLocation("quark", pattern.formatted("orange_corundum")))
198+
.addOptional(new ResourceLocation("quark", pattern.formatted("yellow_corundum")))
199+
.addOptional(new ResourceLocation("quark", pattern.formatted("green_corundum")))
200+
.addOptional(new ResourceLocation("quark", pattern.formatted("blue_corundum")))
201+
.addOptional(new ResourceLocation("quark", pattern.formatted("indigo_corundum")))
202+
.addOptional(new ResourceLocation("quark", pattern.formatted("violet_corundum")))
203+
.addOptional(new ResourceLocation("quark", pattern.formatted("white_corundum")))
204+
.addOptional(new ResourceLocation("quark", pattern.formatted("black_corundum")))
205+
;
206+
});
207+
208+
tag(SILKTOUCH_WITH_SCRIBE)
209+
.addTags(MINEABLE_WITH_SCRIBE)
210+
.addTags(BlockTags.MINEABLE_WITH_PICKAXE);
174211
}
175212
}

src/main/java/galena/oreganized/index/OItems.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static Supplier<? extends Item> compat(String modid, Function<Item.Proper
6161

6262
// Tools
6363
public static final RegistryObject<Item> BUSH_HAMMER = HELPER.createItem("bush_hammer", () -> new BushHammerItem(OItemTiers.LEAD, 2.5F, -2.8F, (new Item.Properties()).stacksTo(1)));
64-
public static final RegistryObject<Item> SCRIBE = HELPER.createItem("scribe", () -> new ScribeItem(new Item.Properties().stacksTo(1)));
64+
public static final RegistryObject<Item> SCRIBE = HELPER.createItem("scribe", () -> new ScribeItem(new Item.Properties().durability(250)));
6565

6666
public static final RegistryObject<Item> ELECTRUM_SWORD = HELPER.createItem("electrum_sword", () -> new SwordItem(OItemTiers.ELECTRUM, 3, -2.2F, (new Item.Properties())));
6767
public static final RegistryObject<Item> ELECTRUM_SHOVEL = HELPER.createItem("electrum_shovel", () -> new ShovelItem(OItemTiers.ELECTRUM, 1.5F, -2.8F, (new Item.Properties())));

src/main/java/galena/oreganized/index/OTags.java

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public static class Blocks {
6868

6969
public static final TagKey<Block> MINEABLE_WITH_BUSH_HAMMER = tag("mineable/bush_hammer");
7070
public static final TagKey<Block> MINEABLE_WITH_SCRIBE = tag("mineable/scribe");
71+
public static final TagKey<Block> SILKTOUCH_WITH_SCRIBE = tag("silktouch_using_scribe");
7172
public static final TagKey<Block> ENGRAVABLE = tag("engravable");
7273
public static final TagKey<Block> ENGRAVABLE_NEEDS_PLATE = tag("engravable/needs_plate");
7374
public static final TagKey<Block> FIRE_SOURCE = tag("fire_source");

src/main/java/galena/oreganized/mixin/BlockMixin.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class BlockMixin {
2020
at = @At(value = "STORE")
2121
)
2222
private static LootParams.Builder modifyLootBuilder(LootParams.Builder builder, @Local BlockState state, @Local ItemStack stack) {
23-
if (stack.getItem() instanceof ScribeItem scribe && scribe.isCorrectToolForDrops(stack, state)) {
23+
if (stack.getItem() instanceof ScribeItem scribe && scribe.dropsLikeSilktouch(stack, state)) {
2424
var virtual = stack.copy();
2525
virtual.enchant(Enchantments.SILK_TOUCH, 1);
2626
return builder.withParameter(LootContextParams.TOOL, virtual);

src/main/java/galena/oreganized/mixin/IceBlockMixin.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class IceBlockMixin {
2121
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/enchantment/EnchantmentHelper;getItemEnchantmentLevel(Lnet/minecraft/world/item/enchantment/Enchantment;Lnet/minecraft/world/item/ItemStack;)I")
2222
)
2323
private int modifyLootBuilder(Enchantment enchantment, ItemStack stack, @Local BlockState state) {
24-
if (stack.getItem() instanceof ScribeItem scribe && scribe.isCorrectToolForDrops(stack, state)) {
24+
if (stack.getItem() instanceof ScribeItem scribe && scribe.dropsLikeSilktouch(stack, state)) {
2525
return 1;
2626
}
2727
return EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, stack);

0 commit comments

Comments
 (0)