Skip to content

Commit

Permalink
Update to 1.20.6, Remove ARRP
Browse files Browse the repository at this point in the history
- Updates the mod and features to 1.20.6
- ARRP is no longer required
- Custom dynamic resource pack implementation
- New resource templating system, loading template resources from the jar with string find-and-replace targets
  • Loading branch information
FoundationGames committed Jun 5, 2024
1 parent c0666ed commit ba3c502
Show file tree
Hide file tree
Showing 23 changed files with 559 additions and 358 deletions.
16 changes: 7 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ plugins {
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

repositories {
maven { url = "https://maven.terraformersmc.com/" }
maven { url = "https://ueaj.dev/maven/" }
maven { url = "https://api.modrinth.com/maven/" }
maven { url = 'https://maven.terraformersmc.com/' }
maven { url = 'https://ueaj.dev/maven/' }
maven { url = 'https://api.modrinth.com/maven/' }

maven { url = 'https://jitpack.io' }
}

dependencies {
Expand All @@ -25,10 +27,6 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// ARRP. This is for generating a runtime resource pack (conditionally, as well)
modImplementation "net.devtech:arrp:${project.arrp_version}"
include "net.devtech:arrp:${project.arrp_version}"

// Mod Menu because config screen access from another place
modApi "com.terraformersmc:modmenu:${project.modmenu_version}"

Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
org.gradle.jvmargs=-Xmx2G

minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.3
loader_version=0.15.11

fabric_version=0.97.0+1.20.4
fabric_version=0.99.4+1.20.6

mod_version = 0.10+1.20.4
mod_version = 0.10+1.20.6
maven_group = foundationgames
archives_base_name = enhancedblockentities

arrp_version=0.8.1
modmenu_version=9.2.0-beta.2
arrp_version=0.8.2
modmenu_version=10.0.0-beta.1

sodium_version=mc1.20.4-0.5.8
sodium_version=mc1.20.6-0.5.8
26 changes: 11 additions & 15 deletions src/main/java/foundationgames/enhancedblockentities/EBESetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import foundationgames.enhancedblockentities.util.EBEUtil;
import foundationgames.enhancedblockentities.util.ResourceUtil;
import foundationgames.enhancedblockentities.util.duck.BakedModelManagerAccess;
import net.devtech.arrp.json.models.JModel;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin;
import net.minecraft.block.Block;
Expand All @@ -32,7 +31,6 @@
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryKey;
import net.minecraft.resource.ResourceType;
import net.minecraft.state.property.Properties;
import net.minecraft.util.DyeColor;
import net.minecraft.util.Identifier;
Expand All @@ -50,19 +48,17 @@ public static void setupRRPChests() {

p = ResourceUtil.getBasePack();

ResourceUtil.addSingleChestModels("entity/chest/normal", "chest", p);
ResourceUtil.addDoubleChestModels("entity/chest/normal_left", "entity/chest/normal_right","chest", p);
ResourceUtil.addSingleChestModels("entity/chest/trapped", "trapped_chest", p);
ResourceUtil.addDoubleChestModels("entity/chest/trapped_left", "entity/chest/trapped_right","trapped_chest", p);
ResourceUtil.addSingleChestModels("entity/chest/christmas", "christmas_chest", p);
ResourceUtil.addDoubleChestModels("entity/chest/christmas_left", "entity/chest/christmas_right","christmas_chest", p);
ResourceUtil.addSingleChestModels("entity/chest/ender", "ender_chest", p);
ResourceUtil.addSingleChestModels("normal", "chest", p);
ResourceUtil.addDoubleChestModels("normal_left", "normal_right","chest", p);
ResourceUtil.addSingleChestModels("trapped", "trapped_chest", p);
ResourceUtil.addDoubleChestModels("trapped_left", "trapped_right","trapped_chest", p);
ResourceUtil.addSingleChestModels("christmas", "christmas_chest", p);
ResourceUtil.addDoubleChestModels("christmas_left", "christmas_right","christmas_chest", p);
ResourceUtil.addSingleChestModels("ender", "ender_chest", p);

p.addResource(ResourceType.CLIENT_RESOURCES, new Identifier("models/item/chest.json"),
ResourceUtil.createChestItemModelResource("chest_center").getBytes());
p.addResource(ResourceType.CLIENT_RESOURCES, new Identifier("models/item/trapped_chest.json"),
ResourceUtil.createChestItemModelResource("trapped_chest_center").getBytes());
p.addModel(JModel.model("block/ender_chest_center"), new Identifier("item/ender_chest"));
ResourceUtil.addChestItemModel(new Identifier("models/item/chest.json"), "chest_center", p);
ResourceUtil.addChestItemModel(new Identifier("models/item/trapped_chest.json"), "trapped_chest_center", p);
ResourceUtil.addParentModel("block/ender_chest_center", new Identifier("item/ender_chest"), p);

p.addDirBlockSprites("entity/chest", "entity/chest/");
}
Expand Down Expand Up @@ -139,7 +135,7 @@ public static void setupRRPShulkerBoxes() {
var id = color != null ? color.getName()+"_shulker_box" : "shulker_box";
ResourceUtil.addShulkerBoxBlockStates(color, pCompat);
ResourceUtil.addShulkerBoxModels(color, p);
p.addModel(JModel.model("block/"+id), new Identifier("item/"+id));
ResourceUtil.addParentModel("block/"+id, new Identifier("item/"+id), p);
}

p.addDirBlockSprites("entity/shulker", "entity/shulker/");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import foundationgames.enhancedblockentities.client.model.ModelIdentifiers;
import foundationgames.enhancedblockentities.client.render.SignRenderManager;
import foundationgames.enhancedblockentities.client.resource.template.TemplateLoader;
import foundationgames.enhancedblockentities.config.EBEConfig;
import foundationgames.enhancedblockentities.util.DateUtil;
import foundationgames.enhancedblockentities.util.EBEUtil;
Expand All @@ -10,6 +11,7 @@
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.item.ModelPredicateProviderRegistry;
import org.apache.logging.log4j.LogManager;
Expand All @@ -21,8 +23,18 @@ public final class EnhancedBlockEntities implements ClientModInitializer {
public static final Logger LOG = LogManager.getLogger("Enhanced Block Entities");
public static final EBEConfig CONFIG = new EBEConfig();

public static final TemplateLoader TEMPLATE_LOADER = new TemplateLoader();

@Override
public void onInitializeClient() {
FabricLoader.getInstance().getModContainer(ID).ifPresent(mod -> {
var roots = mod.getRootPaths();

if (roots.size() > 0) {
TEMPLATE_LOADER.setRoot(roots.get(0).resolve("templates"));
}
});

WorldRenderEvents.END.register(SignRenderManager::endFrame);
ClientTickEvents.END_WORLD_TICK.register(WorldUtil.EVENT_LISTENER);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.function.Supplier;

public class DecoratedPotModelSelector extends ModelSelector {
Expand Down Expand Up @@ -81,7 +82,7 @@ public void writeModelIndices(BlockRenderView view, BlockState state, BlockPos p
}
}

private int getPatternIndex(Item sherd, int max) {
return MathHelper.clamp(this.potteryPatterns.indexOf(DecoratedPotPatterns.fromSherd(sherd)), 0, max - 1);
private int getPatternIndex(Optional<Item> sherd, int max) {
return MathHelper.clamp(this.potteryPatterns.indexOf(sherd.map(DecoratedPotPatterns::fromSherd).orElse(DecoratedPotPatterns.DECORATED_POT_SIDE_KEY)), 0, max - 1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,21 @@ public void render(BlockEntityRenderer<BlockEntity> renderer, BlockEntity blockE
EBEUtil.renderBakedModel(vertexConsumers, blockEntity.getCachedState(), matrices, this.baseModel, light, overlay);

EBEUtil.renderBakedModel(vertexConsumers, blockEntity.getCachedState(), matrices,
this.potPatternModels.get(DecoratedPotPatterns.fromSherd(sherds.back()))[0], light, overlay);
this.potPatternModels.get(
sherds.back().map(DecoratedPotPatterns::fromSherd).orElse(DecoratedPotPatterns.DECORATED_POT_SIDE_KEY)
)[0], light, overlay);
EBEUtil.renderBakedModel(vertexConsumers, blockEntity.getCachedState(), matrices,
this.potPatternModels.get(DecoratedPotPatterns.fromSherd(sherds.left()))[1], light, overlay);
this.potPatternModels.get(
sherds.left().map(DecoratedPotPatterns::fromSherd).orElse(DecoratedPotPatterns.DECORATED_POT_SIDE_KEY)
)[1], light, overlay);
EBEUtil.renderBakedModel(vertexConsumers, blockEntity.getCachedState(), matrices,
this.potPatternModels.get(DecoratedPotPatterns.fromSherd(sherds.right()))[2], light, overlay);
this.potPatternModels.get(
sherds.right().map(DecoratedPotPatterns::fromSherd).orElse(DecoratedPotPatterns.DECORATED_POT_SIDE_KEY)
)[2], light, overlay);
EBEUtil.renderBakedModel(vertexConsumers, blockEntity.getCachedState(), matrices,
this.potPatternModels.get(DecoratedPotPatterns.fromSherd(sherds.front()))[3], light, overlay);
this.potPatternModels.get(
sherds.front().map(DecoratedPotPatterns::fromSherd).orElse(DecoratedPotPatterns.DECORATED_POT_SIDE_KEY)
)[3], light, overlay);

matrices.pop();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.mojang.serialization.JsonOps;
import foundationgames.enhancedblockentities.EnhancedBlockEntities;
import net.minecraft.client.texture.atlas.AtlasSource;
import net.minecraft.client.texture.atlas.AtlasSourceManager;

Expand All @@ -21,7 +20,7 @@ public void put(AtlasSource source) {

public byte[] toBytes() {
return GSON.toJson(AtlasSourceManager.LIST_CODEC.encode(this.sources, JsonOps.INSTANCE, new JsonObject())
.getOrThrow(false, EnhancedBlockEntities.LOG::error))
.getOrThrow())
.getBytes(StandardCharsets.UTF_8);
}
}
Loading

0 comments on commit ba3c502

Please sign in to comment.