mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-15 14:23:41 +01:00
Start working on instanced enti- oh wait I've got to do all this other stuff first
- Separate model-level instance management from object-level instance management - Separate material management from rendering - A few things here and there related to entity instancing - Add a rudimentary command to spawn superglue
This commit is contained in:
parent
d7ed765dde
commit
bef6d77a59
95 changed files with 862 additions and 462 deletions
|
@ -23,11 +23,12 @@ import org.lwjgl.opengl.GLCapabilities;
|
||||||
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
import com.jozufozu.flywheel.backend.gl.shader.GlProgram;
|
||||||
import com.jozufozu.flywheel.backend.gl.versioned.GlCompat;
|
import com.jozufozu.flywheel.backend.gl.versioned.GlCompat;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.MaterialSpec;
|
import com.jozufozu.flywheel.backend.instancing.MaterialSpec;
|
||||||
import com.jozufozu.flywheel.core.CrumblingRenderer;
|
import com.jozufozu.flywheel.backend.instancing.TileInstanceManager;
|
||||||
|
import com.jozufozu.flywheel.core.CrumblingInstanceManager;
|
||||||
import com.jozufozu.flywheel.core.QuadConverter;
|
import com.jozufozu.flywheel.core.QuadConverter;
|
||||||
import com.jozufozu.flywheel.core.WorldContext;
|
import com.jozufozu.flywheel.core.WorldContext;
|
||||||
import com.jozufozu.flywheel.core.WorldTileRenderer;
|
|
||||||
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
||||||
import com.jozufozu.flywheel.core.shader.spec.ProgramSpec;
|
import com.jozufozu.flywheel.core.shader.spec.ProgramSpec;
|
||||||
import com.jozufozu.flywheel.util.WorldAttached;
|
import com.jozufozu.flywheel.util.WorldAttached;
|
||||||
|
@ -53,7 +54,6 @@ import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.vector.Matrix4f;
|
import net.minecraft.util.math.vector.Matrix4f;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.resource.ISelectiveResourceReloadListener;
|
|
||||||
|
|
||||||
public class Backend {
|
public class Backend {
|
||||||
public static final Logger log = LogManager.getLogger(Backend.class);
|
public static final Logger log = LogManager.getLogger(Backend.class);
|
||||||
|
@ -64,11 +64,11 @@ public class Backend {
|
||||||
public static GLCapabilities capabilities;
|
public static GLCapabilities capabilities;
|
||||||
public static GlCompat compat;
|
public static GlCompat compat;
|
||||||
|
|
||||||
public static WorldAttached<WorldTileRenderer<WorldProgram>> tileRenderer = new WorldAttached<>(() -> new WorldTileRenderer<>(WorldContext.INSTANCE));
|
public static WorldAttached<TileInstanceManager> tileInstanceManager = new WorldAttached<>(world -> new TileInstanceManager(WorldContext.INSTANCE.getMaterialManager(world)));
|
||||||
public static LazyValue<Vector<CrumblingRenderer>> blockBreaking = new LazyValue<>(() -> {
|
public static LazyValue<Vector<CrumblingInstanceManager>> blockBreaking = new LazyValue<>(() -> {
|
||||||
Vector<CrumblingRenderer> renderers = new Vector<>(10);
|
Vector<CrumblingInstanceManager> renderers = new Vector<>(10);
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
renderers.add(new CrumblingRenderer());
|
renderers.add(new CrumblingInstanceManager());
|
||||||
}
|
}
|
||||||
return renderers;
|
return renderers;
|
||||||
});
|
});
|
||||||
|
@ -87,7 +87,7 @@ public class Backend {
|
||||||
|
|
||||||
listeners.refreshListener(world -> {
|
listeners.refreshListener(world -> {
|
||||||
if (canUseInstancing() && world != null) {
|
if (canUseInstancing() && world != null) {
|
||||||
WorldTileRenderer<WorldProgram> tileRenderer = Backend.tileRenderer.get(world);
|
TileInstanceManager tileRenderer = Backend.tileInstanceManager.get(world);
|
||||||
tileRenderer.invalidate();
|
tileRenderer.invalidate();
|
||||||
world.loadedTileEntityList.forEach(tileRenderer::add);
|
world.loadedTileEntityList.forEach(tileRenderer::add);
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,9 @@ public class Backend {
|
||||||
});
|
});
|
||||||
|
|
||||||
listeners.setupFrameListener((world, stack, info, gameRenderer, lightTexture) -> {
|
listeners.setupFrameListener((world, stack, info, gameRenderer, lightTexture) -> {
|
||||||
Backend.tileRenderer.get(world)
|
WorldContext.INSTANCE.materialManager.get(world)
|
||||||
|
.checkAndShiftOrigin(info);
|
||||||
|
Backend.tileInstanceManager.get(world)
|
||||||
.beginFrame(info);
|
.beginFrame(info);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -108,6 +110,10 @@ public class Backend {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a string describing the Flywheel backend. When there are eventually multiple backends
|
||||||
|
* (Meshlet, MDI, GL31 Draw Instanced are planned), this will name which one is in use.
|
||||||
|
*/
|
||||||
public static String getBackendDescriptor() {
|
public static String getBackendDescriptor() {
|
||||||
if (canUseInstancing()) {
|
if (canUseInstancing()) {
|
||||||
return "GL33 Instanced Arrays";
|
return "GL33 Instanced Arrays";
|
||||||
|
@ -191,8 +197,7 @@ public class Backend {
|
||||||
IResourceManager manager = mc.getResourceManager();
|
IResourceManager manager = mc.getResourceManager();
|
||||||
|
|
||||||
if (manager instanceof IReloadableResourceManager) {
|
if (manager instanceof IReloadableResourceManager) {
|
||||||
ISelectiveResourceReloadListener listener = shaderLoader::onResourceManagerReload;
|
((IReloadableResourceManager) manager).addReloadListener(shaderLoader);
|
||||||
((IReloadableResourceManager) manager).addReloadListener(listener);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +217,7 @@ public class Backend {
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
ClientWorld world = mc.world;
|
ClientWorld world = mc.world;
|
||||||
|
|
||||||
WorldTileRenderer<WorldProgram> instancer = tileRenderer.get(world);
|
TileInstanceManager instancer = tileInstanceManager.get(world);
|
||||||
|
|
||||||
Entity renderViewEntity = mc.renderViewEntity;
|
Entity renderViewEntity = mc.renderViewEntity;
|
||||||
instancer.tick(renderViewEntity.getX(), renderViewEntity.getY(), renderViewEntity.getZ());
|
instancer.tick(renderViewEntity.getX(), renderViewEntity.getY(), renderViewEntity.getZ());
|
||||||
|
@ -220,11 +225,11 @@ public class Backend {
|
||||||
|
|
||||||
public static void renderLayer(ClientWorld world, RenderType layer, Matrix4f viewProjection, double cameraX, double cameraY, double cameraZ) {
|
public static void renderLayer(ClientWorld world, RenderType layer, Matrix4f viewProjection, double cameraX, double cameraY, double cameraZ) {
|
||||||
if (!canUseInstancing(world)) return;
|
if (!canUseInstancing(world)) return;
|
||||||
WorldTileRenderer<WorldProgram> renderer = tileRenderer.get(world);
|
MaterialManager<WorldProgram> materialManager = WorldContext.INSTANCE.getMaterialManager(world);
|
||||||
|
|
||||||
layer.startDrawing();
|
layer.startDrawing();
|
||||||
|
|
||||||
renderer.render(layer, viewProjection, cameraX, cameraY, cameraZ);
|
materialManager.render(layer, viewProjection, cameraX, cameraY, cameraZ);
|
||||||
|
|
||||||
layer.endDrawing();
|
layer.endDrawing();
|
||||||
}
|
}
|
||||||
|
@ -238,7 +243,7 @@ public class Backend {
|
||||||
Long2ObjectMap<SortedSet<DestroyBlockProgress>> breakingProgressions = worldRenderer.blockBreakingProgressions;
|
Long2ObjectMap<SortedSet<DestroyBlockProgress>> breakingProgressions = worldRenderer.blockBreakingProgressions;
|
||||||
|
|
||||||
if (breakingProgressions.isEmpty()) return;
|
if (breakingProgressions.isEmpty()) return;
|
||||||
Vector<CrumblingRenderer> renderers = blockBreaking.getValue();
|
Vector<CrumblingInstanceManager> renderers = blockBreaking.getValue();
|
||||||
|
|
||||||
BitSet bitSet = new BitSet(10);
|
BitSet bitSet = new BitSet(10);
|
||||||
|
|
||||||
|
@ -264,12 +269,12 @@ public class Backend {
|
||||||
CRUMBLING.startDrawing();
|
CRUMBLING.startDrawing();
|
||||||
bitSet.stream().forEach(i -> {
|
bitSet.stream().forEach(i -> {
|
||||||
Texture breaking = textureManager.getTexture(ModelBakery.BLOCK_DESTRUCTION_STAGE_TEXTURES.get(i));
|
Texture breaking = textureManager.getTexture(ModelBakery.BLOCK_DESTRUCTION_STAGE_TEXTURES.get(i));
|
||||||
CrumblingRenderer renderer = renderers.get(i);
|
CrumblingInstanceManager renderer = renderers.get(i);
|
||||||
renderer.beginFrame(info);
|
renderer.beginFrame(info);
|
||||||
|
|
||||||
if (breaking != null) {
|
if (breaking != null) {
|
||||||
glBindTexture(GL_TEXTURE_2D, breaking.getGlTextureId());
|
glBindTexture(GL_TEXTURE_2D, breaking.getGlTextureId());
|
||||||
renderer.render(RenderType.getCutoutMipped(), viewProjection, cameraX, cameraY, cameraZ, program -> program.setTextureScale(64, 64));
|
renderer.materialManager.render(RenderType.getCutoutMipped(), viewProjection, cameraX, cameraY, cameraZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.invalidate();
|
renderer.invalidate();
|
||||||
|
@ -283,7 +288,7 @@ public class Backend {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void enqueueUpdate(TileEntity te) {
|
public static void enqueueUpdate(TileEntity te) {
|
||||||
tileRenderer.get(te.getWorld()).queueUpdate(te);
|
tileInstanceManager.get(te.getWorld()).queueUpdate(te);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reloadWorldRenderers() {
|
public static void reloadWorldRenderers() {
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
import org.lwjgl.system.MemoryUtil;
|
import org.lwjgl.system.MemoryUtil;
|
||||||
|
|
||||||
|
@ -47,23 +48,25 @@ import net.minecraft.resources.IResource;
|
||||||
import net.minecraft.resources.IResourceManager;
|
import net.minecraft.resources.IResourceManager;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.resource.IResourceType;
|
import net.minecraftforge.resource.IResourceType;
|
||||||
|
import net.minecraftforge.resource.ISelectiveResourceReloadListener;
|
||||||
import net.minecraftforge.resource.VanillaResourceType;
|
import net.minecraftforge.resource.VanillaResourceType;
|
||||||
|
|
||||||
public class ShaderLoader {
|
@ParametersAreNonnullByDefault
|
||||||
|
public class ShaderLoader implements ISelectiveResourceReloadListener {
|
||||||
public static final String SHADER_DIR = "flywheel/shaders/";
|
public static final String SHADER_DIR = "flywheel/shaders/";
|
||||||
public static final String PROGRAM_DIR = "flywheel/programs/";
|
public static final String PROGRAM_DIR = "flywheel/programs/";
|
||||||
public static final ArrayList<String> EXTENSIONS = Lists.newArrayList(".vert", ".vsh", ".frag", ".fsh", ".glsl");
|
public static final ArrayList<String> EXTENSIONS = Lists.newArrayList(".vert", ".vsh", ".frag", ".fsh", ".glsl");
|
||||||
|
|
||||||
// #flwinclude <"valid_namespace:valid/path_to_file.glsl">
|
// #flwinclude <"valid_namespace:valid/path_to_file.glsl">
|
||||||
private static final Pattern includePattern = Pattern.compile("#flwinclude <\"([\\w\\d_]+:[\\w\\d_./]+)\">");
|
private static final Pattern includePattern = Pattern.compile("#flwinclude <\"([\\w\\d_]+:[\\w\\d_./]+)\">");
|
||||||
private static boolean debugDumpFile = true;
|
|
||||||
|
|
||||||
private final Map<ResourceLocation, String> shaderSource = new HashMap<>();
|
private final Map<ResourceLocation, String> shaderSource = new HashMap<>();
|
||||||
|
|
||||||
private boolean shouldCrash;
|
private boolean shouldCrash;
|
||||||
private final Gson gson = new GsonBuilder().create();
|
private final Gson gson = new GsonBuilder().create();
|
||||||
|
|
||||||
void onResourceManagerReload(IResourceManager manager, Predicate<IResourceType> predicate) {
|
@Override
|
||||||
|
public void onResourceManagerReload(IResourceManager manager, Predicate<IResourceType> predicate) {
|
||||||
if (predicate.test(VanillaResourceType.SHADERS)) {
|
if (predicate.test(VanillaResourceType.SHADERS)) {
|
||||||
OptifineHandler.refresh();
|
OptifineHandler.refresh();
|
||||||
Backend.refresh();
|
Backend.refresh();
|
||||||
|
|
|
@ -4,7 +4,7 @@ import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A general interface providing information about any type of thing that could use Flywheel's instanced rendering.
|
* A general interface providing information about any type of thing that could use Flywheel's instanced rendering.
|
||||||
* Right now, that's only {@link InstancedTileRenderer}, but there could be an entity equivalent in the future.
|
* Right now, that's only {@link TileInstanceManager}, but there could be an entity equivalent in the future.
|
||||||
*/
|
*/
|
||||||
public interface IInstance {
|
public interface IInstance {
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.jozufozu.flywheel.backend.instancing;
|
package com.jozufozu.flywheel.backend.instancing;
|
||||||
|
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Something (a TileEntity or Entity) that can be rendered using the instancing API.
|
* Something (a TileEntity or Entity) that can be rendered using the instancing API.
|
||||||
*/
|
*/
|
||||||
|
@ -11,4 +13,6 @@ public interface IInstanceRendered {
|
||||||
default boolean shouldRenderNormally() {
|
default boolean shouldRenderNormally() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
World getWorld();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
package com.jozufozu.flywheel.backend.instancing;
|
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
|
|
||||||
@FunctionalInterface
|
|
||||||
public interface IRendererFactory<T extends TileEntity> {
|
|
||||||
TileEntityInstance<? super T> create(InstancedTileRenderer<?> manager, T te);
|
|
||||||
}
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package com.jozufozu.flywheel.backend.instancing;
|
||||||
|
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface ITileInstanceFactory<T extends TileEntity> {
|
||||||
|
TileEntityInstance<? super T> create(MaterialManager<?> manager, T te);
|
||||||
|
}
|
|
@ -19,8 +19,6 @@ import com.jozufozu.flywheel.backend.model.BufferedModel;
|
||||||
import com.jozufozu.flywheel.backend.model.IndexedModel;
|
import com.jozufozu.flywheel.backend.model.IndexedModel;
|
||||||
import com.jozufozu.flywheel.core.PartialModel;
|
import com.jozufozu.flywheel.core.PartialModel;
|
||||||
import com.jozufozu.flywheel.core.QuadConverter;
|
import com.jozufozu.flywheel.core.QuadConverter;
|
||||||
import com.jozufozu.flywheel.core.shader.IProgramCallback;
|
|
||||||
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
|
||||||
import com.jozufozu.flywheel.util.BufferBuilderReader;
|
import com.jozufozu.flywheel.util.BufferBuilderReader;
|
||||||
import com.jozufozu.flywheel.util.RenderUtil;
|
import com.jozufozu.flywheel.util.RenderUtil;
|
||||||
import com.jozufozu.flywheel.util.VirtualEmptyModelData;
|
import com.jozufozu.flywheel.util.VirtualEmptyModelData;
|
||||||
|
@ -31,22 +29,22 @@ import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.BlockModelRenderer;
|
import net.minecraft.client.renderer.BlockModelRenderer;
|
||||||
import net.minecraft.client.renderer.BlockRendererDispatcher;
|
import net.minecraft.client.renderer.BlockRendererDispatcher;
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
import net.minecraft.client.renderer.BufferBuilder;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
|
||||||
import net.minecraft.client.renderer.model.IBakedModel;
|
import net.minecraft.client.renderer.model.IBakedModel;
|
||||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.vector.Matrix4f;
|
import net.minecraft.util.math.vector.Vector3i;
|
||||||
|
|
||||||
public class RenderMaterial<P extends WorldProgram, D extends InstanceData> {
|
public class InstanceMaterial<D extends InstanceData> {
|
||||||
|
|
||||||
protected final InstancedTileRenderer<P> renderer;
|
protected final Supplier<Vector3i> originCoordinate;
|
||||||
protected final Cache<Object, Instancer<D>> models;
|
protected final Cache<Object, Instancer<D>> models;
|
||||||
protected final MaterialSpec<D> spec;
|
protected final MaterialSpec<D> spec;
|
||||||
|
private final VertexFormat modelFormat;
|
||||||
|
|
||||||
public RenderMaterial(InstancedTileRenderer<P> renderer, MaterialSpec<D> spec) {
|
public InstanceMaterial(Supplier<Vector3i> renderer, MaterialSpec<D> spec) {
|
||||||
this.renderer = renderer;
|
this.originCoordinate = renderer;
|
||||||
this.spec = spec;
|
this.spec = spec;
|
||||||
|
|
||||||
this.models = CacheBuilder.newBuilder()
|
this.models = CacheBuilder.newBuilder()
|
||||||
|
@ -55,35 +53,21 @@ public class RenderMaterial<P extends WorldProgram, D extends InstanceData> {
|
||||||
RenderWork.enqueue(model::delete);
|
RenderWork.enqueue(model::delete);
|
||||||
})
|
})
|
||||||
.build();
|
.build();
|
||||||
}
|
modelFormat = this.spec.getModelFormat();
|
||||||
|
|
||||||
public void render(RenderType layer, Matrix4f projection, double camX, double camY, double camZ) {
|
|
||||||
render(layer, projection, camX, camY, camZ, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void render(RenderType layer, Matrix4f viewProjection, double camX, double camY, double camZ, IProgramCallback<P> setup) {
|
|
||||||
if (!(layer == RenderType.getCutoutMipped())) return;
|
|
||||||
|
|
||||||
P program = renderer.context.getProgram(this.spec.getProgramSpec());
|
|
||||||
program.bind();
|
|
||||||
program.uploadViewProjection(viewProjection);
|
|
||||||
program.uploadCameraPos(camX, camY, camZ);
|
|
||||||
|
|
||||||
if (setup != null) setup.call(program);
|
|
||||||
|
|
||||||
makeRenderCalls();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete() {
|
public void delete() {
|
||||||
//runOnAll(InstancedModel::delete);
|
|
||||||
models.invalidateAll();
|
models.invalidateAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void makeRenderCalls() {
|
/**
|
||||||
runOnAll(Instancer::render);
|
* Clear all instance data without freeing resources.
|
||||||
|
*/
|
||||||
|
public void clear() {
|
||||||
|
models.asMap().values().forEach(Instancer::clear);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runOnAll(Consumer<Instancer<D>> f) {
|
public void forEachInstancer(Consumer<Instancer<D>> f) {
|
||||||
for (Instancer<D> model : models.asMap().values()) {
|
for (Instancer<D> model : models.asMap().values()) {
|
||||||
f.accept(model);
|
f.accept(model);
|
||||||
}
|
}
|
||||||
|
@ -106,31 +90,30 @@ public class RenderMaterial<P extends WorldProgram, D extends InstanceData> {
|
||||||
return get(toRender, () -> buildModel(toRender));
|
return get(toRender, () -> buildModel(toRender));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Instancer<D> get(Object key, Supplier<Instancer<D>> supplier) {
|
public Instancer<D> get(Object key, Supplier<BufferedModel> supplier) {
|
||||||
try {
|
try {
|
||||||
return models.get(key, supplier::get);
|
return models.get(key, () -> new Instancer<>(supplier.get(), originCoordinate, spec));
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Instancer<D> buildModel(BlockState renderedState) {
|
private BufferedModel buildModel(BlockState renderedState) {
|
||||||
BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRendererDispatcher();
|
BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRendererDispatcher();
|
||||||
return buildModel(dispatcher.getModelForState(renderedState), renderedState);
|
return buildModel(dispatcher.getModelForState(renderedState), renderedState);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Instancer<D> buildModel(IBakedModel model, BlockState renderedState) {
|
private BufferedModel buildModel(IBakedModel model, BlockState renderedState) {
|
||||||
return buildModel(model, renderedState, new MatrixStack());
|
return buildModel(model, renderedState, new MatrixStack());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Instancer<D> buildModel(IBakedModel model, BlockState referenceState, MatrixStack ms) {
|
private BufferedModel buildModel(IBakedModel model, BlockState referenceState, MatrixStack ms) {
|
||||||
BufferBuilderReader reader = new BufferBuilderReader(getBufferBuilder(model, referenceState, ms));
|
BufferBuilderReader reader = new BufferBuilderReader(getBufferBuilder(model, referenceState, ms));
|
||||||
|
|
||||||
VertexFormat format = spec.getModelFormat();
|
|
||||||
int vertexCount = reader.getVertexCount();
|
int vertexCount = reader.getVertexCount();
|
||||||
|
|
||||||
ByteBuffer vertices = ByteBuffer.allocate(vertexCount * format.getStride());
|
ByteBuffer vertices = ByteBuffer.allocate(vertexCount * modelFormat.getStride());
|
||||||
vertices.order(ByteOrder.nativeOrder());
|
vertices.order(ByteOrder.nativeOrder());
|
||||||
|
|
||||||
for (int i = 0; i < vertexCount; i++) {
|
for (int i = 0; i < vertexCount; i++) {
|
||||||
|
@ -148,10 +131,9 @@ public class RenderMaterial<P extends WorldProgram, D extends InstanceData> {
|
||||||
|
|
||||||
vertices.rewind();
|
vertices.rewind();
|
||||||
|
|
||||||
BufferedModel bufferedModel = new IndexedModel(GlPrimitive.TRIANGLES, format, vertices, vertexCount, QuadConverter.getInstance().quads2Tris(vertexCount / 4));
|
// return new BufferedModel(GlPrimitive.QUADS, format, vertices, vertexCount);
|
||||||
//BufferedModel bufferedModel = new BufferedModel(GlPrimitive.QUADS, format, vertices, vertexCount);
|
|
||||||
|
|
||||||
return new Instancer<>(bufferedModel, renderer, spec.getInstanceFormat(), spec.getInstanceFactory());
|
return new IndexedModel(GlPrimitive.TRIANGLES, modelFormat, vertices, vertexCount, QuadConverter.getInstance().quads2Tris(vertexCount / 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Direction[] dirs;
|
private static final Direction[] dirs;
|
|
@ -9,24 +9,24 @@ import com.google.common.collect.Maps;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.tileentity.TileEntityType;
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
|
|
||||||
public class InstancedTileRenderRegistry {
|
public class InstancedRenderRegistry {
|
||||||
private static final InstancedTileRenderRegistry INSTANCE = new InstancedTileRenderRegistry();
|
private static final InstancedRenderRegistry INSTANCE = new InstancedRenderRegistry();
|
||||||
|
|
||||||
public static InstancedTileRenderRegistry getInstance() {
|
public static InstancedRenderRegistry getInstance() {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Map<TileEntityType<?>, IRendererFactory<?>> renderers = Maps.newHashMap();
|
private final Map<TileEntityType<?>, ITileInstanceFactory<?>> renderers = Maps.newHashMap();
|
||||||
|
|
||||||
public <T extends TileEntity> void register(TileEntityType<? extends T> type, IRendererFactory<? super T> rendererFactory) {
|
public <T extends TileEntity> void register(TileEntityType<? extends T> type, ITileInstanceFactory<? super T> rendererFactory) {
|
||||||
this.renderers.put(type, rendererFactory);
|
this.renderers.put(type, rendererFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Nullable
|
@Nullable
|
||||||
public <T extends TileEntity> TileEntityInstance<? super T> create(InstancedTileRenderer<?> manager, T tile) {
|
public <T extends TileEntity> TileEntityInstance<? super T> create(MaterialManager<?> manager, T tile) {
|
||||||
TileEntityType<?> type = tile.getType();
|
TileEntityType<?> type = tile.getType();
|
||||||
IRendererFactory<? super T> factory = (IRendererFactory<? super T>) this.renderers.get(type);
|
ITileInstanceFactory<? super T> factory = (ITileInstanceFactory<? super T>) this.renderers.get(type);
|
||||||
|
|
||||||
if (factory == null) return null;
|
if (factory == null) return null;
|
||||||
else return factory.create(manager, tile);
|
else return factory.create(manager, tile);
|
|
@ -3,6 +3,7 @@ package com.jozufozu.flywheel.backend.instancing;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
import com.jozufozu.flywheel.backend.gl.GlVertexArray;
|
import com.jozufozu.flywheel.backend.gl.GlVertexArray;
|
||||||
|
@ -13,9 +14,11 @@ import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer;
|
||||||
import com.jozufozu.flywheel.backend.model.BufferedModel;
|
import com.jozufozu.flywheel.backend.model.BufferedModel;
|
||||||
import com.jozufozu.flywheel.util.AttribUtil;
|
import com.jozufozu.flywheel.util.AttribUtil;
|
||||||
|
|
||||||
|
import net.minecraft.util.math.vector.Vector3i;
|
||||||
|
|
||||||
public class Instancer<D extends InstanceData> {
|
public class Instancer<D extends InstanceData> {
|
||||||
|
|
||||||
public final InstancedTileRenderer<?> renderer;
|
public final Supplier<Vector3i> originCoordinate;
|
||||||
|
|
||||||
protected final BufferedModel model;
|
protected final BufferedModel model;
|
||||||
|
|
||||||
|
@ -32,11 +35,11 @@ public class Instancer<D extends InstanceData> {
|
||||||
boolean anyToRemove;
|
boolean anyToRemove;
|
||||||
boolean anyToUpdate;
|
boolean anyToUpdate;
|
||||||
|
|
||||||
public Instancer(BufferedModel model, InstancedTileRenderer<?> renderer, VertexFormat instanceFormat, IInstanceFactory<D> factory) {
|
public Instancer(BufferedModel model, Supplier<Vector3i> originCoordinate, MaterialSpec<D> spec) {
|
||||||
this.model = model;
|
this.model = model;
|
||||||
this.factory = factory;
|
this.factory = spec.getInstanceFactory();
|
||||||
this.instanceFormat = instanceFormat;
|
this.instanceFormat = spec.getInstanceFormat();
|
||||||
this.renderer = renderer;
|
this.originCoordinate = originCoordinate;
|
||||||
|
|
||||||
if (model.getVertexCount() <= 0)
|
if (model.getVertexCount() <= 0)
|
||||||
throw new IllegalArgumentException("Refusing to instance a model with no vertices.");
|
throw new IllegalArgumentException("Refusing to instance a model with no vertices.");
|
||||||
|
@ -77,6 +80,17 @@ public class Instancer<D extends InstanceData> {
|
||||||
return instanceData;
|
return instanceData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear all instance data without freeing resources.
|
||||||
|
*/
|
||||||
|
public void clear() {
|
||||||
|
data.clear();
|
||||||
|
anyToRemove = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Free acquired resources. Attempting to use this after calling delete is undefined behavior.
|
||||||
|
*/
|
||||||
public void delete() {
|
public void delete() {
|
||||||
if (deleted) return;
|
if (deleted) return;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,129 @@
|
||||||
|
package com.jozufozu.flywheel.backend.instancing;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
|
import com.jozufozu.flywheel.core.WorldContext;
|
||||||
|
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||||
|
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||||
|
import com.jozufozu.flywheel.core.shader.IProgramCallback;
|
||||||
|
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
||||||
|
import com.jozufozu.flywheel.util.WeakHashSet;
|
||||||
|
import com.simibubi.create.foundation.render.AllMaterialSpecs;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||||
|
import net.minecraft.client.renderer.RenderType;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
import net.minecraft.util.math.vector.Matrix4f;
|
||||||
|
import net.minecraft.util.math.vector.Vector3i;
|
||||||
|
|
||||||
|
public class MaterialManager<P extends WorldProgram> {
|
||||||
|
|
||||||
|
public static int MAX_ORIGIN_DISTANCE = 100;
|
||||||
|
|
||||||
|
protected final ArrayList<MaterialRenderer<P>> renderers;
|
||||||
|
protected final Map<ResourceLocation, InstanceMaterial<?>> materials;
|
||||||
|
|
||||||
|
private BlockPos originCoordinate = BlockPos.ZERO;
|
||||||
|
|
||||||
|
private final WeakHashSet<OriginShiftListener> listeners;
|
||||||
|
|
||||||
|
public MaterialManager(WorldContext<P> context) {
|
||||||
|
this.materials = new HashMap<>();
|
||||||
|
this.renderers = new ArrayList<>(Backend.allMaterials().size());
|
||||||
|
this.listeners = new WeakHashSet<>();
|
||||||
|
|
||||||
|
for (MaterialSpec<?> spec : Backend.allMaterials()) {
|
||||||
|
InstanceMaterial<?> material = new InstanceMaterial<>(this::getOriginCoordinate, spec);
|
||||||
|
materials.put(spec.name, material);
|
||||||
|
MaterialRenderer<P> renderer = new MaterialRenderer<>(context.getProgram(spec.getProgramName()), material);
|
||||||
|
renderers.add(renderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render every model for every material.
|
||||||
|
*
|
||||||
|
* @param layer Which vanilla {@link RenderType} is being drawn?
|
||||||
|
* @param viewProjection How do we get from camera space to clip space?
|
||||||
|
*/
|
||||||
|
public void render(RenderType layer, Matrix4f viewProjection, double camX, double camY, double camZ) {
|
||||||
|
render(layer, viewProjection, camX, camY, camZ, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render every model for every material.
|
||||||
|
*
|
||||||
|
* @param layer Which vanilla {@link RenderType} is being drawn?
|
||||||
|
* @param viewProjection How do we get from camera space to clip space?
|
||||||
|
* @param callback Provide additional uniforms or state here.
|
||||||
|
*/
|
||||||
|
public void render(RenderType layer, Matrix4f viewProjection, double camX, double camY, double camZ, IProgramCallback<P> callback) {
|
||||||
|
camX -= originCoordinate.getX();
|
||||||
|
camY -= originCoordinate.getY();
|
||||||
|
camZ -= originCoordinate.getZ();
|
||||||
|
|
||||||
|
Matrix4f translate = Matrix4f.translate((float) -camX, (float) -camY, (float) -camZ);
|
||||||
|
|
||||||
|
translate.multiplyBackward(viewProjection);
|
||||||
|
|
||||||
|
for (MaterialRenderer<P> material : renderers) {
|
||||||
|
material.render(layer, translate, camX, camY, camZ, callback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete() {
|
||||||
|
for (InstanceMaterial<?> material : materials.values()) {
|
||||||
|
material.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public <D extends InstanceData> InstanceMaterial<D> getMaterial(MaterialSpec<D> materialType) {
|
||||||
|
return (InstanceMaterial<D>) materials.get(materialType.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InstanceMaterial<ModelData> getTransformMaterial() {
|
||||||
|
return getMaterial(AllMaterialSpecs.TRANSFORMED);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InstanceMaterial<OrientedData> getOrientedMaterial() {
|
||||||
|
return getMaterial(AllMaterialSpecs.ORIENTED);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3i getOriginCoordinate() {
|
||||||
|
return originCoordinate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onOriginShift(OriginShiftListener listener) {
|
||||||
|
listeners.add(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkAndShiftOrigin(ActiveRenderInfo info) {
|
||||||
|
int cX = MathHelper.floor(info.getProjectedView().x);
|
||||||
|
int cY = MathHelper.floor(info.getProjectedView().y);
|
||||||
|
int cZ = MathHelper.floor(info.getProjectedView().z);
|
||||||
|
|
||||||
|
int dX = cX - originCoordinate.getX();
|
||||||
|
int dY = cY - originCoordinate.getY();
|
||||||
|
int dZ = cZ - originCoordinate.getZ();
|
||||||
|
|
||||||
|
if (Math.abs(dX) > MAX_ORIGIN_DISTANCE || Math.abs(dY) > MAX_ORIGIN_DISTANCE || Math.abs(dZ) > MAX_ORIGIN_DISTANCE) {
|
||||||
|
|
||||||
|
originCoordinate = new BlockPos(cX, cY, cZ);
|
||||||
|
|
||||||
|
materials.values().forEach(InstanceMaterial::clear);
|
||||||
|
listeners.forEach(OriginShiftListener::onOriginShift);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface OriginShiftListener {
|
||||||
|
void onOriginShift();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
package com.jozufozu.flywheel.backend.instancing;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.core.shader.IProgramCallback;
|
||||||
|
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.RenderType;
|
||||||
|
import net.minecraft.util.math.vector.Matrix4f;
|
||||||
|
|
||||||
|
public class MaterialRenderer<P extends WorldProgram> {
|
||||||
|
|
||||||
|
private final P program;
|
||||||
|
private final InstanceMaterial<?> material;
|
||||||
|
|
||||||
|
public MaterialRenderer(P program, InstanceMaterial<?> material) {
|
||||||
|
this.program = program;
|
||||||
|
this.material = material;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void render(RenderType layer, Matrix4f viewProjection, double camX, double camY, double camZ, IProgramCallback<P> setup) {
|
||||||
|
if (!(layer == RenderType.getCutoutMipped())) return;
|
||||||
|
|
||||||
|
program.bind();
|
||||||
|
program.uploadViewProjection(viewProjection);
|
||||||
|
program.uploadCameraPos(camX, camY, camZ);
|
||||||
|
|
||||||
|
if (setup != null) setup.call(program);
|
||||||
|
|
||||||
|
makeRenderCalls();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void makeRenderCalls() {
|
||||||
|
material.forEachInstancer(Instancer::render);
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,7 +21,7 @@ public class MaterialSpec<D extends InstanceData> {
|
||||||
this.instanceFactory = instanceFactory;
|
this.instanceFactory = instanceFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceLocation getProgramSpec() {
|
public ResourceLocation getProgramName() {
|
||||||
return programSpec;
|
return programSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,20 +32,20 @@ import net.minecraft.world.World;
|
||||||
*/
|
*/
|
||||||
public abstract class TileEntityInstance<T extends TileEntity> implements IInstance {
|
public abstract class TileEntityInstance<T extends TileEntity> implements IInstance {
|
||||||
|
|
||||||
protected final InstancedTileRenderer<?> renderer;
|
protected final MaterialManager<?> materialManager;
|
||||||
protected final T tile;
|
protected final T tile;
|
||||||
protected final World world;
|
protected final World world;
|
||||||
protected final BlockPos pos;
|
protected final BlockPos pos;
|
||||||
protected final BlockPos instancePos;
|
protected final BlockPos instancePos;
|
||||||
protected final BlockState blockState;
|
protected final BlockState blockState;
|
||||||
|
|
||||||
public TileEntityInstance(InstancedTileRenderer<?> renderer, T tile) {
|
public TileEntityInstance(MaterialManager<?> materialManager, T tile) {
|
||||||
this.renderer = renderer;
|
this.materialManager = materialManager;
|
||||||
this.tile = tile;
|
this.tile = tile;
|
||||||
this.world = tile.getWorld();
|
this.world = tile.getWorld();
|
||||||
this.pos = tile.getPos();
|
this.pos = tile.getPos();
|
||||||
this.blockState = tile.getBlockState();
|
this.blockState = tile.getBlockState();
|
||||||
this.instancePos = pos.subtract(renderer.getOriginCoordinate());
|
this.instancePos = pos.subtract(materialManager.getOriginCoordinate());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,7 +54,7 @@ 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() {
|
public void update() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,14 +67,12 @@ public abstract class TileEntityInstance<T extends TileEntity> implements IInsta
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free any acquired resources.
|
* Free any acquired resources.
|
||||||
*
|
|
||||||
* <br> eg. call {@link InstanceKey#delete()}.
|
|
||||||
*/
|
*/
|
||||||
public abstract void remove();
|
public abstract void remove();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Just before {@link #update()} would be called, <code>shouldReset()</code> is checked.
|
* Just before {@link #update()} would be called, <code>shouldReset()</code> is checked.
|
||||||
* If this function returns <code>true</code>, then this instance will be {@link #remove}d,
|
* If this function returns <code>true</code>, then this instance will be {@link #remove removed},
|
||||||
* and another instance will be constructed to replace it. This allows for more sane resource
|
* and another instance will be constructed to replace it. This allows for more sane resource
|
||||||
* acquisition compared to trying to update everything within the lifetime of an instance.
|
* acquisition compared to trying to update everything within the lifetime of an instance.
|
||||||
*
|
*
|
||||||
|
@ -86,14 +84,14 @@ public abstract class TileEntityInstance<T extends TileEntity> implements IInsta
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In order to accommodate for floating point precision errors at high coordinates,
|
* In order to accommodate for floating point precision errors at high coordinates,
|
||||||
* {@link InstancedTileRenderer}s are allowed to arbitrarily adjust the origin, and
|
* {@link TileInstanceManager}s are allowed to arbitrarily adjust the origin, and
|
||||||
* shift the world matrix provided as a shader uniform accordingly.
|
* shift the world matrix provided as a shader uniform accordingly.
|
||||||
*
|
*
|
||||||
* @return The {@link BlockPos} at which the {@link TileEntity} this instance
|
* @return The {@link BlockPos position} of the {@link TileEntity} this instance
|
||||||
* represents should be rendered at to appear in the correct location.
|
* represents should be rendered at to appear in the correct location.
|
||||||
*/
|
*/
|
||||||
public BlockPos getInstancePosition() {
|
public BlockPos getInstancePosition() {
|
||||||
return instancePos;
|
return pos.subtract(materialManager.getOriginCoordinate());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -117,11 +115,11 @@ public abstract class TileEntityInstance<T extends TileEntity> implements IInsta
|
||||||
models.forEach(model -> model.setBlockLight(block).setSkyLight(sky));
|
models.forEach(model -> model.setBlockLight(block).setSkyLight(sky));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RenderMaterial<?, ModelData> getTransformMaterial() {
|
protected InstanceMaterial<ModelData> getTransformMaterial() {
|
||||||
return renderer.getTransformMaterial();
|
return materialManager.getTransformMaterial();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RenderMaterial<?, OrientedData> getOrientedMaterial() {
|
protected InstanceMaterial<OrientedData> getOrientedMaterial() {
|
||||||
return renderer.getOrientedMaterial();
|
return materialManager.getOrientedMaterial();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,27 +8,17 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
import com.jozufozu.flywheel.core.WorldContext;
|
|
||||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
|
||||||
import com.jozufozu.flywheel.core.materials.OrientedData;
|
|
||||||
import com.jozufozu.flywheel.core.shader.IProgramCallback;
|
|
||||||
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
|
||||||
import com.simibubi.create.foundation.render.AllMaterialSpecs;
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.vector.Matrix4f;
|
|
||||||
import net.minecraft.util.math.vector.Vector3f;
|
import net.minecraft.util.math.vector.Vector3f;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public abstract class InstancedTileRenderer<P extends WorldProgram> {
|
public class TileInstanceManager implements MaterialManager.OriginShiftListener {
|
||||||
|
|
||||||
public final WorldContext<P> context;
|
public final MaterialManager<?> materialManager;
|
||||||
|
|
||||||
protected final Map<MaterialSpec<?>, RenderMaterial<P, ?>> materials;
|
|
||||||
|
|
||||||
protected final ArrayList<TileEntity> queuedAdditions;
|
protected final ArrayList<TileEntity> queuedAdditions;
|
||||||
protected final ConcurrentHashMap.KeySetView<TileEntity, Boolean> queuedUpdates;
|
protected final ConcurrentHashMap.KeySetView<TileEntity, Boolean> queuedUpdates;
|
||||||
|
@ -40,23 +30,17 @@ public abstract class InstancedTileRenderer<P extends WorldProgram> {
|
||||||
protected int frame;
|
protected int frame;
|
||||||
protected int tick;
|
protected int tick;
|
||||||
|
|
||||||
protected InstancedTileRenderer(WorldContext<P> context) {
|
public TileInstanceManager(MaterialManager<?> materialManager) {
|
||||||
this.context = context;
|
this.materialManager = materialManager;
|
||||||
|
this.queuedUpdates = ConcurrentHashMap.newKeySet(64);
|
||||||
|
this.queuedAdditions = new ArrayList<>(64);
|
||||||
|
this.dynamicInstances = new HashMap<>();
|
||||||
|
this.tickableInstances = new HashMap<>();
|
||||||
|
this.instances = new HashMap<>();
|
||||||
|
|
||||||
materials = new HashMap<>();
|
materialManager.onOriginShift(this);
|
||||||
for (MaterialSpec<?> spec : Backend.allMaterials()) {
|
|
||||||
materials.put(spec, new RenderMaterial<>(this, spec));
|
|
||||||
}
|
|
||||||
|
|
||||||
queuedUpdates = ConcurrentHashMap.newKeySet(64);
|
|
||||||
queuedAdditions = new ArrayList<>(64);
|
|
||||||
dynamicInstances = new HashMap<>();
|
|
||||||
tickableInstances = new HashMap<>();
|
|
||||||
instances = new HashMap<>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract BlockPos getOriginCoordinate();
|
|
||||||
|
|
||||||
public void tick(double cameraX, double cameraY, double cameraZ) {
|
public void tick(double cameraX, double cameraY, double cameraZ) {
|
||||||
tick++;
|
tick++;
|
||||||
|
|
||||||
|
@ -112,40 +96,11 @@ public abstract class InstancedTileRenderer<P extends WorldProgram> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Render every model for every material.
|
public void onOriginShift() {
|
||||||
*
|
ArrayList<TileEntity> instancedTiles = new ArrayList<>(instances.keySet());
|
||||||
* @param layer Which vanilla {@link RenderType} is being drawn?
|
invalidate();
|
||||||
* @param viewProjection How do we get from camera space to clip space?
|
instancedTiles.forEach(this::add);
|
||||||
*/
|
|
||||||
public void render(RenderType layer, Matrix4f viewProjection, double camX, double camY, double camZ) {
|
|
||||||
render(layer, viewProjection, camX, camY, camZ, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Render every model for every material.
|
|
||||||
*
|
|
||||||
* @param layer Which vanilla {@link RenderType} is being drawn?
|
|
||||||
* @param viewProjection How do we get from camera space to clip space?
|
|
||||||
* @param callback Provide additional uniforms or state here.
|
|
||||||
*/
|
|
||||||
public void render(RenderType layer, Matrix4f viewProjection, double camX, double camY, double camZ, IProgramCallback<P> callback) {
|
|
||||||
for (RenderMaterial<P, ?> material : materials.values()) {
|
|
||||||
material.render(layer, viewProjection, camX, camY, camZ, callback);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public <D extends InstanceData> RenderMaterial<P, D> getMaterial(MaterialSpec<D> materialType) {
|
|
||||||
return (RenderMaterial<P, D>) materials.get(materialType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public RenderMaterial<P, ModelData> getTransformMaterial() {
|
|
||||||
return getMaterial(AllMaterialSpecs.TRANSFORMED);
|
|
||||||
}
|
|
||||||
|
|
||||||
public RenderMaterial<P, OrientedData> getOrientedMaterial() {
|
|
||||||
return getMaterial(AllMaterialSpecs.ORIENTED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -267,7 +222,7 @@ public abstract class InstancedTileRenderer<P extends WorldProgram> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T extends TileEntity> TileEntityInstance<? super T> createInternal(T tile) {
|
private <T extends TileEntity> TileEntityInstance<? super T> createInternal(T tile) {
|
||||||
TileEntityInstance<? super T> renderer = InstancedTileRenderRegistry.getInstance().create(this, tile);
|
TileEntityInstance<? super T> renderer = InstancedRenderRegistry.getInstance().create(materialManager, tile);
|
||||||
|
|
||||||
if (renderer != null) {
|
if (renderer != null) {
|
||||||
renderer.updateLight();
|
renderer.updateLight();
|
||||||
|
@ -284,9 +239,6 @@ public abstract class InstancedTileRenderer<P extends WorldProgram> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void invalidate() {
|
public void invalidate() {
|
||||||
for (RenderMaterial<?, ?> material : materials.values()) {
|
|
||||||
material.delete();
|
|
||||||
}
|
|
||||||
instances.clear();
|
instances.clear();
|
||||||
dynamicInstances.clear();
|
dynamicInstances.clear();
|
||||||
tickableInstances.clear();
|
tickableInstances.clear();
|
|
@ -0,0 +1,104 @@
|
||||||
|
package com.jozufozu.flywheel.backend.instancing.entity;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.IInstance;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.ITickableInstance;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.InstanceMaterial;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.TileInstanceManager;
|
||||||
|
import com.jozufozu.flywheel.core.materials.IFlatLight;
|
||||||
|
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||||
|
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||||
|
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
|
import net.minecraft.util.math.vector.Vector3f;
|
||||||
|
import net.minecraft.util.math.vector.Vector3i;
|
||||||
|
import net.minecraft.world.LightType;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The layer between a {@link TileEntity} and the Flywheel backend.
|
||||||
|
**
|
||||||
|
* <br><br> There are a few additional features that overriding classes can opt in to:
|
||||||
|
* <ul>
|
||||||
|
* <li>{@link IDynamicInstance}</li>
|
||||||
|
* <li>{@link ITickableInstance}</li>
|
||||||
|
* </ul>
|
||||||
|
* See the interfaces' documentation for more information about each one.
|
||||||
|
*
|
||||||
|
* <br> Implementing one or more of these will give a {@link EntityInstance} access
|
||||||
|
* to more interesting and regular points within a tick or a frame.
|
||||||
|
*
|
||||||
|
* @param <E> The type of {@link Entity} your class is an instance of.
|
||||||
|
*/
|
||||||
|
public abstract class EntityInstance<E extends Entity> implements IInstance {
|
||||||
|
|
||||||
|
protected final MaterialManager<?> materialManager;
|
||||||
|
protected final E entity;
|
||||||
|
protected final World world;
|
||||||
|
|
||||||
|
public EntityInstance(MaterialManager<?> materialManager, E entity) {
|
||||||
|
this.materialManager = materialManager;
|
||||||
|
this.entity = entity;
|
||||||
|
this.world = entity.world;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Free any acquired resources.
|
||||||
|
*/
|
||||||
|
public abstract void remove();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In order to accommodate for floating point precision errors at high coordinates,
|
||||||
|
* {@link TileInstanceManager}s are allowed to arbitrarily adjust the origin, and
|
||||||
|
* shift the world matrix provided as a shader uniform accordingly.
|
||||||
|
*
|
||||||
|
* @return The {@link BlockPos position} of the {@link Entity} this instance
|
||||||
|
* represents should be rendered at to appear in the correct location.
|
||||||
|
*/
|
||||||
|
public Vector3f getInstancePosition() {
|
||||||
|
Vector3d pos = entity.getPositionVec();
|
||||||
|
Vector3i origin = materialManager.getOriginCoordinate();
|
||||||
|
return new Vector3f(
|
||||||
|
(float) (pos.x - origin.getX()),
|
||||||
|
(float) (pos.y - origin.getY()),
|
||||||
|
(float) (pos.z - origin.getZ())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockPos getWorldPosition() {
|
||||||
|
return entity.getBlockPos();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void relight(BlockPos pos, IFlatLight<?>... models) {
|
||||||
|
relight(world.getLightLevel(LightType.BLOCK, pos), world.getLightLevel(LightType.SKY, pos), models);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected <L extends IFlatLight<?>> void relight(BlockPos pos, Stream<L> models) {
|
||||||
|
relight(world.getLightLevel(LightType.BLOCK, pos), world.getLightLevel(LightType.SKY, pos), models);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void relight(int block, int sky, IFlatLight<?>... models) {
|
||||||
|
relight(block, sky, Arrays.stream(models));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected <L extends IFlatLight<?>> void relight(int block, int sky, Stream<L> models) {
|
||||||
|
models.forEach(model -> model.setBlockLight(block).setSkyLight(sky));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected InstanceMaterial<ModelData> getTransformMaterial() {
|
||||||
|
return materialManager.getTransformMaterial();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected InstanceMaterial<OrientedData> getOrientedMaterial() {
|
||||||
|
return materialManager.getOrientedMaterial();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.jozufozu.flywheel.backend.instancing.entity;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
|
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface IEntityInstanceFactory<E extends Entity> {
|
||||||
|
EntityInstance<? super E> create(MaterialManager<?> manager, E te);
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.jozufozu.flywheel.core;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.TileInstanceManager;
|
||||||
|
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
public class CrumblingInstanceManager extends TileInstanceManager {
|
||||||
|
public CrumblingInstanceManager() {
|
||||||
|
super(new MaterialManager<>(WorldContext.CRUMBLING));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean shouldTick(BlockPos worldPos, float lookX, float lookY, float lookZ, int cX, int cY, int cZ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,14 +0,0 @@
|
||||||
package com.jozufozu.flywheel.core;
|
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
|
|
||||||
public class CrumblingRenderer extends WorldTileRenderer<CrumblingProgram> {
|
|
||||||
public CrumblingRenderer() {
|
|
||||||
super(WorldContext.CRUMBLING);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean shouldTick(BlockPos worldPos, float lookX, float lookY, float lookZ, int cX, int cY, int cZ) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -13,6 +13,7 @@ import com.jozufozu.flywheel.backend.ResourceUtil;
|
||||||
import com.jozufozu.flywheel.backend.ShaderContext;
|
import com.jozufozu.flywheel.backend.ShaderContext;
|
||||||
import com.jozufozu.flywheel.backend.ShaderLoader;
|
import com.jozufozu.flywheel.backend.ShaderLoader;
|
||||||
import com.jozufozu.flywheel.backend.gl.shader.ShaderType;
|
import com.jozufozu.flywheel.backend.gl.shader.ShaderType;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.MaterialSpec;
|
import com.jozufozu.flywheel.backend.instancing.MaterialSpec;
|
||||||
import com.jozufozu.flywheel.backend.loading.InstancedArraysTemplate;
|
import com.jozufozu.flywheel.backend.loading.InstancedArraysTemplate;
|
||||||
import com.jozufozu.flywheel.backend.loading.Program;
|
import com.jozufozu.flywheel.backend.loading.Program;
|
||||||
|
@ -25,8 +26,10 @@ import com.jozufozu.flywheel.core.shader.IMultiProgram;
|
||||||
import com.jozufozu.flywheel.core.shader.StateSensitiveMultiProgram;
|
import com.jozufozu.flywheel.core.shader.StateSensitiveMultiProgram;
|
||||||
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
||||||
import com.jozufozu.flywheel.core.shader.spec.ProgramSpec;
|
import com.jozufozu.flywheel.core.shader.spec.ProgramSpec;
|
||||||
|
import com.jozufozu.flywheel.util.WorldAttached;
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.world.IWorld;
|
||||||
|
|
||||||
public class WorldContext<P extends WorldProgram> extends ShaderContext<P> {
|
public class WorldContext<P extends WorldProgram> extends ShaderContext<P> {
|
||||||
|
|
||||||
|
@ -37,13 +40,16 @@ public class WorldContext<P extends WorldProgram> extends ShaderContext<P> {
|
||||||
public static final WorldContext<CrumblingProgram> CRUMBLING = new WorldContext<>(new ResourceLocation(Flywheel.ID, "context/crumbling"), CrumblingProgram::new);
|
public static final WorldContext<CrumblingProgram> CRUMBLING = new WorldContext<>(new ResourceLocation(Flywheel.ID, "context/crumbling"), CrumblingProgram::new);
|
||||||
|
|
||||||
protected final ResourceLocation name;
|
protected final ResourceLocation name;
|
||||||
private final ExtensibleGlProgram.Factory<P> factory;
|
|
||||||
protected Supplier<Stream<ResourceLocation>> specStream;
|
protected Supplier<Stream<ResourceLocation>> specStream;
|
||||||
protected TemplateFactory templateFactory;
|
protected TemplateFactory templateFactory;
|
||||||
|
|
||||||
|
public final WorldAttached<MaterialManager<P>> materialManager = new WorldAttached<>($ -> new MaterialManager<>(this));
|
||||||
|
|
||||||
private final Map<ShaderType, ResourceLocation> builtins = new EnumMap<>(ShaderType.class);
|
private final Map<ShaderType, ResourceLocation> builtins = new EnumMap<>(ShaderType.class);
|
||||||
private final Map<ShaderType, String> builtinSources = new EnumMap<>(ShaderType.class);
|
private final Map<ShaderType, String> builtinSources = new EnumMap<>(ShaderType.class);
|
||||||
|
|
||||||
|
private final ExtensibleGlProgram.Factory<P> factory;
|
||||||
|
|
||||||
public WorldContext(ResourceLocation root, ExtensibleGlProgram.Factory<P> factory) {
|
public WorldContext(ResourceLocation root, ExtensibleGlProgram.Factory<P> factory) {
|
||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
this.name = root;
|
this.name = root;
|
||||||
|
@ -52,11 +58,15 @@ public class WorldContext<P extends WorldProgram> extends ShaderContext<P> {
|
||||||
|
|
||||||
specStream = () -> Backend.allMaterials()
|
specStream = () -> Backend.allMaterials()
|
||||||
.stream()
|
.stream()
|
||||||
.map(MaterialSpec::getProgramSpec);
|
.map(MaterialSpec::getProgramName);
|
||||||
|
|
||||||
templateFactory = InstancedArraysTemplate::new;
|
templateFactory = InstancedArraysTemplate::new;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MaterialManager<P> getMaterialManager(IWorld world) {
|
||||||
|
return materialManager.get(world);
|
||||||
|
}
|
||||||
|
|
||||||
public WorldContext<P> setSpecStream(Supplier<Stream<ResourceLocation>> specStream) {
|
public WorldContext<P> setSpecStream(Supplier<Stream<ResourceLocation>> specStream) {
|
||||||
this.specStream = specStream;
|
this.specStream = specStream;
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -1,67 +0,0 @@
|
||||||
package com.jozufozu.flywheel.core;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
|
||||||
import com.jozufozu.flywheel.core.shader.IProgramCallback;
|
|
||||||
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
|
||||||
import net.minecraft.client.renderer.RenderType;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
|
||||||
import net.minecraft.util.math.vector.Matrix4f;
|
|
||||||
|
|
||||||
public class WorldTileRenderer<P extends WorldProgram> extends InstancedTileRenderer<P> {
|
|
||||||
public static int MAX_ORIGIN_DISTANCE = 100;
|
|
||||||
|
|
||||||
public BlockPos originCoordinate = BlockPos.ZERO;
|
|
||||||
|
|
||||||
public WorldTileRenderer(WorldContext<P> context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockPos getOriginCoordinate() {
|
|
||||||
return originCoordinate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void beginFrame(ActiveRenderInfo info) {
|
|
||||||
int cX = MathHelper.floor(info.getProjectedView().x);
|
|
||||||
int cY = MathHelper.floor(info.getProjectedView().y);
|
|
||||||
int cZ = MathHelper.floor(info.getProjectedView().z);
|
|
||||||
|
|
||||||
int dX = Math.abs(cX - originCoordinate.getX());
|
|
||||||
int dY = Math.abs(cY - originCoordinate.getY());
|
|
||||||
int dZ = Math.abs(cZ - originCoordinate.getZ());
|
|
||||||
|
|
||||||
if (dX > MAX_ORIGIN_DISTANCE || dY > MAX_ORIGIN_DISTANCE || dZ > MAX_ORIGIN_DISTANCE) {
|
|
||||||
|
|
||||||
originCoordinate = new BlockPos(cX, cY, cZ);
|
|
||||||
|
|
||||||
ArrayList<TileEntity> instancedTiles = new ArrayList<>(instances.keySet());
|
|
||||||
invalidate();
|
|
||||||
instancedTiles.forEach(this::add);
|
|
||||||
}
|
|
||||||
|
|
||||||
super.beginFrame(info);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void render(RenderType layer, Matrix4f viewProjection, double camX, double camY, double camZ,
|
|
||||||
IProgramCallback<P> callback) {
|
|
||||||
BlockPos originCoordinate = getOriginCoordinate();
|
|
||||||
|
|
||||||
camX -= originCoordinate.getX();
|
|
||||||
camY -= originCoordinate.getY();
|
|
||||||
camZ -= originCoordinate.getZ();
|
|
||||||
|
|
||||||
Matrix4f translate = Matrix4f.translate((float) -camX, (float) -camY, (float) -camZ);
|
|
||||||
|
|
||||||
translate.multiplyBackward(viewProjection);
|
|
||||||
|
|
||||||
super.render(layer, translate, camX, camY, camZ, callback);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.jozufozu.flywheel.core.instancing;
|
package com.jozufozu.flywheel.core.instancing;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -10,19 +11,26 @@ import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
public class ConditionalInstance<D extends InstanceData> {
|
public class ConditionalInstance<D extends InstanceData> {
|
||||||
|
|
||||||
final Instancer<D> model;
|
final Instancer<D> model;
|
||||||
Condition condition;
|
ICondition condition;
|
||||||
|
|
||||||
|
Consumer<D> setupFunc;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private D instance;
|
private D instance;
|
||||||
|
|
||||||
public ConditionalInstance(Instancer<D> model, Condition condition) {
|
public ConditionalInstance(Instancer<D> model) {
|
||||||
this.model = model;
|
this.model = model;
|
||||||
this.condition = condition;
|
this.condition = () -> true;
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConditionalInstance<D> setCondition(Condition condition) {
|
public ConditionalInstance<D> withSetupFunc(Consumer<D> setupFunc) {
|
||||||
|
this.setupFunc = setupFunc;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConditionalInstance<D> withCondition(ICondition condition) {
|
||||||
this.condition = condition;
|
this.condition = condition;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -31,6 +39,7 @@ public class ConditionalInstance<D extends InstanceData> {
|
||||||
boolean shouldShow = condition.shouldShow();
|
boolean shouldShow = condition.shouldShow();
|
||||||
if (shouldShow && instance == null) {
|
if (shouldShow && instance == null) {
|
||||||
instance = model.createInstance();
|
instance = model.createInstance();
|
||||||
|
if (setupFunc != null) setupFunc.accept(instance);
|
||||||
} else if (!shouldShow && instance != null) {
|
} else if (!shouldShow && instance != null) {
|
||||||
instance.delete();
|
instance.delete();
|
||||||
instance = null;
|
instance = null;
|
||||||
|
@ -48,7 +57,7 @@ public class ConditionalInstance<D extends InstanceData> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface Condition {
|
public interface ICondition {
|
||||||
boolean shouldShow();
|
boolean shouldShow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
|
|
||||||
public class BasicData extends InstanceData implements IFlatLight<BasicData> {
|
public abstract class BasicData extends InstanceData implements IFlatLight<BasicData> {
|
||||||
|
|
||||||
protected byte blockLight;
|
protected byte blockLight;
|
||||||
protected byte skyLight;
|
protected byte skyLight;
|
||||||
|
|
|
@ -21,12 +21,10 @@ public class OrientedData extends BasicData {
|
||||||
private float qZ;
|
private float qZ;
|
||||||
private float qW;
|
private float qW;
|
||||||
|
|
||||||
|
|
||||||
public OrientedData(Instancer<?> owner) {
|
public OrientedData(Instancer<?> owner) {
|
||||||
super(owner);
|
super(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public OrientedData setPosition(BlockPos pos) {
|
public OrientedData setPosition(BlockPos pos) {
|
||||||
return setPosition(pos.getX(), pos.getY(), pos.getZ());
|
return setPosition(pos.getX(), pos.getY(), pos.getZ());
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,18 +3,18 @@ package com.jozufozu.flywheel.util;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import net.minecraft.world.IWorld;
|
import net.minecraft.world.IWorld;
|
||||||
import net.minecraftforge.common.util.NonNullSupplier;
|
|
||||||
|
|
||||||
public class WorldAttached<T> {
|
public class WorldAttached<T> {
|
||||||
|
|
||||||
Map<IWorld, T> attached;
|
Map<IWorld, T> attached;
|
||||||
private final NonNullSupplier<T> factory;
|
private final WorldAttacher<T> factory;
|
||||||
|
|
||||||
public WorldAttached(NonNullSupplier<T> factory) {
|
public WorldAttached(WorldAttacher<T> factory) {
|
||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
attached = new HashMap<>();
|
attached = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ public class WorldAttached<T> {
|
||||||
T t = attached.get(world);
|
T t = attached.get(world);
|
||||||
if (t != null)
|
if (t != null)
|
||||||
return t;
|
return t;
|
||||||
T entry = factory.get();
|
T entry = factory.attach(world);
|
||||||
put(world, entry);
|
put(world, entry);
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
@ -38,4 +38,15 @@ public class WorldAttached<T> {
|
||||||
.forEach(consumer);
|
.forEach(consumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface WorldAttacher<T> extends Function<IWorld, T> {
|
||||||
|
@Nonnull
|
||||||
|
T attach(IWorld world);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default T apply(IWorld world) {
|
||||||
|
return attach(world);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
import com.jozufozu.flywheel.backend.OptifineHandler;
|
import com.jozufozu.flywheel.backend.OptifineHandler;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.TileInstanceManager;
|
||||||
import com.jozufozu.flywheel.core.PartialModel;
|
import com.jozufozu.flywheel.core.PartialModel;
|
||||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
|
||||||
|
@ -214,10 +214,10 @@ public class CreateClient {
|
||||||
BUFFER_CACHE.invalidate();
|
BUFFER_CACHE.invalidate();
|
||||||
|
|
||||||
if (world != null) {
|
if (world != null) {
|
||||||
Backend.tileRenderer.get(world)
|
Backend.tileInstanceManager.get(world)
|
||||||
.invalidate();
|
.invalidate();
|
||||||
} else {
|
} else {
|
||||||
Backend.tileRenderer.forEach(InstancedTileRenderer::invalidate);
|
Backend.tileInstanceManager.forEach(TileInstanceManager::invalidate);
|
||||||
}
|
}
|
||||||
|
|
||||||
ContraptionRenderDispatcher.invalidateAll();
|
ContraptionRenderDispatcher.invalidateAll();
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package com.simibubi.create.content.contraptions.base;
|
package com.simibubi.create.content.contraptions.base;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
|
|
||||||
import net.minecraft.state.properties.BlockStateProperties;
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
|
||||||
public class BackHalfShaftInstance extends HalfShaftInstance {
|
public class BackHalfShaftInstance extends HalfShaftInstance {
|
||||||
public BackHalfShaftInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
|
public BackHalfShaftInstance(MaterialManager<?> modelManager, KineticTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package com.simibubi.create.content.contraptions.base;
|
package com.simibubi.create.content.contraptions.base;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
|
|
||||||
import net.minecraft.state.properties.BlockStateProperties;
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
|
||||||
public class HalfShaftInstance extends SingleRotatingInstance {
|
public class HalfShaftInstance extends SingleRotatingInstance {
|
||||||
public HalfShaftInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
|
public HalfShaftInstance(MaterialManager<?> modelManager, KineticTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package com.simibubi.create.content.contraptions.base;
|
package com.simibubi.create.content.contraptions.base;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
|
|
||||||
import net.minecraft.state.properties.BlockStateProperties;
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
|
||||||
public class HorizontalHalfShaftInstance extends HalfShaftInstance {
|
public class HorizontalHalfShaftInstance extends HalfShaftInstance {
|
||||||
|
|
||||||
public HorizontalHalfShaftInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
|
public HorizontalHalfShaftInstance(MaterialManager<?> modelManager, KineticTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,6 @@ public class KineticData extends BasicData {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(MappedBuffer buf) {
|
public void write(MappedBuffer buf) {
|
||||||
super.write(buf);
|
super.write(buf);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.simibubi.create.content.contraptions.base;
|
package com.simibubi.create.content.contraptions.base;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.InstanceMaterial;
|
||||||
import com.jozufozu.flywheel.backend.instancing.RenderMaterial;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.content.contraptions.relays.elementary.ICogWheel;
|
import com.simibubi.create.content.contraptions.relays.elementary.ICogWheel;
|
||||||
|
@ -15,7 +15,7 @@ public abstract class KineticTileInstance<T extends KineticTileEntity> extends T
|
||||||
|
|
||||||
protected final Direction.Axis axis;
|
protected final Direction.Axis axis;
|
||||||
|
|
||||||
public KineticTileInstance(InstancedTileRenderer<?> modelManager, T tile) {
|
public KineticTileInstance(MaterialManager<?> modelManager, T tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
|
|
||||||
axis = ((IRotate) blockState.getBlock()).getRotationAxis(blockState);
|
axis = ((IRotate) blockState.getBlock()).getRotationAxis(blockState);
|
||||||
|
@ -84,8 +84,8 @@ public abstract class KineticTileInstance<T extends KineticTileEntity> extends T
|
||||||
return shaft(getRotationAxis());
|
return shaft(getRotationAxis());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final RenderMaterial<?, RotatingData> getRotatingMaterial() {
|
protected final InstanceMaterial<RotatingData> getRotatingMaterial() {
|
||||||
return renderer.getMaterial(AllMaterialSpecs.ROTATING);
|
return materialManager.getMaterial(AllMaterialSpecs.ROTATING);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BlockState shaft(Direction.Axis axis) {
|
public static BlockState shaft(Direction.Axis axis) {
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
package com.simibubi.create.content.contraptions.base;
|
package com.simibubi.create.content.contraptions.base;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.foundation.render.AllMaterialSpecs;
|
import com.simibubi.create.foundation.render.AllMaterialSpecs;
|
||||||
|
|
||||||
public class ShaftlessCogInstance extends SingleRotatingInstance {
|
public class ShaftlessCogInstance extends SingleRotatingInstance {
|
||||||
|
|
||||||
public ShaftlessCogInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
|
public ShaftlessCogInstance(MaterialManager<?> modelManager, KineticTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Instancer<RotatingData> getModel() {
|
protected Instancer<RotatingData> getModel() {
|
||||||
return renderer.getMaterial(AllMaterialSpecs.ROTATING).getModel(AllBlockPartials.SHAFTLESS_COGWHEEL, tile.getBlockState());
|
return materialManager.getMaterial(AllMaterialSpecs.ROTATING).getModel(AllBlockPartials.SHAFTLESS_COGWHEEL, tile.getBlockState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.simibubi.create.content.contraptions.base;
|
package com.simibubi.create.content.contraptions.base;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ public class SingleRotatingInstance extends KineticTileInstance<KineticTileEntit
|
||||||
|
|
||||||
protected final RotatingData rotatingModel;
|
protected final RotatingData rotatingModel;
|
||||||
|
|
||||||
public SingleRotatingInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
|
public SingleRotatingInstance(MaterialManager<?> modelManager, KineticTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
|
|
||||||
rotatingModel = setup(getModel().createInstance());
|
rotatingModel = setup(getModel().createInstance());
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
package com.simibubi.create.content.contraptions.components.actors;
|
package com.simibubi.create.content.contraptions.components.actors;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.RenderMaterial;
|
import com.jozufozu.flywheel.backend.instancing.InstanceMaterial;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer;
|
import com.simibubi.create.foundation.render.AllMaterialSpecs;
|
||||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||||
import com.simibubi.create.foundation.utility.VecHelper;
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
|
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
@ -15,12 +17,12 @@ import net.minecraft.util.math.vector.Quaternion;
|
||||||
public class DrillActorInstance extends ActorInstance {
|
public class DrillActorInstance extends ActorInstance {
|
||||||
|
|
||||||
ActorData drillHead;
|
ActorData drillHead;
|
||||||
private Direction facing;
|
private final Direction facing;
|
||||||
|
|
||||||
public DrillActorInstance(ContraptionKineticRenderer modelManager, MovementContext context) {
|
public DrillActorInstance(MaterialManager<?> materialManager, PlacementSimulationWorld contraption, MovementContext context) {
|
||||||
super(modelManager, context);
|
super(materialManager, contraption, context);
|
||||||
|
|
||||||
RenderMaterial<?, ActorData> renderMaterial = modelManager.getActorMaterial();
|
InstanceMaterial<ActorData> instanceMaterial = materialManager.getMaterial(AllMaterialSpecs.ACTORS);
|
||||||
|
|
||||||
BlockState state = context.state;
|
BlockState state = context.state;
|
||||||
|
|
||||||
|
@ -35,7 +37,7 @@ public class DrillActorInstance extends ActorInstance {
|
||||||
else
|
else
|
||||||
eulerY = facing.getHorizontalAngle() + ((axis == Direction.Axis.X) ? 180 : 0);
|
eulerY = facing.getHorizontalAngle() + ((axis == Direction.Axis.X) ? 180 : 0);
|
||||||
|
|
||||||
drillHead = renderMaterial.getModel(AllBlockPartials.DRILL_HEAD, state).createInstance();
|
drillHead = instanceMaterial.getModel(AllBlockPartials.DRILL_HEAD, state).createInstance();
|
||||||
|
|
||||||
drillHead.setPosition(context.localPos)
|
drillHead.setPosition(context.localPos)
|
||||||
.setBlockLight(localBlockLight())
|
.setBlockLight(localBlockLight())
|
||||||
|
|
|
@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.components.actors;
|
||||||
|
|
||||||
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||||
import com.simibubi.create.content.contraptions.base.RotatingData;
|
import com.simibubi.create.content.contraptions.base.RotatingData;
|
||||||
|
@ -14,7 +14,7 @@ import net.minecraft.util.Direction;
|
||||||
|
|
||||||
public class DrillInstance extends SingleRotatingInstance {
|
public class DrillInstance extends SingleRotatingInstance {
|
||||||
|
|
||||||
public DrillInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
|
public DrillInstance(MaterialManager<?> modelManager, KineticTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,9 @@ package com.simibubi.create.content.contraptions.components.actors;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer;
|
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
|
||||||
import com.simibubi.create.foundation.utility.VecHelper;
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
|
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
|
||||||
|
@ -48,8 +48,8 @@ public class DrillMovementBehaviour extends BlockBreakingMovementBehaviour {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public ActorInstance createInstance(ContraptionKineticRenderer kr, MovementContext context) {
|
public ActorInstance createInstance(MaterialManager<?> materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
|
||||||
return new DrillActorInstance(kr, context);
|
return new DrillActorInstance(materialManager, simulationWorld, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -2,17 +2,18 @@ package com.simibubi.create.content.contraptions.components.actors;
|
||||||
|
|
||||||
import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING;
|
import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.RenderMaterial;
|
import com.jozufozu.flywheel.backend.instancing.InstanceMaterial;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer;
|
|
||||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||||
import com.simibubi.create.foundation.utility.VecHelper;
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
|
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
@ -32,16 +33,16 @@ public class HarvesterActorInstance extends ActorInstance {
|
||||||
private double rotation;
|
private double rotation;
|
||||||
private double previousRotation;
|
private double previousRotation;
|
||||||
|
|
||||||
public HarvesterActorInstance(ContraptionKineticRenderer modelManager, MovementContext context) {
|
public HarvesterActorInstance(MaterialManager<?> materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
|
||||||
super(modelManager, context);
|
super(materialManager, simulationWorld, context);
|
||||||
|
|
||||||
RenderMaterial<?, ModelData> renderMaterial = modelManager.getTransformMaterial();
|
InstanceMaterial<ModelData> instanceMaterial = materialManager.getTransformMaterial();
|
||||||
|
|
||||||
BlockState state = context.state;
|
BlockState state = context.state;
|
||||||
|
|
||||||
facing = state.get(HORIZONTAL_FACING);
|
facing = state.get(HORIZONTAL_FACING);
|
||||||
|
|
||||||
harvester = renderMaterial.getModel(AllBlockPartials.HARVESTER_BLADE, state).createInstance();
|
harvester = instanceMaterial.getModel(AllBlockPartials.HARVESTER_BLADE, state).createInstance();
|
||||||
|
|
||||||
horizontalAngle = facing.getHorizontalAngle() + ((facing.getAxis() == Direction.Axis.X) ? 180 : 0);
|
horizontalAngle = facing.getHorizontalAngle() + ((facing.getAxis() == Direction.Axis.X) ? 180 : 0);
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,10 @@ import javax.annotation.Nullable;
|
||||||
import org.apache.commons.lang3.mutable.MutableBoolean;
|
import org.apache.commons.lang3.mutable.MutableBoolean;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
|
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer;
|
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
|
||||||
import com.simibubi.create.foundation.utility.BlockHelper;
|
import com.simibubi.create.foundation.utility.BlockHelper;
|
||||||
import com.simibubi.create.foundation.utility.VecHelper;
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
|
@ -48,8 +48,8 @@ public class HarvesterMovementBehaviour extends MovementBehaviour {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public ActorInstance createInstance(ContraptionKineticRenderer kr, MovementContext context) {
|
public ActorInstance createInstance(MaterialManager<?> materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
|
||||||
return new HarvesterActorInstance(kr, context);
|
return new HarvesterActorInstance(materialManager, simulationWorld, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.components.crafter;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||||
|
@ -15,7 +15,7 @@ import net.minecraft.util.Direction;
|
||||||
|
|
||||||
public class MechanicalCrafterInstance extends SingleRotatingInstance {
|
public class MechanicalCrafterInstance extends SingleRotatingInstance {
|
||||||
|
|
||||||
public MechanicalCrafterInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
|
public MechanicalCrafterInstance(MaterialManager<?> modelManager, KineticTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package com.simibubi.create.content.contraptions.components.crank;
|
package com.simibubi.create.content.contraptions.components.crank;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.core.PartialModel;
|
import com.jozufozu.flywheel.core.PartialModel;
|
||||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
|
@ -20,7 +20,7 @@ public class HandCrankInstance extends SingleRotatingInstance implements IDynami
|
||||||
private ModelData crank;
|
private ModelData crank;
|
||||||
private Direction facing;
|
private Direction facing;
|
||||||
|
|
||||||
public HandCrankInstance(InstancedTileRenderer<?> modelManager, HandCrankTileEntity tile) {
|
public HandCrankInstance(MaterialManager<?> modelManager, HandCrankTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
this.tile = tile;
|
this.tile = tile;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@ package com.simibubi.create.content.contraptions.components.deployer;
|
||||||
import static com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE;
|
import static com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE;
|
||||||
import static com.simibubi.create.content.contraptions.base.DirectionalKineticBlock.FACING;
|
import static com.simibubi.create.content.contraptions.base.DirectionalKineticBlock.FACING;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.RenderMaterial;
|
import com.jozufozu.flywheel.backend.instancing.InstanceMaterial;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.core.PartialModel;
|
import com.jozufozu.flywheel.core.PartialModel;
|
||||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
|
@ -13,14 +14,13 @@ import com.simibubi.create.content.contraptions.base.KineticTileInstance;
|
||||||
import com.simibubi.create.content.contraptions.base.RotatingData;
|
import com.simibubi.create.content.contraptions.base.RotatingData;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer;
|
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionProgram;
|
|
||||||
import com.simibubi.create.foundation.render.AllMaterialSpecs;
|
import com.simibubi.create.foundation.render.AllMaterialSpecs;
|
||||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||||
import com.simibubi.create.foundation.utility.NBTHelper;
|
import com.simibubi.create.foundation.utility.NBTHelper;
|
||||||
import com.simibubi.create.foundation.utility.VecHelper;
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
|
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
@ -41,10 +41,10 @@ public class DeployerActorInstance extends ActorInstance {
|
||||||
ModelData hand;
|
ModelData hand;
|
||||||
RotatingData shaft;
|
RotatingData shaft;
|
||||||
|
|
||||||
public DeployerActorInstance(ContraptionKineticRenderer modelManager, MovementContext context) {
|
public DeployerActorInstance(MaterialManager<?> materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
|
||||||
super(modelManager, context);
|
super(materialManager, simulationWorld, context);
|
||||||
|
|
||||||
RenderMaterial<ContraptionProgram, ModelData> mat = modelManager.getTransformMaterial();
|
InstanceMaterial<ModelData> mat = materialManager.getTransformMaterial();
|
||||||
|
|
||||||
BlockState state = context.state;
|
BlockState state = context.state;
|
||||||
DeployerTileEntity.Mode mode = NBTHelper.readEnum(context.tileData, "Mode", DeployerTileEntity.Mode.class);
|
DeployerTileEntity.Mode mode = NBTHelper.readEnum(context.tileData, "Mode", DeployerTileEntity.Mode.class);
|
||||||
|
@ -62,7 +62,7 @@ public class DeployerActorInstance extends ActorInstance {
|
||||||
hand = mat.getModel(handPose, state).createInstance();
|
hand = mat.getModel(handPose, state).createInstance();
|
||||||
|
|
||||||
Direction.Axis axis = ((IRotate) state.getBlock()).getRotationAxis(state);
|
Direction.Axis axis = ((IRotate) state.getBlock()).getRotationAxis(state);
|
||||||
shaft = modelManager.getMaterial(AllMaterialSpecs.ROTATING)
|
shaft = materialManager.getMaterial(AllMaterialSpecs.ROTATING)
|
||||||
.getModel(KineticTileInstance.shaft(axis))
|
.getModel(KineticTileInstance.shaft(axis))
|
||||||
.createInstance();
|
.createInstance();
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import static com.simibubi.create.content.contraptions.base.DirectionalKineticBl
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.ITickableInstance;
|
import com.jozufozu.flywheel.backend.instancing.ITickableInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.core.PartialModel;
|
import com.jozufozu.flywheel.core.PartialModel;
|
||||||
import com.jozufozu.flywheel.core.materials.OrientedData;
|
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
|
@ -36,7 +36,7 @@ public class DeployerInstance extends ShaftInstance implements IDynamicInstance,
|
||||||
float progress;
|
float progress;
|
||||||
private boolean newHand = false;
|
private boolean newHand = false;
|
||||||
|
|
||||||
public DeployerInstance(InstancedTileRenderer<?> dispatcher, KineticTileEntity tile) {
|
public DeployerInstance(MaterialManager<?> dispatcher, KineticTileEntity tile) {
|
||||||
super(dispatcher, tile);
|
super(dispatcher, tile);
|
||||||
|
|
||||||
this.tile = (DeployerTileEntity) super.tile;
|
this.tile = (DeployerTileEntity) super.tile;
|
||||||
|
|
|
@ -8,6 +8,7 @@ import javax.annotation.Nullable;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.AllItems;
|
import com.simibubi.create.AllItems;
|
||||||
import com.simibubi.create.AllTags.AllBlockTags;
|
import com.simibubi.create.AllTags.AllBlockTags;
|
||||||
|
@ -16,7 +17,6 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Abs
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
|
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer;
|
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
|
||||||
import com.simibubi.create.content.logistics.item.filter.FilterItem;
|
import com.simibubi.create.content.logistics.item.filter.FilterItem;
|
||||||
import com.simibubi.create.content.schematics.ItemRequirement;
|
import com.simibubi.create.content.schematics.ItemRequirement;
|
||||||
|
@ -268,7 +268,7 @@ public class DeployerMovementBehaviour extends MovementBehaviour {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public ActorInstance createInstance(ContraptionKineticRenderer kr, MovementContext context) {
|
public ActorInstance createInstance(MaterialManager<?> materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
|
||||||
return new DeployerActorInstance(kr, context);
|
return new DeployerActorInstance(materialManager, simulationWorld, context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.components.fan;
|
||||||
|
|
||||||
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
|
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
|
||||||
import com.simibubi.create.content.contraptions.base.RotatingData;
|
import com.simibubi.create.content.contraptions.base.RotatingData;
|
||||||
|
@ -18,7 +18,7 @@ public class FanInstance extends KineticTileInstance<EncasedFanTileEntity> {
|
||||||
final Direction direction;
|
final Direction direction;
|
||||||
private final Direction opposite;
|
private final Direction opposite;
|
||||||
|
|
||||||
public FanInstance(InstancedTileRenderer<?> modelManager, EncasedFanTileEntity tile) {
|
public FanInstance(MaterialManager<?> modelManager, EncasedFanTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
|
|
||||||
direction = blockState.get(FACING);
|
direction = blockState.get(FACING);
|
||||||
|
@ -41,7 +41,7 @@ public class FanInstance extends KineticTileInstance<EncasedFanTileEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void update() {
|
public void update() {
|
||||||
updateRotation(shaft);
|
updateRotation(shaft);
|
||||||
updateRotation(fan, getFanSpeed());
|
updateRotation(fan, getFanSpeed());
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,9 @@ import java.util.List;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.InstanceMaterial;
|
||||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
import com.jozufozu.flywheel.backend.instancing.RenderMaterial;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
|
@ -45,7 +45,7 @@ public class FlyWheelInstance extends KineticTileInstance<FlywheelTileEntity> im
|
||||||
|
|
||||||
protected float lastAngle = Float.NaN;
|
protected float lastAngle = Float.NaN;
|
||||||
|
|
||||||
public FlyWheelInstance(InstancedTileRenderer<?> modelManager, FlywheelTileEntity tile) {
|
public FlyWheelInstance(MaterialManager<?> modelManager, FlywheelTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
|
|
||||||
facing = blockState.get(HORIZONTAL_FACING);
|
facing = blockState.get(HORIZONTAL_FACING);
|
||||||
|
@ -63,7 +63,7 @@ public class FlyWheelInstance extends KineticTileInstance<FlywheelTileEntity> im
|
||||||
|
|
||||||
connectorAngleMult = flipAngle ? -1 : 1;
|
connectorAngleMult = flipAngle ? -1 : 1;
|
||||||
|
|
||||||
RenderMaterial<?, ModelData> mat = getTransformMaterial();
|
InstanceMaterial<ModelData> mat = getTransformMaterial();
|
||||||
|
|
||||||
upperRotating = mat.getModel(AllBlockPartials.FLYWHEEL_UPPER_ROTATING, blockState).createInstance();
|
upperRotating = mat.getModel(AllBlockPartials.FLYWHEEL_UPPER_ROTATING, blockState).createInstance();
|
||||||
lowerRotating = mat.getModel(AllBlockPartials.FLYWHEEL_LOWER_ROTATING, blockState).createInstance();
|
lowerRotating = mat.getModel(AllBlockPartials.FLYWHEEL_LOWER_ROTATING, blockState).createInstance();
|
||||||
|
@ -136,7 +136,7 @@ public class FlyWheelInstance extends KineticTileInstance<FlywheelTileEntity> im
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void update() {
|
public void update() {
|
||||||
updateRotation(shaft);
|
updateRotation(shaft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.simibubi.create.content.contraptions.components.flywheel.engine;
|
package com.simibubi.create.content.contraptions.components.flywheel.engine;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
||||||
import com.jozufozu.flywheel.core.PartialModel;
|
import com.jozufozu.flywheel.core.PartialModel;
|
||||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||||
|
@ -16,7 +16,7 @@ public class EngineInstance extends TileEntityInstance<EngineTileEntity> {
|
||||||
|
|
||||||
protected ModelData frame;
|
protected ModelData frame;
|
||||||
|
|
||||||
public EngineInstance(InstancedTileRenderer<?> modelManager, EngineTileEntity tile) {
|
public EngineInstance(MaterialManager<?> modelManager, EngineTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
|
|
||||||
Block block = blockState
|
Block block = blockState
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.simibubi.create.content.contraptions.components.millstone;
|
package com.simibubi.create.content.contraptions.components.millstone;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||||
import com.simibubi.create.content.contraptions.base.RotatingData;
|
import com.simibubi.create.content.contraptions.base.RotatingData;
|
||||||
|
@ -9,7 +9,7 @@ import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
|
||||||
|
|
||||||
public class MillStoneCogInstance extends SingleRotatingInstance {
|
public class MillStoneCogInstance extends SingleRotatingInstance {
|
||||||
|
|
||||||
public MillStoneCogInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
|
public MillStoneCogInstance(MaterialManager<?> modelManager, KineticTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.simibubi.create.content.contraptions.components.mixer;
|
package com.simibubi.create.content.contraptions.components.mixer;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.core.materials.OrientedData;
|
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.content.contraptions.base.RotatingData;
|
import com.simibubi.create.content.contraptions.base.RotatingData;
|
||||||
|
@ -16,7 +16,7 @@ public class MixerInstance extends ShaftlessCogInstance implements IDynamicInsta
|
||||||
private final OrientedData mixerPole;
|
private final OrientedData mixerPole;
|
||||||
private final MechanicalMixerTileEntity mixer;
|
private final MechanicalMixerTileEntity mixer;
|
||||||
|
|
||||||
public MixerInstance(InstancedTileRenderer<?> dispatcher, MechanicalMixerTileEntity tile) {
|
public MixerInstance(MaterialManager<?> dispatcher, MechanicalMixerTileEntity tile) {
|
||||||
super(dispatcher, tile);
|
super(dispatcher, tile);
|
||||||
this.mixer = tile;
|
this.mixer = tile;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.simibubi.create.content.contraptions.components.press;
|
package com.simibubi.create.content.contraptions.components.press;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.core.materials.OrientedData;
|
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance;
|
import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance;
|
||||||
|
@ -16,7 +16,7 @@ public class PressInstance extends ShaftInstance implements IDynamicInstance {
|
||||||
private final OrientedData pressHead;
|
private final OrientedData pressHead;
|
||||||
private final MechanicalPressTileEntity press;
|
private final MechanicalPressTileEntity press;
|
||||||
|
|
||||||
public PressInstance(InstancedTileRenderer<?> dispatcher, MechanicalPressTileEntity tile) {
|
public PressInstance(MaterialManager<?> dispatcher, MechanicalPressTileEntity tile) {
|
||||||
super(dispatcher, tile);
|
super(dispatcher, tile);
|
||||||
press = tile;
|
press = tile;
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.components.saw;
|
||||||
|
|
||||||
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||||
import com.simibubi.create.content.contraptions.base.RotatingData;
|
import com.simibubi.create.content.contraptions.base.RotatingData;
|
||||||
|
@ -15,7 +15,7 @@ import net.minecraft.util.Rotation;
|
||||||
|
|
||||||
public class SawInstance extends SingleRotatingInstance {
|
public class SawInstance extends SingleRotatingInstance {
|
||||||
|
|
||||||
public SawInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
|
public SawInstance(MaterialManager<?> modelManager, KineticTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.components.structureMovement;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer;
|
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
|
||||||
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
|
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ public abstract class MovementBehaviour {
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
@Nullable
|
@Nullable
|
||||||
public ActorInstance createInstance(ContraptionKineticRenderer kr, MovementContext context) {
|
public ActorInstance createInstance(MaterialManager<?> materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.simibubi.create.content.contraptions.components.structureMovement.bearing;
|
package com.simibubi.create.content.contraptions.components.structureMovement.bearing;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.core.PartialModel;
|
import com.jozufozu.flywheel.core.PartialModel;
|
||||||
import com.jozufozu.flywheel.core.materials.OrientedData;
|
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
|
@ -23,7 +23,7 @@ public class BearingInstance<B extends KineticTileEntity & IBearingTileEntity> e
|
||||||
final Vector3f rotationAxis;
|
final Vector3f rotationAxis;
|
||||||
final Quaternion blockOrientation;
|
final Quaternion blockOrientation;
|
||||||
|
|
||||||
public BearingInstance(InstancedTileRenderer<?> modelManager, B tile) {
|
public BearingInstance(MaterialManager<?> modelManager, B tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
this.bearing = tile;
|
this.bearing = tile;
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
package com.simibubi.create.content.contraptions.components.structureMovement.bearing;
|
package com.simibubi.create.content.contraptions.components.structureMovement.bearing;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.core.materials.OrientedData;
|
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer;
|
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
|
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.state.properties.BlockStateProperties;
|
import net.minecraft.state.properties.BlockStateProperties;
|
||||||
|
@ -21,8 +22,8 @@ public class StabilizedBearingInstance extends ActorInstance {
|
||||||
final Vector3f rotationAxis;
|
final Vector3f rotationAxis;
|
||||||
final Quaternion blockOrientation;
|
final Quaternion blockOrientation;
|
||||||
|
|
||||||
public StabilizedBearingInstance(ContraptionKineticRenderer modelManager, MovementContext context) {
|
public StabilizedBearingInstance(MaterialManager<?> materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
|
||||||
super(modelManager, context);
|
super(materialManager, simulationWorld, context);
|
||||||
|
|
||||||
BlockState blockState = context.state;
|
BlockState blockState = context.state;
|
||||||
|
|
||||||
|
@ -31,7 +32,7 @@ public class StabilizedBearingInstance extends ActorInstance {
|
||||||
|
|
||||||
blockOrientation = BearingInstance.getBlockStateOrientation(facing);
|
blockOrientation = BearingInstance.getBlockStateOrientation(facing);
|
||||||
|
|
||||||
topInstance = modelManager.getOrientedMaterial().getModel(AllBlockPartials.BEARING_TOP, blockState).createInstance();
|
topInstance = materialManager.getOrientedMaterial().getModel(AllBlockPartials.BEARING_TOP, blockState).createInstance();
|
||||||
|
|
||||||
topInstance.setPosition(context.localPos)
|
topInstance.setPosition(context.localPos)
|
||||||
.setRotation(blockOrientation)
|
.setRotation(blockOrientation)
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.be
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.core.PartialModel;
|
import com.jozufozu.flywheel.core.PartialModel;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity;
|
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity;
|
||||||
|
@ -11,7 +12,6 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Mov
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.OrientedContraptionEntity;
|
import com.simibubi.create.content.contraptions.components.structureMovement.OrientedContraptionEntity;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ActorInstance;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionKineticRenderer;
|
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionMatrices;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
|
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
|
||||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||||
|
@ -70,8 +70,8 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public ActorInstance createInstance(ContraptionKineticRenderer kr, MovementContext context) {
|
public ActorInstance createInstance(MaterialManager<?> materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
|
||||||
return new StabilizedBearingInstance(kr, context);
|
return new StabilizedBearingInstance(materialManager, simulationWorld, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static float getCounterRotationAngle(MovementContext context, Direction facing, float renderPartialTicks) {
|
static float getCounterRotationAngle(MovementContext context, Direction facing, float renderPartialTicks) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.simibubi.create.content.contraptions.components.structureMovement.chassis;
|
package com.simibubi.create.content.contraptions.components.structureMovement.chassis;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
||||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
|
@ -23,7 +23,7 @@ public class StickerInstance extends TileEntityInstance<StickerTileEntity> imple
|
||||||
|
|
||||||
private final ModelData head;
|
private final ModelData head;
|
||||||
|
|
||||||
public StickerInstance(InstancedTileRenderer<?> modelManager, StickerTileEntity tile) {
|
public StickerInstance(MaterialManager<?> modelManager, StickerTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
|
|
||||||
head = getTransformMaterial().getModel(AllBlockPartials.STICKER_HEAD, blockState).createInstance();
|
head = getTransformMaterial().getModel(AllBlockPartials.STICKER_HEAD, blockState).createInstance();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.simibubi.create.content.contraptions.components.structureMovement.gantry;
|
package com.simibubi.create.content.contraptions.components.structureMovement.gantry;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
|
@ -29,7 +29,7 @@ public class GantryCarriageInstance extends ShaftInstance implements IDynamicIns
|
||||||
|
|
||||||
private float lastAngle = Float.NaN;
|
private float lastAngle = Float.NaN;
|
||||||
|
|
||||||
public GantryCarriageInstance(InstancedTileRenderer<?> dispatcher, KineticTileEntity tile) {
|
public GantryCarriageInstance(MaterialManager<?> dispatcher, KineticTileEntity tile) {
|
||||||
super(dispatcher, tile);
|
super(dispatcher, tile);
|
||||||
|
|
||||||
gantryCogs = getTransformMaterial()
|
gantryCogs = getTransformMaterial()
|
||||||
|
|
|
@ -0,0 +1,116 @@
|
||||||
|
package com.simibubi.create.content.contraptions.components.structureMovement.glue;
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.backend.gl.GlPrimitive;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.ITickableInstance;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.entity.EntityInstance;
|
||||||
|
import com.jozufozu.flywheel.backend.model.BufferedModel;
|
||||||
|
import com.jozufozu.flywheel.backend.model.IndexedModel;
|
||||||
|
import com.jozufozu.flywheel.core.QuadConverter;
|
||||||
|
import com.jozufozu.flywheel.core.instancing.ConditionalInstance;
|
||||||
|
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||||
|
import com.simibubi.create.AllItems;
|
||||||
|
import com.simibubi.create.foundation.render.AllMaterialSpecs;
|
||||||
|
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||||
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.util.Direction;
|
||||||
|
import net.minecraft.util.math.vector.Quaternion;
|
||||||
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
|
|
||||||
|
public class GlueInstance extends EntityInstance<SuperGlueEntity> implements ITickableInstance {
|
||||||
|
|
||||||
|
private final Quaternion rotation;
|
||||||
|
protected ConditionalInstance<OrientedData> model;
|
||||||
|
|
||||||
|
public GlueInstance(MaterialManager<?> renderer, SuperGlueEntity entity) {
|
||||||
|
super(renderer, entity);
|
||||||
|
|
||||||
|
Instancer<OrientedData> instancer = renderer.getMaterial(AllMaterialSpecs.ORIENTED)
|
||||||
|
.get(entity.getType(), GlueInstance::supplyModel);
|
||||||
|
model = new ConditionalInstance<>(instancer)
|
||||||
|
.withCondition(this::shouldShow)
|
||||||
|
.withSetupFunc(this::positionModel)
|
||||||
|
.update();
|
||||||
|
|
||||||
|
Direction face = entity.getFacingDirection();
|
||||||
|
|
||||||
|
rotation = new Quaternion(AngleHelper.verticalAngle(face), AngleHelper.horizontalAngleNew(face), 0, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tick() {
|
||||||
|
model.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove() {
|
||||||
|
model.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void positionModel(OrientedData model) {
|
||||||
|
|
||||||
|
model.setPosition(getInstancePosition())
|
||||||
|
.setRotation(rotation)
|
||||||
|
.setSkyLight(15)
|
||||||
|
.setBlockLight(15);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean shouldShow() {
|
||||||
|
PlayerEntity player = Minecraft.getInstance().player;
|
||||||
|
|
||||||
|
return entity.isVisible()
|
||||||
|
|| AllItems.SUPER_GLUE.isIn(player.getHeldItemMainhand())
|
||||||
|
|| AllItems.SUPER_GLUE.isIn(player.getHeldItemOffhand());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BufferedModel supplyModel() {
|
||||||
|
Vector3d diff = Vector3d.of(Direction.SOUTH.getDirectionVec());
|
||||||
|
Vector3d extension = diff.normalize()
|
||||||
|
.scale(1 / 32f - 1 / 128f);
|
||||||
|
|
||||||
|
Vector3d plane = VecHelper.axisAlingedPlaneOf(diff);
|
||||||
|
Direction.Axis axis = Direction.getFacingFromVector(diff.x, diff.y, diff.z)
|
||||||
|
.getAxis();
|
||||||
|
|
||||||
|
Vector3d start = Vector3d.ZERO.subtract(extension);
|
||||||
|
Vector3d end = Vector3d.ZERO.add(extension);
|
||||||
|
|
||||||
|
plane = plane.scale(1 / 2f);
|
||||||
|
Vector3d a1 = plane.add(start);
|
||||||
|
Vector3d b1 = plane.add(end);
|
||||||
|
plane = VecHelper.rotate(plane, -90, axis);
|
||||||
|
Vector3d a2 = plane.add(start);
|
||||||
|
Vector3d b2 = plane.add(end);
|
||||||
|
plane = VecHelper.rotate(plane, -90, axis);
|
||||||
|
Vector3d a3 = plane.add(start);
|
||||||
|
Vector3d b3 = plane.add(end);
|
||||||
|
plane = VecHelper.rotate(plane, -90, axis);
|
||||||
|
Vector3d a4 = plane.add(start);
|
||||||
|
Vector3d b4 = plane.add(end);
|
||||||
|
|
||||||
|
float[] quads = new float[] {
|
||||||
|
// x, y, z,nx, ny,nz, u, v
|
||||||
|
// inside quad
|
||||||
|
(float) a1.x, (float) a1.y, (float) a1.z, 0, -1, 0, 1, 0,
|
||||||
|
(float) a2.x, (float) a2.y, (float) a2.z, 0, -1, 0, 1, 1,
|
||||||
|
(float) a3.x, (float) a3.y, (float) a3.z, 0, -1, 0, 0, 1,
|
||||||
|
(float) a4.x, (float) a4.y, (float) a4.z, 0, -1, 0, 0, 0,
|
||||||
|
// outside quad
|
||||||
|
(float) b4.x, (float) b4.y, (float) b4.z, 0, 1, 0, 0, 0,
|
||||||
|
(float) b3.x, (float) b3.y, (float) b3.z, 0, 1, 0, 0, 1,
|
||||||
|
(float) b2.x, (float) b2.y, (float) b2.z, 0, 1, 0, 1, 1,
|
||||||
|
(float) b1.x, (float) b1.y, (float) b1.z, 0, 1, 0, 1, 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
ByteBuffer buffer = ByteBuffer.allocate(quads.length * 4);
|
||||||
|
buffer.asFloatBuffer().put(quads);
|
||||||
|
|
||||||
|
return new IndexedModel(GlPrimitive.TRIANGLES, AllMaterialSpecs.UNLIT_MODEL, buffer, 8, QuadConverter.getInstance().quads2Tris(2));
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.IInstanceRendered;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
import com.simibubi.create.AllEntityTypes;
|
import com.simibubi.create.AllEntityTypes;
|
||||||
import com.simibubi.create.AllItems;
|
import com.simibubi.create.AllItems;
|
||||||
|
@ -64,7 +65,7 @@ import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData;
|
||||||
import net.minecraftforge.fml.network.NetworkHooks;
|
import net.minecraftforge.fml.network.NetworkHooks;
|
||||||
import net.minecraftforge.fml.network.PacketDistributor;
|
import net.minecraftforge.fml.network.PacketDistributor;
|
||||||
|
|
||||||
public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnData, ISpecialEntityItemRequirement {
|
public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnData, ISpecialEntityItemRequirement, IInstanceRendered {
|
||||||
|
|
||||||
private int validationTimer;
|
private int validationTimer;
|
||||||
protected BlockPos hangingPosition;
|
protected BlockPos hangingPosition;
|
||||||
|
@ -480,4 +481,9 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat
|
||||||
public boolean doesEntityNotTriggerPressurePlate() {
|
public boolean doesEntityNotTriggerPressurePlate() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public World getWorld() {
|
||||||
|
return world;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,8 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pu
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.core.instancing.ConditionalInstance;
|
import com.jozufozu.flywheel.core.instancing.ConditionalInstance;
|
||||||
import com.jozufozu.flywheel.core.instancing.GroupInstance;
|
import com.jozufozu.flywheel.core.instancing.GroupInstance;
|
||||||
import com.jozufozu.flywheel.core.instancing.SelectInstance;
|
import com.jozufozu.flywheel.core.instancing.SelectInstance;
|
||||||
|
@ -37,7 +37,7 @@ public abstract class AbstractPulleyInstance extends ShaftInstance implements ID
|
||||||
private byte[] sLight = new byte[1];
|
private byte[] sLight = new byte[1];
|
||||||
private GridAlignedBB volume;
|
private GridAlignedBB volume;
|
||||||
|
|
||||||
public AbstractPulleyInstance(InstancedTileRenderer<?> dispatcher, KineticTileEntity tile) {
|
public AbstractPulleyInstance(MaterialManager<?> dispatcher, KineticTileEntity tile) {
|
||||||
super(dispatcher, tile);
|
super(dispatcher, tile);
|
||||||
|
|
||||||
rotatingAbout = Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, axis);
|
rotatingAbout = Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, axis);
|
||||||
|
@ -52,7 +52,8 @@ public abstract class AbstractPulleyInstance extends ShaftInstance implements ID
|
||||||
.addModel(getHalfMagnetModel());
|
.addModel(getHalfMagnetModel());
|
||||||
|
|
||||||
rope = new GroupInstance<>(getRopeModel());
|
rope = new GroupInstance<>(getRopeModel());
|
||||||
halfRope = new ConditionalInstance<>(getHalfRopeModel(), this::shouldRenderHalfRope);
|
halfRope = new ConditionalInstance<>(getHalfRopeModel())
|
||||||
|
.withCondition(this::shouldRenderHalfRope);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.simibubi.create.content.contraptions.components.structureMovement.pulley;
|
package com.simibubi.create.content.contraptions.components.structureMovement.pulley;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.core.materials.OrientedData;
|
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.content.contraptions.fluids.actors.HosePulleyTileEntity;
|
import com.simibubi.create.content.contraptions.fluids.actors.HosePulleyTileEntity;
|
||||||
|
@ -10,7 +10,7 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
public class HosePulleyInstance extends AbstractPulleyInstance {
|
public class HosePulleyInstance extends AbstractPulleyInstance {
|
||||||
final HosePulleyTileEntity tile = (HosePulleyTileEntity) super.tile;
|
final HosePulleyTileEntity tile = (HosePulleyTileEntity) super.tile;
|
||||||
|
|
||||||
public HosePulleyInstance(InstancedTileRenderer<?> dispatcher, HosePulleyTileEntity tile) {
|
public HosePulleyInstance(MaterialManager<?> dispatcher, HosePulleyTileEntity tile) {
|
||||||
super(dispatcher, tile);
|
super(dispatcher, tile);
|
||||||
beginFrame();
|
beginFrame();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package com.simibubi.create.content.contraptions.components.structureMovement.pulley;
|
package com.simibubi.create.content.contraptions.components.structureMovement.pulley;
|
||||||
|
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.core.materials.OrientedData;
|
import com.jozufozu.flywheel.core.materials.OrientedData;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
|
@ -11,7 +11,7 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
public class RopePulleyInstance extends AbstractPulleyInstance {
|
public class RopePulleyInstance extends AbstractPulleyInstance {
|
||||||
final PulleyTileEntity tile = (PulleyTileEntity) super.tile;
|
final PulleyTileEntity tile = (PulleyTileEntity) super.tile;
|
||||||
|
|
||||||
public RopePulleyInstance(InstancedTileRenderer<?> dispatcher, PulleyTileEntity tile) {
|
public RopePulleyInstance(MaterialManager<?> dispatcher, PulleyTileEntity tile) {
|
||||||
super(dispatcher, tile);
|
super(dispatcher, tile);
|
||||||
beginFrame();
|
beginFrame();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,19 @@
|
||||||
package com.simibubi.create.content.contraptions.components.structureMovement.render;
|
package com.simibubi.create.content.contraptions.components.structureMovement.render;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||||
|
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
|
||||||
|
|
||||||
import net.minecraft.world.LightType;
|
import net.minecraft.world.LightType;
|
||||||
|
|
||||||
public abstract class ActorInstance {
|
public abstract class ActorInstance {
|
||||||
protected final ContraptionKineticRenderer modelManager;
|
protected final MaterialManager<?> materialManager;
|
||||||
protected final MovementContext context;
|
protected final PlacementSimulationWorld simulationWorld;
|
||||||
|
protected final MovementContext context;
|
||||||
|
|
||||||
public ActorInstance(ContraptionKineticRenderer modelManager, MovementContext context) {
|
public ActorInstance(MaterialManager<?> materialManager, PlacementSimulationWorld world, MovementContext context) {
|
||||||
this.modelManager = modelManager;
|
this.materialManager = materialManager;
|
||||||
|
this.simulationWorld = world;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +22,6 @@ public abstract class ActorInstance {
|
||||||
public void beginFrame() { }
|
public void beginFrame() { }
|
||||||
|
|
||||||
protected int localBlockLight() {
|
protected int localBlockLight() {
|
||||||
return modelManager.getContraption().renderWorld.getLightLevel(LightType.BLOCK, context.localPos);
|
return simulationWorld.getLightLevel(LightType.BLOCK, context.localPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,26 +7,24 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.RenderMaterial;
|
import com.jozufozu.flywheel.backend.instancing.TileInstanceManager;
|
||||||
import com.simibubi.create.AllMovementBehaviours;
|
import com.simibubi.create.AllMovementBehaviours;
|
||||||
import com.simibubi.create.content.contraptions.components.actors.ActorData;
|
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
|
import com.simibubi.create.content.contraptions.components.structureMovement.MovementBehaviour;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||||
import com.simibubi.create.foundation.render.AllMaterialSpecs;
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.gen.feature.template.Template;
|
import net.minecraft.world.gen.feature.template.Template;
|
||||||
|
|
||||||
public class ContraptionKineticRenderer extends InstancedTileRenderer<ContraptionProgram> {
|
public class ContraptionInstanceManager extends TileInstanceManager {
|
||||||
|
|
||||||
protected ArrayList<ActorInstance> actors = new ArrayList<>();
|
protected ArrayList<ActorInstance> actors = new ArrayList<>();
|
||||||
|
|
||||||
private final WeakReference<RenderedContraption> contraption;
|
private final WeakReference<RenderedContraption> contraption;
|
||||||
|
|
||||||
ContraptionKineticRenderer(RenderedContraption contraption) {
|
ContraptionInstanceManager(RenderedContraption contraption, MaterialManager<?> materialManager) {
|
||||||
super(ContraptionRenderDispatcher.TILES);
|
super(materialManager);
|
||||||
this.contraption = new WeakReference<>(contraption);
|
this.contraption = new WeakReference<>(contraption);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +52,7 @@ public class ContraptionKineticRenderer extends InstancedTileRenderer<Contraptio
|
||||||
MovementBehaviour movementBehaviour = AllMovementBehaviours.of(blockInfo.state);
|
MovementBehaviour movementBehaviour = AllMovementBehaviours.of(blockInfo.state);
|
||||||
|
|
||||||
if (movementBehaviour != null && movementBehaviour.hasSpecialInstancedRendering()) {
|
if (movementBehaviour != null && movementBehaviour.hasSpecialInstancedRendering()) {
|
||||||
ActorInstance instance = movementBehaviour.createInstance(this, context);
|
ActorInstance instance = movementBehaviour.createInstance(materialManager, getContraption().renderWorld, context);
|
||||||
|
|
||||||
actors.add(instance);
|
actors.add(instance);
|
||||||
|
|
||||||
|
@ -64,17 +62,8 @@ public class ContraptionKineticRenderer extends InstancedTileRenderer<Contraptio
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RenderMaterial<?, ActorData> getActorMaterial() {
|
|
||||||
return getMaterial(AllMaterialSpecs.ACTORS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public RenderedContraption getContraption() {
|
public RenderedContraption getContraption() {
|
||||||
return contraption.get();
|
return contraption.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockPos getOriginCoordinate() {
|
|
||||||
return BlockPos.ZERO;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.simibubi.create.content.contraptions.components.structureMovement.render;
|
||||||
|
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialRenderer;
|
||||||
|
import com.jozufozu.flywheel.core.WorldContext;
|
||||||
|
import com.jozufozu.flywheel.core.shader.IProgramCallback;
|
||||||
|
|
||||||
|
import net.minecraft.client.renderer.RenderType;
|
||||||
|
import net.minecraft.util.math.vector.Matrix4f;
|
||||||
|
|
||||||
|
public class ContraptionMaterialManager extends MaterialManager<ContraptionProgram> {
|
||||||
|
public ContraptionMaterialManager(WorldContext<ContraptionProgram> context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(RenderType layer, Matrix4f viewProjection, double camX, double camY, double camZ, IProgramCallback<ContraptionProgram> callback) {
|
||||||
|
for (MaterialRenderer<ContraptionProgram> material : renderers) {
|
||||||
|
material.render(layer, viewProjection, camX, camY, camZ, callback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package com.simibubi.create.content.contraptions.components.structureMovement.render;
|
package com.simibubi.create.content.contraptions.components.structureMovement.render;
|
||||||
|
|
||||||
|
import static org.lwjgl.opengl.GL11.glBindTexture;
|
||||||
import static org.lwjgl.opengl.GL13.GL_QUADS;
|
import static org.lwjgl.opengl.GL13.GL_QUADS;
|
||||||
import static org.lwjgl.opengl.GL13.GL_TEXTURE0;
|
import static org.lwjgl.opengl.GL13.GL_TEXTURE0;
|
||||||
import static org.lwjgl.opengl.GL13.GL_TEXTURE4;
|
import static org.lwjgl.opengl.GL13.GL_TEXTURE4;
|
||||||
|
@ -123,11 +124,11 @@ public class ContraptionRenderDispatcher {
|
||||||
|
|
||||||
if (Backend.canUseInstancing()) {
|
if (Backend.canUseInstancing()) {
|
||||||
for (RenderedContraption renderer : RENDERERS.values()) {
|
for (RenderedContraption renderer : RENDERERS.values()) {
|
||||||
renderer.kinetics.render(layer, viewProjection, camX, camY, camZ, renderer::setup);
|
renderer.materialManager.render(layer, viewProjection, camX, camY, camZ, renderer::setup);
|
||||||
renderer.teardown();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_3D, 0);
|
||||||
layer.endDrawing();
|
layer.endDrawing();
|
||||||
glDisable(GL_TEXTURE_3D);
|
glDisable(GL_TEXTURE_3D);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
|
|
@ -14,6 +14,7 @@ import com.jozufozu.flywheel.backend.gl.GlPrimitive;
|
||||||
import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes;
|
import com.jozufozu.flywheel.backend.gl.attrib.CommonAttributes;
|
||||||
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
|
import com.jozufozu.flywheel.backend.gl.attrib.VertexFormat;
|
||||||
import com.jozufozu.flywheel.backend.instancing.IInstanceRendered;
|
import com.jozufozu.flywheel.backend.instancing.IInstanceRendered;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.backend.model.ArrayModelRenderer;
|
import com.jozufozu.flywheel.backend.model.ArrayModelRenderer;
|
||||||
import com.jozufozu.flywheel.backend.model.BufferedModel;
|
import com.jozufozu.flywheel.backend.model.BufferedModel;
|
||||||
import com.jozufozu.flywheel.backend.model.IndexedModel;
|
import com.jozufozu.flywheel.backend.model.IndexedModel;
|
||||||
|
@ -48,7 +49,9 @@ public class RenderedContraption extends ContraptionWorldHolder {
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
private final ContraptionLighter<?> lighter;
|
private final ContraptionLighter<?> lighter;
|
||||||
public final ContraptionKineticRenderer kinetics;
|
|
||||||
|
public final MaterialManager<ContraptionProgram> materialManager;
|
||||||
|
public final ContraptionInstanceManager kinetics;
|
||||||
|
|
||||||
private final Map<RenderType, ModelRenderer> renderLayers = new HashMap<>();
|
private final Map<RenderType, ModelRenderer> renderLayers = new HashMap<>();
|
||||||
|
|
||||||
|
@ -58,7 +61,8 @@ public class RenderedContraption extends ContraptionWorldHolder {
|
||||||
public RenderedContraption(World world, PlacementSimulationWorld renderWorld, Contraption contraption) {
|
public RenderedContraption(World world, PlacementSimulationWorld renderWorld, Contraption contraption) {
|
||||||
super(contraption, renderWorld);
|
super(contraption, renderWorld);
|
||||||
this.lighter = contraption.makeLighter();
|
this.lighter = contraption.makeLighter();
|
||||||
this.kinetics = new ContraptionKineticRenderer(this);
|
this.materialManager = new ContraptionMaterialManager(ContraptionRenderDispatcher.TILES);
|
||||||
|
this.kinetics = new ContraptionInstanceManager(this, materialManager);
|
||||||
|
|
||||||
buildLayers();
|
buildLayers();
|
||||||
if (Backend.canUseInstancing()) {
|
if (Backend.canUseInstancing()) {
|
||||||
|
@ -76,7 +80,6 @@ public class RenderedContraption extends ContraptionWorldHolder {
|
||||||
if (structure != null) {
|
if (structure != null) {
|
||||||
setup(shader);
|
setup(shader);
|
||||||
structure.draw();
|
structure.draw();
|
||||||
teardown();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,10 +111,6 @@ public class RenderedContraption extends ContraptionWorldHolder {
|
||||||
lighter.lightVolume.bind();
|
lighter.lightVolume.bind();
|
||||||
}
|
}
|
||||||
|
|
||||||
void teardown() {
|
|
||||||
lighter.lightVolume.unbind();
|
|
||||||
}
|
|
||||||
|
|
||||||
void invalidate() {
|
void invalidate() {
|
||||||
for (ModelRenderer buffer : renderLayers.values()) {
|
for (ModelRenderer buffer : renderLayers.values()) {
|
||||||
buffer.delete();
|
buffer.delete();
|
||||||
|
|
|
@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.fluids;
|
||||||
|
|
||||||
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||||
import com.simibubi.create.content.contraptions.base.RotatingData;
|
import com.simibubi.create.content.contraptions.base.RotatingData;
|
||||||
|
@ -14,7 +14,7 @@ import net.minecraft.util.Direction;
|
||||||
|
|
||||||
public class PumpCogInstance extends SingleRotatingInstance {
|
public class PumpCogInstance extends SingleRotatingInstance {
|
||||||
|
|
||||||
public PumpCogInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
|
public PumpCogInstance(MaterialManager<?> modelManager, KineticTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.simibubi.create.content.contraptions.fluids.pipes;
|
package com.simibubi.create.content.contraptions.fluids.pipes;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
|
@ -23,7 +23,7 @@ public class FluidValveInstance extends ShaftInstance implements IDynamicInstanc
|
||||||
protected final double yRot;
|
protected final double yRot;
|
||||||
protected final int pointerRotationOffset;
|
protected final int pointerRotationOffset;
|
||||||
|
|
||||||
public FluidValveInstance(InstancedTileRenderer<?> dispatcher, KineticTileEntity tile) {
|
public FluidValveInstance(MaterialManager<?> dispatcher, KineticTileEntity tile) {
|
||||||
super(dispatcher, tile);
|
super(dispatcher, tile);
|
||||||
|
|
||||||
Direction facing = blockState.get(FluidValveBlock.FACING);
|
Direction facing = blockState.get(FluidValveBlock.FACING);
|
||||||
|
@ -37,7 +37,7 @@ public class FluidValveInstance extends ShaftInstance implements IDynamicInstanc
|
||||||
boolean twist = pipeAxis.isHorizontal() && shaftAxis == Direction.Axis.Z || pipeAxis.isVertical();
|
boolean twist = pipeAxis.isHorizontal() && shaftAxis == Direction.Axis.Z || pipeAxis.isVertical();
|
||||||
pointerRotationOffset = twist ? 90 : 0;
|
pointerRotationOffset = twist ? 90 : 0;
|
||||||
|
|
||||||
pointer = renderer.getTransformMaterial().getModel(AllBlockPartials.FLUID_VALVE_POINTER, blockState).createInstance();
|
pointer = materialManager.getTransformMaterial().getModel(AllBlockPartials.FLUID_VALVE_POINTER, blockState).createInstance();
|
||||||
|
|
||||||
transformPointer((FluidValveTileEntity) tile);
|
transformPointer((FluidValveTileEntity) tile);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@ import java.util.ArrayList;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.core.PartialModel;
|
import com.jozufozu.flywheel.core.PartialModel;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
|
@ -35,8 +35,8 @@ public class BeltInstance extends KineticTileInstance<BeltTileEntity> {
|
||||||
protected ArrayList<BeltData> keys;
|
protected ArrayList<BeltData> keys;
|
||||||
protected RotatingData pulleyKey;
|
protected RotatingData pulleyKey;
|
||||||
|
|
||||||
public BeltInstance(InstancedTileRenderer<?> modelManager, BeltTileEntity tile) {
|
public BeltInstance(MaterialManager<?> materialManager, BeltTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(materialManager, tile);
|
||||||
|
|
||||||
if (!AllBlocks.BELT.has(blockState))
|
if (!AllBlocks.BELT.has(blockState))
|
||||||
return;
|
return;
|
||||||
|
@ -61,7 +61,7 @@ public class BeltInstance extends KineticTileInstance<BeltTileEntity> {
|
||||||
PartialModel beltPartial = BeltRenderer.getBeltPartial(diagonal, start, end, bottom);
|
PartialModel beltPartial = BeltRenderer.getBeltPartial(diagonal, start, end, bottom);
|
||||||
SpriteShiftEntry spriteShift = BeltRenderer.getSpriteShiftEntry(color, diagonal, bottom);
|
SpriteShiftEntry spriteShift = BeltRenderer.getSpriteShiftEntry(color, diagonal, bottom);
|
||||||
|
|
||||||
Instancer<BeltData> beltModel = modelManager.getMaterial(AllMaterialSpecs.BELTS).getModel(beltPartial, blockState);
|
Instancer<BeltData> beltModel = materialManager.getMaterial(AllMaterialSpecs.BELTS).getModel(beltPartial, blockState);
|
||||||
|
|
||||||
keys.add(setup(beltModel.createInstance(), bottom, spriteShift));
|
keys.add(setup(beltModel.createInstance(), bottom, spriteShift));
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.simibubi.create.content.contraptions.relays.encased;
|
package com.simibubi.create.content.contraptions.relays.encased;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||||
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
|
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import net.minecraft.block.BlockState;
|
||||||
|
|
||||||
public class ShaftInstance extends SingleRotatingInstance {
|
public class ShaftInstance extends SingleRotatingInstance {
|
||||||
|
|
||||||
public ShaftInstance(InstancedTileRenderer<?> dispatcher, KineticTileEntity tile) {
|
public ShaftInstance(MaterialManager<?> dispatcher, KineticTileEntity tile) {
|
||||||
super(dispatcher, tile);
|
super(dispatcher, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,9 @@ package com.simibubi.create.content.contraptions.relays.encased;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.InstanceMaterial;
|
||||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
import com.jozufozu.flywheel.backend.instancing.RenderMaterial;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.content.contraptions.base.IRotate;
|
import com.simibubi.create.content.contraptions.base.IRotate;
|
||||||
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
|
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
|
||||||
|
@ -19,14 +19,14 @@ public class SplitShaftInstance extends KineticTileInstance<SplitShaftTileEntity
|
||||||
|
|
||||||
protected final ArrayList<RotatingData> keys;
|
protected final ArrayList<RotatingData> keys;
|
||||||
|
|
||||||
public SplitShaftInstance(InstancedTileRenderer<?> modelManager, SplitShaftTileEntity tile) {
|
public SplitShaftInstance(MaterialManager<?> modelManager, SplitShaftTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
|
|
||||||
keys = new ArrayList<>(2);
|
keys = new ArrayList<>(2);
|
||||||
|
|
||||||
float speed = tile.getSpeed();
|
float speed = tile.getSpeed();
|
||||||
|
|
||||||
RenderMaterial<?, RotatingData> rotatingMaterial = getRotatingMaterial();
|
InstanceMaterial<RotatingData> rotatingMaterial = getRotatingMaterial();
|
||||||
|
|
||||||
for (Direction dir : Iterate.directionsInAxis(getRotationAxis())) {
|
for (Direction dir : Iterate.directionsInAxis(getRotationAxis())) {
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@ package com.simibubi.create.content.contraptions.relays.gauge;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
|
@ -24,7 +24,7 @@ public abstract class GaugeInstance extends ShaftInstance implements IDynamicIns
|
||||||
|
|
||||||
protected MatrixStack ms;
|
protected MatrixStack ms;
|
||||||
|
|
||||||
protected GaugeInstance(InstancedTileRenderer<?> dispatcher, KineticTileEntity tile) {
|
protected GaugeInstance(MaterialManager<?> dispatcher, KineticTileEntity tile) {
|
||||||
super(dispatcher, tile);
|
super(dispatcher, tile);
|
||||||
|
|
||||||
faces = new ArrayList<>(2);
|
faces = new ArrayList<>(2);
|
||||||
|
@ -144,7 +144,7 @@ public abstract class GaugeInstance extends ShaftInstance implements IDynamicIns
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Speed extends GaugeInstance {
|
public static class Speed extends GaugeInstance {
|
||||||
public Speed(InstancedTileRenderer<?> dispatcher, KineticTileEntity tile) {
|
public Speed(MaterialManager<?> dispatcher, KineticTileEntity tile) {
|
||||||
super(dispatcher, tile);
|
super(dispatcher, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ public abstract class GaugeInstance extends ShaftInstance implements IDynamicIns
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Stress extends GaugeInstance {
|
public static class Stress extends GaugeInstance {
|
||||||
public Stress(InstancedTileRenderer<?> dispatcher, KineticTileEntity tile) {
|
public Stress(MaterialManager<?> dispatcher, KineticTileEntity tile) {
|
||||||
super(dispatcher, tile);
|
super(dispatcher, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,9 @@ import java.util.EnumMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.InstanceMaterial;
|
||||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
import com.jozufozu.flywheel.backend.instancing.RenderMaterial;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
|
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
|
||||||
import com.simibubi.create.content.contraptions.base.RotatingData;
|
import com.simibubi.create.content.contraptions.base.RotatingData;
|
||||||
|
@ -22,7 +22,7 @@ public class GearboxInstance extends KineticTileInstance<GearboxTileEntity> {
|
||||||
protected final EnumMap<Direction, RotatingData> keys;
|
protected final EnumMap<Direction, RotatingData> keys;
|
||||||
protected Direction sourceFacing;
|
protected Direction sourceFacing;
|
||||||
|
|
||||||
public GearboxInstance(InstancedTileRenderer<?> modelManager, GearboxTileEntity tile) {
|
public GearboxInstance(MaterialManager<?> modelManager, GearboxTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
|
|
||||||
keys = new EnumMap<>(Direction.class);
|
keys = new EnumMap<>(Direction.class);
|
||||||
|
@ -33,7 +33,7 @@ public class GearboxInstance extends KineticTileInstance<GearboxTileEntity> {
|
||||||
int skyLight = world.getLightLevel(LightType.SKY, pos);
|
int skyLight = world.getLightLevel(LightType.SKY, pos);
|
||||||
updateSourceFacing();
|
updateSourceFacing();
|
||||||
|
|
||||||
RenderMaterial<?, RotatingData> rotatingMaterial = getRotatingMaterial();
|
InstanceMaterial<RotatingData> rotatingMaterial = getRotatingMaterial();
|
||||||
|
|
||||||
for (Direction direction : Iterate.directions) {
|
for (Direction direction : Iterate.directions) {
|
||||||
final Direction.Axis axis = direction.getAxis();
|
final Direction.Axis axis = direction.getAxis();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.simibubi.create.content.curiosities.armor;
|
package com.simibubi.create.content.curiosities.armor;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||||
import com.simibubi.create.content.contraptions.base.RotatingData;
|
import com.simibubi.create.content.contraptions.base.RotatingData;
|
||||||
|
@ -9,7 +9,7 @@ import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
|
||||||
|
|
||||||
public class CopperBacktankInstance extends SingleRotatingInstance {
|
public class CopperBacktankInstance extends SingleRotatingInstance {
|
||||||
|
|
||||||
public CopperBacktankInstance(InstancedTileRenderer<?> modelManager, KineticTileEntity tile) {
|
public CopperBacktankInstance(MaterialManager<?> modelManager, KineticTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package com.simibubi.create.content.curiosities.projector;
|
package com.simibubi.create.content.curiosities.projector;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
||||||
import com.simibubi.create.foundation.render.effects.EffectsHandler;
|
import com.simibubi.create.foundation.render.effects.EffectsHandler;
|
||||||
|
|
||||||
public class ChromaticProjectorInstance extends TileEntityInstance<ChromaticProjectorTileEntity> implements IDynamicInstance {
|
public class ChromaticProjectorInstance extends TileEntityInstance<ChromaticProjectorTileEntity> implements IDynamicInstance {
|
||||||
|
|
||||||
public ChromaticProjectorInstance(InstancedTileRenderer<?> renderer, ChromaticProjectorTileEntity tile) {
|
public ChromaticProjectorInstance(MaterialManager<?> renderer, ChromaticProjectorTileEntity tile) {
|
||||||
super(renderer, tile);
|
super(renderer, tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import com.jozufozu.flywheel.core.materials.IFlatLight;
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.vector.Vector3f;
|
import net.minecraft.util.math.vector.Vector3f;
|
||||||
|
import net.minecraft.util.math.vector.Vector3i;
|
||||||
|
|
||||||
public class FlapData extends InstanceData implements IFlatLight<FlapData> {
|
public class FlapData extends InstanceData implements IFlatLight<FlapData> {
|
||||||
|
|
||||||
|
@ -43,7 +44,7 @@ public class FlapData extends InstanceData implements IFlatLight<FlapData> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlapData setPosition(int x, int y, int z) {
|
public FlapData setPosition(int x, int y, int z) {
|
||||||
BlockPos origin = owner.renderer.getOriginCoordinate();
|
Vector3i origin = owner.originCoordinate.get();
|
||||||
|
|
||||||
return setPosition((float) (x - origin.getX()),
|
return setPosition((float) (x - origin.getX()),
|
||||||
(float) (y - origin.getY()),
|
(float) (y - origin.getY()),
|
||||||
|
|
|
@ -7,8 +7,8 @@ import java.util.Map;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.content.logistics.block.FlapData;
|
import com.simibubi.create.content.logistics.block.FlapData;
|
||||||
|
@ -23,7 +23,7 @@ public class BeltTunnelInstance extends TileEntityInstance<BeltTunnelTileEntity>
|
||||||
|
|
||||||
private final Map<Direction, ArrayList<FlapData>> tunnelFlaps;
|
private final Map<Direction, ArrayList<FlapData>> tunnelFlaps;
|
||||||
|
|
||||||
public BeltTunnelInstance(InstancedTileRenderer<?> modelManager, BeltTunnelTileEntity tile) {
|
public BeltTunnelInstance(MaterialManager<?> modelManager, BeltTunnelTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
|
|
||||||
tunnelFlaps = new EnumMap<>(Direction.class);
|
tunnelFlaps = new EnumMap<>(Direction.class);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.simibubi.create.content.logistics.block.depot;
|
package com.simibubi.create.content.logistics.block.depot;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
|
@ -19,7 +19,7 @@ public class EjectorInstance extends ShaftInstance implements IDynamicInstance {
|
||||||
|
|
||||||
private float lastProgress = Float.NaN;
|
private float lastProgress = Float.NaN;
|
||||||
|
|
||||||
public EjectorInstance(InstancedTileRenderer<?> dispatcher, EjectorTileEntity tile) {
|
public EjectorInstance(MaterialManager<?> dispatcher, EjectorTileEntity tile) {
|
||||||
super(dispatcher, tile);
|
super(dispatcher, tile);
|
||||||
this.tile = tile;
|
this.tile = tile;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.simibubi.create.content.logistics.block.diodes;
|
package com.simibubi.create.content.logistics.block.diodes;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.ITickableInstance;
|
import com.jozufozu.flywheel.backend.instancing.ITickableInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
||||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
|
@ -15,7 +15,7 @@ public class AdjustableRepeaterInstance extends TileEntityInstance<AdjustableRep
|
||||||
|
|
||||||
protected int previousState;
|
protected int previousState;
|
||||||
|
|
||||||
public AdjustableRepeaterInstance(InstancedTileRenderer<?> modelManager, AdjustableRepeaterTileEntity tile) {
|
public AdjustableRepeaterInstance(MaterialManager<?> modelManager, AdjustableRepeaterTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
|
|
||||||
indicator = modelManager.getTransformMaterial().getModel(AllBlockPartials.FLEXPEATER_INDICATOR, blockState).createInstance();
|
indicator = modelManager.getTransformMaterial().getModel(AllBlockPartials.FLEXPEATER_INDICATOR, blockState).createInstance();
|
||||||
|
|
|
@ -4,8 +4,8 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
||||||
import com.jozufozu.flywheel.core.PartialModel;
|
import com.jozufozu.flywheel.core.PartialModel;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
|
@ -20,7 +20,7 @@ public class FunnelInstance extends TileEntityInstance<FunnelTileEntity> impleme
|
||||||
|
|
||||||
private final ArrayList<FlapData> flaps;
|
private final ArrayList<FlapData> flaps;
|
||||||
|
|
||||||
public FunnelInstance(InstancedTileRenderer<?> modelManager, FunnelTileEntity tile) {
|
public FunnelInstance(MaterialManager<?> modelManager, FunnelTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
|
|
||||||
flaps = new ArrayList<>(4);
|
flaps = new ArrayList<>(4);
|
||||||
|
|
|
@ -5,9 +5,9 @@ import java.util.ArrayList;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
import com.jozufozu.flywheel.backend.instancing.InstanceData;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.InstanceMaterial;
|
||||||
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
import com.jozufozu.flywheel.backend.instancing.Instancer;
|
||||||
import com.jozufozu.flywheel.backend.instancing.RenderMaterial;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
|
@ -44,10 +44,10 @@ public class ArmInstance extends SingleRotatingInstance implements IDynamicInsta
|
||||||
private float upperArmAngle = Float.NaN;
|
private float upperArmAngle = Float.NaN;
|
||||||
private float headAngle = Float.NaN;
|
private float headAngle = Float.NaN;
|
||||||
|
|
||||||
public ArmInstance(InstancedTileRenderer<?> modelManager, ArmTileEntity tile) {
|
public ArmInstance(MaterialManager<?> modelManager, ArmTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
|
|
||||||
RenderMaterial<?, ModelData> mat = getTransformMaterial();
|
InstanceMaterial<ModelData> mat = getTransformMaterial();
|
||||||
|
|
||||||
base = mat.getModel(AllBlockPartials.ARM_BASE, blockState).createInstance();
|
base = mat.getModel(AllBlockPartials.ARM_BASE, blockState).createInstance();
|
||||||
lowerBody = mat.getModel(AllBlockPartials.ARM_LOWER_BODY, blockState).createInstance();
|
lowerBody = mat.getModel(AllBlockPartials.ARM_LOWER_BODY, blockState).createInstance();
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package com.simibubi.create.content.logistics.block.redstone;
|
package com.simibubi.create.content.logistics.block.redstone;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.InstanceMaterial;
|
||||||
import com.jozufozu.flywheel.backend.instancing.RenderMaterial;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
||||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
|
@ -23,10 +23,10 @@ public class AnalogLeverInstance extends TileEntityInstance<AnalogLeverTileEntit
|
||||||
final float rX;
|
final float rX;
|
||||||
final float rY;
|
final float rY;
|
||||||
|
|
||||||
public AnalogLeverInstance(InstancedTileRenderer<?> modelManager, AnalogLeverTileEntity tile) {
|
public AnalogLeverInstance(MaterialManager<?> modelManager, AnalogLeverTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
|
|
||||||
RenderMaterial<?, ModelData> mat = getTransformMaterial();
|
InstanceMaterial<ModelData> mat = getTransformMaterial();
|
||||||
|
|
||||||
handle = mat.getModel(AllBlockPartials.ANALOG_LEVER_HANDLE, blockState).createInstance();
|
handle = mat.getModel(AllBlockPartials.ANALOG_LEVER_HANDLE, blockState).createInstance();
|
||||||
indicator = mat.getModel(AllBlockPartials.ANALOG_LEVER_INDICATOR, blockState).createInstance();
|
indicator = mat.getModel(AllBlockPartials.ANALOG_LEVER_INDICATOR, blockState).createInstance();
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package com.simibubi.create.content.schematics.block;
|
package com.simibubi.create.content.schematics.block;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.InstanceMaterial;
|
||||||
import com.jozufozu.flywheel.backend.instancing.RenderMaterial;
|
import com.jozufozu.flywheel.backend.instancing.MaterialManager;
|
||||||
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
import com.jozufozu.flywheel.backend.instancing.TileEntityInstance;
|
||||||
import com.jozufozu.flywheel.core.materials.ModelData;
|
import com.jozufozu.flywheel.core.materials.ModelData;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
|
@ -17,10 +17,10 @@ public class SchematicannonInstance extends TileEntityInstance<SchematicannonTil
|
||||||
private final ModelData connector;
|
private final ModelData connector;
|
||||||
private final ModelData pipe;
|
private final ModelData pipe;
|
||||||
|
|
||||||
public SchematicannonInstance(InstancedTileRenderer<?> modelManager, SchematicannonTileEntity tile) {
|
public SchematicannonInstance(MaterialManager<?> modelManager, SchematicannonTileEntity tile) {
|
||||||
super(modelManager, tile);
|
super(modelManager, tile);
|
||||||
|
|
||||||
RenderMaterial<?, ModelData> mat = getTransformMaterial();
|
InstanceMaterial<ModelData> mat = getTransformMaterial();
|
||||||
|
|
||||||
connector = mat.getModel(AllBlockPartials.SCHEMATICANNON_CONNECTOR, blockState).createInstance();
|
connector = mat.getModel(AllBlockPartials.SCHEMATICANNON_CONNECTOR, blockState).createInstance();
|
||||||
pipe = mat.getModel(AllBlockPartials.SCHEMATICANNON_PIPE, blockState).createInstance();
|
pipe = mat.getModel(AllBlockPartials.SCHEMATICANNON_PIPE, blockState).createInstance();
|
||||||
|
|
|
@ -5,8 +5,7 @@ import java.util.List;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
import com.jozufozu.flywheel.backend.RenderWork;
|
import com.jozufozu.flywheel.backend.RenderWork;
|
||||||
import com.jozufozu.flywheel.core.WorldTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.TileInstanceManager;
|
||||||
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.simibubi.create.AllFluids;
|
import com.simibubi.create.AllFluids;
|
||||||
|
@ -157,7 +156,7 @@ public class ClientEvents {
|
||||||
if (world.isRemote() && world instanceof ClientWorld && !(world instanceof WrappedClientWorld)) {
|
if (world.isRemote() && world instanceof ClientWorld && !(world instanceof WrappedClientWorld)) {
|
||||||
CreateClient.invalidateRenderers(world);
|
CreateClient.invalidateRenderers(world);
|
||||||
AnimationTickHolder.reset();
|
AnimationTickHolder.reset();
|
||||||
WorldTileRenderer<WorldProgram> renderer = Backend.tileRenderer.get(world);
|
TileInstanceManager renderer = Backend.tileInstanceManager.get(world);
|
||||||
renderer.invalidate();
|
renderer.invalidate();
|
||||||
((ClientWorld) world).loadedTileEntityList.forEach(renderer::add);
|
((ClientWorld) world).loadedTileEntityList.forEach(renderer::add);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ public class AllCommands {
|
||||||
.then(ConfigCommand.register())
|
.then(ConfigCommand.register())
|
||||||
.then(PonderCommand.register())
|
.then(PonderCommand.register())
|
||||||
.then(CloneCommand.register())
|
.then(CloneCommand.register())
|
||||||
|
.then(GlueCommand.register())
|
||||||
|
|
||||||
// utility
|
// utility
|
||||||
.then(util)
|
.then(util)
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.simibubi.create.foundation.command;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.builder.ArgumentBuilder;
|
||||||
|
import com.simibubi.create.content.contraptions.components.structureMovement.glue.SuperGlueEntity;
|
||||||
|
|
||||||
|
import net.minecraft.command.CommandSource;
|
||||||
|
import net.minecraft.command.Commands;
|
||||||
|
import net.minecraft.command.arguments.BlockPosArgument;
|
||||||
|
import net.minecraft.util.Direction;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.server.ServerWorld;
|
||||||
|
|
||||||
|
public class GlueCommand {
|
||||||
|
public static ArgumentBuilder<CommandSource, ?> register() {
|
||||||
|
return Commands.literal("glue")
|
||||||
|
.requires(cs -> cs.hasPermissionLevel(0))
|
||||||
|
.then(Commands.argument("pos", BlockPosArgument.blockPos())
|
||||||
|
//.then(Commands.argument("direction", EnumArgument.enumArgument(Direction.class))
|
||||||
|
.executes(ctx -> {
|
||||||
|
BlockPos pos = BlockPosArgument.getBlockPos(ctx, "pos");
|
||||||
|
|
||||||
|
ServerWorld world = ctx.getSource().getWorld();
|
||||||
|
SuperGlueEntity entity = new SuperGlueEntity(world, pos, Direction.UP);
|
||||||
|
|
||||||
|
entity.playPlaceSound();
|
||||||
|
world.addEntity(entity);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,8 +2,8 @@ package com.simibubi.create.foundation.data;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.instancing.IRendererFactory;
|
import com.jozufozu.flywheel.backend.instancing.ITileInstanceFactory;
|
||||||
import com.jozufozu.flywheel.backend.instancing.InstancedTileRenderRegistry;
|
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
|
||||||
import com.tterrag.registrate.AbstractRegistrate;
|
import com.tterrag.registrate.AbstractRegistrate;
|
||||||
import com.tterrag.registrate.builders.BuilderCallback;
|
import com.tterrag.registrate.builders.BuilderCallback;
|
||||||
import com.tterrag.registrate.builders.TileEntityBuilder;
|
import com.tterrag.registrate.builders.TileEntityBuilder;
|
||||||
|
@ -20,7 +20,7 @@ import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
public class CreateTileEntityBuilder<T extends TileEntity, P> extends TileEntityBuilder<T, P> {
|
public class CreateTileEntityBuilder<T extends TileEntity, P> extends TileEntityBuilder<T, P> {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private NonNullSupplier<IRendererFactory<? super T>> instanceFactory;
|
private NonNullSupplier<ITileInstanceFactory<? super T>> instanceFactory;
|
||||||
|
|
||||||
public static <T extends TileEntity, P> TileEntityBuilder<T, P> create(AbstractRegistrate<?> owner, P parent,
|
public static <T extends TileEntity, P> TileEntityBuilder<T, P> create(AbstractRegistrate<?> owner, P parent,
|
||||||
String name, BuilderCallback callback, NonNullFunction<TileEntityType<T>, ? extends T> factory) {
|
String name, BuilderCallback callback, NonNullFunction<TileEntityType<T>, ? extends T> factory) {
|
||||||
|
@ -32,7 +32,7 @@ public class CreateTileEntityBuilder<T extends TileEntity, P> extends TileEntity
|
||||||
super(owner, parent, name, callback, factory);
|
super(owner, parent, name, callback, factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CreateTileEntityBuilder<T, P> instance(NonNullSupplier<IRendererFactory<? super T>> instanceFactory) {
|
public CreateTileEntityBuilder<T, P> instance(NonNullSupplier<ITileInstanceFactory<? super T>> instanceFactory) {
|
||||||
if (this.instanceFactory == null) {
|
if (this.instanceFactory == null) {
|
||||||
DistExecutor.runWhenOn(Dist.CLIENT, () -> this::registerInstance);
|
DistExecutor.runWhenOn(Dist.CLIENT, () -> this::registerInstance);
|
||||||
}
|
}
|
||||||
|
@ -44,9 +44,9 @@ public class CreateTileEntityBuilder<T extends TileEntity, P> extends TileEntity
|
||||||
|
|
||||||
protected void registerInstance() {
|
protected void registerInstance() {
|
||||||
OneTimeEventReceiver.addModListener(FMLClientSetupEvent.class, ($) -> {
|
OneTimeEventReceiver.addModListener(FMLClientSetupEvent.class, ($) -> {
|
||||||
NonNullSupplier<IRendererFactory<? super T>> instanceFactory = this.instanceFactory;
|
NonNullSupplier<ITileInstanceFactory<? super T>> instanceFactory = this.instanceFactory;
|
||||||
if (instanceFactory != null) {
|
if (instanceFactory != null) {
|
||||||
InstancedTileRenderRegistry.getInstance().register(getEntry(), instanceFactory.get());
|
InstancedRenderRegistry.getInstance().register(getEntry(), instanceFactory.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.simibubi.create.foundation.mixin.flywheel;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
|
import com.jozufozu.flywheel.backend.instancing.IInstanceRendered;
|
||||||
|
|
||||||
|
import net.minecraft.client.world.ClientWorld;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
|
||||||
|
@Mixin(ClientWorld.class)
|
||||||
|
public class CancelEntityRenderMixin {
|
||||||
|
|
||||||
|
@Inject(at = @At("RETURN"), method = "getAllEntities", cancellable = true)
|
||||||
|
private void filterEntities(CallbackInfoReturnable<Iterable<Entity>> cir) {
|
||||||
|
if (Backend.canUseInstancing()) {
|
||||||
|
Iterable<Entity> entities = cir.getReturnValue();
|
||||||
|
|
||||||
|
ArrayList<Entity> list = Lists.newArrayList(entities);
|
||||||
|
list.removeIf(tile -> tile instanceof IInstanceRendered && !((IInstanceRendered) tile).shouldRenderNormally());
|
||||||
|
|
||||||
|
cir.setReturnValue(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -94,7 +94,7 @@ public class RenderHooksMixin {
|
||||||
|
|
||||||
@Inject(at = @At("TAIL"), method = "scheduleBlockRerenderIfNeeded")
|
@Inject(at = @At("TAIL"), method = "scheduleBlockRerenderIfNeeded")
|
||||||
private void checkUpdate(BlockPos pos, BlockState lastState, BlockState newState, CallbackInfo ci) {
|
private void checkUpdate(BlockPos pos, BlockState lastState, BlockState newState, CallbackInfo ci) {
|
||||||
Backend.tileRenderer.get(world)
|
Backend.tileInstanceManager.get(world)
|
||||||
.update(world.getTileEntity(pos));
|
.update(world.getTileEntity(pos));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class TileRemoveMixin {
|
||||||
@Inject(at = @At("TAIL"), method = "remove")
|
@Inject(at = @At("TAIL"), method = "remove")
|
||||||
private void onRemove(CallbackInfo ci) {
|
private void onRemove(CallbackInfo ci) {
|
||||||
if (world instanceof ClientWorld)
|
if (world instanceof ClientWorld)
|
||||||
Backend.tileRenderer.get(this.world)
|
Backend.tileInstanceManager.get(this.world)
|
||||||
.remove((TileEntity) (Object) this);
|
.remove((TileEntity) (Object) this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
import com.jozufozu.flywheel.backend.Backend;
|
import com.jozufozu.flywheel.backend.Backend;
|
||||||
import com.jozufozu.flywheel.core.WorldTileRenderer;
|
import com.jozufozu.flywheel.backend.instancing.TileInstanceManager;
|
||||||
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
@ -36,7 +35,7 @@ public class TileWorldHookMixin {
|
||||||
@Inject(at = @At("TAIL"), method = "addTileEntity")
|
@Inject(at = @At("TAIL"), method = "addTileEntity")
|
||||||
private void onAddTile(TileEntity te, CallbackInfoReturnable<Boolean> cir) {
|
private void onAddTile(TileEntity te, CallbackInfoReturnable<Boolean> cir) {
|
||||||
if (isRemote) {
|
if (isRemote) {
|
||||||
Backend.tileRenderer.get(self)
|
Backend.tileInstanceManager.get(self)
|
||||||
.queueAdd(te);
|
.queueAdd(te);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +46,7 @@ public class TileWorldHookMixin {
|
||||||
@Inject(at = @At(value = "INVOKE", target = "Ljava/util/Set;clear()V", ordinal = 0), method = "tickBlockEntities")
|
@Inject(at = @At(value = "INVOKE", target = "Ljava/util/Set;clear()V", ordinal = 0), method = "tickBlockEntities")
|
||||||
private void onChunkUnload(CallbackInfo ci) {
|
private void onChunkUnload(CallbackInfo ci) {
|
||||||
if (isRemote) {
|
if (isRemote) {
|
||||||
WorldTileRenderer<WorldProgram> kineticRenderer = Backend.tileRenderer.get(self);
|
TileInstanceManager kineticRenderer = Backend.tileInstanceManager.get(self);
|
||||||
for (TileEntity tile : tileEntitiesToBeRemoved) {
|
for (TileEntity tile : tileEntitiesToBeRemoved) {
|
||||||
kineticRenderer.remove(tile);
|
kineticRenderer.remove(tile);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ public abstract class LightUpdateMixin extends AbstractChunkProvider {
|
||||||
.getY()) == sectionY)
|
.getY()) == sectionY)
|
||||||
.map(Map.Entry::getValue)
|
.map(Map.Entry::getValue)
|
||||||
.forEach(tile -> {
|
.forEach(tile -> {
|
||||||
Backend.tileRenderer.get(world)
|
Backend.tileInstanceManager.get(world)
|
||||||
.onLightUpdate(tile);
|
.onLightUpdate(tile);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class NetworkLightUpdateMixin {
|
||||||
chunk.getTileEntityMap()
|
chunk.getTileEntityMap()
|
||||||
.values()
|
.values()
|
||||||
.forEach(tile -> {
|
.forEach(tile -> {
|
||||||
Backend.tileRenderer.get(world)
|
Backend.tileInstanceManager.get(world)
|
||||||
.onLightUpdate(tile);
|
.onLightUpdate(tile);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,14 +21,11 @@ import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.SoundCategory;
|
import net.minecraft.util.SoundCategory;
|
||||||
import net.minecraft.util.SoundEvent;
|
import net.minecraft.util.SoundEvent;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.SectionPos;
|
|
||||||
import net.minecraft.util.registry.DynamicRegistries;
|
import net.minecraft.util.registry.DynamicRegistries;
|
||||||
import net.minecraft.world.ITickList;
|
import net.minecraft.world.ITickList;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
import net.minecraft.world.chunk.AbstractChunkProvider;
|
import net.minecraft.world.chunk.AbstractChunkProvider;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
|
||||||
import net.minecraft.world.chunk.ChunkSection;
|
|
||||||
import net.minecraft.world.lighting.WorldLightManager;
|
import net.minecraft.world.lighting.WorldLightManager;
|
||||||
import net.minecraft.world.storage.ISpawnWorldInfo;
|
import net.minecraft.world.storage.ISpawnWorldInfo;
|
||||||
import net.minecraft.world.storage.MapData;
|
import net.minecraft.world.storage.MapData;
|
||||||
|
@ -38,7 +35,7 @@ import net.minecraft.world.storage.MapData;
|
||||||
public class WrappedWorld extends World {
|
public class WrappedWorld extends World {
|
||||||
|
|
||||||
protected World world;
|
protected World world;
|
||||||
private AbstractChunkProvider provider;
|
protected AbstractChunkProvider provider;
|
||||||
|
|
||||||
public WrappedWorld(World world, AbstractChunkProvider provider) {
|
public WrappedWorld(World world, AbstractChunkProvider provider) {
|
||||||
super((ISpawnWorldInfo) world.getWorldInfo(), world.getRegistryKey(), world.getDimension(), world::getProfiler,
|
super((ISpawnWorldInfo) world.getWorldInfo(), world.getRegistryKey(), world.getDimension(), world::getProfiler,
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#flwbuiltins
|
#flwbuiltins
|
||||||
#flwinclude <"flywheel:core/diffuse.glsl">
|
#flwinclude <"flywheel:core/diffuse.glsl">
|
||||||
|
|
||||||
|
#flwinclude <"flywheel:data/modelvertex.glsl">
|
||||||
|
#flwinclude <"flywheel:data/blockfragment.glsl">
|
||||||
|
|
||||||
#[InstanceData]
|
#[InstanceData]
|
||||||
struct Instance {
|
struct Instance {
|
||||||
vec2 light;
|
vec2 light;
|
||||||
|
@ -9,9 +12,6 @@ struct Instance {
|
||||||
mat3 normalMat;
|
mat3 normalMat;
|
||||||
};
|
};
|
||||||
|
|
||||||
#flwinclude <"flywheel:data/modelvertex.glsl">
|
|
||||||
#flwinclude <"flywheel:data/blockfragment.glsl">
|
|
||||||
|
|
||||||
BlockFrag FLWMain(Vertex v, Instance i) {
|
BlockFrag FLWMain(Vertex v, Instance i) {
|
||||||
vec4 worldPos = i.transform * vec4(v.pos, 1.);
|
vec4 worldPos = i.transform * vec4(v.pos, 1.);
|
||||||
|
|
||||||
|
|
|
@ -7,14 +7,14 @@
|
||||||
"mixins": [
|
"mixins": [
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
"EntityContraptionInteractionMixin",
|
|
||||||
"FixNormalScalingMixin",
|
|
||||||
"HeavyBootsOnPlayerMixin",
|
|
||||||
"WindowResizeMixin",
|
|
||||||
"ModelDataRefreshMixin",
|
|
||||||
"BreakProgressMixin",
|
"BreakProgressMixin",
|
||||||
"ChromaticProjectorHooksMixin",
|
"ChromaticProjectorHooksMixin",
|
||||||
"EntityContraptionInteractionMixin",
|
"EntityContraptionInteractionMixin",
|
||||||
|
"FixNormalScalingMixin",
|
||||||
|
"HeavyBootsOnPlayerMixin",
|
||||||
|
"ModelDataRefreshMixin",
|
||||||
|
"WindowResizeMixin",
|
||||||
|
"flywheel.CancelEntityRenderMixin",
|
||||||
"flywheel.CancelTileEntityRenderMixin",
|
"flywheel.CancelTileEntityRenderMixin",
|
||||||
"flywheel.FogColorTrackerMixin",
|
"flywheel.FogColorTrackerMixin",
|
||||||
"flywheel.RenderHooksMixin",
|
"flywheel.RenderHooksMixin",
|
||||||
|
|
Loading…
Reference in a new issue