Skip to content

Commit

Permalink
Finish 1.21 port (#735)
Browse files Browse the repository at this point in the history
  • Loading branch information
Technici4n authored Jun 15, 2024
1 parent 90e3774 commit ae613d6
Show file tree
Hide file tree
Showing 34 changed files with 99 additions and 248 deletions.
21 changes: 15 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.neoforged.moddev' version '0.1.74'
id 'net.neoforged.moddev' version '0.1.82'
id 'com.diffplug.spotless' version '5.14.0'
id 'com.matthewprenger.cursegradle' version '1.4.0'
id "com.modrinth.minotaur" version "2.+"
Expand Down Expand Up @@ -179,13 +179,18 @@ neoForge {
mods {
modern_industrialization {
sourceSet sourceSets.main
}
modern_industrialization_with_client {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
}

runs {
// applies to all the run configs below
configureEach {
mods = [neoForge.mods.modern_industrialization]

// Recommended logging data for a userdev environment
// The markers can be added/remove as needed separated by commas.
// "SCAN": For mods scan.
Expand All @@ -201,6 +206,8 @@ neoForge {

client {
client()
sourceSet = sourceSets.client
mods = [neoForge.mods.modern_industrialization_with_client]
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
systemProperty 'forge.enabledGameTestNamespaces', "modern_industrialization"
}
Expand All @@ -221,6 +228,8 @@ neoForge {

data {
data()
sourceSet = sourceSets.client
mods = [neoForge.mods.modern_industrialization_with_client]
// example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
// workingDirectory project.file('run-data')

Expand Down Expand Up @@ -264,8 +273,8 @@ dependencies {
}

compileOnly "vazkii.patchouli:Patchouli:${project.patchouli_version}:api"
runtimeOnly "vazkii.patchouli:Patchouli:${project.patchouli_version}"
jarJar "vazkii.patchouli:Patchouli:${project.patchouli_version}"
// runtimeOnly "vazkii.patchouli:Patchouli:${project.patchouli_version}"
// jarJar "vazkii.patchouli:Patchouli:${project.patchouli_version}"

implementation("me.shedaniel.cloth:cloth-config-neoforge:${project.cloth_config_version}")

Expand All @@ -275,7 +284,7 @@ dependencies {
// exclude(group: "net.fabricmc.fabric-api")
// }

implementation "appeng:appliedenergistics2-neoforge:${project.ae2_version}"
compileOnly "appeng:appliedenergistics2-neoforge:${project.ae2_version}"
compileOnly "earth.terrarium.argonauts:argonauts-neoforge-${project.argonauts_minecraft_version}:${project.argonauts_version}"
compileOnly "earth.terrarium.athena:athena-neoforge-${project.athena_minecraft_version}:${project.athena_version}"

Expand Down Expand Up @@ -441,7 +450,7 @@ if (System.getenv("CURSEFORGE_API_KEY") && !version.endsWith("-SNAPSHOT")) {
changelogType = "markdown"
delegate.changelog = changelog

addGameVersion "1.20.6"
addGameVersion "1.21"
addGameVersion "NeoForge"
addGameVersion "Java 21"

Expand Down Expand Up @@ -475,7 +484,7 @@ modrinth {
delegate.changelog = changelog
versionType = releaseChannel
uploadFile = tasks.jar
gameVersions = ["1.20.6"]
gameVersions = ["1.21"]
loaders = ["neoforge"]
dependencies {
required.project "cloth-config"
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ org.gradle.jvmargs=-Xmx2G \

# Core NeoForge properties
minecraft_version=1.21
neo_version=21.0.0-beta
neo_version_range=[21.0.0-beta, 22-)
neo_version=21.0.9-beta
neo_version_range=[21.0.9-beta, 22-)
# For latest see https://parchmentmc.org/docs/getting-started
neogradle.subsystems.parchment.minecraftVersion=1.20.6
neogradle.subsystems.parchment.mappingsVersion=2024.05.01
Expand All @@ -25,9 +25,9 @@ modrinth_project=Gov5Dboq
runtime_itemlist_mod=none

# Dependency versions
cloth_config_version=14.0.126
grandpower_version=2.0.0
grandpower_version_range=[2.0.0, 3)
cloth_config_version=15.0.127
grandpower_version=3.0.0
grandpower_version_range=[3.0.0, 4)

# Optional dependency versions
ae2_version=18.1.3-alpha
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
package aztech.modern_industrialization.blocks.storage.barrel;

import aztech.modern_industrialization.util.RenderHelper;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.ByteBufferBuilder;
import com.mojang.math.Axis;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -41,7 +41,7 @@ private record Entry(BlockPos pos, int sideMask, int itemNameColor) {
}

private static final List<Entry> barrelsToRender = new ArrayList<>();
private static final MultiBufferSource.BufferSource immediate = MultiBufferSource.immediate(new BufferBuilder(128));
private static final MultiBufferSource.BufferSource immediate = MultiBufferSource.immediate(new ByteBufferBuilder(128));

public static void init() {
NeoForge.EVENT_BUS.addListener(DeferredBarrelTextRenderer::render);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package aztech.modern_industrialization.compat.ae2;

import aztech.modern_industrialization.MI;
import aztech.modern_industrialization.pipes.api.PipeNetworkType;
import aztech.modern_industrialization.pipes.api.PipeRenderer;
import aztech.modern_industrialization.pipes.impl.PipeMeshCache;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package aztech.modern_industrialization.compat.viewer.abstraction;

import aztech.modern_industrialization.MI;
import aztech.modern_industrialization.thirdparty.fabrictransfer.api.fluid.FluidVariant;
import aztech.modern_industrialization.thirdparty.fabrictransfer.api.storage.TransferVariant;
import aztech.modern_industrialization.util.Rectangle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package aztech.modern_industrialization.compat.viewer.usage;

import aztech.modern_industrialization.MI;
import aztech.modern_industrialization.MIFluids;
import aztech.modern_industrialization.MIItem;
import aztech.modern_industrialization.MIText;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package aztech.modern_industrialization.compat.viewer.usage;

import aztech.modern_industrialization.MI;
import aztech.modern_industrialization.MIBlock;
import aztech.modern_industrialization.MIRegistries;
import aztech.modern_industrialization.MIText;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import static aztech.modern_industrialization.MITooltips.EU_PER_TICK_PARSER;

import aztech.modern_industrialization.MI;
import aztech.modern_industrialization.MIItem;
import aztech.modern_industrialization.MIText;
import aztech.modern_industrialization.MITooltips;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package aztech.modern_industrialization.compat.viewer.usage;

import aztech.modern_industrialization.MI;
import aztech.modern_industrialization.MIItem;
import aztech.modern_industrialization.MIText;
import aztech.modern_industrialization.compat.rei.machines.ReiMachineRecipes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package aztech.modern_industrialization.compat.viewer.usage;

import aztech.modern_industrialization.MI;
import aztech.modern_industrialization.MIText;
import aztech.modern_industrialization.compat.viewer.abstraction.ViewerCategory;
import aztech.modern_industrialization.machines.guicomponents.NuclearReactorGuiClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package aztech.modern_industrialization.compat.viewer.usage;

import aztech.modern_industrialization.MI;
import aztech.modern_industrialization.MIText;
import aztech.modern_industrialization.compat.viewer.abstraction.ViewerCategory;
import aztech.modern_industrialization.machines.gui.MachineScreen;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import aztech.modern_industrialization.MIText;
import aztech.modern_industrialization.items.FluidFuelItemHelper;
import net.minecraft.ChatFormatting;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
Expand All @@ -35,7 +36,7 @@
import net.minecraft.world.item.ItemStack;

public class HudRenderer {
public static void onRenderHud(GuiGraphics guiGraphics, float delta) {
public static void onRenderHud(GuiGraphics guiGraphics, DeltaTracker deltaTracker) {
Minecraft mc = Minecraft.getInstance();
if (mc.player != null) {
ItemStack chest = mc.player.getItemBySlot(EquipmentSlot.CHEST);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ private BakedQuad getCachedQuad(MachineModelClientData data, Direction d) {
if (cachedQuads[cachedQuadIndex] == null) {
TextureAtlasSprite sprite = model == null ? null : MachineBakedModel.getSprite(model.getSprites(casing), d, facing, true);
if (sprite != null) {
var vc = new QuadBakingVertexConsumer.Buffered();
ModelHelper.emitSprite(vc, d, sprite, -2 * MachineBakedModel.Z_OFFSET);
cachedQuads[cachedQuadIndex] = vc.getQuad();
var vc = new QuadBakingVertexConsumer();
cachedQuads[cachedQuadIndex] = ModelHelper.bakeSprite(vc, d, sprite, -2 * MachineBakedModel.Z_OFFSET);
} else {
cachedQuads[cachedQuadIndex] = NO_QUAD;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,6 @@ private static void vertex(Matrix4f model, VertexConsumer lines, Direction face,
Vec3 coord = GeometryHelper.toWorldCoords(new Vec3(faceX, faceY, 0), face);
// assume normal is not useful, it was added in 1.17 but the shader doesn't seem
// to use it.
lines.vertex(model, (float) coord.x, (float) coord.y, (float) coord.z).color(0f, 0f, 0f, 0.4f).normal(0, 0, 0).endVertex();
lines.addVertex(model, (float) coord.x, (float) coord.y, (float) coord.z).setColor(0f, 0f, 0f, 0.4f).setNormal(0, 0, 0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package aztech.modern_industrialization.machines.gui;

import aztech.modern_industrialization.MI;
import aztech.modern_industrialization.MIText;
import aztech.modern_industrialization.client.DynamicTooltip;
import aztech.modern_industrialization.client.screen.MIHandledScreen;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package aztech.modern_industrialization.machines.guicomponents;

import aztech.modern_industrialization.MI;
import aztech.modern_industrialization.MIText;
import aztech.modern_industrialization.machines.gui.ClientComponentRenderer;
import aztech.modern_industrialization.machines.gui.GuiComponentClient;
Expand All @@ -32,6 +33,7 @@
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;

public class CraftingMultiblockGuiClient implements GuiComponentClient {
public boolean isShapeValid;
Expand Down Expand Up @@ -67,7 +69,7 @@ public ClientComponentRenderer createRenderer(MachineScreen machineScreen) {
}

public class Renderer implements ClientComponentRenderer {
private static final MIIdentifier TEXTURE = MI.id("textures/gui/container/multiblock_info.png");
private static final ResourceLocation TEXTURE = MI.id("textures/gui/container/multiblock_info.png");

@Override
public void renderBackground(GuiGraphics guiGraphics, int x, int y) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package aztech.modern_industrialization.machines.guicomponents;

import aztech.modern_industrialization.MI;
import aztech.modern_industrialization.MIText;
import aztech.modern_industrialization.machines.gui.ClientComponentRenderer;
import aztech.modern_industrialization.machines.gui.GuiComponentClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
*/
package aztech.modern_industrialization.machines.guicomponents;

import aztech.modern_industrialization.MI;
import aztech.modern_industrialization.MIText;
import aztech.modern_industrialization.machines.gui.ClientComponentRenderer;
import aztech.modern_industrialization.machines.gui.GuiComponentClient;
import aztech.modern_industrialization.machines.gui.MachineScreen;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;

public class TemperatureBarClient implements GuiComponentClient {
public final TemperatureBar.Parameters params;
Expand All @@ -52,7 +54,7 @@ public ClientComponentRenderer createRenderer(MachineScreen machineScreen) {

public class Renderer implements ClientComponentRenderer {

private final MIIdentifier TEXTURE = MI.id("textures/gui/efficiency_bar.png");
private final ResourceLocation TEXTURE = MI.id("textures/gui/efficiency_bar.png");
private final int WIDTH = 100, HEIGHT = 2;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.block.state.BlockState;
Expand All @@ -56,8 +56,8 @@ public class MachineBakedModel implements IDynamicBakedModel {

public static final String CASING_FOLDER = "machine_casing";

public static ResourceLocation getCasingModelId(MachineCasing casing) {
return MI.id(CASING_FOLDER + "/" + casing.name);
public static ModelResourceLocation getCasingModelId(MachineCasing casing) {
return ModelResourceLocation.standalone(MI.id(CASING_FOLDER + "/" + casing.name));
}

public static BakedModel getCasingModel(MachineCasing casing) {
Expand Down Expand Up @@ -133,26 +133,26 @@ public ModelData getModelData(BlockAndTintGetter level, BlockPos pos, BlockState
var sprites = getSprites(casing);

List<BakedQuad> quads = new ArrayList<>();
var vc = new QuadBakingVertexConsumer(quads::add);
var vc = new QuadBakingVertexConsumer();

if (side != null) {
// Casing
quads.addAll(getCasingModel(casing).getQuads(state, side, rand, extraData, renderType));
// Machine overlays
TextureAtlasSprite sprite = getSprite(sprites, side, data.frontDirection, false);
if (sprite != null) {
ModelHelper.emitSprite(vc, side, sprite, -Z_OFFSET);
quads.add(ModelHelper.bakeSprite(vc, side, sprite, -Z_OFFSET));
}
}

// Output overlays
if (data.outputDirection != null && side == data.outputDirection) {
ModelHelper.emitSprite(vc, data.outputDirection, sprites[24], -3 * Z_OFFSET);
quads.add(ModelHelper.bakeSprite(vc, data.outputDirection, sprites[24], -3 * Z_OFFSET));
if (data.itemAutoExtract) {
ModelHelper.emitSprite(vc, data.outputDirection, sprites[25], -3 * Z_OFFSET);
quads.add(ModelHelper.bakeSprite(vc, data.outputDirection, sprites[25], -3 * Z_OFFSET));
}
if (data.fluidAutoExtract) {
ModelHelper.emitSprite(vc, data.outputDirection, sprites[26], -3 * Z_OFFSET);
quads.add(ModelHelper.bakeSprite(vc, data.outputDirection, sprites[26], -3 * Z_OFFSET));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private MachineUnbakedModel(JsonObject obj) {

@Override
public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function<Material, TextureAtlasSprite> spriteGetter,
ModelState modelState, ItemOverrides overrides, ResourceLocation modelLocation) {
ModelState modelState, ItemOverrides overrides) {
var defaultOverlays = loadSprites(spriteGetter, this.defaultOverlays);
var tieredOverlays = new HashMap<String, TextureAtlasSprite[]>();
for (var entry : this.tieredOverlays.entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@

import aztech.modern_industrialization.MI;
import com.google.gson.JsonSyntaxException;
import java.util.Objects;
import java.util.function.Function;
import net.minecraft.client.renderer.block.BlockModelShaper;
import net.minecraft.client.renderer.block.model.ItemOverrides;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.resources.model.Material;
import net.minecraft.client.resources.model.ModelBaker;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.client.resources.model.ModelState;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -46,14 +48,14 @@ public class UseBlockModelUnbakedModel implements IUnbakedGeometry<UseBlockModel
public static final IGeometryLoader<UseBlockModelUnbakedModel> LOADER = (jsonObject, deserializationContext) -> {

var blockId = GsonHelper.getAsString(jsonObject, "block");
var block = BuiltInRegistries.BLOCK.getOptional(new ResourceLocation(blockId))
var block = BuiltInRegistries.BLOCK.getOptional(ResourceLocation.parse(blockId))
.orElseThrow(() -> new JsonSyntaxException("Expected \"block\" to be a block, was unknown string " + blockId));

return new UseBlockModelUnbakedModel(block.defaultBlockState());
};

private final BlockState targetState;
private final ResourceLocation delegate;
private final ModelResourceLocation delegate;

private UseBlockModelUnbakedModel(BlockState targetState) {
this.targetState = targetState;
Expand All @@ -62,7 +64,8 @@ private UseBlockModelUnbakedModel(BlockState targetState) {

@Override
public BakedModel bake(IGeometryBakingContext context, ModelBaker baker, Function<Material, TextureAtlasSprite> spriteGetter,
ModelState modelState, ItemOverrides overrides, ResourceLocation modelLocation) {
return new UseBlockModelBakedModel(targetState, baker.bake(delegate, modelState, spriteGetter));
ModelState modelState, ItemOverrides overrides) {
var delegateModel = Objects.requireNonNull(baker.getTopLevelModel(delegate));
return new UseBlockModelBakedModel(targetState, baker.bakeUncached(delegateModel, modelState, spriteGetter));
}
}
Loading

0 comments on commit ae613d6

Please sign in to comment.