Reformat backend

This commit is contained in:
JozsefA 2021-04-29 17:19:08 -07:00
parent d9b04138df
commit 322496f3b4
66 changed files with 2537 additions and 2539 deletions

View file

@ -9,7 +9,6 @@ import org.lwjgl.opengl.GL;
import org.lwjgl.opengl.GLCapabilities; import org.lwjgl.opengl.GLCapabilities;
import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.render.backend.gl.GlFog;
import com.simibubi.create.foundation.render.backend.gl.shader.GlProgram; import com.simibubi.create.foundation.render.backend.gl.shader.GlProgram;
import com.simibubi.create.foundation.render.backend.gl.shader.IMultiProgram; import com.simibubi.create.foundation.render.backend.gl.shader.IMultiProgram;
import com.simibubi.create.foundation.render.backend.gl.shader.ProgramSpec; import com.simibubi.create.foundation.render.backend.gl.shader.ProgramSpec;

View file

@ -2,24 +2,17 @@ package com.simibubi.create.foundation.render.backend;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.CreateClient; import com.simibubi.create.CreateClient;
import com.simibubi.create.content.contraptions.KineticDebugger; import com.simibubi.create.content.contraptions.KineticDebugger;
import com.simibubi.create.foundation.render.KineticRenderer; import com.simibubi.create.foundation.render.KineticRenderer;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.WorldAttached; import com.simibubi.create.foundation.utility.WorldAttached;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.world.ClientWorld; import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.potion.Effects;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Matrix4f; import net.minecraft.util.math.vector.Matrix4f;
import net.minecraft.util.math.vector.Vector3f;
import net.minecraft.world.World; import net.minecraft.world.World;
public class FastRenderDispatcher { public class FastRenderDispatcher {

View file

@ -23,6 +23,7 @@ public class OptifineHandler {
/** /**
* Get information about the current Optifine configuration. * Get information about the current Optifine configuration.
*
* @return {@link Optional#empty()} if Optifine is not installed. * @return {@link Optional#empty()} if Optifine is not installed.
*/ */
public static Optional<OptifineHandler> get() { public static Optional<OptifineHandler> get() {

View file

@ -22,7 +22,7 @@ public class RenderUtil {
// GPUs want matrices in column major order. // GPUs want matrices in column major order.
public static float[] writeMatrixStack(Matrix4f model, Matrix3f normal) { public static float[] writeMatrixStack(Matrix4f model, Matrix3f normal) {
return new float[] { return new float[]{
model.a00, model.a00,
model.a10, model.a10,
model.a20, model.a20,

View file

@ -28,14 +28,14 @@ import org.lwjgl.system.MemoryUtil;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.simibubi.create.foundation.render.backend.gl.GlFogMode; import com.simibubi.create.foundation.render.backend.gl.GlFogMode;
import com.simibubi.create.foundation.render.backend.gl.shader.SingleProgram; import com.simibubi.create.foundation.render.backend.gl.shader.FogSensitiveProgram;
import com.simibubi.create.foundation.render.backend.gl.shader.GlProgram; import com.simibubi.create.foundation.render.backend.gl.shader.GlProgram;
import com.simibubi.create.foundation.render.backend.gl.shader.GlShader; import com.simibubi.create.foundation.render.backend.gl.shader.GlShader;
import com.simibubi.create.foundation.render.backend.gl.shader.FogSensitiveProgram;
import com.simibubi.create.foundation.render.backend.gl.shader.IMultiProgram; import com.simibubi.create.foundation.render.backend.gl.shader.IMultiProgram;
import com.simibubi.create.foundation.render.backend.gl.shader.ProgramSpec; import com.simibubi.create.foundation.render.backend.gl.shader.ProgramSpec;
import com.simibubi.create.foundation.render.backend.gl.shader.ShaderConstants; import com.simibubi.create.foundation.render.backend.gl.shader.ShaderConstants;
import com.simibubi.create.foundation.render.backend.gl.shader.ShaderType; import com.simibubi.create.foundation.render.backend.gl.shader.ShaderType;
import com.simibubi.create.foundation.render.backend.gl.shader.SingleProgram;
import net.minecraft.resources.IResource; import net.minecraft.resources.IResource;
import net.minecraft.resources.IResourceManager; import net.minecraft.resources.IResourceManager;
@ -70,7 +70,7 @@ public class ShaderLoader {
} }
} }
private void loadShaderSources(IResourceManager manager){ private void loadShaderSources(IResourceManager manager) {
Collection<ResourceLocation> allShaders = manager.getAllResourceLocations(SHADER_DIR, s -> { Collection<ResourceLocation> allShaders = manager.getAllResourceLocations(SHADER_DIR, s -> {
for (String ext : EXTENSIONS) { for (String ext : EXTENSIONS) {
if (s.endsWith(ext)) return true; if (s.endsWith(ext)) return true;
@ -185,7 +185,7 @@ public class ShaderLoader {
try { try {
bytebuffer = readToBuffer(is); bytebuffer = readToBuffer(is);
int i = bytebuffer.position(); int i = bytebuffer.position();
((Buffer)bytebuffer).rewind(); ((Buffer) bytebuffer).rewind();
return MemoryUtil.memASCII(bytebuffer, i); return MemoryUtil.memASCII(bytebuffer, i);
} catch (IOException e) { } catch (IOException e) {
@ -202,11 +202,12 @@ public class ShaderLoader {
public ByteBuffer readToBuffer(InputStream is) throws IOException { public ByteBuffer readToBuffer(InputStream is) throws IOException {
ByteBuffer bytebuffer; ByteBuffer bytebuffer;
if (is instanceof FileInputStream) { if (is instanceof FileInputStream) {
FileInputStream fileinputstream = (FileInputStream)is; FileInputStream fileinputstream = (FileInputStream) is;
FileChannel filechannel = fileinputstream.getChannel(); FileChannel filechannel = fileinputstream.getChannel();
bytebuffer = MemoryUtil.memAlloc((int)filechannel.size() + 1); bytebuffer = MemoryUtil.memAlloc((int) filechannel.size() + 1);
while (filechannel.read(bytebuffer) != -1) { } while (filechannel.read(bytebuffer) != -1) {
}
} else { } else {
bytebuffer = MemoryUtil.memAlloc(8192); bytebuffer = MemoryUtil.memAlloc(8192);
ReadableByteChannel readablebytechannel = Channels.newChannel(is); ReadableByteChannel readablebytechannel = Channels.newChannel(is);

View file

@ -73,6 +73,6 @@ public class BasicData extends InstanceData implements IFlatLight<BasicData> {
@Override @Override
public void write(ByteBuffer buf) { public void write(ByteBuffer buf) {
buf.put(new byte[] { blockLight, skyLight, r, g, b, a }); buf.put(new byte[]{blockLight, skyLight, r, g, b, a});
} }
} }

View file

@ -5,8 +5,9 @@ import com.simibubi.create.foundation.render.backend.instancing.InstanceData;
/** /**
* An interface that implementors of {@link InstanceData} should also implement * An interface that implementors of {@link InstanceData} should also implement
* if they wish to make use of Flywheel's provided light update methods. * if they wish to make use of Flywheel's provided light update methods.
* * <p>
* This only covers flat lighting, smooth lighting is still TODO. * This only covers flat lighting, smooth lighting is still TODO.
*
* @param <D> The name of the class that implements this interface. * @param <D> The name of the class that implements this interface.
*/ */
public interface IFlatLight<D extends InstanceData & IFlatLight<D>> { public interface IFlatLight<D extends InstanceData & IFlatLight<D>> {

View file

@ -85,7 +85,7 @@ public class OrientedData extends BasicData {
public void write(ByteBuffer buf) { public void write(ByteBuffer buf) {
super.write(buf); super.write(buf);
buf.asFloatBuffer().put(new float[] { buf.asFloatBuffer().put(new float[]{
posX, posX,
posY, posY,
posZ, posZ,

View file

@ -5,7 +5,7 @@ import org.lwjgl.opengl.GL11;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
public class GlFog { public class GlFog {
public static float[] FOG_COLOR = new float[] {0, 0, 0, 0}; public static float[] FOG_COLOR = new float[]{0, 0, 0, 0};
public static boolean fogEnabled() { public static boolean fogEnabled() {
return GlStateManager.FOG.field_179049_a.field_179201_b; return GlStateManager.FOG.field_179049_a.field_179201_b;

View file

@ -32,6 +32,7 @@ public abstract class GlProgram extends GlObject {
/** /**
* Retrieves the index of the uniform with the given name. * Retrieves the index of the uniform with the given name.
*
* @param uniform The name of the uniform to find the index of * @param uniform The name of the uniform to find the index of
* @return The uniform's index * @return The uniform's index
*/ */
@ -47,6 +48,7 @@ public abstract class GlProgram extends GlObject {
/** /**
* Binds a sampler uniform to the given texture unit. * Binds a sampler uniform to the given texture unit.
*
* @param name The name of the sampler uniform. * @param name The name of the sampler uniform.
* @param binding The index of the texture unit. * @param binding The index of the texture unit.
* @return The sampler uniform's index. * @return The sampler uniform's index.

View file

@ -10,6 +10,7 @@ public interface IMultiProgram<P extends GlProgram> {
/** /**
* Get the shader program most suited for the current game state. * Get the shader program most suited for the current game state.
*
* @return The one true program. * @return The one true program.
*/ */
P get(); P get();

View file

@ -49,9 +49,7 @@ public enum DrawInstanced implements GlVersioned {
public void drawArraysInstanced(int mode, int first, int count, int primcount) { public void drawArraysInstanced(int mode, int first, int count, int primcount) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
} };
;
public abstract void drawArraysInstanced(int mode, int first, int count, int primcount); public abstract void drawArraysInstanced(int mode, int first, int count, int primcount);
} }

View file

@ -13,7 +13,7 @@ import org.lwjgl.system.MemoryUtil;
/** /**
* An instance of this class stores information * An instance of this class stores information
* about what OpenGL features are available. * about what OpenGL features are available.
* * <p>
* Each field stores an enum variant that provides access to the * Each field stores an enum variant that provides access to the
* most appropriate version of a feature for the current system. * most appropriate version of a feature for the current system.
*/ */

View file

@ -9,6 +9,7 @@ import org.lwjgl.opengl.GLCapabilities;
public interface GlVersioned { public interface GlVersioned {
/** /**
* Queries whether this variant is supported by the current system. * Queries whether this variant is supported by the current system.
*
* @param caps The {@link GLCapabilities} reported by the current system. * @param caps The {@link GLCapabilities} reported by the current system.
* @return <code>true</code> if this variant is supported, or if this is the last defined variant. * @return <code>true</code> if this variant is supported, or if this is the last defined variant.
*/ */

View file

@ -37,9 +37,7 @@ public enum InstancedArrays implements GlVersioned {
public void vertexAttribDivisor(int index, int divisor) { public void vertexAttribDivisor(int index, int divisor) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
} };
;
public abstract void vertexAttribDivisor(int index, int divisor); public abstract void vertexAttribDivisor(int index, int divisor);
} }

View file

@ -67,11 +67,11 @@ public enum RGPixelFormat implements GlVersioned {
public int byteCount() { public int byteCount() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
} };
;
public abstract int internalFormat(); public abstract int internalFormat();
public abstract int format(); public abstract int format();
public abstract int byteCount(); public abstract int byteCount();
} }

View file

@ -67,9 +67,7 @@ public enum VertexArrayObject implements GlVersioned {
public void deleteVertexArrays(int array) { public void deleteVertexArrays(int array) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
} };
;
public abstract int genVertexArrays(); public abstract int genVertexArrays();

View file

@ -78,7 +78,8 @@ public class RenderMaterial<P extends BasicProgram, MODEL extends InstancedModel
teardown(); teardown();
} }
public void teardown() {} public void teardown() {
}
public void delete() { public void delete() {
runOnAll(InstancedModel::delete); runOnAll(InstancedModel::delete);

View file

@ -54,14 +54,16 @@ public abstract class TileEntityInstance<T extends TileEntity> implements IInsta
* *
* <br><br> If your animations are complex or more CPU driven, see {@link IDynamicInstance} or {@link ITickableInstance}. * <br><br> If your animations are complex or more CPU driven, see {@link IDynamicInstance} or {@link ITickableInstance}.
*/ */
protected void update() { } protected void update() {
}
/** /**
* Called after construction and when a light update occurs in the world. * Called after construction and when a light update occurs in the world.
* *
* <br> If your model needs it, update light here. * <br> If your model needs it, update light here.
*/ */
public void updateLight() { } public void updateLight() {
}
/** /**
* Free any acquired resources. * Free any acquired resources.

View file

@ -30,7 +30,6 @@ public class InstanceGroup<D extends InstanceData> extends AbstractCollection<D>
} }
/** /**
*
* @param count * @param count
* @return True if the number of elements changed. * @return True if the number of elements changed.
*/ */

View file

@ -49,7 +49,7 @@ public class LightUpdater {
/** /**
* Add a listener associated with the given {@link BlockPos}. * Add a listener associated with the given {@link BlockPos}.
* * <p>
* When a light update occurs in the chunk the position is contained in, * When a light update occurs in the chunk the position is contained in,
* {@link LightUpdateListener#onLightUpdate} will be called. * {@link LightUpdateListener#onLightUpdate} will be called.
* *
@ -71,7 +71,7 @@ public class LightUpdater {
/** /**
* Add a listener associated with the given {@link GridAlignedBB}. * Add a listener associated with the given {@link GridAlignedBB}.
* * <p>
* When a light update occurs in any chunk spanning the given volume, * When a light update occurs in any chunk spanning the given volume,
* {@link LightUpdateListener#onLightUpdate} will be called. * {@link LightUpdateListener#onLightUpdate} will be called.
* *

View file

@ -170,6 +170,7 @@ public class LightVolume {
/** /**
* Copy block light from the world into this volume. * Copy block light from the world into this volume.
*
* @param worldVolume the region in the world to copy data from. * @param worldVolume the region in the world to copy data from.
*/ */
public void copyBlock(IBlockDisplayReader world, GridAlignedBB worldVolume) { public void copyBlock(IBlockDisplayReader world, GridAlignedBB worldVolume) {
@ -192,6 +193,7 @@ public class LightVolume {
/** /**
* Copy sky light from the world into this volume. * Copy sky light from the world into this volume.
*
* @param worldVolume the region in the world to copy data from. * @param worldVolume the region in the world to copy data from.
*/ */
public void copySky(IBlockDisplayReader world, GridAlignedBB worldVolume) { public void copySky(IBlockDisplayReader world, GridAlignedBB worldVolume) {
@ -214,6 +216,7 @@ public class LightVolume {
/** /**
* Copy all light from the world into this volume. * Copy all light from the world into this volume.
*
* @param worldVolume the region in the world to copy data from. * @param worldVolume the region in the world to copy data from.
*/ */
public void copyLight(IBlockDisplayReader world, GridAlignedBB worldVolume) { public void copyLight(IBlockDisplayReader world, GridAlignedBB worldVolume) {