generated from TropheusJ/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Showing
37 changed files
with
659 additions
and
453 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
49 changes: 0 additions & 49 deletions
49
...va/io/github/fabricators_of_create/porting_lib/models/generators/CustomLoaderBuilder.java
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
modules/model_generators/src/main/resources/porting_lib_model_generators.accesswidener
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
modules/model_generators/src/main/resources/porting_lib_model_generators.mixins.json
This file was deleted.
Oops, something went wrong.
Empty file.
25 changes: 0 additions & 25 deletions
25
.../main/java/io/github/fabricators_of_create/porting_lib/models/materials/MaterialData.java
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
...ub/fabricators_of_create/porting_lib/models/materials/extensions/BakedQuadExtensions.java
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
...va/io/github/fabricators_of_create/porting_lib/models/materials/mixin/BakedQuadMixin.java
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
modules/model_materials/src/main/resources/porting_lib_model_materials.accesswidener
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
modules/model_materials/src/main/resources/porting_lib_model_materials.mixins.json
This file was deleted.
Oops, something went wrong.
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
54 changes: 54 additions & 0 deletions
54
...odels/src/main/java/io/github/fabricators_of_create/porting_lib/models/ExtraFaceData.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,54 @@ | ||
package io.github.fabricators_of_create.porting_lib.models; | ||
|
||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonParseException; | ||
import com.mojang.datafixers.util.Either; | ||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.JsonOps; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import java.util.function.Function; | ||
import net.minecraft.client.renderer.block.model.BlockElement; | ||
import net.minecraft.client.renderer.block.model.BlockElementFace; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* Holds extra data that may be injected into a face.<p> | ||
* Used by {@link ItemLayerModel}, {@link BlockElement} and {@link BlockElementFace} | ||
* | ||
* @param color Color in ARGB format | ||
* @param blockLight Block Light for this face from 0-15 (inclusive) | ||
* @param skyLight Sky Light for this face from 0-15 (inclusive) | ||
* @param ambientOcclusion If this face has AO | ||
*/ | ||
public record ExtraFaceData(int color, int blockLight, int skyLight, boolean ambientOcclusion) { | ||
|
||
public static final ExtraFaceData DEFAULT = new ExtraFaceData(0xFFFFFFFF, 0, 0, true); | ||
|
||
public static final Codec<Integer> COLOR = Codec.either(Codec.INT, Codec.STRING).xmap( | ||
either -> either.map(Function.identity(), str -> (int) Long.parseLong(str, 16)), | ||
color -> Either.right(Integer.toHexString(color))); | ||
|
||
public static final Codec<ExtraFaceData> CODEC = RecordCodecBuilder.create( | ||
builder -> builder | ||
.group( | ||
COLOR.optionalFieldOf("color", 0xFFFFFFFF).forGetter(ExtraFaceData::color), | ||
Codec.intRange(0, 15).optionalFieldOf("block_light", 0).forGetter(ExtraFaceData::blockLight), | ||
Codec.intRange(0, 15).optionalFieldOf("sky_light", 0).forGetter(ExtraFaceData::skyLight), | ||
Codec.BOOL.optionalFieldOf("ambient_occlusion", true).forGetter(ExtraFaceData::ambientOcclusion)) | ||
.apply(builder, ExtraFaceData::new)); | ||
/** | ||
* Parses an ExtraFaceData from JSON | ||
* | ||
* @param obj The JsonObject to parse from, weakly-typed to JsonElement to reduce logic complexity. | ||
* @param fallback What to return if the first parameter is null. | ||
* @return The parsed ExtraFaceData, or the fallback parameter if the first parmeter is null. | ||
* @throws JsonParseException | ||
*/ | ||
@Nullable | ||
public static ExtraFaceData read(@Nullable JsonElement obj, @Nullable ExtraFaceData fallback) throws JsonParseException { | ||
if (obj == null) { | ||
return fallback; | ||
} | ||
return CODEC.parse(JsonOps.INSTANCE, obj).getOrThrow(JsonParseException::new); | ||
} | ||
} |
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.