mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-25 06:27:41 +01:00
1.15 port checkpoint: kinetic rendering mostly complete
This commit is contained in:
parent
f16e534a89
commit
1e0711fa95
16 changed files with 117 additions and 85 deletions
|
@ -83,7 +83,7 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft 'net.minecraftforge:forge:1.15.2-31.1.27'
|
minecraft 'net.minecraftforge:forge:1.15.2-31.1.36'
|
||||||
|
|
||||||
// compile against the JEI API but do not include it at runtime
|
// compile against the JEI API but do not include it at runtime
|
||||||
compileOnly fg.deobf("mezz.jei:jei-1.15.2:6.0.0.2:api")
|
compileOnly fg.deobf("mezz.jei:jei-1.15.2:6.0.0.2:api")
|
||||||
|
|
|
@ -5,14 +5,15 @@ import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FAC
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||||
import com.simibubi.create.foundation.utility.Lang;
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
import com.simibubi.create.foundation.utility.SuperByteBuffer;
|
import com.simibubi.create.foundation.utility.SuperByteBuffer;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.client.renderer.Vector3f;
|
||||||
import net.minecraft.client.renderer.model.IBakedModel;
|
import net.minecraft.client.renderer.model.IBakedModel;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Direction.Axis;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||||
|
@ -120,9 +121,13 @@ public enum AllBlockPartials {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SuperByteBuffer renderOnDirectional(BlockState referenceState, Direction facing) {
|
public SuperByteBuffer renderOnDirectional(BlockState referenceState, Direction facing) {
|
||||||
SuperByteBuffer renderPartial = CreateClient.bufferCache.renderPartial(this, referenceState);
|
MatrixStack ms = new MatrixStack();
|
||||||
renderPartial.rotateCentered(Axis.X, AngleHelper.rad(AngleHelper.verticalAngle(facing)));
|
// TODO 1.15 find a way to cache this model matrix computation
|
||||||
renderPartial.rotateCentered(Axis.Y, AngleHelper.rad(AngleHelper.horizontalAngle(facing)));
|
ms.translate(0.5, 0.5, 0.5);
|
||||||
|
ms.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion(AngleHelper.rad(AngleHelper.horizontalAngle(facing))));
|
||||||
|
ms.multiply(Vector3f.POSITIVE_X.getRadialQuaternion(AngleHelper.rad(AngleHelper.verticalAngle(facing))));
|
||||||
|
ms.translate(-0.5, -0.5, -0.5);
|
||||||
|
SuperByteBuffer renderPartial = CreateClient.bufferCache.renderDirectionalPartial(this, referenceState, facing, ms);
|
||||||
return renderPartial;
|
return renderPartial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,11 @@ import com.simibubi.create.modules.contraptions.relays.belt.BeltConnectorItemHan
|
||||||
import com.simibubi.create.modules.curiosities.zapper.terrainzapper.TerrainZapperRenderHandler;
|
import com.simibubi.create.modules.curiosities.zapper.terrainzapper.TerrainZapperRenderHandler;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.client.event.InputEvent.KeyInputEvent;
|
import net.minecraftforge.client.event.InputEvent.KeyInputEvent;
|
||||||
|
@ -70,13 +72,23 @@ public class ClientEvents {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onRenderWorld(RenderWorldLastEvent event) {
|
public static void onRenderWorld(RenderWorldLastEvent event) {
|
||||||
MatrixStack ms = event.getMatrixStack();
|
MatrixStack ms = event.getMatrixStack();
|
||||||
IRenderTypeBuffer buffer = Minecraft.getInstance().getBufferBuilders().getEntityVertexConsumers();
|
ActiveRenderInfo info = Minecraft.getInstance().gameRenderer.getActiveRenderInfo();
|
||||||
|
Vec3d view = info.getProjectedView();
|
||||||
|
|
||||||
|
ms.push();
|
||||||
|
ms.translate(-view.getX(), -view.getY(), -view.getZ());
|
||||||
|
|
||||||
|
IRenderTypeBuffer.Impl buffer = Minecraft.getInstance().getBufferBuilders().getEntityVertexConsumers();
|
||||||
CreateClient.schematicHandler.render(ms, buffer, 0xF000F0, OverlayTexture.DEFAULT_UV);
|
CreateClient.schematicHandler.render(ms, buffer, 0xF000F0, OverlayTexture.DEFAULT_UV);
|
||||||
CreateClient.schematicAndQuillHandler.render(ms, buffer);
|
CreateClient.schematicAndQuillHandler.render(ms, buffer);
|
||||||
CreateClient.schematicHologram.render(ms, buffer);
|
CreateClient.schematicHologram.render(ms, buffer);
|
||||||
KineticDebugger.renderSourceOutline(ms, buffer);
|
KineticDebugger.renderSourceOutline(ms, buffer);
|
||||||
ChassisRangeDisplay.renderOutlines(event.getPartialTicks(), ms, buffer);
|
ChassisRangeDisplay.renderOutlines(event.getPartialTicks(), ms, buffer);
|
||||||
TerrainZapperRenderHandler.render(ms, buffer);
|
TerrainZapperRenderHandler.render(ms, buffer);
|
||||||
|
|
||||||
|
ms.pop();
|
||||||
|
|
||||||
|
buffer.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
package com.simibubi.create.foundation.utility;
|
package com.simibubi.create.foundation.utility;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.ByteOrder;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||||
|
import com.mojang.datafixers.util.Pair;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
import net.minecraft.client.renderer.BufferBuilder;
|
||||||
|
import net.minecraft.client.renderer.BufferBuilder.DrawState;
|
||||||
import net.minecraft.client.renderer.GLAllocation;
|
import net.minecraft.client.renderer.GLAllocation;
|
||||||
import net.minecraft.client.renderer.Matrix4f;
|
import net.minecraft.client.renderer.Matrix4f;
|
||||||
import net.minecraft.client.renderer.Vector4f;
|
import net.minecraft.client.renderer.Vector4f;
|
||||||
|
@ -14,7 +17,6 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Direction.Axis;
|
import net.minecraft.util.Direction.Axis;
|
||||||
import net.minecraft.util.Direction.AxisDirection;
|
import net.minecraft.util.Direction.AxisDirection;
|
||||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
|
||||||
|
|
||||||
public class SuperByteBuffer {
|
public class SuperByteBuffer {
|
||||||
|
|
||||||
|
@ -44,11 +46,12 @@ public class SuperByteBuffer {
|
||||||
private int r, g, b, a;
|
private int r, g, b, a;
|
||||||
|
|
||||||
public SuperByteBuffer(BufferBuilder buf) {
|
public SuperByteBuffer(BufferBuilder buf) {
|
||||||
ByteBuffer original = ObfuscationReflectionHelper.getPrivateValue(BufferBuilder.class, buf, "field_179001_a"); // FIXME speedup
|
Pair<DrawState, ByteBuffer> state = buf.popData();
|
||||||
original.rewind();
|
ByteBuffer original = state.getSecond();
|
||||||
|
original.order(ByteOrder.nativeOrder()); // Vanilla bug, endianness does not carry over into sliced buffers
|
||||||
this.original = original;
|
this.original = original;
|
||||||
|
|
||||||
this.mutable = GLAllocation.createDirectByteBuffer(original.capacity());
|
this.mutable = GLAllocation.createDirectByteBuffer(state.getFirst().getCount() * buf.getVertexFormat().getSize());
|
||||||
this.mutable.order(original.order());
|
this.mutable.order(original.order());
|
||||||
this.mutable.limit(original.limit());
|
this.mutable.limit(original.limit());
|
||||||
mutable.put(this.original);
|
mutable.put(this.original);
|
||||||
|
@ -61,8 +64,8 @@ public class SuperByteBuffer {
|
||||||
original.rewind();
|
original.rewind();
|
||||||
mutable.rewind();
|
mutable.rewind();
|
||||||
|
|
||||||
Matrix4f t = transforms.peek().getModel();
|
Matrix4f t = input.peek().getModel().copy();
|
||||||
t.multiply(input.peek().getModel());
|
t.multiply(transforms.peek().getModel());
|
||||||
for (int vertex = 0; vertex < vertexCount(original); vertex++) {
|
for (int vertex = 0; vertex < vertexCount(original); vertex++) {
|
||||||
Vector4f pos = new Vector4f(getX(original, vertex), getY(original, vertex), getZ(original, vertex), 1F);
|
Vector4f pos = new Vector4f(getX(original, vertex), getY(original, vertex), getZ(original, vertex), 1F);
|
||||||
|
|
||||||
|
@ -94,6 +97,7 @@ public class SuperByteBuffer {
|
||||||
shouldShiftUV = false;
|
shouldShiftUV = false;
|
||||||
shouldColor = false;
|
shouldColor = false;
|
||||||
shouldLight = false;
|
shouldLight = false;
|
||||||
|
mutable.rewind();
|
||||||
return mutable;
|
return mutable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +138,7 @@ public class SuperByteBuffer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SuperByteBuffer rotateCentered(Direction axis, float radians) {
|
public SuperByteBuffer rotateCentered(Direction axis, float radians) {
|
||||||
return translate(-.5f, -.5f, -.5f).rotate(axis, radians).translate(.5f, .5f, .5f);
|
return translate(.5f, .5f, .5f).rotate(axis, radians).translate(-.5f, -.5f, -.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SuperByteBuffer shiftUV(TextureAtlasSprite from, TextureAtlasSprite to) {
|
public SuperByteBuffer shiftUV(TextureAtlasSprite from, TextureAtlasSprite to) {
|
||||||
|
@ -245,7 +249,8 @@ public class SuperByteBuffer {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void putLight(ByteBuffer buffer, int index, int packedLight) {
|
protected void putLight(ByteBuffer buffer, int index, int packedLight) {
|
||||||
buffer.putInt(getBufferPosition(index) + 24, packedLight);
|
buffer.putShort(getBufferPosition(index) + 24, (short) (packedLight & 0xFF));
|
||||||
|
buffer.putShort(getBufferPosition(index) + 26, (short) ((packedLight >> 16) & 0xFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void putColor(ByteBuffer buffer, int index, byte r, byte g, byte b, byte a) {
|
protected void putColor(ByteBuffer buffer, int index, byte r, byte g, byte b, byte a) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.Cache;
|
||||||
|
@ -22,6 +23,7 @@ import net.minecraft.client.renderer.BufferBuilder;
|
||||||
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.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||||
|
|
||||||
|
@ -32,6 +34,7 @@ public class SuperByteBufferCache {
|
||||||
|
|
||||||
public static final Compartment<BlockState> GENERIC_TILE = new Compartment<>();
|
public static final Compartment<BlockState> GENERIC_TILE = new Compartment<>();
|
||||||
public static final Compartment<AllBlockPartials> PARTIAL = new Compartment<>();
|
public static final Compartment<AllBlockPartials> PARTIAL = new Compartment<>();
|
||||||
|
public static final Compartment<Pair<Direction, AllBlockPartials>> DIRECTIONAL_PARTIAL = new Compartment<>();
|
||||||
|
|
||||||
Map<Compartment<?>, Cache<Object, SuperByteBuffer>> cache;
|
Map<Compartment<?>, Cache<Object, SuperByteBuffer>> cache;
|
||||||
|
|
||||||
|
@ -39,6 +42,7 @@ public class SuperByteBufferCache {
|
||||||
cache = new HashMap<>();
|
cache = new HashMap<>();
|
||||||
registerCompartment(GENERIC_TILE);
|
registerCompartment(GENERIC_TILE);
|
||||||
registerCompartment(PARTIAL);
|
registerCompartment(PARTIAL);
|
||||||
|
registerCompartment(DIRECTIONAL_PARTIAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SuperByteBuffer renderBlock(BlockState toRender) {
|
public SuperByteBuffer renderBlock(BlockState toRender) {
|
||||||
|
@ -49,6 +53,18 @@ public class SuperByteBufferCache {
|
||||||
return get(PARTIAL, partial, () -> standardModelRender(partial.get(), referenceState));
|
return get(PARTIAL, partial, () -> standardModelRender(partial.get(), referenceState));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer renderPartial(AllBlockPartials partial, BlockState referenceState, MatrixStack modelTransform) {
|
||||||
|
return get(PARTIAL, partial, () -> standardModelRender(partial.get(), referenceState, modelTransform));
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer renderDirectionalPartial(AllBlockPartials partial, BlockState referenceState, Direction dir) {
|
||||||
|
return get(DIRECTIONAL_PARTIAL, Pair.of(dir, partial), () -> standardModelRender(partial.get(), referenceState));
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuperByteBuffer renderDirectionalPartial(AllBlockPartials partial, BlockState referenceState, Direction dir, MatrixStack modelTransform) {
|
||||||
|
return get(DIRECTIONAL_PARTIAL, Pair.of(dir, partial), () -> standardModelRender(partial.get(), referenceState, modelTransform));
|
||||||
|
}
|
||||||
|
|
||||||
public SuperByteBuffer renderBlockIn(Compartment<BlockState> compartment, BlockState toRender) {
|
public SuperByteBuffer renderBlockIn(Compartment<BlockState> compartment, BlockState toRender) {
|
||||||
return get(compartment, toRender, () -> standardBlockRender(toRender));
|
return get(compartment, toRender, () -> standardBlockRender(toRender));
|
||||||
}
|
}
|
||||||
|
@ -82,16 +98,16 @@ public class SuperByteBufferCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
private SuperByteBuffer standardModelRender(IBakedModel model, BlockState referenceState) {
|
private SuperByteBuffer standardModelRender(IBakedModel model, BlockState referenceState) {
|
||||||
|
return standardModelRender(model, referenceState, new MatrixStack());
|
||||||
|
}
|
||||||
|
|
||||||
|
private SuperByteBuffer standardModelRender(IBakedModel model, BlockState referenceState, MatrixStack ms) {
|
||||||
BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRendererDispatcher();
|
BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRendererDispatcher();
|
||||||
BlockModelRenderer blockRenderer = dispatcher.getBlockModelRenderer();
|
BlockModelRenderer blockRenderer = dispatcher.getBlockModelRenderer();
|
||||||
BufferBuilder builder = new BufferBuilder(0);
|
BufferBuilder builder = new BufferBuilder(DefaultVertexFormats.BLOCK.getIntegerSize());
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
MatrixStack ms = new MatrixStack();
|
|
||||||
ms.push();
|
|
||||||
ms.translate(0, 1, 0);
|
|
||||||
|
|
||||||
builder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
|
builder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
|
||||||
blockRenderer.renderModelFlat(Minecraft.getInstance().world, model, referenceState, BlockPos.ZERO.down(), ms,
|
blockRenderer.renderModelFlat(Minecraft.getInstance().world, model, referenceState, BlockPos.ZERO.up(255), ms,
|
||||||
builder, true, random, 42, OverlayTexture.DEFAULT_UV, EmptyModelData.INSTANCE);
|
builder, true, random, 42, OverlayTexture.DEFAULT_UV, EmptyModelData.INSTANCE);
|
||||||
builder.finishDrawing();
|
builder.finishDrawing();
|
||||||
|
|
||||||
|
|
|
@ -3,17 +3,21 @@ package com.simibubi.create.modules.contraptions;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||||
import com.simibubi.create.config.AllConfigs;
|
import com.simibubi.create.config.AllConfigs;
|
||||||
|
import com.simibubi.create.modules.contraptions.base.IRotate;
|
||||||
import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
|
import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.WorldRenderer;
|
import net.minecraft.client.renderer.WorldRenderer;
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.world.ClientWorld;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.Direction.Axis;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BlockRayTraceResult;
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
|
import net.minecraft.util.math.Vec3i;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
@ -28,6 +32,7 @@ public class KineticDebugger {
|
||||||
|
|
||||||
World world = Minecraft.getInstance().world;
|
World world = Minecraft.getInstance().world;
|
||||||
BlockPos toOutline = te.hasSource() ? te.source : te.getPos();
|
BlockPos toOutline = te.hasSource() ? te.source : te.getPos();
|
||||||
|
BlockState state = te.getBlockState();
|
||||||
VoxelShape shape = world.getBlockState(toOutline).getShape(world, toOutline);
|
VoxelShape shape = world.getBlockState(toOutline).getShape(world, toOutline);
|
||||||
|
|
||||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getLines());
|
IVertexBuilder vb = buffer.getBuffer(RenderType.getLines());
|
||||||
|
@ -39,6 +44,27 @@ public class KineticDebugger {
|
||||||
|
|
||||||
WorldRenderer.func_228431_a_(ms, vb, shape, 0, 0, 0, te.hasSource() ? .5f : 1, .75f, .75f, 1);
|
WorldRenderer.func_228431_a_(ms, vb, shape, 0, 0, 0, te.hasSource() ? .5f : 1, .75f, .75f, 1);
|
||||||
|
|
||||||
|
Vec3i offset = te.getPos().subtract(toOutline);
|
||||||
|
ms.translate(offset.getX(), offset.getY(), offset.getZ());
|
||||||
|
|
||||||
|
if (state.getBlock() instanceof IRotate) {
|
||||||
|
Axis axis = ((IRotate)state.getBlock()).getRotationAxis(state);
|
||||||
|
switch (axis) {
|
||||||
|
case X:
|
||||||
|
vb.vertex(ms.peek().getModel(), 0, 0.5f, 0.5f).color(1f, 1f, 1f, 1f).endVertex();
|
||||||
|
vb.vertex(ms.peek().getModel(), 1, 0.5f, 0.5f).color(1f, 1f, 1f, 1f).endVertex();
|
||||||
|
break;
|
||||||
|
case Y:
|
||||||
|
vb.vertex(ms.peek().getModel(), 0.5f, 0, 0.5f).color(1f, 1f, 1f, 1f).endVertex();
|
||||||
|
vb.vertex(ms.peek().getModel(), 0.5f, 1, 0.5f).color(1f, 1f, 1f, 1f).endVertex();
|
||||||
|
break;
|
||||||
|
case Z:
|
||||||
|
vb.vertex(ms.peek().getModel(), 0.5f, 0.5f, 0).color(1f, 1f, 1f, 1f).endVertex();
|
||||||
|
vb.vertex(ms.peek().getModel(), 0.5f, 0.5f, 1).color(1f, 1f, 1f, 1f).endVertex();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ms.pop();
|
ms.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ public abstract class DirectionalAxisKineticBlock extends DirectionalKineticBloc
|
||||||
if (pistonAxis == Axis.Z)
|
if (pistonAxis == Axis.Z)
|
||||||
return alongFirst ? Axis.X : Axis.Y;
|
return alongFirst ? Axis.X : Axis.Y;
|
||||||
|
|
||||||
return super.getRotationAxis(state);
|
throw new IllegalStateException("Unknown axis??");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -11,7 +11,6 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Direction.Axis;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.IWorld;
|
import net.minecraft.world.IWorld;
|
||||||
|
@ -58,11 +57,6 @@ public abstract class KineticBlock extends Block implements IRotate {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Axis getRotationAxis(BlockState state) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Block
|
// Block
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -12,13 +12,10 @@ import com.simibubi.create.foundation.utility.SuperByteBufferCache.Compartment;
|
||||||
import com.simibubi.create.modules.contraptions.KineticDebugger;
|
import com.simibubi.create.modules.contraptions.KineticDebugger;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.Direction.Axis;
|
import net.minecraft.util.Direction.Axis;
|
||||||
import net.minecraft.util.Direction.AxisDirection;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||||
|
@ -64,7 +61,7 @@ public class KineticTileEntityRenderer extends SafeTileEntityRenderer<KineticTil
|
||||||
public static SuperByteBuffer kineticRotationTransform(SuperByteBuffer buffer, KineticTileEntity te, Axis axis,
|
public static SuperByteBuffer kineticRotationTransform(SuperByteBuffer buffer, KineticTileEntity te, Axis axis,
|
||||||
float angle) {
|
float angle) {
|
||||||
int light = te.getBlockState().getLightValue(te.getWorld(), te.getPos());
|
int light = te.getBlockState().getLightValue(te.getWorld(), te.getPos());
|
||||||
buffer.light((0xF0 << 24) | (light << 4));
|
buffer.light((0xF0 << 16) | (light << 4));
|
||||||
buffer.rotateCentered(axis, angle);
|
buffer.rotateCentered(axis, angle);
|
||||||
|
|
||||||
int white = 0xFFFFFF;
|
int white = 0xFFFFFF;
|
||||||
|
|
|
@ -5,7 +5,6 @@ import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FAC
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||||
import com.simibubi.create.AllBlockPartials;
|
import com.simibubi.create.AllBlockPartials;
|
||||||
import com.simibubi.create.AllBlocks;
|
import com.simibubi.create.AllBlocks;
|
||||||
|
@ -25,12 +24,12 @@ import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
import net.minecraft.client.renderer.ItemRenderer;
|
import net.minecraft.client.renderer.ItemRenderer;
|
||||||
import net.minecraft.client.renderer.RenderHelper;
|
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.Vector3f;
|
import net.minecraft.client.renderer.Vector3f;
|
||||||
import net.minecraft.client.renderer.WorldRenderer;
|
import net.minecraft.client.renderer.WorldRenderer;
|
||||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||||
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Direction.Axis;
|
import net.minecraft.util.Direction.Axis;
|
||||||
import net.minecraft.util.Direction.AxisDirection;
|
import net.minecraft.util.Direction.AxisDirection;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
@ -85,10 +84,14 @@ public class BeltTileEntityRenderer extends SafeTileEntityRenderer<BeltTileEntit
|
||||||
beltBuffer.light(packedLightmapCoords).renderInto(ms, vb);
|
beltBuffer.light(packedLightmapCoords).renderInto(ms, vb);
|
||||||
|
|
||||||
if (te.hasPulley()) {
|
if (te.hasPulley()) {
|
||||||
SuperByteBuffer superBuffer = AllBlockPartials.BELT_PULLEY.renderOn(blockState);
|
// TODO 1.15 find a way to cache this model matrix computation
|
||||||
Axis axis = blockState.get(BeltBlock.HORIZONTAL_FACING).getAxis();
|
MatrixStack modelTransform = new MatrixStack();
|
||||||
superBuffer.rotateCentered(Axis.X, (float) (Math.PI / 2));
|
Direction dir = blockState.get(BeltBlock.HORIZONTAL_FACING);
|
||||||
superBuffer.rotateCentered(Axis.Y, (float) (axis == Axis.X ? 0 : Math.PI / 2));
|
modelTransform.translate(0.5, 0.5, 0.5);
|
||||||
|
modelTransform.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion((float) (dir.getAxis() == Axis.X ? 0 : Math.PI / 2)));
|
||||||
|
modelTransform.multiply(Vector3f.POSITIVE_X.getRadialQuaternion((float) (Math.PI / 2)));
|
||||||
|
modelTransform.translate(-0.5, -0.5, -0.5);
|
||||||
|
SuperByteBuffer superBuffer = CreateClient.bufferCache.renderDirectionalPartial(AllBlockPartials.BELT_PULLEY, blockState, dir, modelTransform);
|
||||||
KineticTileEntityRenderer.standardKineticRotationTransform(superBuffer, te)
|
KineticTileEntityRenderer.standardKineticRotationTransform(superBuffer, te)
|
||||||
.renderInto(ms, vb);
|
.renderInto(ms, vb);
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,4 +78,8 @@ public class GearboxBlock extends RotatedPillarKineticBlock {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Axis getRotationAxis(BlockState state) {
|
||||||
|
return state.get(AXIS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,7 @@
|
||||||
{
|
{
|
||||||
"forge_marker": 1,
|
|
||||||
"defaults": {
|
|
||||||
"model": "create:block/cogwheel"
|
|
||||||
},
|
|
||||||
"variants": {
|
"variants": {
|
||||||
"axis" : {
|
"axis=x" : { "model": "create:block/cogwheel", "x": 90, "y": 90 },
|
||||||
"x": { "x": 90, "y": 90 },
|
"axis=y" : { "model": "create:block/cogwheel" },
|
||||||
"y": {},
|
"axis=z" : { "model": "create:block/cogwheel", "x": 90 }
|
||||||
"z": { "x": 90 }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,14 +1,8 @@
|
||||||
{
|
{
|
||||||
"forge_marker": 1,
|
|
||||||
"defaults": {
|
|
||||||
"model": "create:block/motor"
|
|
||||||
},
|
|
||||||
"variants": {
|
"variants": {
|
||||||
"facing": {
|
"facing=north": { "model": "create:block/motor", "y": 180 },
|
||||||
"north": { "y": 180 },
|
"facing=south": { "model": "create:block/motor" },
|
||||||
"south": { },
|
"facing=east": { "model": "create:block/motor", "y": 270 },
|
||||||
"east": { "y": 270 },
|
"facing=west": { "model": "create:block/motor", "y": 90 }
|
||||||
"west": { "y": 90 }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,13 +1,7 @@
|
||||||
{
|
{
|
||||||
"forge_marker": 1,
|
|
||||||
"defaults": {
|
|
||||||
"model": "create:block/large_cogwheel"
|
|
||||||
},
|
|
||||||
"variants": {
|
"variants": {
|
||||||
"axis" : {
|
"axis=x" : { "model": "create:block/large_cogwheel", "x": 90, "y": 90 },
|
||||||
"x": { "x": 90, "y": 90 },
|
"axis=y" : { "model": "create:block/large_cogwheel" },
|
||||||
"y": {},
|
"axis=z" : { "model": "create:block/large_cogwheel", "x": 90 }
|
||||||
"z": { "x": 90 }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,14 +1,8 @@
|
||||||
{
|
{
|
||||||
"forge_marker": 1,
|
|
||||||
"defaults": {
|
|
||||||
"model": "create:block/mechanical_press_base"
|
|
||||||
},
|
|
||||||
"variants": {
|
"variants": {
|
||||||
"facing": {
|
"facing=north": {"model": "create:block/mechanical_press_base", "y": 0 },
|
||||||
"north": { "y": 0 },
|
"facing=east": {"model": "create:block/mechanical_press_base", "y": 90 },
|
||||||
"east": { "y": 90 },
|
"facing=west": {"model": "create:block/mechanical_press_base", "y": 90 },
|
||||||
"west": { "y": 90 },
|
"facing=south": {"model": "create:block/mechanical_press_base", "y": 0 }
|
||||||
"south": { "y": 0 }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,13 +1,7 @@
|
||||||
{
|
{
|
||||||
"forge_marker": 1,
|
|
||||||
"defaults": {
|
|
||||||
"model": "create:block/shaft"
|
|
||||||
},
|
|
||||||
"variants": {
|
"variants": {
|
||||||
"axis" : {
|
"axis=x" : { "model": "create:block/shaft", "x": 90, "y": 90 },
|
||||||
"x": { "x": 90, "y": 90 },
|
"axis=y" : { "model": "create:block/shaft" },
|
||||||
"y": {},
|
"axis=z" : { "model": "create:block/shaft", "x": 90 }
|
||||||
"z": { "x": 90 }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue