Skip to content

Commit

Permalink
wip: Update to Minecraft 1.21
Browse files Browse the repository at this point in the history
Fabric only so far and BalmModels has a bunch of open TODOs pending Fabric update
  • Loading branch information
BlayTheNinth committed Jun 6, 2024
1 parent 010ce3b commit 1697c84
Show file tree
Hide file tree
Showing 63 changed files with 157 additions and 170 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ bin/

# fabric

run/
runs/
7 changes: 7 additions & 0 deletions buildSrc/src/main/groovy/multiloader-common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ sourcesJar {
}
}

tasks.withType(Javadoc).tap {
configureEach {
failOnError false
options.addStringOption('Xdoclint:-missing', '-quiet')
}
}

jar {
from(rootProject.file("LICENSE")) {
rename { "${it}_${mod_name}" }
Expand Down
29 changes: 0 additions & 29 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,35 +51,6 @@ artifacts {
commonGeneratedResources sourceSets.generated.resources.sourceDirectories.singleFile
}

/*publishing {
publications {
mavenJava(MavenPublication) {
artifactId = mod_id + "-common"
version = project.version + (!project.version.endsWith("SNAPSHOT") ? "+" + minecraft_version : "")
artifact jar
artifact sourcesJar {
archiveClassifier = 'sources'
}
artifact project.javadocJar {
archiveClassifier = 'javadoc'
}
}
}
repositories {
maven {
var releasesRepoUrl = "https://maven.twelveiterations.com/repository/maven-releases/"
var snapshotsRepoUrl = "https://maven.twelveiterations.com/repository/maven-snapshots/"
url = uri(version.toString().endsWith("SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl)
name = "twelveIterationsNexus"
credentials(PasswordCredentials)
}
}
}*/

sourceSets {
main {
java {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
import java.util.function.Supplier;

public class DeferredObject<T> {
private final ResourceLocation identifier;
private final ResourceLocation id;
private final Supplier<T> supplier;
private final Supplier<Boolean> canResolveFunc;
protected T object;

protected DeferredObject(ResourceLocation identifier) {
this(identifier, () -> null, () -> false);
protected DeferredObject(ResourceLocation id) {
this(id, () -> null, () -> false);
}

public DeferredObject(ResourceLocation identifier, Supplier<T> supplier) {
this(identifier, supplier, () -> false);
public DeferredObject(ResourceLocation id, Supplier<T> supplier) {
this(id, supplier, () -> false);
}

public DeferredObject(ResourceLocation identifier, Supplier<T> supplier, Supplier<Boolean> canResolveFunc) {
this.identifier = identifier;
public DeferredObject(ResourceLocation id, Supplier<T> supplier, Supplier<Boolean> canResolveFunc) {
this.id = id;
this.supplier = supplier;
this.canResolveFunc = canResolveFunc;
}
Expand Down Expand Up @@ -57,7 +57,7 @@ public DeferredObject<T> resolveImmediately() {
}

public ResourceLocation getIdentifier() {
return identifier;
return id;
}

public static <T> DeferredObject<T> of(ResourceLocation identifier, T instance) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.model.*;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
Expand All @@ -17,22 +16,21 @@

import java.util.*;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;

public interface BalmModels {
DeferredObject<BakedModel> loadModel(ResourceLocation identifier);
DeferredObject<BakedModel> loadModel(ModelResourceLocation identifier);

DeferredObject<BakedModel> bakeModel(ResourceLocation identifier, UnbakedModel model);
DeferredObject<BakedModel> bakeModel(ModelResourceLocation identifier, UnbakedModel model);

default DeferredObject<BakedModel> loadDynamicModel(ResourceLocation identifier, Set<ResourceLocation> models, @Nullable Function<BlockState, ResourceLocation> modelFunction, @Nullable Function<BlockState, Map<String, String>> textureMapFunction, @Nullable BiConsumer<BlockState, Matrix4f> transformFunction) {
default DeferredObject<BakedModel> loadDynamicModel(ModelResourceLocation identifier, Set<ModelResourceLocation> models, @Nullable Function<BlockState, ModelResourceLocation> modelFunction, @Nullable Function<BlockState, Map<String, String>> textureMapFunction, @Nullable BiConsumer<BlockState, Matrix4f> transformFunction) {
return loadDynamicModel(identifier, models, modelFunction, textureMapFunction, transformFunction, Collections.emptyList());
}

DeferredObject<BakedModel> loadDynamicModel(ResourceLocation identifier, Set<ResourceLocation> models, @Nullable Function<BlockState, ResourceLocation> modelFunction, @Nullable Function<BlockState, Map<String, String>> textureMapFunction, @Nullable BiConsumer<BlockState, Matrix4f> transformFunction, List<RenderType> renderTypes);
DeferredObject<BakedModel> loadDynamicModel(ModelResourceLocation identifier, Set<ModelResourceLocation> models, @Nullable Function<BlockState, ModelResourceLocation> modelFunction, @Nullable Function<BlockState, Map<String, String>> textureMapFunction, @Nullable BiConsumer<BlockState, Matrix4f> transformFunction, List<RenderType> renderTypes);

DeferredObject<BakedModel> retexture(ResourceLocation identifier, Map<String, String> textureMap);
DeferredObject<BakedModel> retexture(ModelResourceLocation identifier, Map<String, String> textureMap);

void overrideModel(Supplier<Block> block, Supplier<BakedModel> model);

Expand All @@ -42,13 +40,13 @@ default DeferredObject<BakedModel> loadDynamicModel(ResourceLocation identifier,

UnbakedModel getUnbakedMissingModel();

default UnbakedModel retexture(ModelBakery bakery, ResourceLocation identifier, Map<String, String> textureMap) {
default UnbakedModel retexture(ModelBakery bakery, ModelResourceLocation identifier, Map<String, String> textureMap) {
Map<String, Either<Material, String>> replacedTexturesMapped = new HashMap<>();
for (Map.Entry<String, String> entry : textureMap.entrySet()) {
replacedTexturesMapped.put(entry.getKey(), Either.left(new Material(TextureAtlas.LOCATION_BLOCKS, new ResourceLocation(entry.getValue()))));
replacedTexturesMapped.put(entry.getKey(), Either.left(new Material(TextureAtlas.LOCATION_BLOCKS, ResourceLocation.parse(entry.getValue()))));
}

BlockModel blockModel = new BlockModel(identifier,
BlockModel blockModel = new BlockModel(identifier.id(),
Collections.emptyList(),
replacedTexturesMapped,
false,
Expand All @@ -57,10 +55,10 @@ default UnbakedModel retexture(ModelBakery bakery, ResourceLocation identifier,
Collections.emptyList());

// We have to resolve parents as that is usually done during stitching, which we're already past
blockModel.resolveParents(bakery::getModel);
// TODO 1.21 blockModel.resolveParents(bakery::getModel);

return blockModel;
}

ModelBaker createBaker(ResourceLocation location, BiFunction<ResourceLocation, Material, TextureAtlasSprite> spriteBiFunction);
ModelBaker createBaker(ModelResourceLocation location, ModelBakery.TextureGetter textureGetter);
}
62 changes: 31 additions & 31 deletions common/src/main/java/net/blay09/mods/balm/api/tag/BalmItemTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,39 @@
import net.minecraft.world.item.Item;

public class BalmItemTags {
public static final TagKey<Item> COOKING_OIL = TagKey.create(Registries.ITEM, new ResourceLocation("c", "cooking_oil"));
public static final TagKey<Item> DIAMONDS = TagKey.create(Registries.ITEM, new ResourceLocation("c", "gems/diamond"));
public static final TagKey<Item> EGGS = TagKey.create(Registries.ITEM, new ResourceLocation("c", "eggs"));
public static final TagKey<Item> EMERALDS = TagKey.create(Registries.ITEM, new ResourceLocation("c", "gems/emerald"));
public static final TagKey<Item> GEMS = TagKey.create(Registries.ITEM, new ResourceLocation("c", "gems"));
public static final TagKey<Item> GOLD_NUGGETS = TagKey.create(Registries.ITEM, new ResourceLocation("c", "nuggets/gold"));
public static final TagKey<Item> INGOTS = TagKey.create(Registries.ITEM, new ResourceLocation("c", "ingots"));
public static final TagKey<Item> IRON_INGOTS = TagKey.create(Registries.ITEM, new ResourceLocation("c", "ingots/iron"));
public static final TagKey<Item> IRON_NUGGETS = TagKey.create(Registries.ITEM, new ResourceLocation("c", "nuggets/iron"));
public static final TagKey<Item> NUGGETS = TagKey.create(Registries.ITEM, new ResourceLocation("c", "nuggets"));
public static final TagKey<Item> ORES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "ores"));
public static final TagKey<Item> STONES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "stones"));
public static final TagKey<Item> WOODEN_CHESTS = TagKey.create(Registries.ITEM, new ResourceLocation("c", "chests/wooden"));
public static final TagKey<Item> WOODEN_RODS = TagKey.create(Registries.ITEM, new ResourceLocation("c", "rods/wooden"));
public static final TagKey<Item> COOKING_OIL = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "cooking_oil"));
public static final TagKey<Item> DIAMONDS = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "gems/diamond"));
public static final TagKey<Item> EGGS = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "eggs"));
public static final TagKey<Item> EMERALDS = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "gems/emerald"));
public static final TagKey<Item> GEMS = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "gems"));
public static final TagKey<Item> GOLD_NUGGETS = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "nuggets/gold"));
public static final TagKey<Item> INGOTS = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "ingots"));
public static final TagKey<Item> IRON_INGOTS = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "ingots/iron"));
public static final TagKey<Item> IRON_NUGGETS = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "nuggets/iron"));
public static final TagKey<Item> NUGGETS = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "nuggets"));
public static final TagKey<Item> ORES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "ores"));
public static final TagKey<Item> STONES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "stones"));
public static final TagKey<Item> WOODEN_CHESTS = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "chests/wooden"));
public static final TagKey<Item> WOODEN_RODS = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "rods/wooden"));

