Skip to content

Commit 2848438

Browse files
committed
change instances of Block to use ResourceLocation
1 parent c71017e commit 2848438

File tree

6 files changed

+18
-27
lines changed

6 files changed

+18
-27
lines changed

src/client/java/aztech/modern_industrialization/textures/PartTextureGenerator.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@
3636
import com.mojang.blaze3d.platform.NativeImage;
3737
import java.io.IOException;
3838
import java.util.Objects;
39-
import net.minecraft.core.registries.BuiltInRegistries;
4039
import net.minecraft.resources.ResourceLocation;
41-
import net.minecraft.world.level.block.Block;
4240

4341
/**
4442
* All the per-part texture processing logic.
@@ -156,9 +154,9 @@ private void processHotIngot() {
156154
material.get(SET).name, itemPath, false, new HotIngotColoramp(coloramp, 0.1, 0.5));
157155
}
158156

159-
private void processOre(Block stoneType, MaterialOreSet oreSet) throws IOException {
157+
private void processOre(ResourceLocation stoneType, MaterialOreSet oreSet) throws IOException {
160158
String template = String.format("modern_industrialization:textures/materialsets/ores/%s.png", oreSet.name);
161-
String stoneId = BuiltInRegistries.BLOCK.getKey(stoneType).getPath();
159+
String stoneId = stoneType.getPath();
162160
String prefix = "";
163161

164162
String from = switch (oreSet) {

src/main/java/aztech/modern_industrialization/compat/kubejs/material/MaterialBuilderJSWrapper.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@
3737
import aztech.modern_industrialization.nuclear.IsotopeFuelParams;
3838
import aztech.modern_industrialization.nuclear.NuclearConstant;
3939
import com.google.gson.JsonObject;
40-
import net.minecraft.core.registries.BuiltInRegistries;
4140
import net.minecraft.resources.ResourceLocation;
42-
import net.minecraft.world.level.block.Block;
4341

4442
public class MaterialBuilderJSWrapper {
4543

@@ -146,14 +144,14 @@ public MaterialBuilderJSWrapper specialCasing(String englishName, String path, f
146144
return this;
147145
}
148146

149-
public MaterialBuilderJSWrapper ore(JsonObject json, Block stoneType) {
147+
public MaterialBuilderJSWrapper ore(JsonObject json, ResourceLocation stoneType) {
150148
materialBuilder.addParts(creator.orePart(json, stoneType));
151149
return this;
152150
}
153151

154152
public MaterialBuilderJSWrapper ore(JsonObject json) {
155-
Block stone = BuiltInRegistries.BLOCK.get(ResourceLocation.fromNamespaceAndPath("minecraft", "stone"));
156-
Block deepslate = BuiltInRegistries.BLOCK.get(ResourceLocation.fromNamespaceAndPath("minecraft", "deepslate"));
153+
ResourceLocation stone = ResourceLocation.fromNamespaceAndPath("minecraft", "stone");
154+
ResourceLocation deepslate = ResourceLocation.fromNamespaceAndPath("minecraft", "deepslate");
157155
materialBuilder.addParts(creator.orePart(json, deepslate));
158156
materialBuilder.addParts(creator.orePart(json, stone));
159157
return this;

src/main/java/aztech/modern_industrialization/compat/kubejs/material/PartJsonCreator.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@
3333
import aztech.modern_industrialization.materials.set.MaterialRawSet;
3434
import aztech.modern_industrialization.nuclear.NuclearConstant;
3535
import com.google.gson.JsonObject;
36-
import net.minecraft.core.registries.BuiltInRegistries;
36+
import net.minecraft.resources.ResourceLocation;
3737
import net.minecraft.util.valueproviders.UniformInt;
38-
import net.minecraft.world.level.block.Block;
3938

4039
public class PartJsonCreator {
4140

@@ -112,8 +111,8 @@ public PartTemplate specialCasing(String englishName, String path, float resista
112111
return MIParts.MACHINE_CASING_SPECIAL.of(englishName, path, resistance);
113112
}
114113

115-
public PartTemplate orePart(JsonObject json, Block stoneType) {
116-
String stoneId = BuiltInRegistries.BLOCK.getKey(stoneType).getPath();
114+
public PartTemplate orePart(JsonObject json, ResourceLocation stoneType) {
115+
String stoneId = stoneType.getPath();
117116
OrePart act;
118117
// I'm not positive that these first two branches actually need to exist. I am in need of guidance.
119118
if (stoneId.equals("stone")) {

src/main/java/aztech/modern_industrialization/materials/part/MIParts.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@
3131
import java.util.List;
3232
import java.util.Map;
3333
import java.util.Set;
34-
import net.minecraft.core.registries.BuiltInRegistries;
3534
import net.minecraft.resources.ResourceLocation;
3635
import net.minecraft.tags.TagKey;
3736
import net.minecraft.world.item.Item;
38-
import net.minecraft.world.level.block.Block;
3937
import net.neoforged.neoforge.common.Tags;
4038

4139
public class MIParts {
@@ -77,8 +75,8 @@ public class MIParts {
7775
public static final CasingPart MACHINE_CASING_SPECIAL = new CasingPart("Special Casing", "machine_casing_special");
7876
public static final PartTemplate NUGGET = new PartTemplate("Nugget", "nugget");
7977

80-
private static final Block STONE = BuiltInRegistries.BLOCK.get(ResourceLocation.fromNamespaceAndPath("minecraft", "stone"));
81-
private static final Block DEEPSLATE = BuiltInRegistries.BLOCK.get(ResourceLocation.fromNamespaceAndPath("minecraft", "deepslate"));
78+
private static final ResourceLocation STONE = ResourceLocation.fromNamespaceAndPath("minecraft", "stone");
79+
private static final ResourceLocation DEEPSLATE = ResourceLocation.fromNamespaceAndPath("minecraft", "deepslate");
8280
public static final OrePart ORE = new OrePart(STONE);
8381
public static final OrePart ORE_DEEPSLATE = new OrePart(DEEPSLATE);
8482

src/main/java/aztech/modern_industrialization/materials/part/OrePart.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import net.minecraft.tags.BiomeTags;
4747
import net.minecraft.tags.BlockTags;
4848
import net.minecraft.util.valueproviders.UniformInt;
49-
import net.minecraft.world.level.block.Block;
5049
import net.minecraft.world.level.levelgen.GenerationStep;
5150
import net.minecraft.world.level.levelgen.VerticalAnchor;
5251
import net.minecraft.world.level.levelgen.feature.Feature;
@@ -58,7 +57,7 @@
5857
import net.neoforged.neoforge.registries.NeoForgeRegistries;
5958

6059
public class OrePart implements PartKeyProvider {
61-
public final Block stoneType;
60+
public final ResourceLocation stoneType;
6261
public final String stoneId;
6362
public final String stoneName;
6463
public final PartKey key;
@@ -84,10 +83,10 @@ public PartTemplate of(MaterialOreSet set) {
8483
return of(new OrePartParams(UniformInt.of(0, 0), set));
8584
}
8685

87-
public OrePart(Block stoneType) {
86+
public OrePart(ResourceLocation stoneType) {
8887
this.stoneType = stoneType;
89-
stoneId = BuiltInRegistries.BLOCK.getKey(stoneType).getPath();
90-
stoneName = stoneType.getName().getString();
88+
stoneId = stoneType.getPath();
89+
stoneName = BuiltInRegistries.BLOCK.get(stoneType).getName().getString();
9190
if (stoneId.equals("stone")) {
9291
key = new PartKey("ore");
9392
} else {
@@ -115,13 +114,13 @@ public PartTemplate of(OrePartParams oreParams) {
115114
oreBlockBlockDefinition = MIBlock.block(
116115
englishName,
117116
itemPath,
118-
MIBlock.BlockDefinitionParams.of(stoneType.properties())
117+
MIBlock.BlockDefinitionParams.of(BuiltInRegistries.BLOCK.get(stoneType).properties())
119118
.withBlockConstructor(s -> new OreBlock(s, oreParams, partContext.getMaterialName()))
120119
.withLoot(new MIBlockLoot.Ore(loot))
121120
.sortOrder(SortOrder.ORES.and(partContext.getMaterialName()))
122121
// even if an ore is made of something weak,
123122
// like netherrack, it should still take at least as long to mine as a stone block.
124-
.destroyTime(Math.max(stoneType.defaultDestroyTime(), 2.25f)));
123+
.destroyTime(Math.max(BuiltInRegistries.BLOCK.get(stoneType).defaultDestroyTime(), 2.25f)));
125124

126125
// Sanity check: Ensure that ores don't drop xp, iff the main part is an ingot
127126
// (i.e. the drop is raw ore).

src/main/java/aztech/modern_industrialization/materials/part/TextureGenParams.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import aztech.modern_industrialization.materials.set.MaterialBlockSet;
2727
import aztech.modern_industrialization.materials.set.MaterialOreSet;
2828
import aztech.modern_industrialization.materials.set.MaterialRawSet;
29+
import net.minecraft.resources.ResourceLocation;
2930
import org.jetbrains.annotations.Nullable;
3031

3132
public sealed interface TextureGenParams {
@@ -53,9 +54,7 @@ record Gem() implements TextureGenParams {
5354
record HotIngot() implements TextureGenParams {
5455
}
5556

56-
// not thrilled about this fully qualified type,
57-
// but I don't actually see a way around it without renaming `TextureGenParams.Block`
58-
record Ore(net.minecraft.world.level.block.Block stoneType, MaterialOreSet oreSet) implements TextureGenParams {
57+
record Ore(ResourceLocation stoneType, MaterialOreSet oreSet) implements TextureGenParams {
5958
}
6059

6160
record RawMetal(boolean isBlock, MaterialRawSet rawSet) implements TextureGenParams {

0 commit comments

Comments
 (0)