-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6cedefd
commit 85ac4bf
Showing
14 changed files
with
193 additions
and
67 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
src/main/java/org/quiltmc/qsl/frozenblock/datafixerupper/api/EmptySchema.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,55 @@ | ||
/* | ||
* Copyright 2022 QuiltMC | ||
* Modified to work on Fabric | ||
* | ||
* 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 org.quiltmc.qsl.frozenblock.datafixerupper.api; | ||
|
||
import java.util.Map; | ||
import java.util.function.Supplier; | ||
|
||
import com.mojang.datafixers.DSL; | ||
import com.mojang.datafixers.schemas.Schema; | ||
import com.mojang.datafixers.types.Type; | ||
import com.mojang.datafixers.types.templates.TypeTemplate; | ||
import it.unimi.dsi.fastutil.objects.Object2ObjectMaps; | ||
import org.jetbrains.annotations.Range; | ||
|
||
/** | ||
* Represents an empty {@link Schema}, having no parent and containing no type definitions. | ||
* <p> | ||
* Modified to work on Fabric | ||
*/ | ||
public final class EmptySchema extends FirstSchema { | ||
/** | ||
* Constructs an empty schema. | ||
* | ||
* @param versionKey the data version key | ||
*/ | ||
public EmptySchema(@Range(from = 0, to = Integer.MAX_VALUE) int versionKey) { | ||
super(versionKey); | ||
} | ||
|
||
// Ensure the schema stays empty. | ||
@Override | ||
public void registerType(boolean recursive, DSL.TypeReference type, Supplier<TypeTemplate> template) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
protected Map<String, Type<?>> buildTypes() { | ||
return Object2ObjectMaps.emptyMap(); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
src/main/java/org/quiltmc/qsl/frozenblock/datafixerupper/api/FirstSchema.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,55 @@ | ||
/* | ||
* Copyright 2022 QuiltMC | ||
* Modified to work on Fabric | ||
* | ||
* 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 org.quiltmc.qsl.frozenblock.datafixerupper.api; | ||
|
||
import java.util.Map; | ||
import java.util.function.Supplier; | ||
|
||
import com.mojang.datafixers.schemas.Schema; | ||
import com.mojang.datafixers.types.templates.TypeTemplate; | ||
import org.jetbrains.annotations.Range; | ||
|
||
/** | ||
* Represents a {@link Schema} that has no parent. | ||
* <p> | ||
* Modified to work on Fabric | ||
*/ | ||
public class FirstSchema extends Schema { | ||
/** | ||
* Creates a schema. | ||
* @param versionKey the data version key | ||
*/ | ||
public FirstSchema(@Range(from = 0, to = Integer.MAX_VALUE) int versionKey) { | ||
super(versionKey, null); | ||
} | ||
|
||
// all of these methods refer to this.parent without checking if its null | ||
@Override | ||
public void registerTypes(Schema schema, Map<String, Supplier<TypeTemplate>> entityTypes, | ||
Map<String, Supplier<TypeTemplate>> blockEntityTypes) {} | ||
|
||
@Override | ||
public Map<String, Supplier<TypeTemplate>> registerEntities(Schema schema) { | ||
return Map.of(); | ||
} | ||
|
||
@Override | ||
public Map<String, Supplier<TypeTemplate>> registerBlockEntities(Schema schema) { | ||
return Map.of(); | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.