mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-21 04:32:15 +00:00
Update to 1.15
Due to the massive rendering changes, certain features, such as emissive item rendering and the forge block rendering/lighting pipeline are currently disabled. Co-authored-by: David Quintana <[email protected]> Co-authored-by: tterrag <[email protected]> Co-authored-by: Unnoen <[email protected]>
This commit is contained in:
1 parent
9e5ecaaf75
commit
1933d05e36
565 files changed
+11114
-13142
No files matched your search
@@ -24,6 +24,9 @@ import java.util.Random;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
@@ -32,8 +35,9 @@ import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IEnviromentBlockReader;
|
||||
import net.minecraft.world.ILightReader;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public interface IForgeBakedModel
|
||||
{
|
||||
@@ -50,16 +54,21 @@ public interface IForgeBakedModel
|
||||
|
||||
default boolean isAmbientOcclusion(BlockState state) { return getBakedModel().isAmbientOcclusion(); }
|
||||
|
||||
/**
|
||||
* Override to tell the new model loader that it shouldn't wrap this model
|
||||
*/
|
||||
default boolean doesHandlePerspectives() { return false; }
|
||||
|
||||
/*
|
||||
* Returns the pair of the model for the given perspective, and the matrix that
|
||||
* should be applied to the GL state before rendering it (matrix may be null).
|
||||
*/
|
||||
default org.apache.commons.lang3.tuple.Pair<? extends IBakedModel, javax.vecmath.Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType)
|
||||
default IBakedModel handlePerspective(ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat)
|
||||
{
|
||||
return net.minecraftforge.client.ForgeHooksClient.handlePerspective(getBakedModel(), cameraTransformType);
|
||||
return net.minecraftforge.client.ForgeHooksClient.handlePerspective(getBakedModel(), cameraTransformType, mat);
|
||||
}
|
||||
|
||||
default @Nonnull IModelData getModelData(@Nonnull IEnviromentBlockReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData)
|
||||
default @Nonnull IModelData getModelData(@Nonnull ILightReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData)
|
||||
{
|
||||
return tileData;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.extensions;
|
||||
|
||||
import net.minecraft.client.renderer.TransformationMatrix;
|
||||
|
||||
/**
|
||||
* An {@code IModelState} is a function from model part to a transformation that should be applied
|
||||
* when that part is baked, thus representing the current "state" of the model and its parts.
|
||||
*/
|
||||
public interface IForgeModelTransform
|
||||
{
|
||||
/**
|
||||
* @param part Part of the model we are wanting to transform. An empty optional means
|
||||
* we want a transform for the entire model.
|
||||
* @return A transformation to apply to the part, if any. The coordinate system of the transform
|
||||
* is determined by the part type.
|
||||
*/
|
||||
default TransformationMatrix getPartTransformation(Object part)
|
||||
{
|
||||
return TransformationMatrix.func_227983_a_();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.extensions;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.TransformationMatrix;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.Vector4f;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.common.model.TransformationHelper;
|
||||
|
||||
/*
|
||||
* Replacement interface for ModelRotation to allow custom transformations of vanilla models.
|
||||
* You should probably use TRSRTransformation directly.
|
||||
*/
|
||||
public interface IForgeTransformationMatrix
|
||||
{
|
||||
default TransformationMatrix getTransformaion()
|
||||
{
|
||||
return (TransformationMatrix)this;
|
||||
}
|
||||
|
||||
default boolean isIdentity()
|
||||
{
|
||||
return getTransformaion().equals(TransformationMatrix.func_227983_a_());
|
||||
}
|
||||
|
||||
default void push(MatrixStack stack)
|
||||
{
|
||||
stack.func_227860_a_();
|
||||
stack.func_227863_a_(getTransformaion().func_227989_d_());
|
||||
Vector3f trans = getTransformaion().getTranslation();
|
||||
stack.func_227861_a_(trans.getX(), trans.getY(), trans.getZ());
|
||||
stack.func_227863_a_(getTransformaion().getRightRot());
|
||||
Vector3f scale = getTransformaion().getScale();
|
||||
stack.func_227861_a_(scale.getX(), scale.getY(), scale.getZ());
|
||||
}
|
||||
|
||||
default TransformationMatrix compose(TransformationMatrix other)
|
||||
{
|
||||
if (getTransformaion().isIdentity()) return other;
|
||||
if (other.isIdentity()) return getTransformaion();
|
||||
Matrix4f m = getTransformaion().func_227988_c_();
|
||||
m.func_226595_a_(other.func_227988_c_());
|
||||
return new TransformationMatrix(m);
|
||||
}
|
||||
|
||||
default TransformationMatrix inverse()
|
||||
{
|
||||
if (isIdentity()) return getTransformaion();
|
||||
javax.vecmath.Matrix4f m = TransformationHelper.toVecmath(getTransformaion().func_227988_c_());
|
||||
m.invert();
|
||||
return new TransformationMatrix(TransformationHelper.toMojang(m));
|
||||
}
|
||||
|
||||
default void transformPosition(Vector4f position)
|
||||
{
|
||||
TransformationHelper.transform(getTransformaion().func_227988_c_(), position);
|
||||
}
|
||||
|
||||
default void transformNormal(Vector3f normal)
|
||||
{
|
||||
javax.vecmath.Vector3f copy = TransformationHelper.toVecmath(normal);
|
||||
transformNormal(copy);
|
||||
normal.set(copy.x, copy.y, copy.z);
|
||||
}
|
||||
|
||||
default void transformNormal(javax.vecmath.Vector3f normal)
|
||||
{
|
||||
getTransformaion().getNormalMatrix().transform(normal);
|
||||
normal.normalize();
|
||||
}
|
||||
|
||||
default Direction rotateTransform(Direction facing)
|
||||
{
|
||||
return Direction.func_229385_a_(getTransformaion().func_227988_c_(), facing);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.extensions;
|
||||
|
||||
import net.minecraftforge.common.model.animation.IClip;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface IForgeUnbakedModel
|
||||
{
|
||||
/**
|
||||
* Retrieves information about an animation clip in the model.
|
||||
* @param name The clip name
|
||||
* @return
|
||||
*/
|
||||
default Optional<? extends IClip> getClip(String name) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.extensions;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.Vector4f;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import org.lwjgl.system.MemoryStack;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
public interface IForgeVertexBuilder
|
||||
{
|
||||
// Copy of func_227889_a_ with alpha support
|
||||
default void addVertexData(MatrixStack.Entry matrixEntry, BakedQuad bakedQuad, float red, float green, float blue, float alpha, int lightmapCoord, int overlayColkor) {
|
||||
addVertexData(matrixEntry, bakedQuad, new float[]{1.0F, 1.0F, 1.0F, 1.0F}, red, green, blue, alpha, new int[]{lightmapCoord, lightmapCoord, lightmapCoord, lightmapCoord}, overlayColkor, false);
|
||||
}
|
||||
|
||||
// Copy of func_227890_a_ with alpha support
|
||||
default void addVertexData(MatrixStack.Entry matrixEntry, BakedQuad bakedQuad, float[] baseBrightness, float red, float green, float blue, float alpha, int[] lightmapCoords, int overlayCoords, boolean p_227890_9_) {
|
||||
int[] aint = bakedQuad.getVertexData();
|
||||
Vec3i faceNormal = bakedQuad.getFace().getDirectionVec();
|
||||
Vector3f normal = new Vector3f((float)faceNormal.getX(), (float)faceNormal.getY(), (float)faceNormal.getZ());
|
||||
Matrix4f matrix4f = matrixEntry.func_227870_a_();
|
||||
normal.func_229188_a_(matrixEntry.func_227872_b_());
|
||||
int intSize = DefaultVertexFormats.BLOCK.getIntegerSize();
|
||||
int vertexCount = aint.length / intSize;
|
||||
|
||||
try (MemoryStack memorystack = MemoryStack.stackPush()) {
|
||||
ByteBuffer bytebuffer = memorystack.malloc(DefaultVertexFormats.BLOCK.getSize());
|
||||
IntBuffer intbuffer = bytebuffer.asIntBuffer();
|
||||
|
||||
for(int v = 0; v < vertexCount; ++v) {
|
||||
intbuffer.clear();
|
||||
intbuffer.put(aint, v * 8, 8);
|
||||
float f = bytebuffer.getFloat(0);
|
||||
float f1 = bytebuffer.getFloat(4);
|
||||
float f2 = bytebuffer.getFloat(8);
|
||||
float cr;
|
||||
float cg;
|
||||
float cb;
|
||||
float ca;
|
||||
if (p_227890_9_) {
|
||||
float r = (float)(bytebuffer.get(12) & 255) / 255.0F;
|
||||
float g = (float)(bytebuffer.get(13) & 255) / 255.0F;
|
||||
float b = (float)(bytebuffer.get(14) & 255) / 255.0F;
|
||||
float a = (float)(bytebuffer.get(15) & 255) / 255.0F;
|
||||
cr = r * baseBrightness[v] * red;
|
||||
cg = g * baseBrightness[v] * green;
|
||||
cb = b * baseBrightness[v] * blue;
|
||||
ca = a * alpha;
|
||||
} else {
|
||||
cr = baseBrightness[v] * red;
|
||||
cg = baseBrightness[v] * green;
|
||||
cb = baseBrightness[v] * blue;
|
||||
ca = alpha;
|
||||
}
|
||||
|
||||
int lightmapCoord = lightmapCoords[v];
|
||||
float f9 = bytebuffer.getFloat(16);
|
||||
float f10 = bytebuffer.getFloat(20);
|
||||
Vector4f pos = new Vector4f(f, f1, f2, 1.0F);
|
||||
pos.func_229372_a_(matrix4f);
|
||||
((IVertexBuilder)this).func_225588_a_(pos.getX(), pos.getY(), pos.getZ(), cr, cg, cb, ca, f9, f10, overlayCoords, lightmapCoord, normal.getX(), normal.getY(), normal.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user