mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-29 08:26:37 +01:00
start working on schematic rendering
This commit is contained in:
parent
d50e07369b
commit
90993ce8e1
8 changed files with 51 additions and 17 deletions
|
@ -31,6 +31,8 @@ import net.minecraftforge.client.event.ModelRegistryEvent;
|
|||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -24,7 +24,7 @@ public class FlyWheelInstance extends KineticTileInstance<FlywheelTileEntity> {
|
|||
protected Direction facing;
|
||||
|
||||
protected InstanceKey<RotatingData> shaft;
|
||||
protected InstanceKey<RotatingData> wheel;
|
||||
// protected InstanceKey<RotatingData> wheel;
|
||||
|
||||
public FlyWheelInstance(InstancedTileRenderer<?> modelManager, FlywheelTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
|
@ -37,28 +37,28 @@ public class FlyWheelInstance extends KineticTileInstance<FlywheelTileEntity> {
|
|||
Direction.Axis axis = ((IRotate) lastState.getBlock()).getRotationAxis(lastState);
|
||||
Consumer<RotatingData> setup = setupFunc(tile.getSpeed(), axis);
|
||||
shaft = shaftModel().setupInstance(setup);
|
||||
wheel = wheelModel().setupInstance(setup);
|
||||
// wheel = wheelModel().setupInstance(setup);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onUpdate() {
|
||||
Direction.Axis axis = ((IRotate) lastState.getBlock()).getRotationAxis(lastState);
|
||||
updateRotation(shaft, axis);
|
||||
updateRotation(wheel, axis);
|
||||
// updateRotation(wheel, axis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLight() {
|
||||
shaft.modifyInstance(this::relight);
|
||||
wheel.modifyInstance(this::relight);
|
||||
// wheel.modifyInstance(this::relight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
shaft.delete();
|
||||
wheel.delete();
|
||||
shaft = null;
|
||||
wheel = null;
|
||||
// wheel.delete();
|
||||
// wheel = null;
|
||||
}
|
||||
|
||||
protected InstancedModel<RotatingData> shaftModel() {
|
||||
|
|
|
@ -69,9 +69,9 @@ public class FlywheelRenderer extends KineticTileEntityRenderer {
|
|||
.renderInto(ms, vb);
|
||||
}
|
||||
|
||||
// kineticRotationTransform(wheel, te, blockState.get(HORIZONTAL_FACING)
|
||||
// .getAxis(), AngleHelper.rad(angle), light);
|
||||
// wheel.renderInto(ms, vb);
|
||||
kineticRotationTransform(wheel, te, blockState.get(HORIZONTAL_FACING)
|
||||
.getAxis(), AngleHelper.rad(angle), light);
|
||||
wheel.renderInto(ms, vb);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public class SchematicHandler {
|
|||
public SchematicHandler() {
|
||||
renderers = new Vector<>(3);
|
||||
for (int i = 0; i < renderers.capacity(); i++)
|
||||
renderers.add(new SchematicRenderer());
|
||||
renderers.add(new SchematicRendererWithInstancing());
|
||||
|
||||
overlay = new SchematicHotbarSlotOverlay();
|
||||
currentTool = Tools.Deploy;
|
||||
|
|
|
@ -34,7 +34,7 @@ public class SchematicRenderer {
|
|||
private final Set<RenderType> startedBufferBuilders = new HashSet<>(getLayerCount());
|
||||
private boolean active;
|
||||
private boolean changed;
|
||||
private SchematicWorld schematic;
|
||||
protected SchematicWorld schematic;
|
||||
private BlockPos anchor;
|
||||
|
||||
public SchematicRenderer() {
|
||||
|
@ -81,7 +81,7 @@ public class SchematicRenderer {
|
|||
buffer);
|
||||
}
|
||||
|
||||
private void redraw(Minecraft minecraft) {
|
||||
protected void redraw(Minecraft minecraft) {
|
||||
usedBlockRenderLayers.clear();
|
||||
startedBufferBuilders.clear();
|
||||
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package com.simibubi.create.content.schematics.client;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.foundation.render.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.contraption.ContraptionKineticRenderer;
|
||||
import com.simibubi.create.foundation.renderState.SuperRenderTypeBuffer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.loading.FMLClientLaunchProvider;
|
||||
|
||||
public class SchematicRendererWithInstancing extends SchematicRenderer {
|
||||
public final ContraptionKineticRenderer tiles;
|
||||
|
||||
public SchematicRendererWithInstancing() {
|
||||
this.tiles = new ContraptionKineticRenderer();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void redraw(Minecraft minecraft) {
|
||||
super.redraw(minecraft);
|
||||
|
||||
tiles.invalidate();
|
||||
|
||||
schematic.getRenderedTileEntities().forEach(tiles::add);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack ms, SuperRenderTypeBuffer buffer) {
|
||||
super.render(ms, buffer);
|
||||
|
||||
//tiles.render(RenderType.getCutoutMipped(), FastRenderDispatcher.getProjectionMatrix(), );
|
||||
}
|
||||
}
|
|
@ -106,7 +106,7 @@ public class FastRenderDispatcher {
|
|||
}
|
||||
|
||||
// copied from GameRenderer.renderWorld
|
||||
private static Matrix4f getProjectionMatrix() {
|
||||
public static Matrix4f getProjectionMatrix() {
|
||||
if (projectionMatrixThisFrame != null) return projectionMatrixThisFrame;
|
||||
|
||||
float partialTicks = AnimationTickHolder.getPartialTicks();
|
||||
|
|
|
@ -68,10 +68,6 @@ public abstract class InstancedModel<D extends InstanceData> extends BufferedMod
|
|||
return instanceCount() == 0;
|
||||
}
|
||||
|
||||
public void clearInstanceData() {
|
||||
|
||||
}
|
||||
|
||||
protected void deleteInternal() {
|
||||
super.deleteInternal();
|
||||
instanceVBO.delete();
|
||||
|
|
Loading…
Reference in a new issue