// Dye tags
public static final TagKey<Item> DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes"));
public static final TagKey<Item> WHITE_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/white"));
public static final TagKey<Item> ORANGE_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/orange"));
public static final TagKey<Item> MAGENTA_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/magenta"));
public static final TagKey<Item> LIGHT_BLUE_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/light_blue"));
public static final TagKey<Item> YELLOW_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/yellow"));
public static final TagKey<Item> LIME_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/lime"));
public static final TagKey<Item> PINK_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/pink"));
public static final TagKey<Item> GRAY_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/gray"));
public static final TagKey<Item> LIGHT_GRAY_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/light_gray"));
public static final TagKey<Item> CYAN_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/cyan"));
public static final TagKey<Item> PURPLE_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/purple"));
public static final TagKey<Item> BLUE_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/blue"));
public static final TagKey<Item> BROWN_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/brown"));
public static final TagKey<Item> GREEN_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/green"));
public static final TagKey<Item> RED_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/red"));
public static final TagKey<Item> BLACK_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/black"));
public static final TagKey<Item> DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes"));
public static final TagKey<Item> WHITE_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/white"));
public static final TagKey<Item> ORANGE_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/orange"));
public static final TagKey<Item> MAGENTA_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/magenta"));
public static final TagKey<Item> LIGHT_BLUE_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/light_blue"));
public static final TagKey<Item> YELLOW_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/yellow"));
public static final TagKey<Item> LIME_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/lime"));
public static final TagKey<Item> PINK_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/pink"));
public static final TagKey<Item> GRAY_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/gray"));
public static final TagKey<Item> LIGHT_GRAY_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/light_gray"));
public static final TagKey<Item> CYAN_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/cyan"));
public static final TagKey<Item> PURPLE_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/purple"));
public static final TagKey<Item> BLUE_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/blue"));
public static final TagKey<Item> BROWN_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/brown"));
public static final TagKey<Item> GREEN_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/green"));
public static final TagKey<Item> RED_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/red"));
public static final TagKey<Item> BLACK_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/black"));

@SuppressWarnings("unchecked")
public static final TagKey<Item>[] DYE_TAGS = new TagKey[] {
Expand Down
Loading

0 comments on commit 1697c84

Please sign in to comment.