Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 1.21 (WIP) #16

Draft
wants to merge 3 commits into
base: 1.21
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions common/src/main/java/io/vram/frex/api/buffer/QuadEmitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@

import org.jetbrains.annotations.Nullable;
import org.joml.Vector3f;

import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.core.Direction;

import io.vram.frex.api.material.RenderMaterial;
import io.vram.frex.api.mesh.QuadView;
import io.vram.frex.api.model.util.FaceUtil;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.core.Direction;

public interface QuadEmitter extends QuadView, QuadSink {
/**
Expand Down
6 changes: 2 additions & 4 deletions common/src/main/java/io/vram/frex/api/buffer/QuadSink.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@
package io.vram.frex.api.buffer;

import com.mojang.blaze3d.vertex.VertexConsumer;

import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;

import io.vram.frex.api.model.InputContext;
import io.vram.frex.api.rendertype.RenderTypeUtil;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;

/**
* Universal interface for models to send vertex data to the back end.
Expand Down
24 changes: 10 additions & 14 deletions common/src/main/java/io/vram/frex/api/buffer/VertexEmitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@

import org.jetbrains.annotations.ApiStatus.Experimental;
import org.joml.Matrix4f;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;

import io.vram.frex.api.material.RenderMaterial;

@Experimental
Expand All @@ -39,40 +37,38 @@ public interface VertexEmitter extends VertexConsumer, QuadSink {
*/
VertexEmitter material(RenderMaterial material);

VertexEmitter vertex(float x, float y, float z);

/**
* @param color rgba - alpha is high byte, red and blue pre-swapped if needed
*/
@Override
VertexEmitter color(int color);
VertexEmitter setColor(int color);

@Override
default VertexEmitter vertex(double x, double y, double z) {
vertex((float) x, (float) y, (float) z);
default VertexEmitter addVertex(float x, float y, float z) {
addVertex(x, y, z);
return this;
}

@Override
VertexEmitter vertex(Matrix4f matrix, float x, float y, float z);
VertexEmitter addVertex(Matrix4f matrix, float x, float y, float z);

@Override
VertexEmitter normal(PoseStack.Pose matrix, float x, float y, float z);
VertexEmitter setNormal(PoseStack.Pose matrix, float x, float y, float z);

@Override
VertexEmitter color(int red, int green, int blue, int alpha);
VertexEmitter setColor(int red, int green, int blue, int alpha);

@Override
VertexEmitter uv(float u, float v);
VertexEmitter setUv(float u, float v);

@Override
VertexEmitter overlayCoords(int u, int v);
VertexEmitter setUv1(int u, int v);

@Override
VertexEmitter uv2(int u, int v);
VertexEmitter setUv2(int u, int v);

@Override
VertexEmitter normal(float x, float y, float z);
VertexEmitter setNormal(float x, float y, float z);

@Override
default VertexEmitter asVertexEmitter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
package io.vram.frex.api.config;

import java.util.function.Supplier;

import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;

import io.vram.frex.impl.config.ShaderConfigImpl;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@

package io.vram.frex.api.light;

import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;

import io.vram.frex.api.config.FrexFeature;
import io.vram.frex.impl.light.HeldItemLightListenerImpl;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;

@FunctionalInterface
public interface HeldItemLightListener {
Expand Down
3 changes: 1 addition & 2 deletions common/src/main/java/io/vram/frex/api/light/ItemLight.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@

package io.vram.frex.api.light;

import net.minecraft.world.item.ItemStack;

import io.vram.frex.impl.light.ItemLightLoader;
import io.vram.frex.impl.light.SimpleItemLight;
import net.minecraft.world.item.ItemStack;

@FunctionalInterface
public interface ItemLight {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
package io.vram.frex.api.material;

import java.util.function.BooleanSupplier;

import net.minecraft.resources.ResourceLocation;

import io.vram.frex.api.renderer.Renderer;

@FunctionalInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@
package io.vram.frex.api.material;

import org.jetbrains.annotations.Nullable;

import net.minecraft.resources.ResourceLocation;

import io.vram.frex.api.renderer.Renderer;
import io.vram.frex.api.texture.MaterialTexture;
import io.vram.frex.impl.material.MaterialFinderPool;
import net.minecraft.resources.ResourceLocation;

/**
* Finds standard {@link RenderMaterial} instances used to communicate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
package io.vram.frex.api.material;

import org.jetbrains.annotations.ApiStatus.Experimental;

import net.minecraft.resources.ResourceLocation;

import io.vram.frex.impl.material.MaterialLoaderImpl;
import net.minecraft.resources.ResourceLocation;

/**
* For use by model loading libraries - handles deserialization of material JSON
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
package io.vram.frex.api.material;

import org.jetbrains.annotations.Nullable;

import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.core.particles.ParticleType;
Expand All @@ -31,7 +30,6 @@
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.FluidState;

import io.vram.frex.impl.material.map.MaterialMapLoader;

public interface MaterialMap<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@
package io.vram.frex.api.material;

import org.jetbrains.annotations.Nullable;

import net.minecraft.resources.ResourceLocation;

import io.vram.frex.api.renderer.Renderer;
import net.minecraft.resources.ResourceLocation;

public interface MaterialShader {
ResourceLocation DEFAULT_VERTEX_SOURCE = new ResourceLocation("frex:shaders/material/default.vert");
ResourceLocation DEFAULT_FRAGMENT_SOURCE = new ResourceLocation("frex:shaders/material/default.frag");
ResourceLocation DEFAULT_VERTEX_SOURCE = ResourceLocation.parse("frex:shaders/material/default.vert");
ResourceLocation DEFAULT_FRAGMENT_SOURCE = ResourceLocation.parse("frex:shaders/material/default.frag");

int index();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
package io.vram.frex.api.material;

import org.jetbrains.annotations.Nullable;

import net.minecraft.resources.ResourceLocation;

import io.vram.frex.api.renderer.Renderer;
import net.minecraft.resources.ResourceLocation;

/**
* Immutable material specification, governs practically all aspects of
Expand All @@ -38,8 +36,8 @@
*
*/
public interface RenderMaterial extends MaterialView, MaterialTransform {
ResourceLocation STANDARD_MATERIAL_KEY = new ResourceLocation("frex", "standard");
ResourceLocation MISSING_MATERIAL_KEY = new ResourceLocation("frex", "missing");
ResourceLocation STANDARD_MATERIAL_KEY = ResourceLocation.fromNamespaceAndPath("frex", "standard");
ResourceLocation MISSING_MATERIAL_KEY = ResourceLocation.fromNamespaceAndPath("frex", "missing");

int index();

Expand Down
9 changes: 3 additions & 6 deletions common/src/main/java/io/vram/frex/api/math/MatrixStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@

import org.joml.Matrix3f;
import org.joml.Matrix4f;

import com.mojang.blaze3d.vertex.PoseStack;

import io.vram.frex.mixinterface.PoseStackExt;

public interface MatrixStack {
Expand All @@ -45,13 +42,13 @@ default void setIdentity() {
normalMatrix().identity();
}

PoseStack toVanilla();
com.mojang.blaze3d.vertex.PoseStack toVanilla();

static MatrixStack fromVanilla(PoseStack poseStack) {
static MatrixStack fromVanilla(com.mojang.blaze3d.vertex.PoseStack poseStack) {
return ((PoseStackExt) poseStack).frx_asMatrixStack();
}

static MatrixStack create() {
return fromVanilla(new PoseStack());
return fromVanilla(new com.mojang.blaze3d.vertex.PoseStack());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@
package io.vram.frex.api.math;

import org.joml.Vector3f;

import net.minecraft.core.Direction;
import net.minecraft.core.Vec3i;

import io.vram.frex.api.mesh.QuadView;
import io.vram.frex.api.model.util.GeometryUtil;
import net.minecraft.core.Direction;
import net.minecraft.core.Vec3i;

/**
* Static routines of general utility for renderer implementations.
Expand Down
6 changes: 2 additions & 4 deletions common/src/main/java/io/vram/frex/api/mesh/MeshBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@
package io.vram.frex.api.mesh;

import com.mojang.blaze3d.vertex.BufferBuilder;

import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.core.Direction;

import io.vram.frex.api.buffer.QuadEmitter;
import io.vram.frex.api.material.RenderMaterial;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.core.Direction;

/**
* Similar in purpose to {@link BufferBuilder} but simpler
Expand Down
11 changes: 4 additions & 7 deletions common/src/main/java/io/vram/frex/api/mesh/QuadView.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,17 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.joml.Vector3f;

import com.mojang.blaze3d.vertex.DefaultVertexFormat;

import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.core.Direction;

import io.vram.frex.api.buffer.QuadEmitter;
import io.vram.frex.api.material.RenderMaterial;
import io.vram.frex.api.math.PackedVector3f;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.core.Direction;

public interface QuadView {
/** Count of integers in a conventional (un-modded) block or item vertex. */
int VANILLA_VERTEX_STRIDE = DefaultVertexFormat.BLOCK.getIntegerSize();
int VANILLA_VERTEX_STRIDE = DefaultVertexFormat.BLOCK.getVertexSize() / 4;

/** Count of integers in a conventional (un-modded) block or item quad. */
int VANILLA_QUAD_STRIDE = VANILLA_VERTEX_STRIDE * 4;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,16 @@
package io.vram.frex.api.model;

import java.util.Random;

import org.jetbrains.annotations.Nullable;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;

import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.block.ModelBlockRenderer;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.block.state.BlockState;

import org.jetbrains.annotations.Nullable;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import io.vram.frex.api.material.MaterialConstants;
import io.vram.frex.api.material.RenderMaterial;
import io.vram.frex.api.model.util.FaceUtil;
Expand Down
12 changes: 5 additions & 7 deletions common/src/main/java/io/vram/frex/api/model/BlockModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
package io.vram.frex.api.model;

import org.jetbrains.annotations.Nullable;

import io.vram.frex.api.buffer.QuadSink;
import io.vram.frex.api.model.InputContext.Type;
import io.vram.frex.api.world.BlockEntityRenderData;
import io.vram.frex.impl.model.BiomeLookupHelper;
import io.vram.frex.impl.model.ModelLookups;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.model.BakedModel;
Expand All @@ -32,12 +36,6 @@
import net.minecraft.world.level.biome.Biomes;
import net.minecraft.world.level.block.state.BlockState;

import io.vram.frex.api.buffer.QuadSink;
import io.vram.frex.api.model.InputContext.Type;
import io.vram.frex.api.world.BlockEntityRenderData;
import io.vram.frex.impl.model.BiomeLookupHelper;
import io.vram.frex.impl.model.ModelLookups;

@FunctionalInterface
public interface BlockModel extends DynamicModel {
void renderAsBlock(BlockInputContext input, QuadSink output);
Expand Down
5 changes: 2 additions & 3 deletions common/src/main/java/io/vram/frex/api/model/EntityModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@

package io.vram.frex.api.model;

import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.Entity;

import io.vram.frex.api.buffer.QuadSink;
import io.vram.frex.api.model.InputContext.Type;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.Entity;

@FunctionalInterface
public interface EntityModel<T extends Entity> extends DynamicModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@

package io.vram.frex.api.model;

import net.minecraft.util.RandomSource;

import io.vram.frex.api.math.MatrixStack;
import net.minecraft.util.RandomSource;

public interface InputContext {
RandomSource random();
Expand Down
Loading