diff --git a/src/main/java/com/jozufozu/flywheel/backend/Backend.java b/src/main/java/com/jozufozu/flywheel/backend/Backend.java index aa1525cfe..a6b40f781 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/Backend.java +++ b/src/main/java/com/jozufozu/flywheel/backend/Backend.java @@ -42,7 +42,7 @@ public class Backend { private boolean enabled; public boolean chunkCachingEnabled; - private final List> contexts = new ArrayList<>(); + private final List> contexts = new ArrayList<>(); private final Map> materialRegistry = new HashMap<>(); private final Map programSpecRegistry = new HashMap<>(); @@ -83,7 +83,7 @@ public class Backend { /** * Register a shader context. */ - public > C register(C spec) { + public > C register(C spec) { contexts.add(spec); return spec; } @@ -154,7 +154,7 @@ public class Backend { return programSpecRegistry.values(); } - public Collection> allContexts() { + public Collection> allContexts() { return contexts; } @@ -164,7 +164,7 @@ public class Backend { public static boolean isFlywheelWorld(@Nullable LevelAccessor world) { if (world == null) return false; - if (world instanceof FlywheelWorld && ((FlywheelWorld) world).supportsFlywheel()) return true; + if (world instanceof IFlywheelWorld && ((IFlywheelWorld) world).supportsFlywheel()) return true; return world == Minecraft.getInstance().level; } @@ -183,7 +183,7 @@ public class Backend { public void _clearContexts() { SpecMetaRegistry.clear(); programSpecRegistry.clear(); - contexts.forEach(ShaderContext::delete); + contexts.forEach(IShaderContext::delete); contexts.clear(); materialRegistry.clear(); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/FlywheelWorld.java b/src/main/java/com/jozufozu/flywheel/backend/IFlywheelWorld.java similarity index 90% rename from src/main/java/com/jozufozu/flywheel/backend/FlywheelWorld.java rename to src/main/java/com/jozufozu/flywheel/backend/IFlywheelWorld.java index 6adfd1b6e..52f1712ed 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/FlywheelWorld.java +++ b/src/main/java/com/jozufozu/flywheel/backend/IFlywheelWorld.java @@ -6,7 +6,7 @@ package com.jozufozu.flywheel.backend; * * Minecraft.getInstance().world is special cased and will support Flywheel by default. */ -public interface FlywheelWorld { +public interface IFlywheelWorld { default boolean supportsFlywheel() { return true; } diff --git a/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java b/src/main/java/com/jozufozu/flywheel/backend/IShaderContext.java similarity index 90% rename from src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java rename to src/main/java/com/jozufozu/flywheel/backend/IShaderContext.java index 66585908e..0d24963f2 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/ShaderContext.java +++ b/src/main/java/com/jozufozu/flywheel/backend/IShaderContext.java @@ -6,7 +6,7 @@ import com.jozufozu.flywheel.backend.gl.shader.GlProgram; import net.minecraft.resources.ResourceLocation; -public interface ShaderContext

{ +public interface IShaderContext

{ default P getProgram(ResourceLocation loc) { return this.getProgramSupplier(loc) diff --git a/src/main/java/com/jozufozu/flywheel/backend/Loader.java b/src/main/java/com/jozufozu/flywheel/backend/Loader.java index a55f8da18..363dcff13 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/Loader.java +++ b/src/main/java/com/jozufozu/flywheel/backend/Loader.java @@ -82,7 +82,7 @@ public class Loader implements ResourceManagerReloadListener { Resolver.INSTANCE.resolve(sources); - for (ShaderContext context : backend.allContexts()) { + for (IShaderContext context : backend.allContexts()) { context.load(); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/AttribSpec.java b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/IAttribSpec.java similarity index 83% rename from src/main/java/com/jozufozu/flywheel/backend/gl/attrib/AttribSpec.java rename to src/main/java/com/jozufozu/flywheel/backend/gl/attrib/IAttribSpec.java index ba23e6f0b..04a8daf00 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/AttribSpec.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/IAttribSpec.java @@ -1,6 +1,6 @@ package com.jozufozu.flywheel.backend.gl.attrib; -public interface AttribSpec { +public interface IAttribSpec { void vertexAttribPointer(int stride, int index, int offset); diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/MatrixAttributes.java b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/MatrixAttributes.java index b92c1b46c..aef66036c 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/MatrixAttributes.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/MatrixAttributes.java @@ -4,7 +4,7 @@ import org.lwjgl.opengl.GL20; import com.jozufozu.flywheel.backend.gl.GlNumericType; -public enum MatrixAttributes implements AttribSpec { +public enum MatrixAttributes implements IAttribSpec { MAT3(3, 3), MAT4(4, 4), ; diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexAttribSpec.java b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexAttribSpec.java index ce22cc01e..7219ddb20 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexAttribSpec.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexAttribSpec.java @@ -4,7 +4,7 @@ import org.lwjgl.opengl.GL20; import com.jozufozu.flywheel.backend.gl.GlNumericType; -public class VertexAttribSpec implements AttribSpec { +public class VertexAttribSpec implements IAttribSpec { private final GlNumericType type; private final int count; diff --git a/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexFormat.java b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexFormat.java index a772e583f..9d48fd142 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexFormat.java +++ b/src/main/java/com/jozufozu/flywheel/backend/gl/attrib/VertexFormat.java @@ -5,16 +5,16 @@ import java.util.Collections; public class VertexFormat { - private final ArrayList allAttributes; + private final ArrayList allAttributes; private final int numAttributes; private final int stride; - public VertexFormat(ArrayList allAttributes) { + public VertexFormat(ArrayList allAttributes) { this.allAttributes = allAttributes; int numAttributes = 0, stride = 0; - for (AttribSpec spec : allAttributes) { + for (IAttribSpec spec : allAttributes) { numAttributes += spec.getAttributeCount(); stride += spec.getSize(); } @@ -32,7 +32,7 @@ public class VertexFormat { public void vertexAttribPointers(int index) { int offset = 0; - for (AttribSpec spec : this.allAttributes) { + for (IAttribSpec spec : this.allAttributes) { spec.vertexAttribPointer(stride, index, offset); index += spec.getAttributeCount(); offset += spec.getSize(); @@ -44,12 +44,12 @@ public class VertexFormat { } public static class Builder { - private final ArrayList allAttributes = new ArrayList<>(); + private final ArrayList allAttributes = new ArrayList<>(); public Builder() { } - public Builder addAttributes(AttribSpec... attributes) { + public Builder addAttributes(IAttribSpec... attributes) { Collections.addAll(allAttributes, attributes); return this; } diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/AbstractInstance.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/AbstractInstance.java index 3ddaf416c..b17051c50 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/AbstractInstance.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/AbstractInstance.java @@ -5,7 +5,7 @@ import java.util.stream.Stream; import com.jozufozu.flywheel.backend.instancing.tile.TileInstanceManager; import com.jozufozu.flywheel.backend.material.MaterialManager; -import com.jozufozu.flywheel.core.materials.FlatLight; +import com.jozufozu.flywheel.core.materials.IFlatLight; import com.jozufozu.flywheel.light.ILightUpdateListener; import com.jozufozu.flywheel.light.ImmutableBox; import com.jozufozu.flywheel.light.LightProvider; @@ -19,7 +19,7 @@ import net.minecraft.world.level.Level; * A general interface providing information about any type of thing that could use Flywheel's instanced rendering. * Right now, that's only {@link TileInstanceManager}, but there could be an entity equivalent in the future. */ -public abstract class AbstractInstance implements Instance, ILightUpdateListener { +public abstract class AbstractInstance implements IInstance, ILightUpdateListener { protected final MaterialManager materialManager; public final Level world; @@ -38,7 +38,7 @@ public abstract class AbstractInstance implements Instance, ILightUpdateListener * Update instance data here. Good for when data doesn't change very often and when animations are GPU based. * Don't query lighting data here, that's handled separately in {@link #updateLight()}. * - *

If your animations are complex or more CPU driven, see {@link DynamicInstance} or {@link TickableInstance}. + *

If your animations are complex or more CPU driven, see {@link IDynamicInstance} or {@link ITickableInstance}. */ public void update() { } @@ -77,19 +77,19 @@ public abstract class AbstractInstance implements Instance, ILightUpdateListener updateLight(); } - protected void relight(BlockPos pos, FlatLight... models) { + protected void relight(BlockPos pos, IFlatLight... models) { relight(world.getBrightness(LightLayer.BLOCK, pos), world.getBrightness(LightLayer.SKY, pos), models); } - protected void relight(BlockPos pos, Stream models) { + protected > void relight(BlockPos pos, Stream models) { relight(world.getBrightness(LightLayer.BLOCK, pos), world.getBrightness(LightLayer.SKY, pos), models); } - protected void relight(int block, int sky, FlatLight... models) { + protected void relight(int block, int sky, IFlatLight... models) { relight(block, sky, Arrays.stream(models)); } - protected void relight(int block, int sky, Stream models) { + protected > void relight(int block, int sky, Stream models) { models.forEach(model -> model.setBlockLight(block) .setSkyLight(sky)); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/GPUInstancer.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/GPUInstancer.java index 7f477e750..1e9d85dcd 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/GPUInstancer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/GPUInstancer.java @@ -13,13 +13,13 @@ import com.jozufozu.flywheel.backend.model.IBufferedModel; import com.jozufozu.flywheel.backend.model.ModelAllocator; import com.jozufozu.flywheel.backend.struct.StructType; import com.jozufozu.flywheel.backend.struct.StructWriter; -import com.jozufozu.flywheel.core.model.Model; +import com.jozufozu.flywheel.core.model.IModel; import com.jozufozu.flywheel.util.AttribUtil; public class GPUInstancer implements Instancer { private final ModelAllocator modelAllocator; - private final Model modelData; + private final IModel modelData; private final VertexFormat instanceFormat; private final StructType type; @@ -36,7 +36,7 @@ public class GPUInstancer implements Instancer { boolean anyToRemove; boolean anyToUpdate; - public GPUInstancer(ModelAllocator modelAllocator, Model model, StructType type) { + public GPUInstancer(ModelAllocator modelAllocator, IModel model, StructType type) { this.modelAllocator = modelAllocator; this.modelData = model; this.type = type; diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/DynamicInstance.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/IDynamicInstance.java similarity index 89% rename from src/main/java/com/jozufozu/flywheel/backend/instancing/DynamicInstance.java rename to src/main/java/com/jozufozu/flywheel/backend/instancing/IDynamicInstance.java index d371a0c25..e801d16f8 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/DynamicInstance.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/IDynamicInstance.java @@ -4,14 +4,14 @@ import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance; /** * An interface giving {@link TileEntityInstance}s a hook to have a function called at - * the start of a frame. By implementing {@link DynamicInstance}, a {@link TileEntityInstance} + * the start of a frame. By implementing {@link IDynamicInstance}, a {@link TileEntityInstance} * can animate its models in ways that could not be easily achieved by shader attribute * parameterization. * *

If your goal is offloading work to shaders, but you're unsure exactly how you need * to parameterize the instances, you're encouraged to implement this for prototyping. */ -public interface DynamicInstance extends Instance { +public interface IDynamicInstance extends IInstance { /** * Called every frame. *
diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/Instance.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/IInstance.java similarity index 80% rename from src/main/java/com/jozufozu/flywheel/backend/instancing/Instance.java rename to src/main/java/com/jozufozu/flywheel/backend/instancing/IInstance.java index 4a6d5f1c1..9514740d8 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/Instance.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/IInstance.java @@ -2,6 +2,6 @@ package com.jozufozu.flywheel.backend.instancing; import net.minecraft.core.BlockPos; -public interface Instance { +public interface IInstance { BlockPos getWorldPosition(); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceRendered.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/IInstanceRendered.java similarity index 76% rename from src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceRendered.java rename to src/main/java/com/jozufozu/flywheel/backend/instancing/IInstanceRendered.java index 68009ed94..50073b868 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceRendered.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/IInstanceRendered.java @@ -1,9 +1,11 @@ package com.jozufozu.flywheel.backend.instancing; +import net.minecraft.world.level.Level; + /** * Something (a BlockEntity or Entity) that can be rendered using the instancing API. */ -public interface InstanceRendered { +public interface IInstanceRendered { /** * @return true if there are parts of the renderer that cannot be implemented with Flywheel. @@ -11,4 +13,6 @@ public interface InstanceRendered { default boolean shouldRenderNormally() { return false; } + + Level getWorld(); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/TickableInstance.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/ITickableInstance.java similarity index 88% rename from src/main/java/com/jozufozu/flywheel/backend/instancing/TickableInstance.java rename to src/main/java/com/jozufozu/flywheel/backend/instancing/ITickableInstance.java index f6906b41c..71e5e1d8d 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/TickableInstance.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/ITickableInstance.java @@ -4,9 +4,9 @@ import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance; /** * An interface giving {@link TileEntityInstance}s a hook to have a function called at - * the end of every tick. By implementing {@link TickableInstance}, a {@link TileEntityInstance} + * the end of every tick. By implementing {@link ITickableInstance}, a {@link TileEntityInstance} * can update frequently, but not every frame. - *
There are a few cases in which this should be considered over {@link DynamicInstance}: + *
There are a few cases in which this should be considered over {@link IDynamicInstance}: *

    *
  • * You'd like to change something about the instance every now and then. @@ -18,7 +18,7 @@ import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance; *
  • *
*/ -public interface TickableInstance extends Instance { +public interface ITickableInstance extends IInstance { /** * Called every tick. diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceManager.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceManager.java index 014b31665..573d3fac2 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceManager.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceManager.java @@ -27,8 +27,8 @@ public abstract class InstanceManager implements MaterialManagerImpl.OriginSh private final Set queuedUpdates; protected final Map instances; - protected final Object2ObjectOpenHashMap tickableInstances; - protected final Object2ObjectOpenHashMap dynamicInstances; + protected final Object2ObjectOpenHashMap tickableInstances; + protected final Object2ObjectOpenHashMap dynamicInstances; protected int frame; protected int tick; @@ -70,7 +70,7 @@ public abstract class InstanceManager implements MaterialManagerImpl.OriginSh * Ticks the InstanceManager. * *

- * {@link TickableInstance}s get ticked. + * {@link ITickableInstance}s get ticked. *
* Queued updates are processed. *

@@ -86,7 +86,7 @@ public abstract class InstanceManager implements MaterialManagerImpl.OriginSh if (tickableInstances.size() > 0) { tickableInstances.object2ObjectEntrySet().parallelStream().forEach(e -> { - TickableInstance instance = e.getValue(); + ITickableInstance instance = e.getValue(); if (!instance.decreaseTickRateWithDistance()) { instance.tick(); return; @@ -121,7 +121,7 @@ public abstract class InstanceManager implements MaterialManagerImpl.OriginSh dynamicInstances.object2ObjectEntrySet() .parallelStream() .forEach(e -> { - DynamicInstance dyn = e.getValue(); + IDynamicInstance dyn = e.getValue(); if (!dyn.decreaseFramerateWithDistance() || shouldFrameUpdate(dyn.getWorldPosition(), lookX, lookY, lookZ, cX, cY, cZ)) dyn.beginFrame(); }); @@ -159,8 +159,8 @@ public abstract class InstanceManager implements MaterialManagerImpl.OriginSh * *

* By default this is the only hook an IInstance has to change its internal state. This is the lowest frequency - * update hook IInstance gets. For more frequent updates, see {@link TickableInstance} and - * {@link DynamicInstance}. + * update hook IInstance gets. For more frequent updates, see {@link ITickableInstance} and + * {@link IDynamicInstance}. *

* * @param obj the object to update. @@ -291,9 +291,9 @@ public abstract class InstanceManager implements MaterialManagerImpl.OriginSh .addListener(renderer); instances.put(obj, renderer); - if (renderer instanceof DynamicInstance) dynamicInstances.put(obj, (DynamicInstance) renderer); + if (renderer instanceof IDynamicInstance) dynamicInstances.put(obj, (IDynamicInstance) renderer); - if (renderer instanceof TickableInstance) tickableInstances.put(obj, ((TickableInstance) renderer)); + if (renderer instanceof ITickableInstance) tickableInstances.put(obj, ((ITickableInstance) renderer)); } return renderer; diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceWorld.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceWorld.java index c292b9ae6..9c9d94e1e 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceWorld.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceWorld.java @@ -71,7 +71,7 @@ public class InstanceWorld { *

* Check and shift the origin coordinate. *
- * Call {@link DynamicInstance#beginFrame()} on all instances in this world. + * Call {@link IDynamicInstance#beginFrame()} on all instances in this world. *

*/ public void beginFrame(BeginFrameEvent event) { @@ -84,7 +84,7 @@ public class InstanceWorld { /** * Tick the renderers after the game has ticked: *

- * Call {@link TickableInstance#tick()} on all instances in this world. + * Call {@link ITickableInstance#tick()} on all instances in this world. *

*/ public void tick() { diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedRenderRegistry.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedRenderRegistry.java index ba797eda3..cbafe6398 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedRenderRegistry.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstancedRenderRegistry.java @@ -6,8 +6,8 @@ import javax.annotation.Nullable; import com.google.common.collect.Maps; import com.jozufozu.flywheel.backend.instancing.entity.EntityInstance; -import com.jozufozu.flywheel.backend.instancing.entity.EntityInstanceFactory; -import com.jozufozu.flywheel.backend.instancing.tile.TileInstanceFactory; +import com.jozufozu.flywheel.backend.instancing.entity.IEntityInstanceFactory; +import com.jozufozu.flywheel.backend.instancing.tile.ITileInstanceFactory; import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance; import com.jozufozu.flywheel.backend.material.MaterialManager; @@ -26,21 +26,19 @@ public class InstancedRenderRegistry { } private final Object2BooleanMap skipRender = new Object2BooleanLinkedOpenHashMap<>(); - private final Map, TileInstanceFactory> tiles = Maps.newHashMap(); - private final Map, EntityInstanceFactory> entities = Maps.newHashMap(); + private final Map, ITileInstanceFactory> tiles = Maps.newHashMap(); + private final Map, IEntityInstanceFactory> entities = Maps.newHashMap(); protected InstancedRenderRegistry() { skipRender.defaultReturnValue(false); } public boolean shouldSkipRender(T type) { - // _skipRender is faster than instanceof and cast, take advantage of short-circuiting - return _skipRender(type.getType()) || ((type instanceof InstanceRendered) && !((InstanceRendered) type).shouldRenderNormally()); + return _skipRender(type.getType()) || ((type instanceof IInstanceRendered) && !((IInstanceRendered) type).shouldRenderNormally()); } public boolean shouldSkipRender(T type) { - // _skipRender is faster than instanceof and cast, take advantage of short-circuiting - return _skipRender(type.getType()) || ((type instanceof InstanceRendered) && !((InstanceRendered) type).shouldRenderNormally()); + return _skipRender(type.getType()) || ((type instanceof IInstanceRendered) && !((IInstanceRendered) type).shouldRenderNormally()); } public boolean canInstance(BlockEntityType type) { @@ -63,7 +61,7 @@ public class InstancedRenderRegistry { * @deprecated will be removed in 0.3.0, use {@link #tile} */ @Deprecated - public void register(BlockEntityType type, TileInstanceFactory rendererFactory) { + public void register(BlockEntityType type, ITileInstanceFactory rendererFactory) { this.tile(type) .factory(rendererFactory); } @@ -72,7 +70,7 @@ public class InstancedRenderRegistry { * @deprecated will be removed in 0.3.0, use {@link #entity} */ @Deprecated - public void register(EntityType type, EntityInstanceFactory rendererFactory) { + public void register(EntityType type, IEntityInstanceFactory rendererFactory) { this.entity(type) .factory(rendererFactory); } @@ -81,7 +79,7 @@ public class InstancedRenderRegistry { @Nullable public TileEntityInstance create(MaterialManager manager, T tile) { BlockEntityType type = tile.getType(); - TileInstanceFactory factory = (TileInstanceFactory) this.tiles.get(type); + ITileInstanceFactory factory = (ITileInstanceFactory) this.tiles.get(type); if (factory == null) return null; else return factory.create(manager, tile); @@ -92,7 +90,7 @@ public class InstancedRenderRegistry { @Nullable public EntityInstance create(MaterialManager manager, T tile) { EntityType type = tile.getType(); - EntityInstanceFactory factory = (EntityInstanceFactory) this.entities.get(type); + IEntityInstanceFactory factory = (IEntityInstanceFactory) this.entities.get(type); if (factory == null) return null; else return factory.create(manager, tile); @@ -109,7 +107,7 @@ public class InstancedRenderRegistry { CONFIG setSkipRender(boolean skipRender); } - public class TileConfig implements Config, TileInstanceFactory> { + public class TileConfig implements Config, ITileInstanceFactory> { private final BlockEntityType type; @@ -118,7 +116,7 @@ public class InstancedRenderRegistry { this.type = type; } - public TileConfig factory(TileInstanceFactory rendererFactory) { + public TileConfig factory(ITileInstanceFactory rendererFactory) { tiles.put(type, rendererFactory); return this; } @@ -128,7 +126,7 @@ public class InstancedRenderRegistry { } } - public class EntityConfig implements Config, EntityInstanceFactory> { + public class EntityConfig implements Config, IEntityInstanceFactory> { private final EntityType type; @@ -137,7 +135,7 @@ public class InstancedRenderRegistry { this.type = type; } - public EntityConfig factory(EntityInstanceFactory rendererFactory) { + public EntityConfig factory(IEntityInstanceFactory rendererFactory) { entities.put(type, rendererFactory); return this; } diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/entity/EntityInstance.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/entity/EntityInstance.java index 94851e9da..64e92c3ee 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/entity/EntityInstance.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/entity/EntityInstance.java @@ -1,8 +1,8 @@ package com.jozufozu.flywheel.backend.instancing.entity; import com.jozufozu.flywheel.backend.instancing.AbstractInstance; -import com.jozufozu.flywheel.backend.instancing.DynamicInstance; -import com.jozufozu.flywheel.backend.instancing.TickableInstance; +import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; +import com.jozufozu.flywheel.backend.instancing.ITickableInstance; import com.jozufozu.flywheel.backend.instancing.tile.TileInstanceManager; import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.light.GridAlignedBB; @@ -24,8 +24,8 @@ import net.minecraft.core.Vec3i; * * *

There are a few additional features that overriding classes can opt in to: *
    - *
  • {@link DynamicInstance}
  • - *
  • {@link TickableInstance}
  • + *
  • {@link IDynamicInstance}
  • + *
  • {@link ITickableInstance}
  • *
* See the interfaces' documentation for more information about each one. * diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/entity/EntityInstanceFactory.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/entity/IEntityInstanceFactory.java similarity index 80% rename from src/main/java/com/jozufozu/flywheel/backend/instancing/entity/EntityInstanceFactory.java rename to src/main/java/com/jozufozu/flywheel/backend/instancing/entity/IEntityInstanceFactory.java index 2ff5bcaa7..67d5a0257 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/entity/EntityInstanceFactory.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/entity/IEntityInstanceFactory.java @@ -5,6 +5,6 @@ import com.jozufozu.flywheel.backend.material.MaterialManager; import net.minecraft.world.entity.Entity; @FunctionalInterface -public interface EntityInstanceFactory { +public interface IEntityInstanceFactory { EntityInstance create(MaterialManager manager, E te); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/tile/TileInstanceFactory.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/tile/ITileInstanceFactory.java similarity index 81% rename from src/main/java/com/jozufozu/flywheel/backend/instancing/tile/TileInstanceFactory.java rename to src/main/java/com/jozufozu/flywheel/backend/instancing/tile/ITileInstanceFactory.java index e4803ce04..3f8cdd1b8 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/tile/TileInstanceFactory.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/tile/ITileInstanceFactory.java @@ -5,6 +5,6 @@ import com.jozufozu.flywheel.backend.material.MaterialManager; import net.minecraft.world.level.block.entity.BlockEntity; @FunctionalInterface -public interface TileInstanceFactory { +public interface ITileInstanceFactory { TileEntityInstance create(MaterialManager manager, T te); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/tile/TileEntityInstance.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/tile/TileEntityInstance.java index 08f2412b2..b51e9fddb 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/tile/TileEntityInstance.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/tile/TileEntityInstance.java @@ -1,8 +1,8 @@ package com.jozufozu.flywheel.backend.instancing.tile; import com.jozufozu.flywheel.backend.instancing.AbstractInstance; -import com.jozufozu.flywheel.backend.instancing.DynamicInstance; -import com.jozufozu.flywheel.backend.instancing.TickableInstance; +import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; +import com.jozufozu.flywheel.backend.instancing.ITickableInstance; import com.jozufozu.flywheel.backend.material.Material; import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.core.Materials; @@ -22,8 +22,8 @@ import net.minecraft.core.BlockPos; * *

There are a few additional features that overriding classes can opt in to: *
    - *
  • {@link DynamicInstance}
  • - *
  • {@link TickableInstance}
  • + *
  • {@link IDynamicInstance}
  • + *
  • {@link ITickableInstance}
  • *
* See the interfaces' documentation for more information about each one. * diff --git a/src/main/java/com/jozufozu/flywheel/backend/material/Material.java b/src/main/java/com/jozufozu/flywheel/backend/material/Material.java index 33cfb823b..a7a68133d 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/material/Material.java +++ b/src/main/java/com/jozufozu/flywheel/backend/material/Material.java @@ -6,7 +6,7 @@ import com.jozufozu.flywheel.backend.instancing.InstanceData; import com.jozufozu.flywheel.backend.instancing.Instancer; import com.jozufozu.flywheel.core.PartialModel; import com.jozufozu.flywheel.core.model.BlockModel; -import com.jozufozu.flywheel.core.model.Model; +import com.jozufozu.flywheel.core.model.IModel; import com.jozufozu.flywheel.util.Pair; import com.jozufozu.flywheel.util.RenderUtil; import com.mojang.blaze3d.vertex.PoseStack; @@ -22,7 +22,7 @@ public interface Material { * @param modelSupplier A factory that creates the IModel that you want to render. * @return An instancer for the given model, capable of rendering many copies for little cost. */ - Instancer model(Object key, Supplier modelSupplier); + Instancer model(Object key, Supplier modelSupplier); default Instancer getModel(PartialModel partial, BlockState referenceState) { return model(partial, () -> new BlockModel(partial.get(), referenceState)); diff --git a/src/main/java/com/jozufozu/flywheel/backend/material/MaterialImpl.java b/src/main/java/com/jozufozu/flywheel/backend/material/MaterialImpl.java index 8582d5a2c..ce3fa98d0 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/material/MaterialImpl.java +++ b/src/main/java/com/jozufozu/flywheel/backend/material/MaterialImpl.java @@ -10,7 +10,7 @@ import com.jozufozu.flywheel.backend.instancing.GPUInstancer; import com.jozufozu.flywheel.backend.instancing.InstanceData; import com.jozufozu.flywheel.backend.instancing.Instancer; import com.jozufozu.flywheel.backend.model.ModelPool; -import com.jozufozu.flywheel.core.model.Model; +import com.jozufozu.flywheel.core.model.IModel; /** * A collection of Instancers that all have the same format. @@ -42,7 +42,7 @@ public class MaterialImpl implements Material { * @return An instancer for the given model, capable of rendering many copies for little cost. */ @Override - public Instancer model(Object key, Supplier modelSupplier) { + public Instancer model(Object key, Supplier modelSupplier) { try { return models.get(key, () -> new GPUInstancer<>(modelPool, modelSupplier.get(), spec.getInstanceType())); } catch (ExecutionException e) { diff --git a/src/main/java/com/jozufozu/flywheel/backend/material/MaterialManager.java b/src/main/java/com/jozufozu/flywheel/backend/material/MaterialManager.java index 15f2e3fd5..74f17e702 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/material/MaterialManager.java +++ b/src/main/java/com/jozufozu/flywheel/backend/material/MaterialManager.java @@ -4,7 +4,6 @@ import com.jozufozu.flywheel.backend.state.IRenderState; import com.jozufozu.flywheel.backend.state.RenderLayer; import com.jozufozu.flywheel.backend.state.TextureRenderState; -import net.minecraft.client.renderer.RenderStateShard; import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.core.Vec3i; diff --git a/src/main/java/com/jozufozu/flywheel/backend/model/ArrayModelRenderer.java b/src/main/java/com/jozufozu/flywheel/backend/model/ArrayModelRenderer.java index 533033680..48359821c 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/model/ArrayModelRenderer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/model/ArrayModelRenderer.java @@ -3,14 +3,14 @@ package com.jozufozu.flywheel.backend.model; import java.util.function.Supplier; import com.jozufozu.flywheel.backend.gl.GlVertexArray; -import com.jozufozu.flywheel.core.model.Model; +import com.jozufozu.flywheel.core.model.IModel; import com.jozufozu.flywheel.util.AttribUtil; public class ArrayModelRenderer extends ModelRenderer { protected GlVertexArray vao; - public ArrayModelRenderer(Supplier model) { + public ArrayModelRenderer(Supplier model) { super(model); } @@ -29,7 +29,7 @@ public class ArrayModelRenderer extends ModelRenderer { @Override protected void init() { initialized = true; - Model model = modelSupplier.get(); + IModel model = modelSupplier.get(); if (model.empty()) return; diff --git a/src/main/java/com/jozufozu/flywheel/backend/model/BufferedModel.java b/src/main/java/com/jozufozu/flywheel/backend/model/BufferedModel.java index 05c14f7eb..5b5b5026d 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/model/BufferedModel.java +++ b/src/main/java/com/jozufozu/flywheel/backend/model/BufferedModel.java @@ -9,17 +9,17 @@ import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer; import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType; import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; import com.jozufozu.flywheel.backend.gl.buffer.MappedGlBuffer; -import com.jozufozu.flywheel.core.model.Model; +import com.jozufozu.flywheel.core.model.IModel; import com.jozufozu.flywheel.util.AttribUtil; public class BufferedModel implements IBufferedModel { - protected final Model model; + protected final IModel model; protected final GlPrimitive primitiveMode; protected GlBuffer vbo; protected boolean deleted; - public BufferedModel(GlPrimitive primitiveMode, Model model) { + public BufferedModel(GlPrimitive primitiveMode, IModel model) { this.model = model; this.primitiveMode = primitiveMode; diff --git a/src/main/java/com/jozufozu/flywheel/backend/model/ImmediateAllocator.java b/src/main/java/com/jozufozu/flywheel/backend/model/ImmediateAllocator.java index e290549e4..7da671ca0 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/model/ImmediateAllocator.java +++ b/src/main/java/com/jozufozu/flywheel/backend/model/ImmediateAllocator.java @@ -1,13 +1,13 @@ package com.jozufozu.flywheel.backend.model; -import com.jozufozu.flywheel.core.model.Model; +import com.jozufozu.flywheel.core.model.IModel; public class ImmediateAllocator implements ModelAllocator { public static final ImmediateAllocator INSTANCE = new ImmediateAllocator(); @Override - public IBufferedModel alloc(Model model, Callback allocationCallback) { + public IBufferedModel alloc(IModel model, Callback allocationCallback) { IndexedModel out = new IndexedModel(model); allocationCallback.onAlloc(out); return out; diff --git a/src/main/java/com/jozufozu/flywheel/backend/model/IndexedModel.java b/src/main/java/com/jozufozu/flywheel/backend/model/IndexedModel.java index 8008b74c6..ab0de034f 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/model/IndexedModel.java +++ b/src/main/java/com/jozufozu/flywheel/backend/model/IndexedModel.java @@ -4,7 +4,7 @@ import org.lwjgl.opengl.GL20; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.gl.GlPrimitive; -import com.jozufozu.flywheel.core.model.Model; +import com.jozufozu.flywheel.core.model.IModel; /** * An indexed triangle model. Just what the driver ordered. @@ -15,7 +15,7 @@ public class IndexedModel extends BufferedModel { protected ElementBuffer ebo; - public IndexedModel(Model model) { + public IndexedModel(IModel model) { super(GlPrimitive.TRIANGLES, model); this.ebo = model.createEBO(); diff --git a/src/main/java/com/jozufozu/flywheel/backend/model/ModelAllocator.java b/src/main/java/com/jozufozu/flywheel/backend/model/ModelAllocator.java index 8756f9427..afa45904a 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/model/ModelAllocator.java +++ b/src/main/java/com/jozufozu/flywheel/backend/model/ModelAllocator.java @@ -1,6 +1,6 @@ package com.jozufozu.flywheel.backend.model; -import com.jozufozu.flywheel.core.model.Model; +import com.jozufozu.flywheel.core.model.IModel; public interface ModelAllocator { /** @@ -9,7 +9,7 @@ public interface ModelAllocator { * @param model The model to allocate. * @return A handle to the allocated model. */ - IBufferedModel alloc(Model model, Callback allocationCallback); + IBufferedModel alloc(IModel model, Callback allocationCallback); @FunctionalInterface interface Callback { diff --git a/src/main/java/com/jozufozu/flywheel/backend/model/ModelPool.java b/src/main/java/com/jozufozu/flywheel/backend/model/ModelPool.java index 61eab6fed..c905ca44f 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/model/ModelPool.java +++ b/src/main/java/com/jozufozu/flywheel/backend/model/ModelPool.java @@ -10,7 +10,7 @@ import com.jozufozu.flywheel.backend.gl.buffer.GlBuffer; import com.jozufozu.flywheel.backend.gl.buffer.GlBufferType; import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; import com.jozufozu.flywheel.backend.gl.buffer.MappedGlBuffer; -import com.jozufozu.flywheel.core.model.Model; +import com.jozufozu.flywheel.core.model.IModel; import com.jozufozu.flywheel.util.AttribUtil; public class ModelPool implements ModelAllocator { @@ -47,7 +47,7 @@ public class ModelPool implements ModelAllocator { * @return A handle to the allocated model. */ @Override - public PooledModel alloc(Model model, Callback callback) { + public PooledModel alloc(IModel model, Callback callback) { PooledModel bufferedModel = new PooledModel(model, vertices); bufferedModel.callback = callback; vertices += model.vertexCount(); @@ -153,12 +153,12 @@ public class ModelPool implements ModelAllocator { private final ElementBuffer ebo; private Callback callback; - private final Model model; + private final IModel model; private int first; private boolean remove; - public PooledModel(Model model, int first) { + public PooledModel(IModel model, int first) { this.model = model; this.first = first; ebo = model.createEBO(); diff --git a/src/main/java/com/jozufozu/flywheel/backend/model/ModelRenderer.java b/src/main/java/com/jozufozu/flywheel/backend/model/ModelRenderer.java index b6802caad..72a11d601 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/model/ModelRenderer.java +++ b/src/main/java/com/jozufozu/flywheel/backend/model/ModelRenderer.java @@ -2,16 +2,16 @@ package com.jozufozu.flywheel.backend.model; import java.util.function.Supplier; -import com.jozufozu.flywheel.core.model.Model; +import com.jozufozu.flywheel.core.model.IModel; public class ModelRenderer { - protected Supplier modelSupplier; + protected Supplier modelSupplier; protected IBufferedModel model; protected boolean initialized; - public ModelRenderer(Supplier modelSupplier) { + public ModelRenderer(Supplier modelSupplier) { this.modelSupplier = modelSupplier; } @@ -34,7 +34,7 @@ public class ModelRenderer { protected void init() { initialized = true; - Model model = modelSupplier.get(); + IModel model = modelSupplier.get(); if (model.empty()) return; diff --git a/src/main/java/com/jozufozu/flywheel/backend/pipeline/ShaderCompiler.java b/src/main/java/com/jozufozu/flywheel/backend/pipeline/IShaderPipeline.java similarity index 54% rename from src/main/java/com/jozufozu/flywheel/backend/pipeline/ShaderCompiler.java rename to src/main/java/com/jozufozu/flywheel/backend/pipeline/IShaderPipeline.java index 4a559519a..370281fcd 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/pipeline/ShaderCompiler.java +++ b/src/main/java/com/jozufozu/flywheel/backend/pipeline/IShaderPipeline.java @@ -1,15 +1,15 @@ package com.jozufozu.flywheel.backend.pipeline; -import com.jozufozu.flywheel.backend.gl.shader.GlProgram; -import com.jozufozu.flywheel.core.shader.GameStateProgram; +import com.jozufozu.flywheel.core.shader.IMultiProgram; +import com.jozufozu.flywheel.core.shader.WorldProgram; import com.jozufozu.flywheel.core.shader.spec.ProgramSpec; /** * The main interface for compiling usable shaders from program specs. * @param

the type of the program that this pipeline compiles. */ -public interface ShaderCompiler

{ +public interface IShaderPipeline

{ - GameStateProgram

compile(ProgramSpec spec); + IMultiProgram

compile(ProgramSpec spec); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/pipeline/WorldShaderCompiler.java b/src/main/java/com/jozufozu/flywheel/backend/pipeline/WorldShaderPipeline.java similarity index 83% rename from src/main/java/com/jozufozu/flywheel/backend/pipeline/WorldShaderCompiler.java rename to src/main/java/com/jozufozu/flywheel/backend/pipeline/WorldShaderPipeline.java index e3e6486b4..f26126c23 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/pipeline/WorldShaderCompiler.java +++ b/src/main/java/com/jozufozu/flywheel/backend/pipeline/WorldShaderPipeline.java @@ -9,33 +9,34 @@ import com.jozufozu.flywheel.backend.source.FileResolution; import com.jozufozu.flywheel.backend.source.SourceFile; import com.jozufozu.flywheel.core.shader.ExtensibleGlProgram; import com.jozufozu.flywheel.core.shader.GameStateProgram; +import com.jozufozu.flywheel.core.shader.IMultiProgram; import com.jozufozu.flywheel.core.shader.WorldProgram; import com.jozufozu.flywheel.core.shader.spec.ProgramSpec; import com.jozufozu.flywheel.core.shader.spec.ProgramState; import net.minecraft.resources.ResourceLocation; -public class WorldShaderCompiler

implements ShaderCompiler

{ +public class WorldShaderPipeline

implements IShaderPipeline

{ private final ExtensibleGlProgram.Factory

factory; private final Template template; private final FileResolution header; - public WorldShaderCompiler(ExtensibleGlProgram.Factory

factory, Template template, FileResolution header) { + public WorldShaderPipeline(ExtensibleGlProgram.Factory

factory, Template template, FileResolution header) { this.factory = factory; this.template = template; this.header = header; } - public GameStateProgram

compile(ProgramSpec spec) { + public IMultiProgram

compile(ProgramSpec spec) { SourceFile file = spec.getSource().getFile(); return compile(spec.name, file, spec.getStates()); } - public GameStateProgram

compile(ResourceLocation name, SourceFile file, List variants) { + public IMultiProgram

compile(ResourceLocation name, SourceFile file, List variants) { WorldShader shader = new WorldShader(name, template, header) .setMainSource(file); diff --git a/src/main/java/com/jozufozu/flywheel/backend/source/FileResolution.java b/src/main/java/com/jozufozu/flywheel/backend/source/FileResolution.java index 471d5b0c8..ba4e5f343 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/source/FileResolution.java +++ b/src/main/java/com/jozufozu/flywheel/backend/source/FileResolution.java @@ -62,7 +62,7 @@ public class FileResolution { * Called after all files are loaded. If we can't find the file here, it doesn't exist. *

*/ - void resolve(SourceHolder sources) { + void resolve(ISourceHolder sources) { try { file = sources.findSource(fileLoc); diff --git a/src/main/java/com/jozufozu/flywheel/backend/source/SourceHolder.java b/src/main/java/com/jozufozu/flywheel/backend/source/ISourceHolder.java similarity index 86% rename from src/main/java/com/jozufozu/flywheel/backend/source/SourceHolder.java rename to src/main/java/com/jozufozu/flywheel/backend/source/ISourceHolder.java index 9d25cbaea..df209dcf7 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/source/SourceHolder.java +++ b/src/main/java/com/jozufozu/flywheel/backend/source/ISourceHolder.java @@ -6,7 +6,7 @@ import net.minecraft.resources.ResourceLocation; * A minimal source file lookup function. */ @FunctionalInterface -public interface SourceHolder { +public interface ISourceHolder { SourceFile findSource(ResourceLocation name); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/source/Resolver.java b/src/main/java/com/jozufozu/flywheel/backend/source/Resolver.java index 4377d8496..185fcd4af 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/source/Resolver.java +++ b/src/main/java/com/jozufozu/flywheel/backend/source/Resolver.java @@ -28,7 +28,7 @@ public class Resolver { /** * Try and resolve all referenced source files, printing errors if any aren't found. */ - public void resolve(SourceHolder sources) { + public void resolve(ISourceHolder sources) { for (FileResolution resolution : resolutions.values()) { resolution.resolve(sources); } diff --git a/src/main/java/com/jozufozu/flywheel/backend/source/ShaderSources.java b/src/main/java/com/jozufozu/flywheel/backend/source/ShaderSources.java index d6c291fde..b53893a76 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/source/ShaderSources.java +++ b/src/main/java/com/jozufozu/flywheel/backend/source/ShaderSources.java @@ -17,7 +17,7 @@ import net.minecraft.resources.ResourceLocation; /** * The main object for loading and parsing source files. */ -public class ShaderSources implements SourceHolder { +public class ShaderSources implements ISourceHolder { public static final String SHADER_DIR = "flywheel/shaders/"; public static final ArrayList EXTENSIONS = Lists.newArrayList(".vert", ".vsh", ".frag", ".fsh", ".glsl"); diff --git a/src/main/java/com/jozufozu/flywheel/backend/state/IRenderState.java b/src/main/java/com/jozufozu/flywheel/backend/state/IRenderState.java index d488a08ca..b24a755f8 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/state/IRenderState.java +++ b/src/main/java/com/jozufozu/flywheel/backend/state/IRenderState.java @@ -6,10 +6,6 @@ import com.jozufozu.flywheel.backend.gl.GlTextureUnit; import net.minecraft.resources.ResourceLocation; -/** - * @deprecated TODO: Rework this to be more in-line/convertable with vanilla - */ -@Deprecated public interface IRenderState { void bind(); diff --git a/src/main/java/com/jozufozu/flywheel/core/Contexts.java b/src/main/java/com/jozufozu/flywheel/core/Contexts.java index 908b39b71..99eb438de 100644 --- a/src/main/java/com/jozufozu/flywheel/core/Contexts.java +++ b/src/main/java/com/jozufozu/flywheel/core/Contexts.java @@ -3,9 +3,9 @@ package com.jozufozu.flywheel.core; import com.jozufozu.flywheel.Flywheel; import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.SpecMetaRegistry; -import com.jozufozu.flywheel.backend.pipeline.ShaderCompiler; +import com.jozufozu.flywheel.backend.pipeline.IShaderPipeline; import com.jozufozu.flywheel.backend.pipeline.InstancingTemplate; -import com.jozufozu.flywheel.backend.pipeline.WorldShaderCompiler; +import com.jozufozu.flywheel.backend.pipeline.WorldShaderPipeline; import com.jozufozu.flywheel.backend.source.FileResolution; import com.jozufozu.flywheel.backend.source.Resolver; import com.jozufozu.flywheel.core.crumbling.CrumblingProgram; @@ -32,8 +32,8 @@ public class Contexts { FileResolution crumblingBuiltins = Resolver.INSTANCE.findShader(ResourceUtil.subPath(Names.CRUMBLING, ".glsl")); FileResolution worldBuiltins = Resolver.INSTANCE.findShader(ResourceUtil.subPath(Names.WORLD, ".glsl")); - ShaderCompiler crumblingPipeline = new WorldShaderCompiler<>(CrumblingProgram::new, InstancingTemplate.INSTANCE, crumblingBuiltins); - ShaderCompiler worldPipeline = new WorldShaderCompiler<>(WorldProgram::new, InstancingTemplate.INSTANCE, worldBuiltins); + IShaderPipeline crumblingPipeline = new WorldShaderPipeline<>(CrumblingProgram::new, InstancingTemplate.INSTANCE, crumblingBuiltins); + IShaderPipeline worldPipeline = new WorldShaderPipeline<>(WorldProgram::new, InstancingTemplate.INSTANCE, worldBuiltins); CRUMBLING = backend.register(WorldContext.builder(backend, Names.CRUMBLING).build(crumblingPipeline)); WORLD = backend.register(WorldContext.builder(backend, Names.WORLD).build(worldPipeline)); diff --git a/src/main/java/com/jozufozu/flywheel/core/WorldContext.java b/src/main/java/com/jozufozu/flywheel/core/WorldContext.java index 1b995f1a5..063d8d27a 100644 --- a/src/main/java/com/jozufozu/flywheel/core/WorldContext.java +++ b/src/main/java/com/jozufozu/flywheel/core/WorldContext.java @@ -6,24 +6,24 @@ import java.util.function.Supplier; import java.util.stream.Stream; import com.jozufozu.flywheel.backend.Backend; -import com.jozufozu.flywheel.backend.ShaderContext; +import com.jozufozu.flywheel.backend.IShaderContext; import com.jozufozu.flywheel.backend.material.MaterialSpec; -import com.jozufozu.flywheel.backend.pipeline.ShaderCompiler; -import com.jozufozu.flywheel.core.shader.GameStateProgram; +import com.jozufozu.flywheel.backend.pipeline.IShaderPipeline; +import com.jozufozu.flywheel.core.shader.IMultiProgram; import com.jozufozu.flywheel.core.shader.WorldProgram; import com.jozufozu.flywheel.core.shader.spec.ProgramSpec; import net.minecraft.resources.ResourceLocation; -public class WorldContext

implements ShaderContext

{ +public class WorldContext

implements IShaderContext

{ public final Backend backend; - protected final Map> programs = new HashMap<>(); + protected final Map> programs = new HashMap<>(); protected final ResourceLocation name; protected final Supplier> specStream; - public final ShaderCompiler

pipeline; + public final IShaderPipeline

pipeline; - public WorldContext(Backend backend, ResourceLocation name, Supplier> specStream, ShaderCompiler

pipeline) { + public WorldContext(Backend backend, ResourceLocation name, Supplier> specStream, IShaderPipeline

pipeline) { this.backend = backend; this.name = name; this.specStream = specStream; @@ -61,7 +61,7 @@ public class WorldContext

implements ShaderContext

{ @Override public void delete() { programs.values() - .forEach(GameStateProgram::delete); + .forEach(IMultiProgram::delete); programs.clear(); } @@ -84,7 +84,7 @@ public class WorldContext

implements ShaderContext

{ return this; } - public

WorldContext

build(ShaderCompiler

pipeline) { + public

WorldContext

build(IShaderPipeline

pipeline) { if (specStream == null) { specStream = () -> backend.allMaterials() .stream() diff --git a/src/main/java/com/jozufozu/flywheel/core/materials/BasicData.java b/src/main/java/com/jozufozu/flywheel/core/materials/BasicData.java index e697bfe50..e6e9c537a 100644 --- a/src/main/java/com/jozufozu/flywheel/core/materials/BasicData.java +++ b/src/main/java/com/jozufozu/flywheel/core/materials/BasicData.java @@ -1,9 +1,11 @@ package com.jozufozu.flywheel.core.materials; +import org.lwjgl.system.MemoryUtil; + import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.jozufozu.flywheel.backend.instancing.InstanceData; -public abstract class BasicData extends InstanceData implements FlatLight { +public abstract class BasicData extends InstanceData implements IFlatLight { public byte blockLight; public byte skyLight; diff --git a/src/main/java/com/jozufozu/flywheel/core/materials/FlatLight.java b/src/main/java/com/jozufozu/flywheel/core/materials/IFlatLight.java similarity index 77% rename from src/main/java/com/jozufozu/flywheel/core/materials/FlatLight.java rename to src/main/java/com/jozufozu/flywheel/core/materials/IFlatLight.java index 53be55243..93c90dbea 100644 --- a/src/main/java/com/jozufozu/flywheel/core/materials/FlatLight.java +++ b/src/main/java/com/jozufozu/flywheel/core/materials/IFlatLight.java @@ -7,19 +7,21 @@ import com.jozufozu.flywheel.backend.instancing.InstanceData; * if they wish to make use of Flywheel's provided light update methods. *

* This only covers flat lighting, smooth lighting is still TODO. + * + * @param The name of the class that implements this interface. */ -public interface FlatLight { +public interface IFlatLight> { /** * @param blockLight An integer in the range [0, 15] representing the * amount of block light this instance should receive. * @return this */ - FlatLight setBlockLight(int blockLight); + D setBlockLight(int blockLight); /** * @param skyLight An integer in the range [0, 15] representing the * amount of sky light this instance should receive. * @return this */ - FlatLight setSkyLight(int skyLight); + D setSkyLight(int skyLight); } diff --git a/src/main/java/com/jozufozu/flywheel/core/model/BakedModelModel.java b/src/main/java/com/jozufozu/flywheel/core/model/BakedModelModel.java index a5cd7d888..314cf9092 100644 --- a/src/main/java/com/jozufozu/flywheel/core/model/BakedModelModel.java +++ b/src/main/java/com/jozufozu/flywheel/core/model/BakedModelModel.java @@ -25,7 +25,7 @@ import net.minecraft.core.Direction; import com.mojang.math.Vector3f; import net.minecraft.core.Vec3i; -public class BakedModelModel implements Model { +public class BakedModelModel implements IModel { // DOWN, UP, NORTH, SOUTH, WEST, EAST, null private static final Direction[] dirs; diff --git a/src/main/java/com/jozufozu/flywheel/core/model/BlockModel.java b/src/main/java/com/jozufozu/flywheel/core/model/BlockModel.java index 1ecab0eda..7cd27db3b 100644 --- a/src/main/java/com/jozufozu/flywheel/core/model/BlockModel.java +++ b/src/main/java/com/jozufozu/flywheel/core/model/BlockModel.java @@ -2,6 +2,8 @@ package com.jozufozu.flywheel.core.model; import java.util.Arrays; +import org.lwjgl.opengl.GL11; + import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.jozufozu.flywheel.core.Formats; @@ -23,7 +25,7 @@ import net.minecraft.core.BlockPos; /** * A model of a single block. */ -public class BlockModel implements Model { +public class BlockModel implements IModel { private static final PoseStack IDENTITY = new PoseStack(); private final BufferBuilderReader reader; diff --git a/src/main/java/com/jozufozu/flywheel/core/model/Model.java b/src/main/java/com/jozufozu/flywheel/core/model/IModel.java similarity index 98% rename from src/main/java/com/jozufozu/flywheel/core/model/Model.java rename to src/main/java/com/jozufozu/flywheel/core/model/IModel.java index e9f92ed95..b7ffd1a1b 100644 --- a/src/main/java/com/jozufozu/flywheel/core/model/Model.java +++ b/src/main/java/com/jozufozu/flywheel/core/model/IModel.java @@ -25,7 +25,7 @@ import com.jozufozu.flywheel.core.QuadConverter; * assert model.size() == final - initial; * } */ -public interface Model { +public interface IModel { /** * Copy this model into the given buffer. diff --git a/src/main/java/com/jozufozu/flywheel/core/model/ModelPart.java b/src/main/java/com/jozufozu/flywheel/core/model/ModelPart.java index 9606d2e25..6ccb583e3 100644 --- a/src/main/java/com/jozufozu/flywheel/core/model/ModelPart.java +++ b/src/main/java/com/jozufozu/flywheel/core/model/ModelPart.java @@ -6,7 +6,7 @@ import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat; import com.jozufozu.flywheel.backend.gl.buffer.VecBuffer; import com.jozufozu.flywheel.core.Formats; -public class ModelPart implements Model { +public class ModelPart implements IModel { private final List cuboids; private int vertices; diff --git a/src/main/java/com/jozufozu/flywheel/core/model/WorldModel.java b/src/main/java/com/jozufozu/flywheel/core/model/WorldModel.java index b01c3c788..938d5cdca 100644 --- a/src/main/java/com/jozufozu/flywheel/core/model/WorldModel.java +++ b/src/main/java/com/jozufozu/flywheel/core/model/WorldModel.java @@ -12,7 +12,7 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; -public class WorldModel implements Model { +public class WorldModel implements IModel { private final BufferBuilderReader reader; diff --git a/src/main/java/com/jozufozu/flywheel/core/shader/GameStateProgram.java b/src/main/java/com/jozufozu/flywheel/core/shader/GameStateProgram.java index bd9742928..9b67fdf37 100644 --- a/src/main/java/com/jozufozu/flywheel/core/shader/GameStateProgram.java +++ b/src/main/java/com/jozufozu/flywheel/core/shader/GameStateProgram.java @@ -2,14 +2,13 @@ package com.jozufozu.flywheel.core.shader; import java.util.ArrayList; import java.util.List; -import java.util.function.Supplier; import com.google.common.collect.ImmutableList; import com.jozufozu.flywheel.backend.gl.shader.GlProgram; import com.jozufozu.flywheel.core.shader.spec.IGameStateCondition; import com.jozufozu.flywheel.util.Pair; -public class GameStateProgram

implements Supplier

{ +public class GameStateProgram

implements IMultiProgram

{ private final List> variants; private final P fallback; @@ -19,9 +18,6 @@ public class GameStateProgram

implements Supplier

{ this.fallback = fallback; } - /** - * Get the shader program most suited for the current game state. - */ @Override public P get() { for (Pair variant : variants) { @@ -32,9 +28,7 @@ public class GameStateProgram

implements Supplier

{ return fallback; } - /** - * Delete all associated programs. - */ + @Override public void delete() { for (Pair variant : variants) { variant.getSecond() @@ -61,7 +55,7 @@ public class GameStateProgram

implements Supplier

{ return this; } - public GameStateProgram

build() { + public IMultiProgram

build() { return new GameStateProgram<>(ImmutableList.copyOf(variants), fallback); } } diff --git a/src/main/java/com/jozufozu/flywheel/core/shader/IMultiProgram.java b/src/main/java/com/jozufozu/flywheel/core/shader/IMultiProgram.java new file mode 100644 index 000000000..924a989a5 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/core/shader/IMultiProgram.java @@ -0,0 +1,26 @@ +package com.jozufozu.flywheel.core.shader; + +import java.util.function.Supplier; + +import com.jozufozu.flywheel.backend.gl.shader.GlProgram; + +/** + * Encapsulates any number of shader programs for use in similar contexts. + * Allows the implementor to choose which shader program to use based on arbitrary state. + * + * @param

+ */ +public interface IMultiProgram

extends Supplier

{ + + /** + * Get the shader program most suited for the current game state. + * + * @return The one true program. + */ + P get(); + + /** + * Delete all shader programs encapsulated by your implementation. + */ + void delete(); +} diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/BellInstance.java b/src/main/java/com/jozufozu/flywheel/vanilla/BellInstance.java index 418575abf..cddfddec7 100644 --- a/src/main/java/com/jozufozu/flywheel/vanilla/BellInstance.java +++ b/src/main/java/com/jozufozu/flywheel/vanilla/BellInstance.java @@ -1,6 +1,6 @@ package com.jozufozu.flywheel.vanilla; -import com.jozufozu.flywheel.backend.instancing.DynamicInstance; +import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance; import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.core.Materials; @@ -14,7 +14,7 @@ import net.minecraft.util.Mth; import com.mojang.math.Quaternion; import com.mojang.math.Vector3f; -public class BellInstance extends TileEntityInstance implements DynamicInstance { +public class BellInstance extends TileEntityInstance implements IDynamicInstance { private final OrientedData bell; diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/ChestInstance.java b/src/main/java/com/jozufozu/flywheel/vanilla/ChestInstance.java index 8737b7dee..905f86fee 100644 --- a/src/main/java/com/jozufozu/flywheel/vanilla/ChestInstance.java +++ b/src/main/java/com/jozufozu/flywheel/vanilla/ChestInstance.java @@ -4,7 +4,7 @@ import java.util.Calendar; import javax.annotation.Nonnull; -import com.jozufozu.flywheel.backend.instancing.DynamicInstance; +import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance; import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.backend.state.TextureRenderState; @@ -29,7 +29,7 @@ import net.minecraft.world.level.block.DoubleBlockCombiner; import com.mojang.math.Quaternion; import com.mojang.math.Vector3f; -public class ChestInstance extends TileEntityInstance implements DynamicInstance { +public class ChestInstance extends TileEntityInstance implements IDynamicInstance { private final MatrixTransformStack stack = new MatrixTransformStack(); private final OrientedData body; diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/MinecartInstance.java b/src/main/java/com/jozufozu/flywheel/vanilla/MinecartInstance.java index c3da45544..820b4d364 100644 --- a/src/main/java/com/jozufozu/flywheel/vanilla/MinecartInstance.java +++ b/src/main/java/com/jozufozu/flywheel/vanilla/MinecartInstance.java @@ -1,13 +1,13 @@ package com.jozufozu.flywheel.vanilla; -import com.jozufozu.flywheel.backend.instancing.DynamicInstance; -import com.jozufozu.flywheel.backend.instancing.TickableInstance; +import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; +import com.jozufozu.flywheel.backend.instancing.ITickableInstance; import com.jozufozu.flywheel.backend.instancing.entity.EntityInstance; import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.backend.state.TextureRenderState; import com.jozufozu.flywheel.core.Materials; import com.jozufozu.flywheel.core.materials.model.ModelData; -import com.jozufozu.flywheel.core.model.Model; +import com.jozufozu.flywheel.core.model.IModel; import com.jozufozu.flywheel.core.model.ModelPart; import com.jozufozu.flywheel.util.AnimationTickHolder; import com.jozufozu.flywheel.util.transform.MatrixTransformStack; @@ -21,7 +21,7 @@ import net.minecraft.util.Mth; import net.minecraft.world.phys.Vec3; import com.mojang.math.Vector3f; -public class MinecartInstance extends EntityInstance implements DynamicInstance, TickableInstance { +public class MinecartInstance extends EntityInstance implements IDynamicInstance, ITickableInstance { private static final ResourceLocation MINECART_LOCATION = new ResourceLocation("textures/entity/minecart.png"); @@ -153,7 +153,7 @@ public class MinecartInstance extends EntityInstance .createInstance(); } - private Model getBodyModel() { + private IModel getBodyModel() { int y = -3; return ModelPart.builder(64, 32) .cuboid().invertYZ().start(-10, -8, -y).size(20, 16, 2).textureOffset(0, 10).rotateX(((float)Math.PI / 2F)).endCuboid() diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxInstance.java b/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxInstance.java index 1397dded1..334778b89 100644 --- a/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxInstance.java +++ b/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxInstance.java @@ -1,6 +1,6 @@ package com.jozufozu.flywheel.vanilla; -import com.jozufozu.flywheel.backend.instancing.DynamicInstance; +import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance; import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.core.Materials; @@ -18,7 +18,7 @@ import net.minecraft.core.Direction; import com.mojang.math.Quaternion; import com.mojang.math.Vector3f; -public class ShulkerBoxInstance extends TileEntityInstance implements DynamicInstance { +public class ShulkerBoxInstance extends TileEntityInstance implements IDynamicInstance { private final TextureAtlasSprite texture;