-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make dynamic registry element path include namespace for none vanilla…
… registries (#4180) * Make dynamic registry element path be namespaced Fixes #4179 * Remove old method of prepending the namespace The old method of prepending only applied in certain locations, and thus gives different results depending on the circumstance * Add simple RegistryKeysTest --------- Co-authored-by: modmuss <[email protected]>
- Loading branch information
Showing
3 changed files
with
65 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...gistry-sync-v0/src/test/java/net/fabricmc/fabric/test/registry/sync/RegistryKeysTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.fabricmc.fabric.test.registry.sync; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import net.minecraft.Bootstrap; | ||
import net.minecraft.SharedConstants; | ||
import net.minecraft.registry.Registry; | ||
import net.minecraft.registry.RegistryKey; | ||
import net.minecraft.registry.RegistryKeys; | ||
import net.minecraft.util.Identifier; | ||
|
||
public class RegistryKeysTest { | ||
private static final RegistryKey<Registry<Object>> TEST_KEY = RegistryKey.ofRegistry(Identifier.of("registry-keys", "test")); | ||
|
||
@BeforeAll | ||
static void beforeAll() { | ||
SharedConstants.createGameVersion(); | ||
Bootstrap.initialize(); | ||
} | ||
|
||
@Test | ||
void getPath() { | ||
assertEquals("item", RegistryKeys.getPath(RegistryKeys.ITEM)); | ||
assertEquals("registry-keys/test", RegistryKeys.getPath(TEST_KEY)); | ||
} | ||
|
||
@Test | ||
void getTagPath() { | ||
assertEquals("tags/item", RegistryKeys.getTagPath(RegistryKeys.ITEM)); | ||
assertEquals("tags/registry-keys/test", RegistryKeys.getTagPath(TEST_KEY)); | ||
} | ||
} |