Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public class BonkRecipeCapability extends RecipeCapability<BonkIngredient> {
public final static BonkRecipeCapability CAP = new BonkRecipeCapability();

protected BonkRecipeCapability() {
super(new ResourceLocation("MOD_ID", "bonk"), 0x777777, false, 5, BonkIngredient.Serializer.INSTANCE);
super(ResourceLocation.fromNamespaceAndPath("MOD_ID", "bonk"), 0x777777, false, 5, BonkIngredient.Serializer.INSTANCE);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion docs/content/Modpacks/Other-Topics/Ambiguous-Methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ or
GTCEuStartupEvents.registry("gtceu:recipe_type", event => {
event.create("unboxinator")
.setProgressBar(
ResourceTexture["(net.minecraft.resources.ResourceLocation)"](new ResourceLocation("kubejs:textures/gui/progress_bar/progress_bar_stone_oreifier.png")),
ResourceTexture["(net.minecraft.resources.ResourceLocation)"](ResourceLocation.tryParse("kubejs:textures/gui/progress_bar/progress_bar_stone_oreifier.png")),
Comment thread
gustovafing marked this conversation as resolved.
Outdated
FillDirection.LEFT_TO_RIGHT
)
// Rest of the recipe type
Expand Down
6 changes: 3 additions & 3 deletions docs/content/Modpacks/Other-Topics/Dimension-Icons.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Below is an example of making new and modifying existing dimension icons in a Ja
```java
private void registerDimensionMarkers(GTCEuAPI.RegisterEvent<ResourceLocation, DimensionMarker> event) {
// Making a new icon.
ResourceLocation sceneDimKey = new ResourceLocation(Phantasia.MOD_ID, "scene");
ResourceLocation sceneDimKey = ResourceLocation.fromNamespaceAndPath(Phantasia.MOD_ID, "scene");
DimensionMarker sceneMarker = new DimensionMarker(
3, // Tier
() -> Items.DIAMOND_BLOCK, // Supplier for the actual Icon ItemStack.
Expand All @@ -24,7 +24,7 @@ private void registerDimensionMarkers(GTCEuAPI.RegisterEvent<ResourceLocation, D
event.register(sceneDimKey, sceneMarker);

// Editing an existing icon.
ResourceLocation netherKey = new ResourceLocation("minecraft", "the_nether");
ResourceLocation netherKey = ResourceLocation.withDefaultNamespace("the_nether");
DimensionMarker upgradedNetherMarker = new DimensionMarker(
5,
() -> Items.NETHERITE_BLOCK,
Expand All @@ -41,7 +41,7 @@ GTCEuStartupEvents.registry("gtceu:dimension_marker", event => {
// Edit existing dimension icon,
const DimensionMarker = Java.loadClass('com.gregtechceu.gtceu.api.data.DimensionMarker')

let netherKey = new ResourceLocation("minecraft", "the_nether")
let netherKey = ResourceLocation.withDefaultNamespace("the_nether")

let upgradedNetherMarker = new DimensionMarker(
5,
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/gregtechceu/gtceu/GTCEu.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public class GTCEu {

public static final String MOD_ID = "gtceu";
private static final ResourceLocation TEMPLATE_LOCATION = new ResourceLocation(MOD_ID, "");
private static final ResourceLocation TEMPLATE_LOCATION = ResourceLocation.fromNamespaceAndPath(MOD_ID, "");
public static final String NAME = "GregTechCEu";
public static final Logger LOGGER = LogManager.getLogger(NAME);

Expand All @@ -51,7 +51,7 @@ public static ResourceLocation id(String path) {

int i = path.indexOf(':');
if (i > 0) {
return new ResourceLocation(path);
return ResourceLocation.parse(path);
} else if (i == 0) {
path = path.substring(i + 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ private CompoundTag createCoverConfigTag(@Nullable CoverBehavior cover) {

private void applyCoverConfigTag(ServerPlayer player, Direction dir, CompoundTag tag) {
if (tag.isEmpty()) return;
var def = GTRegistries.COVERS.get(new ResourceLocation(tag.getString("id")));
var def = GTRegistries.COVERS.get(ResourceLocation.tryParse(tag.getString("id")));
Comment thread
gustovafing marked this conversation as resolved.
Outdated
ItemStack stack = ItemStack.of(tag.getCompound("item"));
if (def == null) return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private CapeRegistry load(CompoundTag tag) {
String capeId = capesTag.getString(j);
if (capeId.isEmpty())
continue;
capes.add(new ResourceLocation(capeId));
capes.add(ResourceLocation.parse(capeId));
}
UNLOCKED_CAPES.put(uuid, capes);
}
Expand All @@ -130,7 +130,7 @@ private CapeRegistry load(CompoundTag tag) {
if (capeId.isEmpty())
continue;
UUID uuid = entryTag.getUUID("owner");
CURRENT_CAPES.put(uuid, new ResourceLocation(capeId));
CURRENT_CAPES.put(uuid, ResourceLocation.tryParse(capeId));
Comment thread
gustovafing marked this conversation as resolved.
Outdated
}

return this;
Expand Down
26 changes: 13 additions & 13 deletions src/main/java/com/gregtechceu/gtceu/api/data/tag/TagPrefix.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,28 +104,28 @@ public boolean isEmpty() {
.registerOre(
Blocks.STONE::defaultBlockState, () -> GTMaterials.Stone, BlockBehaviour.Properties.of()
.mapColor(MapColor.STONE).requiresCorrectToolForDrops().strength(3.0F, 3.0F),
new ResourceLocation("block/stone"), false, false, true);
ResourceLocation.withDefaultNamespace("block/stone"), false, false, true);

public static final TagPrefix oreGranite = oreTagPrefix(GTCEu.id("granite"), BlockTags.MINEABLE_WITH_PICKAXE)
.langValue("Granite %s Ore")
.registerOre(
Blocks.GRANITE::defaultBlockState, () -> GTMaterials.Granite, BlockBehaviour.Properties.of()
.mapColor(MapColor.DIRT).requiresCorrectToolForDrops().strength(3.0F, 3.0F),
new ResourceLocation("block/granite"));
ResourceLocation.withDefaultNamespace("block/granite"));

public static final TagPrefix oreDiorite = oreTagPrefix(GTCEu.id("diorite"), BlockTags.MINEABLE_WITH_PICKAXE)
.langValue("Diorite %s Ore")
.registerOre(
Blocks.DIORITE::defaultBlockState, () -> GTMaterials.Diorite, BlockBehaviour.Properties.of()
.mapColor(MapColor.QUARTZ).requiresCorrectToolForDrops().strength(3.0F, 3.0F),
new ResourceLocation("block/diorite"));
ResourceLocation.withDefaultNamespace("block/diorite"));

public static final TagPrefix oreAndesite = oreTagPrefix(GTCEu.id("andesite"), BlockTags.MINEABLE_WITH_PICKAXE)
.langValue("Andesite %s Ore")
.registerOre(
Blocks.ANDESITE::defaultBlockState, () -> GTMaterials.Andesite, BlockBehaviour.Properties.of()
.mapColor(MapColor.DIRT).requiresCorrectToolForDrops().strength(3.0F, 3.0F),
new ResourceLocation("block/andesite"));
ResourceLocation.withDefaultNamespace("block/andesite"));

public static final TagPrefix oreRedGranite = oreTagPrefix("red_granite", BlockTags.MINEABLE_WITH_PICKAXE)
.langValue("Red Granite %s Ore")
Expand All @@ -147,66 +147,66 @@ public boolean isEmpty() {
Blocks.DEEPSLATE::defaultBlockState, () -> GTMaterials.Deepslate, BlockBehaviour.Properties.of()
.mapColor(MapColor.DEEPSLATE).requiresCorrectToolForDrops().strength(4.5F, 3.0F)
.sound(SoundType.DEEPSLATE),
new ResourceLocation("block/deepslate"), false, false, true);
ResourceLocation.withDefaultNamespace("block/deepslate"), false, false, true);

public static final TagPrefix oreTuff = oreTagPrefix(GTCEu.id("tuff"), BlockTags.MINEABLE_WITH_PICKAXE)
.langValue("Tuff %s Ore")
.registerOre(
Blocks.TUFF::defaultBlockState, () -> GTMaterials.Tuff, BlockBehaviour.Properties.of()
.mapColor(MapColor.TERRACOTTA_GRAY).requiresCorrectToolForDrops().strength(3.0F, 3.0F)
.sound(SoundType.TUFF),
new ResourceLocation("block/tuff"));
ResourceLocation.withDefaultNamespace("block/tuff"));

public static final TagPrefix oreSand = oreTagPrefix(GTCEu.id("sand"), BlockTags.MINEABLE_WITH_SHOVEL)
.langValue("Sand %s Ore")
.registerOre(Blocks.SAND::defaultBlockState, () -> GTMaterials.SiliconDioxide,
BlockBehaviour.Properties.of().mapColor(MapColor.SAND).instrument(NoteBlockInstrument.SNARE)
.strength(0.5F).sound(SoundType.SAND),
new ResourceLocation("block/sand"), false, true, false);
ResourceLocation.withDefaultNamespace("block/sand"), false, true, false);

public static final TagPrefix oreRedSand = oreTagPrefix(GTCEu.id("redSand"), BlockTags.MINEABLE_WITH_SHOVEL)
.langValue("Red Sand %s Ore")
.registerOre(Blocks.RED_SAND::defaultBlockState, () -> GTMaterials.SiliconDioxide,
BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_ORANGE).instrument(NoteBlockInstrument.SNARE)
.strength(0.5F).sound(SoundType.SAND),
new ResourceLocation("block/red_sand"), false, true, false);
ResourceLocation.withDefaultNamespace("block/red_sand"), false, true, false);

public static final TagPrefix oreGravel = oreTagPrefix(GTCEu.id("gravel"), BlockTags.MINEABLE_WITH_SHOVEL)
.langValue("Gravel %s Ore")
.registerOre(Blocks.GRAVEL::defaultBlockState, () -> GTMaterials.Flint,
BlockBehaviour.Properties.of().mapColor(MapColor.STONE).instrument(NoteBlockInstrument.SNARE)
.strength(0.6F).sound(SoundType.GRAVEL),
new ResourceLocation("block/gravel"), false, true, false);
ResourceLocation.withDefaultNamespace("block/gravel"), false, true, false);

public static final TagPrefix oreBasalt = oreTagPrefix(GTCEu.id("basalt"), BlockTags.MINEABLE_WITH_PICKAXE)
.langValue("Basalt %s Ore")
.registerOre(Blocks.BASALT::defaultBlockState, () -> GTMaterials.Basalt,
BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BLACK)
.instrument(NoteBlockInstrument.BASEDRUM).requiresCorrectToolForDrops().strength(2.5F, 4.2F)
.sound(SoundType.BASALT),
new ResourceLocation("block/basalt"), true);
ResourceLocation.withDefaultNamespace("block/basalt"), true);

public static final TagPrefix oreNetherrack = oreTagPrefix(GTCEu.id("netherrack"), BlockTags.MINEABLE_WITH_PICKAXE)
.langValue("Nether %s Ore")
.registerOre(Blocks.NETHERRACK::defaultBlockState, () -> GTMaterials.Netherrack,
BlockBehaviour.Properties.of().mapColor(MapColor.NETHER).instrument(NoteBlockInstrument.BASEDRUM)
.requiresCorrectToolForDrops().strength(3.0F, 3.0F).sound(SoundType.NETHER_ORE),
new ResourceLocation("block/netherrack"), true, false, true);
ResourceLocation.withDefaultNamespace("block/netherrack"), true, false, true);

public static final TagPrefix oreBlackstone = oreTagPrefix(GTCEu.id("blackstone"), BlockTags.MINEABLE_WITH_PICKAXE)
.langValue("Blackstone %s Ore")
.registerOre(Blocks.BLACKSTONE::defaultBlockState, () -> GTMaterials.Blackstone,
BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BLACK)
.instrument(NoteBlockInstrument.BASEDRUM).requiresCorrectToolForDrops()
.strength(3.0F, 3.0F),
new ResourceLocation("block/blackstone"), true, false, false);
ResourceLocation.withDefaultNamespace("block/blackstone"), true, false, false);

public static final TagPrefix oreEndstone = oreTagPrefix(GTCEu.id("endstone"), BlockTags.MINEABLE_WITH_PICKAXE)
.langValue("End %s Ore")
.registerOre(Blocks.END_STONE::defaultBlockState, () -> GTMaterials.Endstone,
BlockBehaviour.Properties.of().mapColor(MapColor.SAND).instrument(NoteBlockInstrument.BASEDRUM)
.requiresCorrectToolForDrops().strength(4.5F, 9.0F),
new ResourceLocation("block/end_stone"), true, false, true);
ResourceLocation.withDefaultNamespace("block/end_stone"), true, false, true);

public static final TagPrefix rawOre = new TagPrefix(GTCEu.id("raw"), true)
.idPattern("raw_%s")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public static <T> TagKey<T> optionalTag(ResourceKey<? extends Registry<T>> regis
* @return optional tag #forge:path or #minecraft:path
*/
public static <T> TagKey<T> createTag(Registry<T> registry, String path, boolean vanilla) {
if (vanilla) return optionalTag(registry, new ResourceLocation("minecraft", path));
return optionalTag(registry, new ResourceLocation("forge", path));
if (vanilla) return optionalTag(registry, ResourceLocation.withDefaultNamespace(path));
return optionalTag(registry, ResourceLocation.fromNamespaceAndPath("forge", path));
}

/**
Expand All @@ -40,8 +40,8 @@ public static <T> TagKey<T> createTag(Registry<T> registry, String path, boolean
*/
public static <T> TagKey<T> createTag(ResourceKey<? extends Registry<T>> registryKey, String path,
boolean vanilla) {
if (vanilla) return optionalTag(registryKey, new ResourceLocation("minecraft", path));
return optionalTag(registryKey, new ResourceLocation("forge", path));
if (vanilla) return optionalTag(registryKey, ResourceLocation.withDefaultNamespace(path));
return optionalTag(registryKey, ResourceLocation.fromNamespaceAndPath("forge", path));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static FluidVeinWorldEntry readFromNBT(@NotNull CompoundTag tag) {
if (tag.contains("vein")) {
veinId = tag.getString("vein");
vein = GTMemoizer.memoize(() -> {
ResourceLocation key = new ResourceLocation(veinId);
ResourceLocation key = ResourceLocation.tryParse(veinId);
Comment thread
gustovafing marked this conversation as resolved.
Outdated
return GTRegistries.BEDROCK_FLUID_DEFINITIONS.get(key);
});
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static OreVeinWorldEntry readFromNBT(@NotNull CompoundTag tag) {
info.operationsRemaining = tag.getInt("operationsRemaining");

if (tag.contains("vein")) {
ResourceLocation id = new ResourceLocation(tag.getString("vein"));
ResourceLocation id = ResourceLocation.tryParse(tag.getString("vein"));
Comment thread
gustovafing marked this conversation as resolved.
Outdated
if (GTRegistries.BEDROCK_ORE_DEFINITIONS.containsKey(id)) {
info.definition = GTRegistries.BEDROCK_ORE_DEFINITIONS.get(id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,16 +298,16 @@ private void determineName(@NotNull Material material, @Nullable FluidStorageKey
private void determineTextures(@NotNull Material material, @Nullable FluidStorageKey key, @NotNull String modid) {
if (!material.isNull() && key != null) {
if (hasCustomStill) {
still = new ResourceLocation(modid, "block/fluids/fluid." + name);
still = ResourceLocation.fromNamespaceAndPath(modid, "block/fluids/fluid." + name);
} else {
still = key.getIconType().getBlockTexturePath(material.getMaterialIconSet(), true);
}
} else {
still = new ResourceLocation(modid, "block/fluids/fluid." + name);
still = ResourceLocation.fromNamespaceAndPath(modid, "block/fluids/fluid." + name);
}

if (hasCustomFlowing) {
flowing = new ResourceLocation(modid, "block/fluids/fluid." + name + "_flow");
flowing = ResourceLocation.fromNamespaceAndPath(modid, "block/fluids/fluid." + name + "_flow");
} else {
flowing = still;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/gregtechceu/gtceu/api/item/IGTTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -822,10 +822,10 @@ default Map<Enchantment, Integer> getDefaultEnchantments(ItemStack stack) {
}
}

ResourceLocation COFH_SMASHING_ENCHANT_ID = new ResourceLocation(GTValues.MODID_ENSORCELLATION, "smashing");
ResourceLocation COFH_SMASHING_ENCHANT_ID = ResourceLocation.fromNamespaceAndPath(GTValues.MODID_ENSORCELLATION, "smashing");
Set<ResourceLocation> AUTOSMELT_ENCHANT_IDS = Util.make(new HashSet<>(), set -> {
set.add(new ResourceLocation(GTValues.MODID_ENDERIO, "auto_smelt")); // EnderIO
set.add(new ResourceLocation(GTValues.MODID_ENSORCELLATION, "smelting")); // CoFH
set.add(ResourceLocation.fromNamespaceAndPath(GTValues.MODID_ENDERIO, "auto_smelt")); // EnderIO
set.add(ResourceLocation.fromNamespaceAndPath(GTValues.MODID_ENSORCELLATION, "smelting")); // CoFH
});

default boolean definition$canApplyAtEnchantingTable(@NotNull ItemStack stack, Enchantment enchantment) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public boolean isValidArmor(ItemStack itemStack, Entity entity, EquipmentSlot eq

@Override
public ResourceLocation getArmorTexture(ItemStack stack, Entity entity, EquipmentSlot slot, String type) {
return new ResourceLocation("minecraft", "textures/armor/diamond_layer_0.png");
return ResourceLocation.withDefaultNamespace("textures/armor/diamond_layer_0.png");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public FluidStack asStack() {
}

public static FluidInfo fromNbt(CompoundTag tag) {
Fluid fluid = BuiltInRegistries.FLUID.get(new ResourceLocation(tag.getString("fluid")));
Fluid fluid = BuiltInRegistries.FLUID.get(ResourceLocation.tryParse(tag.getString("fluid")));
Comment thread
gustovafing marked this conversation as resolved.
Outdated
int left = tag.getInt("left");
int yield = tag.getInt("yield");
return new FluidInfo(fluid, yield, left);
Expand Down Expand Up @@ -271,7 +271,7 @@ public void serialize(FluidInfo item, FriendlyByteBuf buf) {

@Override
public FluidInfo deserialize(FriendlyByteBuf buf) {
return new FluidInfo(BuiltInRegistries.FLUID.get(new ResourceLocation(buf.readUtf())), buf.readVarInt(),
return new FluidInfo(BuiltInRegistries.FLUID.get(ResourceLocation.tryParse(buf.readUtf())), buf.readVarInt(),
Comment thread
gustovafing marked this conversation as resolved.
Outdated
buf.readVarInt());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,11 @@ public static FluidIngredient fromJson(@Nullable JsonElement json, boolean allow
} else if (GsonHelper.isStringValue(jsonObject, "value")) {
String value = GsonHelper.getAsString(jsonObject, "value");
if (value.startsWith("#")) {
ResourceLocation resourceLocation = new ResourceLocation(value.substring(1));
ResourceLocation resourceLocation = ResourceLocation.parse(value.substring(1));
TagKey<Fluid> tagKey = TagKey.create(Registries.FLUID, resourceLocation);
return FluidIngredient.fromValue(new TagValue(tagKey), amount, nbt);
} else {
Fluid fluid = BuiltInRegistries.FLUID.get(new ResourceLocation(value));
Fluid fluid = BuiltInRegistries.FLUID.get(ResourceLocation.parse(value));
return FluidIngredient.fromValue(new FluidValue(fluid), amount, nbt);
}
} else {
Expand All @@ -307,11 +307,11 @@ private static FluidIngredient.Value valueFromJson(JsonObject json) {
throw new JsonParseException("A fluid ingredient entry is either a tag or a fluid, not both");
}
if (json.has("fluid")) {
Fluid fluid = BuiltInRegistries.FLUID.get(new ResourceLocation(GsonHelper.getAsString(json, "fluid")));
Fluid fluid = BuiltInRegistries.FLUID.get(ResourceLocation.parse(GsonHelper.getAsString(json, "fluid")));
return new FluidValue(fluid);
}
if (json.has("tag")) {
ResourceLocation resourceLocation = new ResourceLocation(GsonHelper.getAsString(json, "tag"));
ResourceLocation resourceLocation = ResourceLocation.parse(GsonHelper.getAsString(json, "tag"));
TagKey<Fluid> tagKey = TagKey.create(Registries.FLUID, resourceLocation);
return new TagValue(tagKey);
}
Expand Down
Loading
Loading