mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-16 08:13:43 +01:00
Merge branch 'mc1.16/dev' into mc1.16/chromatic-projector
# Conflicts: # src/main/java/com/simibubi/create/foundation/render/backend/Backend.java # src/main/java/com/simibubi/create/foundation/render/backend/ShaderLoader.java # src/main/java/com/simibubi/create/foundation/render/backend/core/BasicProgram.java # src/main/java/com/simibubi/create/foundation/render/backend/gl/GlBuffer.java # src/main/java/com/simibubi/create/foundation/render/backend/gl/GlVertexArray.java # src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/FogSensitiveProgram.java # src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/GlProgram.java # src/main/java/com/simibubi/create/foundation/render/backend/gl/shader/ProgramSpec.java # src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/GlCompat.java # src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/instancing/DrawInstanced.java # src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/instancing/InstancedArrays.java # src/main/java/com/simibubi/create/foundation/render/backend/gl/versioned/instancing/VertexArrayObject.java # src/main/java/com/simibubi/create/foundation/render/backend/instancing/InstancedModel.java # src/main/java/com/simibubi/create/foundation/render/backend/instancing/RenderMaterial.java
This commit is contained in:
commit
37e8e87553
150 changed files with 2998 additions and 2961 deletions
|
@ -1,38 +1,20 @@
|
|||
package com.simibubi.create;
|
||||
|
||||
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
||||
import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.content.contraptions.fluids.FluidTransportBehaviour.AttachmentTypes;
|
||||
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.RenderMaterial;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.content.contraptions.fluids.FluidTransportBehaviour;
|
||||
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
|
||||
public class AllBlockPartials {
|
||||
|
||||
private static final List<AllBlockPartials> all = new ArrayList<>();
|
||||
|
||||
public static final AllBlockPartials SCHEMATICANNON_CONNECTOR = get("schematicannon/connector"),
|
||||
public static final PartialModel SCHEMATICANNON_CONNECTOR = get("schematicannon/connector"),
|
||||
SCHEMATICANNON_PIPE = get("schematicannon/pipe"),
|
||||
|
||||
SHAFTLESS_COGWHEEL = get("cogwheel_shaftless"), SHAFT_HALF = get("shaft_half"),
|
||||
|
@ -123,124 +105,40 @@ public class AllBlockPartials {
|
|||
|
||||
;
|
||||
|
||||
public static final Map<AttachmentTypes, Map<Direction, AllBlockPartials>> PIPE_ATTACHMENTS = map();
|
||||
public static final Map<HeatLevel, AllBlockPartials> BLAZES = map();
|
||||
public static final Map<FluidTransportBehaviour.AttachmentTypes, Map<Direction, PartialModel>> PIPE_ATTACHMENTS = new HashMap<>();
|
||||
public static final Map<BlazeBurnerBlock.HeatLevel, PartialModel> BLAZES = new HashMap<>();
|
||||
|
||||
static {
|
||||
populateMaps();
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
private ResourceLocation modelLocation;
|
||||
private IBakedModel bakedModel;
|
||||
|
||||
private AllBlockPartials() {}
|
||||
|
||||
private static void populateMaps() {
|
||||
for (AttachmentTypes type : AttachmentTypes.values()) {
|
||||
static void populateMaps() {
|
||||
for (FluidTransportBehaviour.AttachmentTypes type : FluidTransportBehaviour.AttachmentTypes.values()) {
|
||||
if (!type.hasModel())
|
||||
continue;
|
||||
Map<Direction, AllBlockPartials> map = map();
|
||||
Map<Direction, PartialModel> map = new HashMap<>();
|
||||
for (Direction d : Iterate.directions) {
|
||||
String asId = Lang.asId(type.name());
|
||||
map.put(d, get("fluid_pipe/" + asId + "/" + Lang.asId(d.getString())));
|
||||
}
|
||||
PIPE_ATTACHMENTS.put(type, map);
|
||||
}
|
||||
for (HeatLevel heat : HeatLevel.values()) {
|
||||
if (heat == HeatLevel.NONE)
|
||||
for (BlazeBurnerBlock.HeatLevel heat : BlazeBurnerBlock.HeatLevel.values()) {
|
||||
if (heat == BlazeBurnerBlock.HeatLevel.NONE)
|
||||
continue;
|
||||
BLAZES.put(heat, get("blaze_burner/blaze/" + heat.getString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static <T, U> Map<T, U> map() {
|
||||
return new HashMap<>();
|
||||
private static PartialModel getEntity(String path) {
|
||||
return new PartialModel(new ResourceLocation(Create.ID, "entity/" + path));
|
||||
}
|
||||
|
||||
private static AllBlockPartials getEntity(String path) {
|
||||
AllBlockPartials partials = new AllBlockPartials();
|
||||
partials.modelLocation = new ResourceLocation(Create.ID, "entity/" + path);
|
||||
all.add(partials);
|
||||
return partials;
|
||||
private static PartialModel get(String path) {
|
||||
return new PartialModel(new ResourceLocation(Create.ID, "block/" + path));
|
||||
}
|
||||
|
||||
private static AllBlockPartials get(String path) {
|
||||
AllBlockPartials partials = new AllBlockPartials();
|
||||
partials.modelLocation = new ResourceLocation(Create.ID, "block/" + path);
|
||||
all.add(partials);
|
||||
return partials;
|
||||
public static void clientInit() {
|
||||
// init static fields
|
||||
}
|
||||
|
||||
public static void onModelRegistry(ModelRegistryEvent event) {
|
||||
for (AllBlockPartials partial : all)
|
||||
ModelLoader.addSpecialModel(partial.modelLocation);
|
||||
}
|
||||
|
||||
public static void onModelBake(ModelBakeEvent event) {
|
||||
Map<ResourceLocation, IBakedModel> modelRegistry = event.getModelRegistry();
|
||||
for (AllBlockPartials partial : all)
|
||||
partial.bakedModel = modelRegistry.get(partial.modelLocation);
|
||||
}
|
||||
|
||||
public IBakedModel get() {
|
||||
return bakedModel;
|
||||
}
|
||||
|
||||
public SuperByteBuffer renderOn(BlockState referenceState) {
|
||||
return CreateClient.bufferCache.renderPartial(this, referenceState);
|
||||
}
|
||||
|
||||
public SuperByteBuffer renderOnDirectionalSouth(BlockState referenceState) {
|
||||
Direction facing = referenceState.get(FACING);
|
||||
return renderOnDirectionalSouth(referenceState, facing);
|
||||
}
|
||||
|
||||
public SuperByteBuffer renderOnDirectional(BlockState referenceState) {
|
||||
Direction facing = referenceState.get(FACING);
|
||||
return renderOnDirectional(referenceState, facing);
|
||||
}
|
||||
|
||||
public SuperByteBuffer renderOnHorizontal(BlockState referenceState) {
|
||||
Direction facing = referenceState.get(HORIZONTAL_FACING);
|
||||
return renderOnDirectionalSouth(referenceState, facing);
|
||||
}
|
||||
|
||||
public SuperByteBuffer renderOnDirectionalSouth(BlockState referenceState, Direction facing) {
|
||||
MatrixStack ms = new MatrixStack();
|
||||
// TODO 1.15 find a way to cache this model matrix computation
|
||||
MatrixStacker.of(ms)
|
||||
.centre()
|
||||
.rotateY(AngleHelper.horizontalAngle(facing))
|
||||
.rotateX(AngleHelper.verticalAngle(facing))
|
||||
.unCentre();
|
||||
return CreateClient.bufferCache.renderDirectionalPartial(this, referenceState, facing, ms);
|
||||
}
|
||||
|
||||
public SuperByteBuffer renderOnDirectional(BlockState referenceState, Direction facing) {
|
||||
MatrixStack ms = new MatrixStack();
|
||||
// TODO 1.15 find a way to cache this model matrix computation
|
||||
MatrixStacker.of(ms)
|
||||
.centre()
|
||||
.rotateY(AngleHelper.horizontalAngle(facing))
|
||||
.rotateX(facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90)
|
||||
.unCentre();
|
||||
return CreateClient.bufferCache.renderDirectionalPartial(this, referenceState, facing, ms);
|
||||
}
|
||||
|
||||
public <M extends InstancedModel<?>> M getModel(RenderMaterial<?, M> mat, BlockState referenceState,
|
||||
Direction facing) {
|
||||
Supplier<MatrixStack> ms = () -> {
|
||||
MatrixStack stack = new MatrixStack();
|
||||
MatrixStacker.of(stack)
|
||||
.centre()
|
||||
.rotateY(AngleHelper.horizontalAngle(facing))
|
||||
.rotateX(AngleHelper.verticalAngle(facing))
|
||||
.unCentre();
|
||||
return stack;
|
||||
};
|
||||
return mat.getModel(this, referenceState, facing, ms);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.simibubi.create.foundation.render.KineticRenderer;
|
|||
import com.simibubi.create.foundation.render.SuperByteBufferCache;
|
||||
import com.simibubi.create.foundation.render.backend.Backend;
|
||||
import com.simibubi.create.foundation.render.backend.OptifineHandler;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
|
||||
import com.simibubi.create.foundation.utility.WorldAttached;
|
||||
import com.simibubi.create.foundation.utility.ghost.GhostBlocks;
|
||||
|
@ -115,6 +116,8 @@ public class CreateClient {
|
|||
.getResourceManager();
|
||||
if (resourceManager instanceof IReloadableResourceManager)
|
||||
((IReloadableResourceManager) resourceManager).addReloadListener(new ResourceReloadHandler());
|
||||
|
||||
AllBlockPartials.clientInit();
|
||||
}
|
||||
|
||||
public static void onTextureStitch(TextureStitchEvent.Pre event) {
|
||||
|
@ -128,7 +131,7 @@ public class CreateClient {
|
|||
|
||||
public static void onModelBake(ModelBakeEvent event) {
|
||||
Map<ResourceLocation, IBakedModel> modelRegistry = event.getModelRegistry();
|
||||
AllBlockPartials.onModelBake(event);
|
||||
PartialModel.onModelBake(event);
|
||||
|
||||
getCustomBlockModels()
|
||||
.foreach((block, modelFunc) -> swapModels(modelRegistry, getAllBlockStateModelLocations(block), modelFunc));
|
||||
|
@ -141,7 +144,7 @@ public class CreateClient {
|
|||
}
|
||||
|
||||
public static void onModelRegistry(ModelRegistryEvent event) {
|
||||
AllBlockPartials.onModelRegistry(event);
|
||||
PartialModel.onModelRegistry(event);
|
||||
|
||||
getCustomRenderedItems().foreach((item, modelFunc) -> modelFunc.apply(null)
|
||||
.getModelLocations()
|
||||
|
|
|
@ -28,7 +28,7 @@ public abstract class ProcessingViaFanCategory<T extends IRecipe<?>> extends Cre
|
|||
public ProcessingViaFanCategory(IDrawable icon) {
|
||||
this(177, icon);
|
||||
}
|
||||
|
||||
|
||||
protected ProcessingViaFanCategory(int width, IDrawable icon) {
|
||||
super(icon, emptyBackground(width, 71));
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.simibubi.create.AllBlockPartials;
|
|||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel;
|
||||
import com.simibubi.create.foundation.gui.GuiGameElement;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
|
||||
import mezz.jei.api.gui.drawable.IDrawable;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
|
@ -30,7 +31,7 @@ public class AnimatedBlazeBurner implements IDrawable {
|
|||
.scale(scale)
|
||||
.render(matrixStack);
|
||||
|
||||
AllBlockPartials blaze = AllBlockPartials.BLAZES.get(heatLevel);
|
||||
PartialModel blaze = AllBlockPartials.BLAZES.get(heatLevel);
|
||||
GuiGameElement.of(blaze)
|
||||
.atLocal(1, 1.65, 1)
|
||||
.rotate(0, 180, 0)
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.simibubi.create.compat.jei.category.animations;
|
|||
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
||||
import mezz.jei.api.gui.drawable.IDrawable;
|
||||
|
@ -14,15 +15,15 @@ public abstract class AnimatedKinetics implements IDrawable {
|
|||
public static float getCurrentAngle() {
|
||||
return ((AnimationTickHolder.getRenderTime()) * 4f) % 360;
|
||||
}
|
||||
|
||||
|
||||
protected BlockState shaft(Axis axis) {
|
||||
return AllBlocks.SHAFT.getDefaultState().with(BlockStateProperties.AXIS, axis);
|
||||
}
|
||||
|
||||
protected AllBlockPartials cogwheel() {
|
||||
|
||||
protected PartialModel cogwheel() {
|
||||
return AllBlockPartials.SHAFTLESS_COGWHEEL;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 50;
|
||||
|
|
|
@ -20,7 +20,7 @@ public class AnimatedMillstone extends AnimatedKinetics {
|
|||
.rotateBlock(22.5, getCurrentAngle() * 2, 0)
|
||||
.scale(scale)
|
||||
.render(matrixStack);
|
||||
|
||||
|
||||
GuiGameElement.of(AllBlocks.MILLSTONE.getDefaultState())
|
||||
.rotateBlock(22.5, 22.5, 0)
|
||||
.scale(scale)
|
||||
|
|
|
@ -14,9 +14,9 @@ public class HalfShaftInstance extends SingleRotatingInstance {
|
|||
|
||||
@Override
|
||||
protected InstancedModel<RotatingData> getModel() {
|
||||
Direction dir = getShaftDirection();
|
||||
return AllBlockPartials.SHAFT_HALF.getModel(getRotatingMaterial(), blockState, dir);
|
||||
}
|
||||
Direction dir = getShaftDirection();
|
||||
return getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, blockState, dir);
|
||||
}
|
||||
|
||||
protected Direction getShaftDirection() {
|
||||
return blockState.get(BlockStateProperties.FACING);
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
|
|||
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
public class DrillInstance extends SingleRotatingInstance {
|
||||
|
||||
|
@ -20,6 +21,7 @@ public class DrillInstance extends SingleRotatingInstance {
|
|||
@Override
|
||||
protected InstancedModel<RotatingData> getModel() {
|
||||
BlockState referenceState = tile.getBlockState();
|
||||
return AllBlockPartials.DRILL_HEAD.getModel(getRotatingMaterial(), referenceState, referenceState.get(FACING));
|
||||
Direction facing = referenceState.get(FACING);
|
||||
return getRotatingMaterial().getModel(AllBlockPartials.DRILL_HEAD, referenceState, facing);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.simibubi.create.AllBlockPartials;
|
|||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
@ -25,22 +26,18 @@ public class DrillRenderer extends KineticTileEntityRenderer {
|
|||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
|
||||
return AllBlockPartials.DRILL_HEAD.renderOnDirectionalSouth(te.getBlockState());
|
||||
}
|
||||
|
||||
protected static SuperByteBuffer getRotatingModel(BlockState state) {
|
||||
return AllBlockPartials.DRILL_HEAD.renderOnDirectionalSouth(state);
|
||||
return PartialBufferer.getFacing(AllBlockPartials.DRILL_HEAD, te.getBlockState());
|
||||
}
|
||||
|
||||
public static void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal,
|
||||
IRenderTypeBuffer buffer) {
|
||||
MatrixStack[] matrixStacks = new MatrixStack[] { ms, msLocal };
|
||||
MatrixStack[] matrixStacks = new MatrixStack[]{ms, msLocal};
|
||||
BlockState state = context.state;
|
||||
SuperByteBuffer superBuffer = AllBlockPartials.DRILL_HEAD.renderOn(state);
|
||||
SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.DRILL_HEAD, state);
|
||||
Direction facing = state.get(DrillBlock.FACING);
|
||||
|
||||
|
||||
float speed = (float) (context.contraption.stalled
|
||||
|| !VecHelper.isVecPointingTowards(context.relativeMotion, facing
|
||||
|| !VecHelper.isVecPointingTowards(context.relativeMotion, facing
|
||||
.getOpposite()) ? context.getAnimationSpeed() : 0);
|
||||
float time = AnimationTickHolder.getRenderTime() / 20;
|
||||
float angle = (float) (((time * speed) % 360));
|
||||
|
@ -52,11 +49,11 @@ public class DrillRenderer extends KineticTileEntityRenderer {
|
|||
.rotateX(AngleHelper.verticalAngle(facing))
|
||||
.rotateZ(angle)
|
||||
.unCentre();
|
||||
|
||||
|
||||
superBuffer
|
||||
.light(msLocal.peek()
|
||||
.getModel())
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
|||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
|
@ -31,28 +32,28 @@ public class HarvesterRenderer extends SafeTileEntityRenderer<HarvesterTileEntit
|
|||
protected void renderSafe(HarvesterTileEntity te, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffer,
|
||||
int light, int overlay) {
|
||||
BlockState blockState = te.getBlockState();
|
||||
SuperByteBuffer superBuffer = AllBlockPartials.HARVESTER_BLADE.renderOn(blockState);
|
||||
SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.HARVESTER_BLADE, blockState);
|
||||
transform(te.getWorld(), blockState.get(HarvesterBlock.HORIZONTAL_FACING), superBuffer,
|
||||
te.manuallyAnimatedSpeed);
|
||||
te.manuallyAnimatedSpeed);
|
||||
superBuffer.light(light)
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.getCutoutMipped()));
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.getCutoutMipped()));
|
||||
}
|
||||
|
||||
public static void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal,
|
||||
IRenderTypeBuffer buffers) {
|
||||
BlockState blockState = context.state;
|
||||
Direction facing = blockState.get(HORIZONTAL_FACING);
|
||||
SuperByteBuffer superBuffer = AllBlockPartials.HARVESTER_BLADE.renderOn(blockState);
|
||||
SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.HARVESTER_BLADE, blockState);
|
||||
float speed = (float) (!VecHelper.isVecPointingTowards(context.relativeMotion, facing.getOpposite())
|
||||
? context.getAnimationSpeed()
|
||||
: 0);
|
||||
? context.getAnimationSpeed()
|
||||
: 0);
|
||||
if (context.contraption.stalled)
|
||||
speed = 0;
|
||||
|
||||
transform(context.world, facing, superBuffer, speed);
|
||||
|
||||
superBuffer.light(msLocal.peek()
|
||||
.getModel(), ContraptionRenderDispatcher.getLightOnContraption(context))
|
||||
.getModel(), ContraptionRenderDispatcher.getLightOnContraption(context))
|
||||
.renderInto(ms, buffers.getBuffer(RenderType.getCutoutMipped()));
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,9 @@ import com.simibubi.create.AllBlockPartials;
|
|||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
@ -63,16 +65,16 @@ public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer<Por
|
|||
for (MatrixStack ms : matrixStacks)
|
||||
ms.push();
|
||||
|
||||
SuperByteBuffer middle = getMiddleForState(blockState, lit).renderOn(blockState);
|
||||
SuperByteBuffer top = getTopForState(blockState).renderOn(blockState);
|
||||
SuperByteBuffer middle = PartialBufferer.get(getMiddleForState(blockState, lit), blockState);
|
||||
SuperByteBuffer top = PartialBufferer.get(getTopForState(blockState), blockState);
|
||||
|
||||
Direction facing = blockState.get(PortableStorageInterfaceBlock.FACING);
|
||||
for (MatrixStack ms : matrixStacks)
|
||||
MatrixStacker.of(ms)
|
||||
.centre()
|
||||
.rotateY(AngleHelper.horizontalAngle(facing))
|
||||
.rotateX(facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90)
|
||||
.unCentre();
|
||||
.centre()
|
||||
.rotateY(AngleHelper.horizontalAngle(facing))
|
||||
.rotateX(facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90)
|
||||
.unCentre();
|
||||
|
||||
for (MatrixStack ms : matrixStacks) {
|
||||
ms.translate(0, progress / 2f, 0);
|
||||
|
@ -109,7 +111,7 @@ public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer<Por
|
|||
return psi;
|
||||
}
|
||||
|
||||
static AllBlockPartials getMiddleForState(BlockState state, boolean lit) {
|
||||
static PartialModel getMiddleForState(BlockState state, boolean lit) {
|
||||
if (AllBlocks.PORTABLE_FLUID_INTERFACE.has(state))
|
||||
return lit ? AllBlockPartials.PORTABLE_FLUID_INTERFACE_MIDDLE_POWERED
|
||||
: AllBlockPartials.PORTABLE_FLUID_INTERFACE_MIDDLE;
|
||||
|
@ -117,7 +119,7 @@ public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer<Por
|
|||
: AllBlockPartials.PORTABLE_STORAGE_INTERFACE_MIDDLE;
|
||||
}
|
||||
|
||||
static AllBlockPartials getTopForState(BlockState state) {
|
||||
static PartialModel getTopForState(BlockState state) {
|
||||
if (AllBlocks.PORTABLE_FLUID_INTERFACE.has(state))
|
||||
return AllBlockPartials.PORTABLE_FLUID_INTERFACE_TOP;
|
||||
return AllBlockPartials.PORTABLE_STORAGE_INTERFACE_TOP;
|
||||
|
|
|
@ -6,7 +6,9 @@ import com.simibubi.create.AllBlockPartials;
|
|||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.clock.CuckooClockTileEntity.Animation;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -38,18 +40,18 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
|
|||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||
|
||||
// Render Hands
|
||||
SuperByteBuffer hourHand = AllBlockPartials.CUCKOO_HOUR_HAND.renderOn(blockState);
|
||||
SuperByteBuffer minuteHand = AllBlockPartials.CUCKOO_MINUTE_HAND.renderOn(blockState);
|
||||
SuperByteBuffer hourHand = PartialBufferer.get(AllBlockPartials.CUCKOO_HOUR_HAND, blockState);
|
||||
SuperByteBuffer minuteHand = PartialBufferer.get(AllBlockPartials.CUCKOO_MINUTE_HAND, blockState);
|
||||
float hourAngle = clock.hourHand.get(partialTicks);
|
||||
float minuteAngle = clock.minuteHand.get(partialTicks);
|
||||
rotateHand(hourHand, hourAngle, direction).light(packedLightmapCoords)
|
||||
.renderInto(ms, vb);
|
||||
.renderInto(ms, vb);
|
||||
rotateHand(minuteHand, minuteAngle, direction).light(packedLightmapCoords)
|
||||
.renderInto(ms, vb);
|
||||
.renderInto(ms, vb);
|
||||
|
||||
// Doors
|
||||
SuperByteBuffer leftDoor = AllBlockPartials.CUCKOO_LEFT_DOOR.renderOn(blockState);
|
||||
SuperByteBuffer rightDoor = AllBlockPartials.CUCKOO_RIGHT_DOOR.renderOn(blockState);
|
||||
SuperByteBuffer leftDoor = PartialBufferer.get(AllBlockPartials.CUCKOO_LEFT_DOOR, blockState);
|
||||
SuperByteBuffer rightDoor = PartialBufferer.get(AllBlockPartials.CUCKOO_RIGHT_DOOR, blockState);
|
||||
float angle = 0;
|
||||
float offset = 0;
|
||||
|
||||
|
@ -78,13 +80,13 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
|
|||
// Figure
|
||||
if (clock.animationType != Animation.NONE) {
|
||||
offset = -(angle / 135) * 1 / 2f + 10 / 16f;
|
||||
PartialModel partialModel = (clock.animationType == Animation.PIG ? AllBlockPartials.CUCKOO_PIG : AllBlockPartials.CUCKOO_CREEPER);
|
||||
SuperByteBuffer figure =
|
||||
(clock.animationType == Animation.PIG ? AllBlockPartials.CUCKOO_PIG : AllBlockPartials.CUCKOO_CREEPER)
|
||||
.renderOn(blockState);
|
||||
PartialBufferer.get(partialModel, blockState);
|
||||
figure.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(direction.rotateYCCW())));
|
||||
figure.translate(offset, 0, 0);
|
||||
figure.light(packedLightmapCoords)
|
||||
.renderInto(ms, vb);
|
||||
.renderInto(ms, vb);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -94,10 +96,10 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
|
|||
return transform(AllBlockPartials.SHAFT_HALF, te);
|
||||
}
|
||||
|
||||
private SuperByteBuffer transform(AllBlockPartials partial, KineticTileEntity te) {
|
||||
return partial.renderOnDirectionalSouth(te.getBlockState(), te.getBlockState()
|
||||
.get(CuckooClockBlock.HORIZONTAL_FACING)
|
||||
.getOpposite());
|
||||
private SuperByteBuffer transform(PartialModel partial, KineticTileEntity te) {
|
||||
return PartialBufferer.getFacing(partial, te.getBlockState(), te.getBlockState()
|
||||
.get(CuckooClockBlock.HORIZONTAL_FACING)
|
||||
.getOpposite());
|
||||
}
|
||||
|
||||
private SuperByteBuffer rotateHand(SuperByteBuffer buffer, float angle, Direction facing) {
|
||||
|
|
|
@ -9,8 +9,10 @@ import com.simibubi.create.AllBlockPartials;
|
|||
import com.simibubi.create.AllSpriteShifts;
|
||||
import com.simibubi.create.content.contraptions.components.crafter.MechanicalCrafterTileEntity.Phase;
|
||||
import com.simibubi.create.content.contraptions.components.crafter.RecipeGridHandler.GroupedItems;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
@ -155,7 +157,7 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
|
|||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||
|
||||
if (!FastRenderDispatcher.available(te.getWorld())) {
|
||||
SuperByteBuffer superBuffer = AllBlockPartials.SHAFTLESS_COGWHEEL.renderOn(blockState);
|
||||
SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.SHAFTLESS_COGWHEEL, blockState);
|
||||
standardKineticRotationTransform(superBuffer, te, light);
|
||||
superBuffer.rotateCentered(Direction.UP, (float) (blockState.get(HORIZONTAL_FACING).getAxis() != Direction.Axis.X ? 0 : Math.PI / 2));
|
||||
superBuffer.rotateCentered(Direction.EAST, (float) (Math.PI / 2));
|
||||
|
@ -180,7 +182,7 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
|
|||
if (te.phase == Phase.EXPORTING) {
|
||||
int textureIndex = (int) ((te.getCountDownSpeed() / 128f * AnimationTickHolder.getTicks()));
|
||||
beltBuffer.shiftUVtoSheet(AllSpriteShifts.CRAFTER_THINGIES, (textureIndex % 4) / 4f, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
beltBuffer.renderInto(ms, vb);
|
||||
beltFrameBuffer.renderInto(ms, vb);
|
||||
|
@ -193,11 +195,11 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
|
|||
|
||||
}
|
||||
|
||||
private SuperByteBuffer renderAndTransform(MechanicalCrafterTileEntity te, AllBlockPartials renderBlock,
|
||||
private SuperByteBuffer renderAndTransform(MechanicalCrafterTileEntity te, PartialModel renderBlock,
|
||||
BlockState crafterState, BlockPos pos) {
|
||||
SuperByteBuffer buffer = renderBlock.renderOn(crafterState);
|
||||
SuperByteBuffer buffer = PartialBufferer.get(renderBlock, crafterState);
|
||||
float xRot = crafterState.get(MechanicalCrafterBlock.POINTING)
|
||||
.getXRotation();
|
||||
.getXRotation();
|
||||
float yRot = AngleHelper.horizontalAngle(crafterState.get(HORIZONTAL_FACING));
|
||||
buffer.rotateCentered(Direction.UP, (float) ((yRot + 90) / 180 * Math.PI));
|
||||
buffer.rotateCentered(Direction.EAST, (float) ((xRot) / 180 * Math.PI));
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.simibubi.create.AllTileEntities;
|
|||
import com.simibubi.create.content.contraptions.base.DirectionalKineticBlock;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
import com.simibubi.create.foundation.config.AllConfigs;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
|
@ -38,12 +39,12 @@ public class HandCrankBlock extends DirectionalKineticBlock implements ITE<HandC
|
|||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
||||
return AllShapes.CRANK.get(state.get(FACING));
|
||||
}
|
||||
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AllBlockPartials getRenderedHandle() {
|
||||
public PartialModel getRenderedHandle() {
|
||||
return AllBlockPartials.HAND_CRANK_HANDLE;
|
||||
}
|
||||
|
||||
|
||||
public int getRotationSpeed() {
|
||||
return 32;
|
||||
}
|
||||
|
@ -117,7 +118,7 @@ public class HandCrankBlock extends DirectionalKineticBlock implements ITE<HandC
|
|||
public Class<HandCrankTileEntity> getTileEntityClass() {
|
||||
return HandCrankTileEntity.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) {
|
||||
return false;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package com.simibubi.create.content.contraptions.components.crank;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.SingleRotatingInstance;
|
||||
import com.simibubi.create.foundation.render.backend.core.ModelData;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
|
||||
|
@ -22,21 +22,22 @@ public class HandCrankInstance extends SingleRotatingInstance implements IDynami
|
|||
|
||||
public HandCrankInstance(InstancedTileRenderer<?> modelManager, HandCrankTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
this.tile = tile;
|
||||
this.tile = tile;
|
||||
|
||||
Block block = blockState.getBlock();
|
||||
AllBlockPartials renderedHandle = null;
|
||||
if (block instanceof HandCrankBlock)
|
||||
renderedHandle = ((HandCrankBlock) block).getRenderedHandle();
|
||||
if (renderedHandle == null)
|
||||
return;
|
||||
Block block = blockState.getBlock();
|
||||
PartialModel renderedHandle = null;
|
||||
if (block instanceof HandCrankBlock)
|
||||
renderedHandle = ((HandCrankBlock) block).getRenderedHandle();
|
||||
if (renderedHandle == null)
|
||||
return;
|
||||
|
||||
facing = blockState.get(BlockStateProperties.FACING);
|
||||
InstancedModel<ModelData> model = renderedHandle.getModel(getTransformMaterial(), blockState, facing.getOpposite());
|
||||
crank = model.createInstance();
|
||||
facing = blockState.get(BlockStateProperties.FACING);
|
||||
Direction opposite = facing.getOpposite();
|
||||
InstancedModel<ModelData> model = getTransformMaterial().getModel(renderedHandle, blockState, opposite);
|
||||
crank = model.createInstance();
|
||||
|
||||
rotateCrank();
|
||||
}
|
||||
rotateCrank();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beginFrame() {
|
||||
|
|
|
@ -3,11 +3,12 @@ package com.simibubi.create.content.contraptions.components.crank;
|
|||
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -31,17 +32,17 @@ public class HandCrankRenderer extends KineticTileEntityRenderer {
|
|||
|
||||
BlockState state = te.getBlockState();
|
||||
Block block = state.getBlock();
|
||||
AllBlockPartials renderedHandle = null;
|
||||
PartialModel renderedHandle = null;
|
||||
if (block instanceof HandCrankBlock)
|
||||
renderedHandle = ((HandCrankBlock) block).getRenderedHandle();
|
||||
if (renderedHandle == null)
|
||||
return;
|
||||
|
||||
Direction facing = state.get(FACING);
|
||||
SuperByteBuffer handle = renderedHandle.renderOnDirectionalSouth(state, facing.getOpposite());
|
||||
SuperByteBuffer handle = PartialBufferer.getFacing(renderedHandle, state, facing.getOpposite());
|
||||
HandCrankTileEntity crank = (HandCrankTileEntity) te;
|
||||
kineticRotationTransform(handle, te, facing.getAxis(),
|
||||
(crank.independentAngle + partialTicks * crank.chasingVelocity) / 360, light);
|
||||
(crank.independentAngle + partialTicks * crank.chasingVelocity) / 360, light);
|
||||
handle.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.components.crank;
|
|||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.utility.DyeHelper;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -68,7 +68,7 @@ public class ValveHandleBlock extends HandCrankBlock {
|
|||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public AllBlockPartials getRenderedHandle() {
|
||||
public PartialModel getRenderedHandle() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import com.simibubi.create.content.contraptions.components.structureMovement.ren
|
|||
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.backend.core.ModelData;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.RenderMaterial;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
|
@ -48,7 +49,7 @@ public class DeployerActorInstance extends ActorInstance {
|
|||
|
||||
BlockState state = context.state;
|
||||
DeployerTileEntity.Mode mode = NBTHelper.readEnum(context.tileData, "Mode", DeployerTileEntity.Mode.class);
|
||||
AllBlockPartials handPose = DeployerRenderer.getHandPose(mode);
|
||||
PartialModel handPose = DeployerRenderer.getHandPose(mode);
|
||||
|
||||
stationaryTimer = context.data.contains("StationaryTimer");
|
||||
facing = state.get(FACING);
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.simibubi.create.AllBlockPartials;
|
|||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.relays.encased.ShaftInstance;
|
||||
import com.simibubi.create.foundation.render.backend.core.OrientedData;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.ITickableInstance;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
|
||||
|
@ -31,7 +32,7 @@ public class DeployerInstance extends ShaftInstance implements IDynamicInstance,
|
|||
|
||||
protected OrientedData hand;
|
||||
|
||||
AllBlockPartials currentHand;
|
||||
PartialModel currentHand;
|
||||
float progress;
|
||||
private boolean newHand = false;
|
||||
|
||||
|
@ -89,7 +90,7 @@ public class DeployerInstance extends ShaftInstance implements IDynamicInstance,
|
|||
}
|
||||
|
||||
private boolean updateHandPose() {
|
||||
AllBlockPartials handPose = tile.getHandPose();
|
||||
PartialModel handPose = tile.getHandPose();
|
||||
|
||||
if (currentHand == handPose) return false;
|
||||
currentHand = handPose;
|
||||
|
|
|
@ -11,8 +11,10 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
|||
import com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity.Mode;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer;
|
||||
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
|
@ -117,14 +119,13 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
|
|||
BlockPos pos = te.getPos();
|
||||
Vector3d offset = getHandOffset(te, partialTicks, blockState);
|
||||
|
||||
SuperByteBuffer pole = AllBlockPartials.DEPLOYER_POLE.renderOn(blockState);
|
||||
SuperByteBuffer hand = te.getHandPose()
|
||||
.renderOn(blockState);
|
||||
SuperByteBuffer pole = PartialBufferer.get(AllBlockPartials.DEPLOYER_POLE, blockState);
|
||||
SuperByteBuffer hand = PartialBufferer.get(te.getHandPose(), blockState);
|
||||
|
||||
transform(te.getWorld(), pole.translate(offset.x, offset.y, offset.z), blockState, pos, true).renderInto(ms,
|
||||
vb);
|
||||
vb);
|
||||
transform(te.getWorld(), hand.translate(offset.x, offset.y, offset.z), blockState, pos, false).renderInto(ms,
|
||||
vb);
|
||||
vb);
|
||||
}
|
||||
|
||||
protected Vector3d getHandOffset(DeployerTileEntity te, float partialTicks, BlockState blockState) {
|
||||
|
@ -155,16 +156,16 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
|
|||
|
||||
public static void renderInContraption(MovementContext context, MatrixStack ms, MatrixStack msLocal,
|
||||
IRenderTypeBuffer buffer) {
|
||||
MatrixStack[] matrixStacks = new MatrixStack[] { ms, msLocal };
|
||||
MatrixStack[] matrixStacks = new MatrixStack[]{ms, msLocal};
|
||||
IVertexBuilder builder = buffer.getBuffer(RenderType.getSolid());
|
||||
BlockState blockState = context.state;
|
||||
BlockPos pos = BlockPos.ZERO;
|
||||
Mode mode = NBTHelper.readEnum(context.tileData, "Mode", Mode.class);
|
||||
World world = context.world;
|
||||
AllBlockPartials handPose = getHandPose(mode);
|
||||
PartialModel handPose = getHandPose(mode);
|
||||
|
||||
SuperByteBuffer pole = AllBlockPartials.DEPLOYER_POLE.renderOn(blockState);
|
||||
SuperByteBuffer hand = handPose.renderOn(blockState);
|
||||
SuperByteBuffer pole = PartialBufferer.get(AllBlockPartials.DEPLOYER_POLE, blockState);
|
||||
SuperByteBuffer hand = PartialBufferer.get(handPose, blockState);
|
||||
pole = transform(world, pole, blockState, pos, true);
|
||||
hand = transform(world, hand, blockState, pos, false);
|
||||
|
||||
|
@ -192,7 +193,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
|
|||
.renderInto(ms, builder);
|
||||
}
|
||||
|
||||
static AllBlockPartials getHandPose(DeployerTileEntity.Mode mode) {
|
||||
static PartialModel getHandPose(DeployerTileEntity.Mode mode) {
|
||||
return mode == DeployerTileEntity.Mode.PUNCH ? AllBlockPartials.DEPLOYER_HAND_PUNCHING : AllBlockPartials.DEPLOYER_HAND_POINTING;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
|||
import com.simibubi.create.content.curiosities.tools.SandPaperItem;
|
||||
import com.simibubi.create.foundation.advancement.AllTriggers;
|
||||
import com.simibubi.create.foundation.item.TooltipHelper;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour;
|
||||
import com.simibubi.create.foundation.utility.NBTHelper;
|
||||
|
@ -113,7 +114,7 @@ public class DeployerTileEntity extends KineticTileEntity {
|
|||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
|
||||
|
||||
if (getSpeed() == 0)
|
||||
return;
|
||||
if (!world.isRemote && player != null && player.blockBreakingProgress != null) {
|
||||
|
@ -331,7 +332,7 @@ public class DeployerTileEntity extends KineticTileEntity {
|
|||
private IItemHandlerModifiable createHandler() {
|
||||
return new DeployerItemHandler(this);
|
||||
}
|
||||
|
||||
|
||||
public void redstoneUpdate() {
|
||||
if (world.isRemote)
|
||||
return;
|
||||
|
@ -342,7 +343,7 @@ public class DeployerTileEntity extends KineticTileEntity {
|
|||
sendData();
|
||||
}
|
||||
|
||||
public AllBlockPartials getHandPose() {
|
||||
public PartialModel getHandPose() {
|
||||
return mode == Mode.PUNCH ? AllBlockPartials.DEPLOYER_HAND_PUNCHING
|
||||
: heldItem.isEmpty() ? AllBlockPartials.DEPLOYER_HAND_POINTING : AllBlockPartials.DEPLOYER_HAND_HOLDING;
|
||||
}
|
||||
|
@ -395,7 +396,7 @@ public class DeployerTileEntity extends KineticTileEntity {
|
|||
|
||||
float progress = 0;
|
||||
int timerSpeed = getTimerSpeed();
|
||||
AllBlockPartials handPose = getHandPose();
|
||||
PartialModel handPose = getHandPose();
|
||||
|
||||
if (state == State.EXPANDING)
|
||||
progress = 1 - (timer - partialTicks * timerSpeed) / 1000f;
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.mojang.blaze3d.vertex.IVertexBuilder;
|
|||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
@ -30,17 +31,17 @@ public class EncasedFanRenderer extends KineticTileEntityRenderer {
|
|||
if (FastRenderDispatcher.available(te.getWorld())) return;
|
||||
|
||||
Direction direction = te.getBlockState()
|
||||
.get(FACING);
|
||||
.get(FACING);
|
||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getCutoutMipped());
|
||||
|
||||
int lightBehind = WorldRenderer.getLightmapCoordinates(te.getWorld(), te.getPos().offset(direction.getOpposite()));
|
||||
int lightInFront = WorldRenderer.getLightmapCoordinates(te.getWorld(), te.getPos().offset(direction));
|
||||
|
||||
|
||||
SuperByteBuffer shaftHalf =
|
||||
AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouth(te.getBlockState(), direction.getOpposite());
|
||||
PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction.getOpposite());
|
||||
SuperByteBuffer fanInner =
|
||||
AllBlockPartials.ENCASED_FAN_INNER.renderOnDirectionalSouth(te.getBlockState(), direction.getOpposite());
|
||||
|
||||
PartialBufferer.getFacing(AllBlockPartials.ENCASED_FAN_INNER, te.getBlockState(), direction.getOpposite());
|
||||
|
||||
float time = AnimationTickHolder.getRenderTime(te.getWorld());
|
||||
float speed = te.getSpeed() * 5;
|
||||
if (speed > 0)
|
||||
|
|
|
@ -19,17 +19,17 @@ public class FanInstance extends KineticTileInstance<EncasedFanTileEntity> {
|
|||
private final Direction opposite;
|
||||
|
||||
public FanInstance(InstancedTileRenderer<?> modelManager, EncasedFanTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
super(modelManager, tile);
|
||||
|
||||
direction = blockState.get(FACING);
|
||||
direction = blockState.get(FACING);
|
||||
|
||||
opposite = direction.getOpposite();
|
||||
shaft = AllBlockPartials.SHAFT_HALF.getModel(getRotatingMaterial(), blockState, opposite).createInstance();
|
||||
fan = AllBlockPartials.ENCASED_FAN_INNER.getModel(getRotatingMaterial(), blockState, opposite).createInstance();
|
||||
opposite = direction.getOpposite();
|
||||
shaft = getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, blockState, opposite).createInstance();
|
||||
fan = getRotatingMaterial().getModel(AllBlockPartials.ENCASED_FAN_INNER, blockState, opposite).createInstance();
|
||||
|
||||
setup(shaft);
|
||||
setup(fan, getFanSpeed());
|
||||
}
|
||||
setup(shaft);
|
||||
setup(fan, getFanSpeed());
|
||||
}
|
||||
|
||||
private float getFanSpeed() {
|
||||
float speed = tile.getSpeed() * 5;
|
||||
|
|
|
@ -46,24 +46,24 @@ public class FlyWheelInstance extends KineticTileInstance<FlywheelTileEntity> im
|
|||
protected float lastAngle = Float.NaN;
|
||||
|
||||
public FlyWheelInstance(InstancedTileRenderer<?> modelManager, FlywheelTileEntity tile) {
|
||||
super(modelManager, tile);
|
||||
super(modelManager, tile);
|
||||
|
||||
facing = blockState.get(HORIZONTAL_FACING);
|
||||
facing = blockState.get(HORIZONTAL_FACING);
|
||||
|
||||
shaft = setup(shaftModel().createInstance());
|
||||
shaft = setup(shaftModel().createInstance());
|
||||
|
||||
BlockState referenceState = blockState.rotate(Rotation.CLOCKWISE_90);
|
||||
wheel = AllBlockPartials.FLYWHEEL.getModel(getTransformMaterial(), referenceState, referenceState.get(HORIZONTAL_FACING)).createInstance();
|
||||
BlockState referenceState = blockState.rotate(Rotation.CLOCKWISE_90);
|
||||
wheel = getTransformMaterial().getModel(AllBlockPartials.FLYWHEEL, referenceState, referenceState.get(HORIZONTAL_FACING)).createInstance();
|
||||
|
||||
connection = FlywheelBlock.getConnection(blockState);
|
||||
if (connection != null) {
|
||||
connectedLeft = blockState.get(FlywheelBlock.CONNECTION) == FlywheelBlock.ConnectionState.LEFT;
|
||||
connection = FlywheelBlock.getConnection(blockState);
|
||||
if (connection != null) {
|
||||
connectedLeft = blockState.get(FlywheelBlock.CONNECTION) == FlywheelBlock.ConnectionState.LEFT;
|
||||
|
||||
boolean flipAngle = connection.getAxis() == Direction.Axis.X ^ connection.getAxisDirection() == Direction.AxisDirection.NEGATIVE;
|
||||
boolean flipAngle = connection.getAxis() == Direction.Axis.X ^ connection.getAxisDirection() == Direction.AxisDirection.NEGATIVE;
|
||||
|
||||
connectorAngleMult = flipAngle ? -1 : 1;
|
||||
connectorAngleMult = flipAngle ? -1 : 1;
|
||||
|
||||
RenderMaterial<?, InstancedModel<ModelData>> mat = getTransformMaterial();
|
||||
RenderMaterial<?, InstancedModel<ModelData>> mat = getTransformMaterial();
|
||||
|
||||
upperRotating = mat.getModel(AllBlockPartials.FLYWHEEL_UPPER_ROTATING, blockState).createInstance();
|
||||
lowerRotating = mat.getModel(AllBlockPartials.FLYWHEEL_LOWER_ROTATING, blockState).createInstance();
|
||||
|
@ -159,8 +159,9 @@ public class FlyWheelInstance extends KineticTileInstance<FlywheelTileEntity> im
|
|||
}
|
||||
|
||||
protected InstancedModel<RotatingData> shaftModel() {
|
||||
return AllBlockPartials.SHAFT_HALF.getModel(getRotatingMaterial(), blockState, facing.getOpposite());
|
||||
}
|
||||
Direction opposite = facing.getOpposite();
|
||||
return getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, blockState, opposite);
|
||||
}
|
||||
|
||||
protected void transformConnector(MatrixStacker ms, boolean upper, boolean rotating, float angle, boolean flip) {
|
||||
float shift = upper ? 1 / 4f : -1 / 8f;
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.simibubi.create.AllBlockPartials;
|
|||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.flywheel.FlywheelBlock.ConnectionState;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
|
@ -17,6 +18,7 @@ import net.minecraft.client.renderer.IRenderTypeBuffer;
|
|||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.Direction.AxisDirection;
|
||||
|
@ -54,33 +56,39 @@ public class FlywheelRenderer extends KineticTileEntityRenderer {
|
|||
boolean flip = blockState.get(FlywheelBlock.CONNECTION) == ConnectionState.LEFT;
|
||||
|
||||
transformConnector(
|
||||
rotateToFacing(AllBlockPartials.FLYWHEEL_UPPER_ROTATING.renderOn(blockState), connection), true, true,
|
||||
rotation, flip).light(light)
|
||||
rotateToFacing(PartialBufferer.get(AllBlockPartials.FLYWHEEL_UPPER_ROTATING, blockState), connection), true, true,
|
||||
rotation, flip).light(light)
|
||||
.renderInto(ms, vb);
|
||||
transformConnector(
|
||||
rotateToFacing(AllBlockPartials.FLYWHEEL_LOWER_ROTATING.renderOn(blockState), connection), false, true,
|
||||
rotation, flip).light(light)
|
||||
rotateToFacing(PartialBufferer.get(AllBlockPartials.FLYWHEEL_LOWER_ROTATING, blockState), connection), false, true,
|
||||
rotation, flip).light(light)
|
||||
.renderInto(ms, vb);
|
||||
|
||||
transformConnector(rotateToFacing(AllBlockPartials.FLYWHEEL_UPPER_SLIDING.renderOn(blockState), connection),
|
||||
true, false, rotation, flip).light(light)
|
||||
|
||||
transformConnector(rotateToFacing(PartialBufferer.get(AllBlockPartials.FLYWHEEL_UPPER_SLIDING, blockState), connection),
|
||||
true, false, rotation, flip).light(light)
|
||||
.renderInto(ms, vb);
|
||||
transformConnector(rotateToFacing(AllBlockPartials.FLYWHEEL_LOWER_SLIDING.renderOn(blockState), connection),
|
||||
false, false, rotation, flip).light(light)
|
||||
transformConnector(rotateToFacing(PartialBufferer.get(AllBlockPartials.FLYWHEEL_LOWER_SLIDING, blockState), connection),
|
||||
false, false, rotation, flip).light(light)
|
||||
.renderInto(ms, vb);
|
||||
}
|
||||
|
||||
SuperByteBuffer wheel = AllBlockPartials.FLYWHEEL.renderOnHorizontal(blockState.rotate(Rotation.CLOCKWISE_90));
|
||||
renderFlywheel(te, ms, light, blockState, angle, vb);
|
||||
}
|
||||
|
||||
private void renderFlywheel(KineticTileEntity te, MatrixStack ms, int light, BlockState blockState, float angle, IVertexBuilder vb) {
|
||||
BlockState referenceState = blockState.rotate(Rotation.CLOCKWISE_90);
|
||||
Direction facing = referenceState.get(BlockStateProperties.HORIZONTAL_FACING);
|
||||
SuperByteBuffer wheel = PartialBufferer.getFacing(AllBlockPartials.FLYWHEEL, referenceState, facing);
|
||||
kineticRotationTransform(wheel, te, blockState.get(HORIZONTAL_FACING)
|
||||
.getAxis(), AngleHelper.rad(angle), light);
|
||||
.getAxis(), AngleHelper.rad(angle), light);
|
||||
wheel.renderInto(ms, vb);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
|
||||
return AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouth(te.getBlockState(), te.getBlockState()
|
||||
.get(HORIZONTAL_FACING)
|
||||
.getOpposite());
|
||||
return PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), te.getBlockState()
|
||||
.get(BlockStateProperties.HORIZONTAL_FACING)
|
||||
.getOpposite());
|
||||
}
|
||||
|
||||
protected SuperByteBuffer transformConnector(SuperByteBuffer buffer, boolean upper, boolean rotating, float angle,
|
||||
|
|
|
@ -2,8 +2,8 @@ package com.simibubi.create.content.contraptions.components.flywheel.engine;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -37,12 +37,12 @@ public abstract class EngineBlock extends HorizontalBlock implements IWrenchable
|
|||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ActionResultType onWrenched(BlockState state, ItemUseContext context) {
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public abstract TileEntity createTileEntity(BlockState state, IBlockReader world);
|
||||
|
||||
|
@ -88,14 +88,14 @@ public abstract class EngineBlock extends HorizontalBlock implements IWrenchable
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static BlockPos getBaseBlockPos(BlockState state, BlockPos pos) {
|
||||
return pos.offset(state.get(HORIZONTAL_FACING).getOpposite());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public abstract AllBlockPartials getFrameModel();
|
||||
public abstract PartialModel getFrameModel();
|
||||
|
||||
protected abstract boolean isValidBaseBlock(BlockState baseBlock, IBlockReader world, BlockPos pos);
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.simibubi.create.content.contraptions.components.flywheel.engine;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.foundation.render.backend.core.ModelData;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.TileEntityInstance;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
|
@ -25,7 +25,7 @@ public class EngineInstance extends TileEntityInstance<EngineTileEntity> {
|
|||
return;
|
||||
|
||||
EngineBlock engineBlock = (EngineBlock) block;
|
||||
AllBlockPartials frame = engineBlock.getFrameModel();
|
||||
PartialModel frame = engineBlock.getFrameModel();
|
||||
|
||||
Direction facing = blockState.get(BlockStateProperties.HORIZONTAL_FACING);
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package com.simibubi.create.content.contraptions.components.flywheel.engine;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
|
||||
|
@ -29,16 +30,16 @@ public class EngineRenderer<T extends EngineTileEntity> extends SafeTileEntityRe
|
|||
.getBlock();
|
||||
if (block instanceof EngineBlock) {
|
||||
EngineBlock engineBlock = (EngineBlock) block;
|
||||
AllBlockPartials frame = engineBlock.getFrameModel();
|
||||
PartialModel frame = engineBlock.getFrameModel();
|
||||
if (frame != null) {
|
||||
Direction facing = te.getBlockState()
|
||||
.get(EngineBlock.HORIZONTAL_FACING);
|
||||
.get(EngineBlock.HORIZONTAL_FACING);
|
||||
float angle = AngleHelper.rad(AngleHelper.horizontalAngle(facing));
|
||||
frame.renderOn(te.getBlockState())
|
||||
.rotateCentered(Direction.UP, angle)
|
||||
.translate(0, 0, -1)
|
||||
.light(WorldRenderer.getLightmapCoordinates(te.getWorld(), te.getBlockState(), te.getPos()))
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||
PartialBufferer.get(frame, te.getBlockState())
|
||||
.rotateCentered(Direction.UP, angle)
|
||||
.translate(0, 0, -1)
|
||||
.light(WorldRenderer.getLightmapCoordinates(te.getWorld(), te.getBlockState(), te.getPos()))
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.simibubi.create.AllBlocks;
|
|||
import com.simibubi.create.AllShapes;
|
||||
import com.simibubi.create.AllTileEntities;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld;
|
||||
|
||||
import net.minecraft.block.AbstractFurnaceBlock;
|
||||
|
@ -41,7 +42,7 @@ public class FurnaceEngineBlock extends EngineBlock implements ITE<FurnaceEngine
|
|||
}
|
||||
|
||||
@Override
|
||||
public AllBlockPartials getFrameModel() {
|
||||
public PartialModel getFrameModel() {
|
||||
return AllBlockPartials.FURNACE_GENERATOR_FRAME;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,5 +18,5 @@ public class MillstoneRenderer extends KineticTileEntityRenderer {
|
|||
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
|
||||
return CreateClient.bufferCache.renderPartial(AllBlockPartials.MILLSTONE_COG, te.getBlockState());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.mojang.blaze3d.vertex.IVertexBuilder;
|
|||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
@ -40,7 +41,7 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer {
|
|||
|
||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||
|
||||
SuperByteBuffer superBuffer = AllBlockPartials.SHAFTLESS_COGWHEEL.renderOn(blockState);
|
||||
SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.SHAFTLESS_COGWHEEL, blockState);
|
||||
standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, vb);
|
||||
|
||||
int packedLightmapCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, pos);
|
||||
|
@ -49,16 +50,16 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer {
|
|||
float time = AnimationTickHolder.getRenderTime(te.getWorld());
|
||||
float angle = ((time * speed * 6 / 10f) % 360) / 180 * (float) Math.PI;
|
||||
|
||||
SuperByteBuffer poleRender = AllBlockPartials.MECHANICAL_MIXER_POLE.renderOn(blockState);
|
||||
SuperByteBuffer poleRender = PartialBufferer.get(AllBlockPartials.MECHANICAL_MIXER_POLE, blockState);
|
||||
poleRender.translate(0, -renderedHeadOffset, 0)
|
||||
.light(packedLightmapCoords)
|
||||
.renderInto(ms, vb);
|
||||
.light(packedLightmapCoords)
|
||||
.renderInto(ms, vb);
|
||||
|
||||
SuperByteBuffer headRender = AllBlockPartials.MECHANICAL_MIXER_HEAD.renderOn(blockState);
|
||||
SuperByteBuffer headRender = PartialBufferer.get(AllBlockPartials.MECHANICAL_MIXER_HEAD, blockState);
|
||||
headRender.rotateCentered(Direction.UP, angle)
|
||||
.translate(0, -renderedHeadOffset, 0)
|
||||
.light(packedLightmapCoords)
|
||||
.renderInto(ms, vb);
|
||||
.translate(0, -renderedHeadOffset, 0)
|
||||
.light(packedLightmapCoords)
|
||||
.renderInto(ms, vb);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.components.motor;
|
|||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
|
@ -15,7 +16,7 @@ public class CreativeMotorRenderer extends KineticTileEntityRenderer {
|
|||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
|
||||
return AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouth(te.getBlockState());
|
||||
return PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package com.simibubi.create.content.contraptions.components.press;
|
||||
|
||||
import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
|
||||
|
@ -37,10 +40,10 @@ public class MechanicalPressRenderer extends KineticTileEntityRenderer {
|
|||
int packedLightmapCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), blockState, pos);
|
||||
float renderedHeadOffset = ((MechanicalPressTileEntity) te).getRenderedHeadOffset(partialTicks);
|
||||
|
||||
SuperByteBuffer headRender = AllBlockPartials.MECHANICAL_PRESS_HEAD.renderOnHorizontal(blockState);
|
||||
SuperByteBuffer headRender = PartialBufferer.getFacing(AllBlockPartials.MECHANICAL_PRESS_HEAD, blockState, blockState.get(HORIZONTAL_FACING));
|
||||
headRender.translate(0, -renderedHeadOffset, 0)
|
||||
.light(packedLightmapCoords)
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||
.light(packedLightmapCoords)
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
|
|||
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Rotation;
|
||||
|
||||
public class SawInstance extends SingleRotatingInstance {
|
||||
|
@ -22,7 +23,8 @@ public class SawInstance extends SingleRotatingInstance {
|
|||
protected InstancedModel<RotatingData> getModel() {
|
||||
if (blockState.get(FACING).getAxis().isHorizontal()) {
|
||||
BlockState referenceState = blockState.rotate(tile.getWorld(), tile.getPos(), Rotation.CLOCKWISE_180);
|
||||
return AllBlockPartials.SHAFT_HALF.getModel(getRotatingMaterial(), referenceState, referenceState.get(FACING));
|
||||
Direction facing = referenceState.get(FACING);
|
||||
return getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, referenceState, facing);
|
||||
} else {
|
||||
return getRotatingMaterial().getModel(shaft());
|
||||
}
|
||||
|
|
|
@ -9,8 +9,10 @@ import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
|||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringRenderer;
|
||||
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
|
@ -53,7 +55,7 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
|
|||
protected void renderBlade(SawTileEntity te, MatrixStack ms, IRenderTypeBuffer buffer, int light) {
|
||||
BlockState blockState = te.getBlockState();
|
||||
SuperByteBuffer superBuffer;
|
||||
AllBlockPartials partial;
|
||||
PartialModel partial;
|
||||
float speed = te.getSpeed();
|
||||
|
||||
ms.push();
|
||||
|
@ -77,13 +79,13 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
|
|||
|
||||
if (!blockState.get(SawBlock.AXIS_ALONG_FIRST_COORDINATE))
|
||||
MatrixStacker.of(ms)
|
||||
.centre()
|
||||
.rotateY(90)
|
||||
.unCentre();
|
||||
.centre()
|
||||
.rotateY(90)
|
||||
.unCentre();
|
||||
}
|
||||
superBuffer = partial.renderOnDirectionalSouth(blockState);
|
||||
superBuffer = PartialBufferer.getFacing(partial, blockState);
|
||||
superBuffer.light(light)
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.getCutoutMipped()));
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.getCutoutMipped()));
|
||||
|
||||
ms.pop();
|
||||
}
|
||||
|
@ -140,7 +142,7 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
|
|||
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
|
||||
BlockState state = te.getBlockState();
|
||||
if (state.get(FACING).getAxis().isHorizontal())
|
||||
return AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouth(state.rotate(te.getWorld(), te.getPos(), Rotation.CLOCKWISE_180));
|
||||
return PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, state.rotate(te.getWorld(), te.getPos(), Rotation.CLOCKWISE_180));
|
||||
return CreateClient.bufferCache.renderBlockIn(KineticTileEntityRenderer.KINETIC_TILE,
|
||||
getRenderedBlockState(te));
|
||||
}
|
||||
|
@ -171,14 +173,14 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
|
|||
|
||||
if (SawBlock.isHorizontal(state)) {
|
||||
if (shouldAnimate)
|
||||
superBuffer = AllBlockPartials.SAW_BLADE_HORIZONTAL_ACTIVE.renderOn(state);
|
||||
superBuffer = PartialBufferer.get(AllBlockPartials.SAW_BLADE_HORIZONTAL_ACTIVE, state);
|
||||
else
|
||||
superBuffer = AllBlockPartials.SAW_BLADE_HORIZONTAL_INACTIVE.renderOn(state);
|
||||
superBuffer = PartialBufferer.get(AllBlockPartials.SAW_BLADE_HORIZONTAL_INACTIVE, state);
|
||||
} else {
|
||||
if (shouldAnimate)
|
||||
superBuffer = AllBlockPartials.SAW_BLADE_VERTICAL_ACTIVE.renderOn(state);
|
||||
superBuffer = PartialBufferer.get(AllBlockPartials.SAW_BLADE_VERTICAL_ACTIVE, state);
|
||||
else
|
||||
superBuffer = AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE.renderOn(state);
|
||||
superBuffer = PartialBufferer.get(AllBlockPartials.SAW_BLADE_VERTICAL_INACTIVE, state);
|
||||
}
|
||||
|
||||
for (MatrixStack m : matrixStacks) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.simibubi.create.AllBlockPartials;
|
|||
import com.simibubi.create.content.contraptions.base.BackHalfShaftInstance;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.foundation.render.backend.core.OrientedData;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
|
@ -31,7 +32,7 @@ public class BearingInstance<B extends KineticTileEntity & IBearingTileEntity> e
|
|||
|
||||
blockOrientation = getBlockStateOrientation(facing);
|
||||
|
||||
AllBlockPartials top =
|
||||
PartialModel top =
|
||||
bearing.isWoodenTop() ? AllBlockPartials.BEARING_TOP_WOODEN : AllBlockPartials.BEARING_TOP;
|
||||
|
||||
topInstance = getOrientedMaterial().getModel(top, blockState).createInstance();
|
||||
|
|
|
@ -4,8 +4,10 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
|||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
|
@ -30,27 +32,27 @@ public class BearingRenderer extends KineticTileEntityRenderer {
|
|||
|
||||
IBearingTileEntity bearingTe = (IBearingTileEntity) te;
|
||||
final Direction facing = te.getBlockState()
|
||||
.get(BlockStateProperties.FACING);
|
||||
AllBlockPartials top =
|
||||
bearingTe.isWoodenTop() ? AllBlockPartials.BEARING_TOP_WOODEN : AllBlockPartials.BEARING_TOP;
|
||||
SuperByteBuffer superBuffer = top.renderOn(te.getBlockState());
|
||||
.get(BlockStateProperties.FACING);
|
||||
PartialModel top =
|
||||
bearingTe.isWoodenTop() ? AllBlockPartials.BEARING_TOP_WOODEN : AllBlockPartials.BEARING_TOP;
|
||||
SuperByteBuffer superBuffer = PartialBufferer.get(top, te.getBlockState());
|
||||
|
||||
float interpolatedAngle = bearingTe.getInterpolatedAngle(partialTicks - 1);
|
||||
kineticRotationTransform(superBuffer, te, facing.getAxis(), (float) (interpolatedAngle / 180 * Math.PI), light);
|
||||
|
||||
if (facing.getAxis()
|
||||
.isHorizontal())
|
||||
.isHorizontal())
|
||||
superBuffer.rotateCentered(Direction.UP,
|
||||
AngleHelper.rad(AngleHelper.horizontalAngle(facing.getOpposite())));
|
||||
AngleHelper.rad(AngleHelper.horizontalAngle(facing.getOpposite())));
|
||||
superBuffer.rotateCentered(Direction.EAST, AngleHelper.rad(-90 - AngleHelper.verticalAngle(facing)));
|
||||
superBuffer.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
|
||||
return AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouth(te.getBlockState(), te.getBlockState()
|
||||
.get(BearingBlock.FACING)
|
||||
.getOpposite());
|
||||
return PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), te.getBlockState()
|
||||
.get(BearingBlock.FACING)
|
||||
.getOpposite());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,8 +12,10 @@ import com.simibubi.create.content.contraptions.components.structureMovement.Ori
|
|||
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.ContraptionRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
|
@ -34,8 +36,8 @@ public class StabilizedBearingMovementBehaviour extends MovementBehaviour {
|
|||
if (FastRenderDispatcher.available()) return;
|
||||
|
||||
Direction facing = context.state.get(BlockStateProperties.FACING);
|
||||
AllBlockPartials top = AllBlockPartials.BEARING_TOP;
|
||||
SuperByteBuffer superBuffer = top.renderOn(context.state);
|
||||
PartialModel top = AllBlockPartials.BEARING_TOP;
|
||||
SuperByteBuffer superBuffer = PartialBufferer.get(top, context.state);
|
||||
float renderPartialTicks = AnimationTickHolder.getPartialTicks();
|
||||
|
||||
// rotate to match blockstate
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.ch
|
|||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
||||
|
@ -28,7 +29,7 @@ public class StickerRenderer extends SafeTileEntityRenderer<StickerTileEntity> {
|
|||
if (FastRenderDispatcher.available(te.getWorld())) return;
|
||||
|
||||
BlockState state = te.getBlockState();
|
||||
SuperByteBuffer head = AllBlockPartials.STICKER_HEAD.renderOn(state);
|
||||
SuperByteBuffer head = PartialBufferer.get(AllBlockPartials.STICKER_HEAD, state);
|
||||
float offset = te.piston.getValue(AnimationTickHolder.getPartialTicks(te.getWorld()));
|
||||
|
||||
if (te.getWorld() != Minecraft.getInstance().world && !te.isVirtual())
|
||||
|
@ -36,9 +37,9 @@ public class StickerRenderer extends SafeTileEntityRenderer<StickerTileEntity> {
|
|||
|
||||
Direction facing = state.get(StickerBlock.FACING);
|
||||
head.matrixStacker()
|
||||
.nudge(te.hashCode())
|
||||
.centre()
|
||||
.rotateY(AngleHelper.horizontalAngle(facing))
|
||||
.nudge(te.hashCode())
|
||||
.centre()
|
||||
.rotateY(AngleHelper.horizontalAngle(facing))
|
||||
.rotateX(AngleHelper.verticalAngle(facing) + 90)
|
||||
.unCentre()
|
||||
.translate(0, (offset * offset) * 4 / 16f, 0);
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
|||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
|
@ -54,16 +55,16 @@ public class GantryCarriageRenderer extends KineticTileEntityRenderer {
|
|||
if (facing == Direction.NORTH || facing == Direction.EAST)
|
||||
angleForTe *= -1;
|
||||
|
||||
SuperByteBuffer cogs = AllBlockPartials.GANTRY_COGS.renderOn(state);
|
||||
SuperByteBuffer cogs = PartialBufferer.get(AllBlockPartials.GANTRY_COGS, state);
|
||||
cogs.matrixStacker()
|
||||
.centre()
|
||||
.rotateY(AngleHelper.horizontalAngle(facing))
|
||||
.rotateX(facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90)
|
||||
.rotateY(alongFirst ^ facing.getAxis() == Axis.Z ? 90 : 0)
|
||||
.translate(0, -9 / 16f, 0)
|
||||
.multiply(Vector3f.POSITIVE_X.getRadialQuaternion(-angleForTe))
|
||||
.translate(0, 9 / 16f, 0)
|
||||
.unCentre();
|
||||
.centre()
|
||||
.rotateY(AngleHelper.horizontalAngle(facing))
|
||||
.rotateX(facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90)
|
||||
.rotateY(alongFirst ^ facing.getAxis() == Axis.Z ? 90 : 0)
|
||||
.translate(0, -9 / 16f, 0)
|
||||
.multiply(Vector3f.POSITIVE_X.getRadialQuaternion(-angleForTe))
|
||||
.translate(0, 9 / 16f, 0)
|
||||
.unCentre();
|
||||
|
||||
cogs.light(light)
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||
|
|
|
@ -2,12 +2,13 @@ package com.simibubi.create.content.contraptions.components.structureMovement.pu
|
|||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.IRotate;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -24,11 +25,11 @@ import net.minecraft.world.World;
|
|||
|
||||
public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer {
|
||||
|
||||
private AllBlockPartials halfRope;
|
||||
private AllBlockPartials halfMagnet;
|
||||
private PartialModel halfRope;
|
||||
private PartialModel halfMagnet;
|
||||
|
||||
public AbstractPulleyRenderer(TileEntityRendererDispatcher dispatcher, AllBlockPartials halfRope,
|
||||
AllBlockPartials halfMagnet) {
|
||||
public AbstractPulleyRenderer(TileEntityRendererDispatcher dispatcher, PartialModel halfRope,
|
||||
PartialModel halfMagnet) {
|
||||
super(dispatcher);
|
||||
this.halfRope = halfRope;
|
||||
this.halfMagnet = halfMagnet;
|
||||
|
@ -50,16 +51,16 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer {
|
|||
boolean running = isRunning(te);
|
||||
|
||||
Axis rotationAxis = ((IRotate) te.getBlockState()
|
||||
.getBlock()).getRotationAxis(te.getBlockState());
|
||||
.getBlock()).getRotationAxis(te.getBlockState());
|
||||
kineticRotationTransform(getRotatedCoil(te), te, rotationAxis, AngleHelper.rad(offset * 180), light)
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||
|
||||
World world = te.getWorld();
|
||||
BlockState blockState = te.getBlockState();
|
||||
BlockPos pos = te.getPos();
|
||||
|
||||
SuperByteBuffer halfMagnet = this.halfMagnet.renderOn(blockState);
|
||||
SuperByteBuffer halfRope = this.halfRope.renderOn(blockState);
|
||||
SuperByteBuffer halfMagnet = PartialBufferer.get(this.halfMagnet, blockState);
|
||||
SuperByteBuffer halfRope = PartialBufferer.get(this.halfRope, blockState);
|
||||
SuperByteBuffer magnet = renderMagnet(te);
|
||||
SuperByteBuffer rope = renderRope(te);
|
||||
|
||||
|
@ -89,7 +90,7 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer {
|
|||
|
||||
protected abstract Axis getShaftAxis(KineticTileEntity te);
|
||||
|
||||
protected abstract AllBlockPartials getCoil();
|
||||
protected abstract PartialModel getCoil();
|
||||
|
||||
protected abstract SuperByteBuffer renderRope(KineticTileEntity te);
|
||||
|
||||
|
@ -106,8 +107,7 @@ public abstract class AbstractPulleyRenderer extends KineticTileEntityRenderer {
|
|||
|
||||
protected SuperByteBuffer getRotatedCoil(KineticTileEntity te) {
|
||||
BlockState blockState = te.getBlockState();
|
||||
return getCoil().renderOnDirectionalSouth(blockState,
|
||||
Direction.getFacingFromAxis(AxisDirection.POSITIVE, getShaftAxis(te)));
|
||||
return PartialBufferer.getFacing(getCoil(), blockState, Direction.getFacingFromAxis(AxisDirection.POSITIVE, getShaftAxis(te)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public class HosePulleyInstance extends AbstractPulleyInstance {
|
|||
}
|
||||
|
||||
protected InstancedModel<OrientedData> getCoilModel() {
|
||||
return AllBlockPartials.HOSE_COIL.getModel(getOrientedMaterial(), blockState, rotatingAbout);
|
||||
return getOrientedMaterial().getModel(AllBlockPartials.HOSE_COIL, blockState, rotatingAbout);
|
||||
}
|
||||
|
||||
protected InstancedModel<OrientedData> getHalfRopeModel() {
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.simibubi.create.CreateClient;
|
|||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
|
@ -24,7 +25,7 @@ public class PulleyRenderer extends AbstractPulleyRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected AllBlockPartials getCoil() {
|
||||
protected PartialModel getCoil() {
|
||||
return AllBlockPartials.ROPE_COIL;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ public class RopePulleyInstance extends AbstractPulleyInstance {
|
|||
}
|
||||
|
||||
protected InstancedModel<OrientedData> getCoilModel() {
|
||||
return AllBlockPartials.ROPE_COIL.getModel(getOrientedMaterial(), blockState, rotatingAbout);
|
||||
return getOrientedMaterial().getModel(AllBlockPartials.ROPE_COIL, blockState, rotatingAbout);
|
||||
}
|
||||
|
||||
protected InstancedModel<OrientedData> getHalfRopeModel() {
|
||||
|
|
|
@ -44,7 +44,6 @@ import net.minecraft.client.renderer.texture.OverlayTexture;
|
|||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.world.IBlockDisplayReader;
|
||||
import net.minecraft.world.LightType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.template.Template;
|
||||
|
@ -52,57 +51,27 @@ import net.minecraftforge.client.ForgeHooksClient;
|
|||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
|
||||
public class ContraptionRenderDispatcher {
|
||||
public static final Int2ObjectMap<RenderedContraption> renderers = new Int2ObjectOpenHashMap<>();
|
||||
public static final Compartment<Pair<Contraption, Integer>> CONTRAPTION = new Compartment<>();
|
||||
protected static PlacementSimulationWorld renderWorld;
|
||||
public static final Int2ObjectMap<RenderedContraption> renderers = new Int2ObjectOpenHashMap<>();
|
||||
public static final Compartment<Pair<Contraption, Integer>> CONTRAPTION = new Compartment<>();
|
||||
protected static PlacementSimulationWorld renderWorld;
|
||||
|
||||
public static void notifyLightPacket(IBlockDisplayReader world, int chunkX, int chunkZ) {
|
||||
for (RenderedContraption renderer : renderers.values()) {
|
||||
renderer.getLighter().lightVolume.notifyLightPacket(world, chunkX, chunkZ);
|
||||
}
|
||||
}
|
||||
public static void tick() {
|
||||
if (Minecraft.getInstance().isGamePaused()) return;
|
||||
|
||||
public static void renderTileEntities(World world, Contraption c, MatrixStack ms, MatrixStack msLocal,
|
||||
IRenderTypeBuffer buffer) {
|
||||
PlacementSimulationWorld renderWorld = null;
|
||||
if (Backend.canUseVBOs()) {
|
||||
RenderedContraption renderer = getRenderer(world, c);
|
||||
for (RenderedContraption contraption : renderers.values()) {
|
||||
contraption.getLighter().tick(contraption);
|
||||
|
||||
renderWorld = renderer.renderWorld;
|
||||
}
|
||||
TileEntityRenderHelper.renderTileEntities(world, renderWorld, c.specialRenderedTileEntities, ms, msLocal, buffer);
|
||||
contraption.kinetics.tick();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public static void beginFrame(ActiveRenderInfo info, double camX, double camY, double camZ) {
|
||||
for (RenderedContraption renderer : renderers.values()) {
|
||||
renderer.beginFrame(info, camX, camY, camZ);
|
||||
}
|
||||
}
|
||||
|
||||
public static void tick() {
|
||||
if (Minecraft.getInstance().isGamePaused()) return;
|
||||
|
||||
for (RenderedContraption contraption : renderers.values()) {
|
||||
contraption.getLighter().tick(contraption);
|
||||
|
||||
contraption.kinetics.tick();
|
||||
}
|
||||
}
|
||||
|
||||
private static RenderedContraption getRenderer(World world, Contraption c) {
|
||||
int entityId = c.entity.getEntityId();
|
||||
RenderedContraption contraption = renderers.get(entityId);
|
||||
|
||||
if (contraption == null) {
|
||||
contraption = new RenderedContraption(world, c);
|
||||
renderers.put(entityId, contraption);
|
||||
}
|
||||
|
||||
return contraption;
|
||||
}
|
||||
|
||||
public static void beginFrame(ActiveRenderInfo info, double camX, double camY, double camZ) {
|
||||
for (RenderedContraption renderer : renderers.values()) {
|
||||
renderer.beginFrame(info, camX, camY, camZ);
|
||||
}
|
||||
}
|
||||
|
||||
public static void renderLayer(RenderType layer, Matrix4f viewProjection, double camX, double camY, double camZ) {
|
||||
public static void renderLayer(RenderType layer, Matrix4f viewProjection, double camX, double camY, double camZ) {
|
||||
removeDeadContraptions();
|
||||
|
||||
if (renderers.isEmpty()) return;
|
||||
|
@ -121,79 +90,110 @@ public class ContraptionRenderDispatcher {
|
|||
|
||||
if (Backend.canUseInstancing()) {
|
||||
for (RenderedContraption renderer : renderers.values()) {
|
||||
renderer.kinetics.render(layer, viewProjection, camX, camY, camZ, renderer::setup);
|
||||
renderer.teardown();
|
||||
}
|
||||
}
|
||||
renderer.kinetics.render(layer, viewProjection, camX, camY, camZ, renderer::setup);
|
||||
renderer.teardown();
|
||||
}
|
||||
}
|
||||
|
||||
layer.endDrawing();
|
||||
GL11.glDisable(GL13.GL_TEXTURE_3D);
|
||||
GL13.glActiveTexture(GL40.GL_TEXTURE0);
|
||||
}
|
||||
layer.endDrawing();
|
||||
GL11.glDisable(GL13.GL_TEXTURE_3D);
|
||||
GL13.glActiveTexture(GL40.GL_TEXTURE0);
|
||||
}
|
||||
|
||||
public static void removeDeadContraptions() {
|
||||
renderers.values().removeIf(renderer -> {
|
||||
if (renderer.isDead()) {
|
||||
renderer.invalidate();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
private static RenderedContraption getRenderer(World world, Contraption c) {
|
||||
int entityId = c.entity.getEntityId();
|
||||
RenderedContraption contraption = renderers.get(entityId);
|
||||
|
||||
public static void invalidateAll() {
|
||||
for (RenderedContraption renderer : renderers.values()) {
|
||||
renderer.invalidate();
|
||||
}
|
||||
if (contraption == null) {
|
||||
contraption = new RenderedContraption(world, c);
|
||||
renderers.put(entityId, contraption);
|
||||
}
|
||||
|
||||
renderers.clear();
|
||||
}
|
||||
return contraption;
|
||||
}
|
||||
|
||||
public static void render(AbstractContraptionEntity entity, MatrixStack ms, IRenderTypeBuffer buffers,
|
||||
MatrixStack msLocal, Contraption contraption) {
|
||||
if (Backend.canUseVBOs()) {
|
||||
ContraptionRenderDispatcher.renderDynamic(entity.world, contraption, ms, msLocal, buffers);
|
||||
} else {
|
||||
ContraptionRenderDispatcher.renderDynamic(entity.world, contraption, ms, msLocal, buffers);
|
||||
ContraptionRenderDispatcher.renderStructure(entity.world, contraption, ms, msLocal, buffers);
|
||||
}
|
||||
}
|
||||
public static void render(AbstractContraptionEntity entity, MatrixStack ms, IRenderTypeBuffer buffers,
|
||||
MatrixStack msLocal, Contraption contraption) {
|
||||
if (Backend.canUseVBOs() && Backend.isFlywheelWorld(entity.world)) {
|
||||
ContraptionRenderDispatcher.renderDynamic(entity.world, contraption, ms, msLocal, buffers);
|
||||
} else {
|
||||
ContraptionRenderDispatcher.renderDynamic(entity.world, contraption, ms, msLocal, buffers);
|
||||
ContraptionRenderDispatcher.renderStructure(entity.world, contraption, ms, msLocal, buffers);
|
||||
}
|
||||
}
|
||||
|
||||
public static void renderDynamic(World world, Contraption c, MatrixStack ms, MatrixStack msLocal,
|
||||
IRenderTypeBuffer buffer) {
|
||||
renderTileEntities(world, c, ms, msLocal, buffer);
|
||||
if (buffer instanceof IRenderTypeBuffer.Impl)
|
||||
((IRenderTypeBuffer.Impl) buffer).draw();
|
||||
renderActors(world, c, ms, msLocal, buffer);
|
||||
}
|
||||
public static void renderStructure(World world, Contraption c, MatrixStack ms, MatrixStack msLocal,
|
||||
IRenderTypeBuffer buffer) {
|
||||
SuperByteBufferCache bufferCache = CreateClient.bufferCache;
|
||||
List<RenderType> blockLayers = RenderType.getBlockLayers();
|
||||
|
||||
public static void renderStructure(World world, Contraption c, MatrixStack ms, MatrixStack msLocal,
|
||||
IRenderTypeBuffer buffer) {
|
||||
SuperByteBufferCache bufferCache = CreateClient.bufferCache;
|
||||
List<RenderType> blockLayers = RenderType.getBlockLayers();
|
||||
buffer.getBuffer(RenderType.getSolid());
|
||||
for (int i = 0; i < blockLayers.size(); i++) {
|
||||
RenderType layer = blockLayers.get(i);
|
||||
Pair<Contraption, Integer> key = Pair.of(c, i);
|
||||
SuperByteBuffer contraptionBuffer = bufferCache.get(CONTRAPTION, key, () -> buildStructureBuffer(c, layer));
|
||||
if (contraptionBuffer.isEmpty())
|
||||
continue;
|
||||
Matrix4f model = msLocal.peek()
|
||||
.getModel();
|
||||
contraptionBuffer.light(model)
|
||||
.renderInto(ms, buffer.getBuffer(layer));
|
||||
}
|
||||
}
|
||||
|
||||
buffer.getBuffer(RenderType.getSolid());
|
||||
for (int i = 0; i < blockLayers.size(); i++) {
|
||||
RenderType layer = blockLayers.get(i);
|
||||
Pair<Contraption, Integer> key = Pair.of(c, i);
|
||||
SuperByteBuffer contraptionBuffer = bufferCache.get(CONTRAPTION, key, () -> buildStructureBuffer(c, layer));
|
||||
if (contraptionBuffer.isEmpty())
|
||||
continue;
|
||||
Matrix4f model = msLocal.peek()
|
||||
.getModel();
|
||||
contraptionBuffer.light(model)
|
||||
.renderInto(ms, buffer.getBuffer(layer));
|
||||
}
|
||||
}
|
||||
public static void renderDynamic(World world, Contraption c, MatrixStack ms, MatrixStack msLocal,
|
||||
IRenderTypeBuffer buffer) {
|
||||
renderTileEntities(world, c, ms, msLocal, buffer);
|
||||
if (buffer instanceof IRenderTypeBuffer.Impl)
|
||||
((IRenderTypeBuffer.Impl) buffer).draw();
|
||||
renderActors(world, c, ms, msLocal, buffer);
|
||||
}
|
||||
|
||||
private static SuperByteBuffer buildStructureBuffer(Contraption c, RenderType layer) {
|
||||
BufferBuilder builder = buildStructure(c, layer);
|
||||
return new SuperByteBuffer(builder);
|
||||
}
|
||||
public static void renderTileEntities(World world, Contraption c, MatrixStack ms, MatrixStack msLocal,
|
||||
IRenderTypeBuffer buffer) {
|
||||
PlacementSimulationWorld renderWorld = null;
|
||||
if (Backend.canUseVBOs() && Backend.isFlywheelWorld(world)) {
|
||||
RenderedContraption renderer = getRenderer(world, c);
|
||||
|
||||
public static BufferBuilder buildStructure(Contraption c, RenderType layer) {
|
||||
if (renderWorld == null || renderWorld.getWorld() != Minecraft.getInstance().world)
|
||||
renderWorld = new PlacementSimulationWorld(Minecraft.getInstance().world);
|
||||
renderWorld = renderer.renderWorld;
|
||||
}
|
||||
TileEntityRenderHelper.renderTileEntities(world, renderWorld, c.specialRenderedTileEntities, ms, msLocal, buffer);
|
||||
|
||||
}
|
||||
|
||||
protected static void renderActors(World world, Contraption c, MatrixStack ms, MatrixStack msLocal,
|
||||
IRenderTypeBuffer buffer) {
|
||||
MatrixStack[] matrixStacks = new MatrixStack[]{ms, msLocal};
|
||||
for (Pair<Template.BlockInfo, MovementContext> actor : c.getActors()) {
|
||||
MovementContext context = actor.getRight();
|
||||
if (context == null)
|
||||
continue;
|
||||
if (context.world == null)
|
||||
context.world = world;
|
||||
Template.BlockInfo blockInfo = actor.getLeft();
|
||||
for (MatrixStack m : matrixStacks) {
|
||||
m.push();
|
||||
MatrixStacker.of(m)
|
||||
.translate(blockInfo.pos);
|
||||
}
|
||||
|
||||
MovementBehaviour movementBehaviour = AllMovementBehaviours.of(blockInfo.state);
|
||||
if (movementBehaviour != null)
|
||||
movementBehaviour.renderInContraption(context, ms, msLocal, buffer);
|
||||
|
||||
for (MatrixStack m : matrixStacks)
|
||||
m.pop();
|
||||
}
|
||||
}
|
||||
|
||||
private static SuperByteBuffer buildStructureBuffer(Contraption c, RenderType layer) {
|
||||
BufferBuilder builder = buildStructure(c, layer);
|
||||
return new SuperByteBuffer(builder);
|
||||
}
|
||||
|
||||
public static BufferBuilder buildStructure(Contraption c, RenderType layer) {
|
||||
if (renderWorld == null || renderWorld.getWorld() != Minecraft.getInstance().world)
|
||||
renderWorld = new PlacementSimulationWorld(Minecraft.getInstance().world);
|
||||
|
||||
ForgeHooksClient.setRenderLayer(layer);
|
||||
MatrixStack ms = new MatrixStack();
|
||||
|
@ -232,31 +232,6 @@ public class ContraptionRenderDispatcher {
|
|||
return builder;
|
||||
}
|
||||
|
||||
protected static void renderActors(World world, Contraption c, MatrixStack ms, MatrixStack msLocal,
|
||||
IRenderTypeBuffer buffer) {
|
||||
MatrixStack[] matrixStacks = new MatrixStack[] { ms, msLocal };
|
||||
for (Pair<Template.BlockInfo, MovementContext> actor : c.getActors()) {
|
||||
MovementContext context = actor.getRight();
|
||||
if (context == null)
|
||||
continue;
|
||||
if (context.world == null)
|
||||
context.world = world;
|
||||
Template.BlockInfo blockInfo = actor.getLeft();
|
||||
for (MatrixStack m : matrixStacks) {
|
||||
m.push();
|
||||
MatrixStacker.of(m)
|
||||
.translate(blockInfo.pos);
|
||||
}
|
||||
|
||||
MovementBehaviour movementBehaviour = AllMovementBehaviours.of(blockInfo.state);
|
||||
if (movementBehaviour != null)
|
||||
movementBehaviour.renderInContraption(context, ms, msLocal, buffer);
|
||||
|
||||
for (MatrixStack m : matrixStacks)
|
||||
m.pop();
|
||||
}
|
||||
}
|
||||
|
||||
public static int getLight(World world, float lx, float ly, float lz) {
|
||||
BlockPos.Mutable pos = new BlockPos.Mutable();
|
||||
float sky = 0, block = 0;
|
||||
|
@ -292,14 +267,32 @@ public class ContraptionRenderDispatcher {
|
|||
return packedLight;
|
||||
}
|
||||
|
||||
public static int getLightOnContraption(MovementContext context) {
|
||||
int entityId = context.contraption.entity.getEntityId();
|
||||
public static int getLightOnContraption(MovementContext context) {
|
||||
int entityId = context.contraption.entity.getEntityId();
|
||||
|
||||
RenderedContraption renderedContraption = renderers.get(entityId);
|
||||
if (renderedContraption != null) {
|
||||
return renderedContraption.renderWorld.getLightLevel(LightType.BLOCK, context.localPos);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
RenderedContraption renderedContraption = renderers.get(entityId);
|
||||
if (renderedContraption != null) {
|
||||
return renderedContraption.renderWorld.getLightLevel(LightType.BLOCK, context.localPos);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public static void invalidateAll() {
|
||||
for (RenderedContraption renderer : renderers.values()) {
|
||||
renderer.invalidate();
|
||||
}
|
||||
|
||||
renderers.clear();
|
||||
}
|
||||
|
||||
public static void removeDeadContraptions() {
|
||||
renderers.values().removeIf(renderer -> {
|
||||
if (renderer.isDead()) {
|
||||
renderer.invalidate();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.simibubi.create.AllBlockPartials;
|
|||
import com.simibubi.create.CreateClient;
|
||||
import com.simibubi.create.content.contraptions.KineticDebugger;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.ColorHelper;
|
||||
|
@ -36,7 +37,7 @@ public class CouplingRenderer {
|
|||
c -> {
|
||||
if (c.getFirst().hasContraptionCoupling(true))
|
||||
return;
|
||||
CouplingRenderer.renderCoupling(ms, buffer, c.map(MinecartController::cart));
|
||||
CouplingRenderer.renderCoupling(ms, buffer, c.map(MinecartController::cart));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -47,37 +48,37 @@ public class CouplingRenderer {
|
|||
|
||||
public static void renderCoupling(MatrixStack ms, IRenderTypeBuffer buffer, Couple<AbstractMinecartEntity> carts) {
|
||||
ClientWorld world = Minecraft.getInstance().world;
|
||||
|
||||
|
||||
if (carts.getFirst() == null || carts.getSecond() == null)
|
||||
return;
|
||||
|
||||
|
||||
Couple<Integer> lightValues =
|
||||
carts.map(c -> WorldRenderer.getLightmapCoordinates(world, new BlockPos(c.getBoundingBox()
|
||||
.getCenter())));
|
||||
|
||||
Vector3d center = carts.getFirst()
|
||||
.getPositionVec()
|
||||
.add(carts.getSecond()
|
||||
.getPositionVec())
|
||||
.scale(.5f);
|
||||
.getPositionVec()
|
||||
.add(carts.getSecond()
|
||||
.getPositionVec())
|
||||
.scale(.5f);
|
||||
|
||||
Couple<CartEndpoint> transforms = carts.map(c -> getSuitableCartEndpoint(c, center));
|
||||
|
||||
BlockState renderState = Blocks.AIR.getDefaultState();
|
||||
IVertexBuilder builder = buffer.getBuffer(RenderType.getSolid());
|
||||
SuperByteBuffer attachment = AllBlockPartials.COUPLING_ATTACHMENT.renderOn(renderState);
|
||||
SuperByteBuffer ring = AllBlockPartials.COUPLING_RING.renderOn(renderState);
|
||||
SuperByteBuffer connector = AllBlockPartials.COUPLING_CONNECTOR.renderOn(renderState);
|
||||
SuperByteBuffer attachment = PartialBufferer.get(AllBlockPartials.COUPLING_ATTACHMENT, renderState);
|
||||
SuperByteBuffer ring = PartialBufferer.get(AllBlockPartials.COUPLING_RING, renderState);
|
||||
SuperByteBuffer connector = PartialBufferer.get(AllBlockPartials.COUPLING_CONNECTOR, renderState);
|
||||
|
||||
Vector3d zero = Vector3d.ZERO;
|
||||
Vector3d firstEndpoint = transforms.getFirst()
|
||||
.apply(zero);
|
||||
.apply(zero);
|
||||
Vector3d secondEndpoint = transforms.getSecond()
|
||||
.apply(zero);
|
||||
.apply(zero);
|
||||
Vector3d endPointDiff = secondEndpoint.subtract(firstEndpoint);
|
||||
double connectorYaw = -Math.atan2(endPointDiff.z, endPointDiff.x) * 180.0D / Math.PI;
|
||||
double connectorPitch = Math.atan2(endPointDiff.y, endPointDiff.mul(1, 0, 1)
|
||||
.length()) * 180 / Math.PI;
|
||||
.length()) * 180 / Math.PI;
|
||||
|
||||
MatrixStacker msr = MatrixStacker.of(ms);
|
||||
carts.forEachWithContext((cart, isFirst) -> {
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
|
|||
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
public class PumpCogInstance extends SingleRotatingInstance {
|
||||
|
||||
|
@ -19,7 +20,8 @@ public class PumpCogInstance extends SingleRotatingInstance {
|
|||
|
||||
@Override
|
||||
protected InstancedModel<RotatingData> getModel() {
|
||||
BlockState referenceState = tile.getBlockState();
|
||||
return AllBlockPartials.MECHANICAL_PUMP_COG.getModel(getRotatingMaterial(), referenceState, referenceState.get(FACING));
|
||||
}
|
||||
BlockState referenceState = tile.getBlockState();
|
||||
Direction facing = referenceState.get(FACING);
|
||||
return getRotatingMaterial().getModel(AllBlockPartials.MECHANICAL_PUMP_COG, referenceState, facing);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
|||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
|
@ -34,17 +35,17 @@ public class PumpRenderer extends KineticTileEntityRenderer {
|
|||
float angle = MathHelper.lerp(pump.arrowDirection.getValue(partialTicks), 0, 90) - 90;
|
||||
for (float yRot : new float[] { 0, 90 }) {
|
||||
ms.push();
|
||||
SuperByteBuffer arrow = AllBlockPartials.MECHANICAL_PUMP_ARROW.renderOn(blockState);
|
||||
SuperByteBuffer arrow = PartialBufferer.get(AllBlockPartials.MECHANICAL_PUMP_ARROW, blockState);
|
||||
Direction direction = blockState.get(PumpBlock.FACING);
|
||||
MatrixStacker.of(ms)
|
||||
.centre()
|
||||
.rotateY(AngleHelper.horizontalAngle(direction) + 180)
|
||||
.rotateX(-AngleHelper.verticalAngle(direction) - 90)
|
||||
.unCentre()
|
||||
.translate(rotationOffset)
|
||||
.rotateY(yRot)
|
||||
.rotateZ(angle)
|
||||
.translateBack(rotationOffset);
|
||||
.centre()
|
||||
.rotateY(AngleHelper.horizontalAngle(direction) + 180)
|
||||
.rotateX(-AngleHelper.verticalAngle(direction) - 90)
|
||||
.unCentre()
|
||||
.translate(rotationOffset)
|
||||
.rotateY(yRot)
|
||||
.rotateZ(angle)
|
||||
.translateBack(rotationOffset);
|
||||
arrow.light(light).renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||
ms.pop();
|
||||
}
|
||||
|
@ -52,7 +53,7 @@ public class PumpRenderer extends KineticTileEntityRenderer {
|
|||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
|
||||
return AllBlockPartials.MECHANICAL_PUMP_COG.renderOnDirectionalSouth(te.getBlockState());
|
||||
return PartialBufferer.getFacing(AllBlockPartials.MECHANICAL_PUMP_COG, te.getBlockState());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,9 @@ package com.simibubi.create.content.contraptions.fluids.actors;
|
|||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.components.structureMovement.pulley.AbstractPulleyRenderer;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
|
@ -23,18 +25,18 @@ public class HosePulleyRenderer extends AbstractPulleyRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected AllBlockPartials getCoil() {
|
||||
protected PartialModel getCoil() {
|
||||
return AllBlockPartials.HOSE_COIL;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer renderRope(KineticTileEntity te) {
|
||||
return AllBlockPartials.HOSE.renderOn(te.getBlockState());
|
||||
return PartialBufferer.get(AllBlockPartials.HOSE, te.getBlockState());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SuperByteBuffer renderMagnet(KineticTileEntity te) {
|
||||
return AllBlockPartials.HOSE_MAGNET.renderOn(te.getBlockState());
|
||||
return PartialBufferer.get(AllBlockPartials.HOSE_MAGNET, te.getBlockState());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.simibubi.create.content.contraptions.fluids.actors;
|
|||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.foundation.fluid.FluidRenderer;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.fluid.SmartFluidTankBehaviour.TankSegment;
|
||||
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
||||
|
@ -20,7 +22,7 @@ public class SpoutRenderer extends SafeTileEntityRenderer<SpoutTileEntity> {
|
|||
super(dispatcher);
|
||||
}
|
||||
|
||||
static final AllBlockPartials[] BITS =
|
||||
static final PartialModel[] BITS =
|
||||
{ AllBlockPartials.SPOUT_TOP, AllBlockPartials.SPOUT_MIDDLE, AllBlockPartials.SPOUT_BOTTOM };
|
||||
|
||||
@Override
|
||||
|
@ -69,10 +71,10 @@ public class SpoutRenderer extends SafeTileEntityRenderer<SpoutTileEntity> {
|
|||
squeeze = -1;
|
||||
|
||||
ms.push();
|
||||
for (AllBlockPartials bit : BITS) {
|
||||
bit.renderOn(te.getBlockState())
|
||||
.light(light)
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||
for (PartialModel bit : BITS) {
|
||||
PartialBufferer.get(bit, te.getBlockState())
|
||||
.light(light)
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||
ms.translate(0, -3 * squeeze / 32f, 0);
|
||||
}
|
||||
ms.pop();
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
|||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
|
@ -31,7 +32,7 @@ public class FluidValveRenderer extends KineticTileEntityRenderer {
|
|||
|
||||
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
|
||||
BlockState blockState = te.getBlockState();
|
||||
SuperByteBuffer pointer = AllBlockPartials.FLUID_VALVE_POINTER.renderOn(blockState);
|
||||
SuperByteBuffer pointer = PartialBufferer.get(AllBlockPartials.FLUID_VALVE_POINTER, blockState);
|
||||
Direction facing = blockState.get(FluidValveBlock.FACING);
|
||||
|
||||
if (!(te instanceof FluidValveTileEntity))
|
||||
|
|
|
@ -21,4 +21,4 @@ public class GogglesModel extends WrappedBakedModel {
|
|||
return super.handlePerspective(cameraTransformType, mat);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,9 @@ package com.simibubi.create.content.contraptions.processing.burner;
|
|||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.processing.burner.BlazeBurnerBlock.HeatLevel;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
@ -30,11 +32,11 @@ public class BlazeBurnerRenderer extends SafeTileEntityRenderer<BlazeBurnerTileE
|
|||
float renderTick = AnimationTickHolder.getRenderTime(te.getWorld()) + (te.hashCode() % 13) * 16f;
|
||||
float offset = (MathHelper.sin((float) ((renderTick / 16f) % (2 * Math.PI))) + .5f) / 16f;
|
||||
|
||||
AllBlockPartials blazeModel = AllBlockPartials.BLAZES.get(heatLevel);
|
||||
SuperByteBuffer blazeBuffer = blazeModel.renderOn(te.getBlockState());
|
||||
PartialModel blazeModel = AllBlockPartials.BLAZES.get(heatLevel);
|
||||
SuperByteBuffer blazeBuffer = PartialBufferer.get(blazeModel, te.getBlockState());
|
||||
blazeBuffer.rotateCentered(Direction.UP, AngleHelper.rad(te.headAngle.getValue(partialTicks)));
|
||||
blazeBuffer.translate(0, offset, 0);
|
||||
blazeBuffer.light(0xF000F0)
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.mojang.blaze3d.vertex.IVertexBuilder;
|
|||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.CreateClient;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer;
|
||||
|
@ -43,10 +44,10 @@ public class SpeedControllerRenderer extends SmartTileEntityRenderer<SpeedContro
|
|||
BlockState blockState = tileEntityIn.getBlockState();
|
||||
boolean alongX = blockState.get(SpeedControllerBlock.HORIZONTAL_AXIS) == Axis.X;
|
||||
|
||||
SuperByteBuffer bracket = AllBlockPartials.SPEED_CONTROLLER_BRACKET.renderOn(blockState);
|
||||
SuperByteBuffer bracket = PartialBufferer.get(AllBlockPartials.SPEED_CONTROLLER_BRACKET, blockState);
|
||||
bracket.translate(0, 1, 0);
|
||||
bracket.rotateCentered(Direction.UP,
|
||||
(float) (alongX ? Math.PI : Math.PI / 2));
|
||||
(float) (alongX ? Math.PI : Math.PI / 2));
|
||||
bracket.light(WorldRenderer.getLightmapCoordinates(world, pos.up()));
|
||||
bracket.renderInto(ms, builder);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.simibubi.create.content.contraptions.base.KineticRenderMaterials;
|
|||
import com.simibubi.create.content.contraptions.base.KineticTileInstance;
|
||||
import com.simibubi.create.content.contraptions.base.RotatingData;
|
||||
import com.simibubi.create.foundation.block.render.SpriteShiftEntry;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.InstanceData;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRenderer;
|
||||
|
@ -57,7 +58,7 @@ public class BeltInstance extends KineticTileInstance<BeltTileEntity> {
|
|||
DyeColor color = tile.color.orElse(null);
|
||||
|
||||
for (boolean bottom : Iterate.trueAndFalse) {
|
||||
AllBlockPartials beltPartial = BeltRenderer.getBeltPartial(diagonal, start, end, bottom);
|
||||
PartialModel beltPartial = BeltRenderer.getBeltPartial(diagonal, start, end, bottom);
|
||||
SpriteShiftEntry spriteShift = BeltRenderer.getSpriteShiftEntry(color, diagonal, bottom);
|
||||
|
||||
InstancedModel<BeltData> beltModel = modelManager.getMaterial(KineticRenderMaterials.BELTS).getModel(beltPartial, blockState);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.simibubi.create.content.contraptions.relays.belt;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
|
@ -11,9 +12,11 @@ import com.simibubi.create.CreateClient;
|
|||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack;
|
||||
import com.simibubi.create.foundation.block.render.SpriteShiftEntry;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.ShadowRenderHelper;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
@ -93,10 +96,10 @@ public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> {
|
|||
|
||||
for (boolean bottom : Iterate.trueAndFalse) {
|
||||
|
||||
AllBlockPartials beltPartial = getBeltPartial(diagonal, start, end, bottom);
|
||||
PartialModel beltPartial = getBeltPartial(diagonal, start, end, bottom);
|
||||
|
||||
SuperByteBuffer beltBuffer = beltPartial.renderOn(blockState)
|
||||
.light(light);
|
||||
SuperByteBuffer beltBuffer = PartialBufferer.get(beltPartial, blockState)
|
||||
.light(light);
|
||||
|
||||
SpriteShiftEntry spriteShift = getSpriteShiftEntry(color, diagonal, bottom);
|
||||
|
||||
|
@ -127,18 +130,20 @@ public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> {
|
|||
}
|
||||
|
||||
if (te.hasPulley()) {
|
||||
// TODO 1.15 find a way to cache this model matrix computation
|
||||
MatrixStack modelTransform = new MatrixStack();
|
||||
Direction dir = blockState.get(BeltBlock.HORIZONTAL_FACING).rotateY();
|
||||
if (sideways) dir = Direction.UP;
|
||||
msr = MatrixStacker.of(modelTransform);
|
||||
msr.centre();
|
||||
if (dir.getAxis() == Axis.X) msr.rotateY(90);
|
||||
if (dir.getAxis() == Axis.Y) msr.rotateX(90);
|
||||
msr.rotateX(90);
|
||||
msr.unCentre();
|
||||
Direction dir = sideways ? Direction.UP : blockState.get(BeltBlock.HORIZONTAL_FACING).rotateY();
|
||||
|
||||
SuperByteBuffer superBuffer = CreateClient.bufferCache.renderDirectionalPartial(AllBlockPartials.BELT_PULLEY, blockState, dir, modelTransform);
|
||||
Supplier<MatrixStack> matrixStackSupplier = () -> {
|
||||
MatrixStack stack = new MatrixStack();
|
||||
MatrixStacker stacker = MatrixStacker.of(stack);
|
||||
stacker.centre();
|
||||
if (dir.getAxis() == Axis.X) stacker.rotateY(90);
|
||||
if (dir.getAxis() == Axis.Y) stacker.rotateX(90);
|
||||
stacker.rotateX(90);
|
||||
stacker.unCentre();
|
||||
return stack;
|
||||
};
|
||||
|
||||
SuperByteBuffer superBuffer = CreateClient.bufferCache.renderDirectionalPartial(AllBlockPartials.BELT_PULLEY, blockState, dir, matrixStackSupplier);
|
||||
KineticTileEntityRenderer.standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, vb);
|
||||
}
|
||||
}
|
||||
|
@ -155,7 +160,7 @@ public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> {
|
|||
: bottom ? AllSpriteShifts.BELT_OFFSET : AllSpriteShifts.BELT;
|
||||
}
|
||||
|
||||
public static AllBlockPartials getBeltPartial(boolean diagonal, boolean start, boolean end, boolean bottom) {
|
||||
public static PartialModel getBeltPartial(boolean diagonal, boolean start, boolean end, boolean bottom) {
|
||||
if (diagonal) {
|
||||
if (start) return AllBlockPartials.BELT_DIAGONAL_START;
|
||||
if (end) return AllBlockPartials.BELT_DIAGONAL_END;
|
||||
|
|
|
@ -30,12 +30,12 @@ public class SplitShaftInstance extends KineticTileInstance<SplitShaftTileEntity
|
|||
|
||||
for (Direction dir : Iterate.directionsInAxis(getRotationAxis())) {
|
||||
|
||||
InstancedModel<RotatingData> half = AllBlockPartials.SHAFT_HALF.getModel(rotatingMaterial, blockState, dir);
|
||||
InstancedModel<RotatingData> half = rotatingMaterial.getModel(AllBlockPartials.SHAFT_HALF, blockState, dir);
|
||||
|
||||
float splitSpeed = speed * tile.getRotationSpeedModifier(dir);
|
||||
float splitSpeed = speed * tile.getRotationSpeedModifier(dir);
|
||||
|
||||
keys.add(setup(half.createInstance(), splitSpeed));
|
||||
}
|
||||
keys.add(setup(half.createInstance(), splitSpeed));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.simibubi.create.AllBlockPartials;
|
|||
import com.simibubi.create.content.contraptions.base.IRotate;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
@ -51,7 +52,7 @@ public class SplitShaftRenderer extends KineticTileEntityRenderer {
|
|||
angle = angle / 180f * (float) Math.PI;
|
||||
|
||||
SuperByteBuffer superByteBuffer =
|
||||
AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouth(te.getBlockState(), direction);
|
||||
PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction);
|
||||
kineticRotationTransform(superByteBuffer, te, axis, angle, light);
|
||||
superByteBuffer.renderInto(ms, buffer.getBuffer(RenderType.getSolid()));
|
||||
}
|
||||
|
|
|
@ -6,8 +6,10 @@ import com.simibubi.create.AllBlockPartials;
|
|||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.content.contraptions.relays.gauge.GaugeBlock.Type;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -25,11 +27,11 @@ public class GaugeRenderer extends KineticTileEntityRenderer {
|
|||
public static GaugeRenderer speed(TileEntityRendererDispatcher dispatcher) {
|
||||
return new GaugeRenderer(dispatcher, Type.SPEED);
|
||||
}
|
||||
|
||||
|
||||
public static GaugeRenderer stress(TileEntityRendererDispatcher dispatcher) {
|
||||
return new GaugeRenderer(dispatcher, Type.STRESS);
|
||||
}
|
||||
|
||||
|
||||
protected GaugeRenderer(TileEntityRendererDispatcher dispatcher, GaugeBlock.Type type) {
|
||||
super(dispatcher);
|
||||
this.type = type;
|
||||
|
@ -45,17 +47,17 @@ public class GaugeRenderer extends KineticTileEntityRenderer {
|
|||
GaugeTileEntity gaugeTE = (GaugeTileEntity) te;
|
||||
int lightCoords = WorldRenderer.getLightmapCoordinates(te.getWorld(), gaugeState, te.getPos());
|
||||
|
||||
PartialModel partialModel = (type == Type.SPEED ? AllBlockPartials.GAUGE_HEAD_SPEED : AllBlockPartials.GAUGE_HEAD_STRESS);
|
||||
SuperByteBuffer headBuffer =
|
||||
(type == Type.SPEED ? AllBlockPartials.GAUGE_HEAD_SPEED : AllBlockPartials.GAUGE_HEAD_STRESS)
|
||||
.renderOn(gaugeState);
|
||||
SuperByteBuffer dialBuffer = AllBlockPartials.GAUGE_DIAL.renderOn(gaugeState);
|
||||
PartialBufferer.get(partialModel, gaugeState);
|
||||
SuperByteBuffer dialBuffer = PartialBufferer.get(AllBlockPartials.GAUGE_DIAL, gaugeState);
|
||||
|
||||
float dialPivot = 5.75f / 16;
|
||||
float progress = MathHelper.lerp(partialTicks, gaugeTE.prevDialState, gaugeTE.dialState);
|
||||
|
||||
for (Direction facing : Iterate.directions) {
|
||||
if (!((GaugeBlock) gaugeState.getBlock()).shouldRenderHeadOnFace(te.getWorld(), te.getPos(), gaugeState,
|
||||
facing))
|
||||
facing))
|
||||
continue;
|
||||
|
||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||
|
|
|
@ -36,20 +36,20 @@ public class GearboxInstance extends KineticTileInstance<GearboxTileEntity> {
|
|||
RenderMaterial<?, InstancedModel<RotatingData>> rotatingMaterial = getRotatingMaterial();
|
||||
|
||||
for (Direction direction : Iterate.directions) {
|
||||
final Direction.Axis axis = direction.getAxis();
|
||||
if (boxAxis == axis)
|
||||
continue;
|
||||
final Direction.Axis axis = direction.getAxis();
|
||||
if (boxAxis == axis)
|
||||
continue;
|
||||
|
||||
InstancedModel<RotatingData> shaft = AllBlockPartials.SHAFT_HALF.getModel(rotatingMaterial, blockState, direction);
|
||||
InstancedModel<RotatingData> shaft = rotatingMaterial.getModel(AllBlockPartials.SHAFT_HALF, blockState, direction);
|
||||
|
||||
RotatingData key = shaft.createInstance();
|
||||
RotatingData key = shaft.createInstance();
|
||||
|
||||
key.setRotationAxis(Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, axis).getUnitVector())
|
||||
.setRotationalSpeed(getSpeed(direction))
|
||||
.setRotationOffset(getRotationOffset(axis)).setColor(tile)
|
||||
.setPosition(getInstancePosition())
|
||||
.setBlockLight(blockLight)
|
||||
.setSkyLight(skyLight);
|
||||
key.setRotationAxis(Direction.getFacingFromAxis(Direction.AxisDirection.POSITIVE, axis).getUnitVector())
|
||||
.setRotationalSpeed(getSpeed(direction))
|
||||
.setRotationOffset(getRotationOffset(axis)).setColor(tile)
|
||||
.setPosition(getInstancePosition())
|
||||
.setBlockLight(blockLight)
|
||||
.setSkyLight(skyLight);
|
||||
|
||||
keys.put(direction, key);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
|||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
@ -37,7 +38,7 @@ public class GearboxRenderer extends KineticTileEntityRenderer {
|
|||
if (boxAxis == axis)
|
||||
continue;
|
||||
|
||||
SuperByteBuffer shaft = AllBlockPartials.SHAFT_HALF.renderOnDirectionalSouth(te.getBlockState(), direction);
|
||||
SuperByteBuffer shaft = PartialBufferer.getFacing(AllBlockPartials.SHAFT_HALF, te.getBlockState(), direction);
|
||||
float offset = getRotationOffsetForPosition(te, pos, axis);
|
||||
float angle = (time * te.getSpeed() * 3f / 10) % 360;
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Map;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
|
||||
|
@ -86,7 +87,7 @@ public class CrossPlaneMirror extends SymmetryMirror {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AllBlockPartials getModel() {
|
||||
public PartialModel getModel() {
|
||||
return AllBlockPartials.SYMMETRY_CROSSPLANE;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
@ -17,13 +17,13 @@ public class EmptyMirror extends SymmetryMirror {
|
|||
|
||||
public static enum Align implements IStringSerializable {
|
||||
None("none");
|
||||
|
||||
|
||||
private final String name;
|
||||
private Align(String name) { this.name = name; }
|
||||
@Override public String getString() { return name; }
|
||||
@Override public String toString() { return name; }
|
||||
}
|
||||
|
||||
|
||||
public EmptyMirror(Vector3d pos) {
|
||||
super(pos);
|
||||
orientation = Align.None;
|
||||
|
@ -50,10 +50,10 @@ public class EmptyMirror extends SymmetryMirror {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AllBlockPartials getModel() {
|
||||
public PartialModel getModel() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ITextComponent> getAlignToolTips() {
|
||||
return ImmutableList.of();
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Map;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
|
||||
|
@ -82,7 +83,7 @@ public class PlaneMirror extends SymmetryMirror {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AllBlockPartials getModel() {
|
||||
public PartialModel getModel() {
|
||||
return AllBlockPartials.SYMMETRY_PLANE;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.util.Map;
|
|||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -80,7 +80,7 @@ public abstract class SymmetryMirror {
|
|||
|
||||
public abstract String typeName();
|
||||
|
||||
public abstract AllBlockPartials getModel();
|
||||
public abstract PartialModel getModel();
|
||||
|
||||
public void applyModelTransform(MatrixStack ms) {}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.Map;
|
|||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -43,7 +44,7 @@ public class TriplePlaneMirror extends SymmetryMirror {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AllBlockPartials getModel() {
|
||||
public PartialModel getModel() {
|
||||
return AllBlockPartials.SYMMETRY_TRIPLEPLANE;
|
||||
}
|
||||
|
||||
|
@ -54,12 +55,12 @@ public class TriplePlaneMirror extends SymmetryMirror {
|
|||
@Override
|
||||
public void setOrientation(int index) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IStringSerializable getOrientation() {
|
||||
return CrossPlaneMirror.Align.Y;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ITextComponent> getAlignToolTips() {
|
||||
return ImmutableList.of(Lang.translate("orientation.horizontal"));
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simibubi.create.content.curiosities.tools;
|
|||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.AllItems;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
|
||||
|
@ -28,7 +29,7 @@ public class ExtendoGripRenderHandler {
|
|||
|
||||
public static float mainHandAnimation;
|
||||
public static float lastMainHandAnimation;
|
||||
public static AllBlockPartials pose = AllBlockPartials.DEPLOYER_HAND_PUNCHING;
|
||||
public static PartialModel pose = AllBlockPartials.DEPLOYER_HAND_PUNCHING;
|
||||
|
||||
public static void tick() {
|
||||
lastMainHandAnimation = mainHandAnimation;
|
||||
|
|
|
@ -52,7 +52,7 @@ public class RedstoneLinkNetworkHandler {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return item.hashCode() ^ color;
|
||||
return (item.hashCode() * 31) ^ color;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -66,7 +66,7 @@ public class BeltTunnelInstance extends TileEntityInstance<BeltTunnelTileEntity>
|
|||
tunnelFlaps.put(direction, flaps);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean shouldReset() {
|
||||
return super.shouldReset() || tunnelFlaps.size() != tile.flaps.size();
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simibubi.create.content.logistics.block.belts.tunnel;
|
|||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer;
|
||||
|
@ -32,7 +33,7 @@ public class BeltTunnelRenderer extends SmartTileEntityRenderer<BeltTunnelTileEn
|
|||
|
||||
if (FastRenderDispatcher.available(te.getWorld())) return;
|
||||
|
||||
SuperByteBuffer flapBuffer = AllBlockPartials.BELT_TUNNEL_FLAP.renderOn(te.getBlockState());
|
||||
SuperByteBuffer flapBuffer = PartialBufferer.get(AllBlockPartials.BELT_TUNNEL_FLAP, te.getBlockState());
|
||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||
Vector3d pivot = VecHelper.voxelSpace(0, 10, 1f);
|
||||
MatrixStacker msr = MatrixStacker.of(ms);
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.mojang.blaze3d.vertex.IVertexBuilder;
|
|||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
|
@ -45,10 +46,10 @@ public class EjectorRenderer extends KineticTileEntityRenderer {
|
|||
float angle = lidProgress * 70;
|
||||
|
||||
if (!FastRenderDispatcher.available(te.getWorld())) {
|
||||
SuperByteBuffer model = AllBlockPartials.EJECTOR_TOP.renderOn(te.getBlockState());
|
||||
SuperByteBuffer model = PartialBufferer.get(AllBlockPartials.EJECTOR_TOP, te.getBlockState());
|
||||
applyLidAngle(te, angle, model.matrixStacker());
|
||||
model.light(light)
|
||||
.renderInto(ms, vertexBuilder);
|
||||
.renderInto(ms, vertexBuilder);
|
||||
}
|
||||
|
||||
MatrixStacker msr = MatrixStacker.of(ms);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.simibubi.create.content.logistics.block.diodes;
|
||||
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.tileEntity.renderer.ColoredOverlayTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.utility.ColorHelper;
|
||||
|
@ -20,7 +21,7 @@ public class AdjustableRepeaterRenderer extends ColoredOverlayTileEntityRenderer
|
|||
|
||||
@Override
|
||||
protected SuperByteBuffer getOverlayBuffer(AdjustableRepeaterTileEntity te) {
|
||||
return AllBlockPartials.FLEXPEATER_INDICATOR.renderOn(te.getBlockState());
|
||||
return PartialBufferer.get(AllBlockPartials.FLEXPEATER_INDICATOR, te.getBlockState());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.contraptions.base.KineticRenderMaterials;
|
||||
import com.simibubi.create.content.logistics.block.FlapData;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.IDynamicInstance;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.InstanceData;
|
||||
import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
|
||||
|
@ -26,7 +27,7 @@ public class FunnelInstance extends TileEntityInstance<FunnelTileEntity> impleme
|
|||
|
||||
if (!tile.hasFlap()) return;
|
||||
|
||||
AllBlockPartials flapPartial = (blockState.getBlock() instanceof FunnelBlock ? AllBlockPartials.FUNNEL_FLAP
|
||||
PartialModel flapPartial = (blockState.getBlock() instanceof FunnelBlock ? AllBlockPartials.FUNNEL_FLAP
|
||||
: AllBlockPartials.BELT_FUNNEL_FLAP);
|
||||
InstancedModel<FlapData> model = modelManager.getMaterial(KineticRenderMaterials.FLAPS)
|
||||
.getModel(flapPartial, blockState);
|
||||
|
|
|
@ -3,8 +3,10 @@ package com.simibubi.create.content.logistics.block.funnel;
|
|||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.tileEntity.renderer.SmartTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
|
@ -33,18 +35,19 @@ public class FunnelRenderer extends SmartTileEntityRenderer<FunnelTileEntity> {
|
|||
|
||||
BlockState blockState = te.getBlockState();
|
||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||
SuperByteBuffer flapBuffer = (blockState.getBlock() instanceof FunnelBlock ? AllBlockPartials.FUNNEL_FLAP
|
||||
: AllBlockPartials.BELT_FUNNEL_FLAP).renderOn(blockState);
|
||||
PartialModel partialModel = (blockState.getBlock() instanceof FunnelBlock ? AllBlockPartials.FUNNEL_FLAP
|
||||
: AllBlockPartials.BELT_FUNNEL_FLAP);
|
||||
SuperByteBuffer flapBuffer = PartialBufferer.get(partialModel, blockState);
|
||||
Vector3d pivot = VecHelper.voxelSpace(0, 10, 9.5f);
|
||||
MatrixStacker msr = MatrixStacker.of(ms);
|
||||
|
||||
float horizontalAngle = AngleHelper.horizontalAngle(FunnelBlock.getFunnelFacing(blockState)
|
||||
.getOpposite());
|
||||
.getOpposite());
|
||||
float f = te.flap.get(partialTicks);
|
||||
|
||||
ms.push();
|
||||
msr.centre()
|
||||
.rotateY(horizontalAngle)
|
||||
.rotateY(horizontalAngle)
|
||||
.unCentre();
|
||||
ms.translate(0, 0, -te.getFlapOffset());
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.simibubi.create.content.logistics.block.funnel.FunnelBlock;
|
|||
import com.simibubi.create.content.logistics.block.funnel.FunnelTileEntity;
|
||||
import com.simibubi.create.foundation.advancement.AllTriggers;
|
||||
import com.simibubi.create.foundation.item.SmartInventory;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.belt.TransportedItemStackHandlerBehaviour.TransportedResult;
|
||||
|
@ -100,7 +101,7 @@ public abstract class ArmInteractionPoint {
|
|||
@OnlyIn(Dist.CLIENT)
|
||||
void transformFlag(MatrixStack stack) {}
|
||||
|
||||
AllBlockPartials getFlagType() {
|
||||
PartialModel getFlagType() {
|
||||
return mode == Mode.TAKE ? AllBlockPartials.FLAG_LONG_OUT : AllBlockPartials.FLAG_LONG_IN;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.simibubi.create.AllBlockPartials;
|
|||
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||
import com.simibubi.create.content.logistics.block.mechanicalArm.ArmTileEntity.Phase;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
@ -66,7 +67,7 @@ public class ArmRenderer extends KineticTileEntityRenderer {
|
|||
float lowerArmAngle = arm.lowerArmAngle.get(pt) - 135;
|
||||
float upperArmAngle = arm.upperArmAngle.get(pt) - 90;
|
||||
float headAngle = arm.headAngle.get(pt);
|
||||
|
||||
|
||||
boolean rave = arm.phase == Phase.DANCING;
|
||||
float renderTick = AnimationTickHolder.getRenderTime(te.getWorld()) + (te.hashCode() % 64);
|
||||
if (rave) {
|
||||
|
@ -104,21 +105,21 @@ public class ArmRenderer extends KineticTileEntityRenderer {
|
|||
}
|
||||
|
||||
private void renderArm(IVertexBuilder builder, MatrixStack ms, MatrixStack msLocal, MatrixStacker msr, BlockState blockState, int color, float baseAngle, float lowerArmAngle, float upperArmAngle, float headAngle, boolean hasItem, boolean isBlockItem, int light) {
|
||||
SuperByteBuffer base = AllBlockPartials.ARM_BASE.renderOn(blockState).light(light);
|
||||
SuperByteBuffer lowerBody = AllBlockPartials.ARM_LOWER_BODY.renderOn(blockState).light(light);
|
||||
SuperByteBuffer upperBody = AllBlockPartials.ARM_UPPER_BODY.renderOn(blockState).light(light);
|
||||
SuperByteBuffer head = AllBlockPartials.ARM_HEAD.renderOn(blockState).light(light);
|
||||
SuperByteBuffer claw = AllBlockPartials.ARM_CLAW_BASE.renderOn(blockState).light(light);
|
||||
SuperByteBuffer clawGrip = AllBlockPartials.ARM_CLAW_GRIP.renderOn(blockState);
|
||||
SuperByteBuffer base = PartialBufferer.get(AllBlockPartials.ARM_BASE, blockState).light(light);
|
||||
SuperByteBuffer lowerBody = PartialBufferer.get(AllBlockPartials.ARM_LOWER_BODY, blockState).light(light);
|
||||
SuperByteBuffer upperBody = PartialBufferer.get(AllBlockPartials.ARM_UPPER_BODY, blockState).light(light);
|
||||
SuperByteBuffer head = PartialBufferer.get(AllBlockPartials.ARM_HEAD, blockState).light(light);
|
||||
SuperByteBuffer claw = PartialBufferer.get(AllBlockPartials.ARM_CLAW_BASE, blockState).light(light);
|
||||
SuperByteBuffer clawGrip = PartialBufferer.get(AllBlockPartials.ARM_CLAW_GRIP, blockState);
|
||||
|
||||
transformBase(msr, baseAngle);
|
||||
base.transform(msLocal)
|
||||
.renderInto(ms, builder);
|
||||
.renderInto(ms, builder);
|
||||
|
||||
transformLowerArm(msr, lowerArmAngle);
|
||||
lowerBody.color(color)
|
||||
.transform(msLocal)
|
||||
.renderInto(ms, builder);
|
||||
.transform(msLocal)
|
||||
.renderInto(ms, builder);
|
||||
|
||||
transformUpperArm(msr, upperArmAngle);
|
||||
upperBody.color(color)
|
||||
|
@ -182,7 +183,7 @@ public class ArmRenderer extends KineticTileEntityRenderer {
|
|||
|
||||
@Override
|
||||
protected SuperByteBuffer getRotatedModel(KineticTileEntity te) {
|
||||
return AllBlockPartials.ARM_COG.renderOn(te.getBlockState());
|
||||
return PartialBufferer.get(AllBlockPartials.ARM_COG, te.getBlockState());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simibubi.create.content.logistics.block.redstone;
|
|||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
||||
|
@ -36,20 +37,20 @@ public class AnalogLeverRenderer extends SafeTileEntityRenderer<AnalogLeverTileE
|
|||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||
|
||||
// Handle
|
||||
SuperByteBuffer handle = AllBlockPartials.ANALOG_LEVER_HANDLE.renderOn(leverState);
|
||||
SuperByteBuffer handle = PartialBufferer.get(AllBlockPartials.ANALOG_LEVER_HANDLE, leverState);
|
||||
float angle = (float) ((state / 15) * 90 / 180 * Math.PI);
|
||||
transform(handle, leverState).translate(1 / 2f, 1 / 16f, 1 / 2f)
|
||||
.rotate(Direction.EAST, angle)
|
||||
.translate(-1 / 2f, -1 / 16f, -1 / 2f);
|
||||
.rotate(Direction.EAST, angle)
|
||||
.translate(-1 / 2f, -1 / 16f, -1 / 2f);
|
||||
handle.light(lightCoords)
|
||||
.renderInto(ms, vb);
|
||||
.renderInto(ms, vb);
|
||||
|
||||
// Indicator
|
||||
int color = ColorHelper.mixColors(0x2C0300, 0xCD0000, state / 15f);
|
||||
SuperByteBuffer indicator = transform(AllBlockPartials.ANALOG_LEVER_INDICATOR.renderOn(leverState), leverState);
|
||||
SuperByteBuffer indicator = transform(PartialBufferer.get(AllBlockPartials.ANALOG_LEVER_INDICATOR, leverState), leverState);
|
||||
indicator.light(lightCoords)
|
||||
.color(color)
|
||||
.renderInto(ms, vb);
|
||||
.color(color)
|
||||
.renderInto(ms, vb);
|
||||
}
|
||||
|
||||
private SuperByteBuffer transform(SuperByteBuffer buffer, BlockState leverState) {
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.mojang.blaze3d.vertex.IVertexBuilder;
|
|||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.schematics.block.LaunchedItem.ForBlockState;
|
||||
import com.simibubi.create.content.schematics.block.LaunchedItem.ForEntity;
|
||||
import com.simibubi.create.foundation.render.PartialBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.render.backend.FastRenderDispatcher;
|
||||
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
||||
|
@ -31,7 +32,7 @@ public class SchematicannonRenderer extends SafeTileEntityRenderer<Schematicanno
|
|||
public SchematicannonRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||
super(dispatcher);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isGlobalRenderer(SchematicannonTileEntity p_188185_1_) {
|
||||
return true;
|
||||
|
@ -62,13 +63,13 @@ public class SchematicannonRenderer extends SafeTileEntityRenderer<Schematicanno
|
|||
|
||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||
|
||||
SuperByteBuffer connector = AllBlockPartials.SCHEMATICANNON_CONNECTOR.renderOn(state);
|
||||
SuperByteBuffer connector = PartialBufferer.get(AllBlockPartials.SCHEMATICANNON_CONNECTOR, state);
|
||||
connector.translate(.5f, 0, .5f);
|
||||
connector.rotate(Direction.UP, (float) ((yaw + 90) / 180 * Math.PI));
|
||||
connector.translate(-.5f, 0, -.5f);
|
||||
connector.light(lightCoords).renderInto(ms, vb);
|
||||
|
||||
SuperByteBuffer pipe = AllBlockPartials.SCHEMATICANNON_PIPE.renderOn(state);
|
||||
SuperByteBuffer pipe = PartialBufferer.get(AllBlockPartials.SCHEMATICANNON_PIPE, state);
|
||||
pipe.translate(.5f, 15 / 16f, .5f);
|
||||
pipe.rotate(Direction.UP, (float) ((yaw + 90) / 180 * Math.PI));
|
||||
pipe.rotate(Direction.SOUTH, (float) (pitch / 180 * Math.PI));
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
package com.simibubi.create.foundation;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class OptionalUtil {
|
||||
|
||||
public static <T> Optional<T> thenTry(Optional<T> first, Optional<T> thenTry) {
|
||||
if (first.isPresent()) {
|
||||
return first;
|
||||
} else {
|
||||
return thenTry;
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> Optional<T> thenTryLazy(Supplier<Optional<T>> first, Supplier<Optional<T>> thenTry) {
|
||||
Optional<T> one = first.get();
|
||||
if (one.isPresent()) {
|
||||
return one;
|
||||
} else {
|
||||
return thenTry.get();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,8 +8,8 @@ import com.mojang.blaze3d.platform.GlStateManager.DestFactor;
|
|||
import com.mojang.blaze3d.platform.GlStateManager.SourceFactor;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.foundation.fluid.FluidRenderer;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.utility.ColorHelper;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
import com.simibubi.create.foundation.utility.VirtualEmptyModelData;
|
||||
|
@ -53,7 +53,7 @@ public class GuiGameElement {
|
|||
return new GuiBlockStateRenderBuilder(state);
|
||||
}
|
||||
|
||||
public static GuiRenderBuilder of(AllBlockPartials partial) {
|
||||
public static GuiRenderBuilder of(PartialModel partial) {
|
||||
return new GuiBlockPartialRenderBuilder(partial);
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,7 @@ public class GuiGameElement {
|
|||
|
||||
public static class GuiBlockPartialRenderBuilder extends GuiBlockModelRenderBuilder {
|
||||
|
||||
public GuiBlockPartialRenderBuilder(AllBlockPartials partial) {
|
||||
public GuiBlockPartialRenderBuilder(PartialModel partial) {
|
||||
super(partial.get(), null);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,13 +2,13 @@ package com.simibubi.create.foundation.render;
|
|||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
public class Compartment<T> {
|
||||
public static final Compartment<BlockState> GENERIC_TILE = new Compartment<>();
|
||||
public static final Compartment<AllBlockPartials> PARTIAL = new Compartment<>();
|
||||
public static final Compartment<Pair<Direction, AllBlockPartials>> DIRECTIONAL_PARTIAL = new Compartment<>();
|
||||
public static final Compartment<PartialModel> PARTIAL = new Compartment<>();
|
||||
public static final Compartment<Pair<Direction, PartialModel>> DIRECTIONAL_PARTIAL = new Compartment<>();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package com.simibubi.create.foundation.render;
|
||||
|
||||
import static net.minecraft.state.properties.BlockStateProperties.FACING;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.CreateClient;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
public class PartialBufferer {
|
||||
|
||||
public static SuperByteBuffer get(PartialModel partial, BlockState referenceState) {
|
||||
return CreateClient.bufferCache.renderPartial(partial, referenceState);
|
||||
}
|
||||
|
||||
public static SuperByteBuffer getFacing(PartialModel partial, BlockState referenceState) {
|
||||
Direction facing = referenceState.get(FACING);
|
||||
return getFacing(partial, referenceState, facing);
|
||||
}
|
||||
|
||||
public static SuperByteBuffer getFacing(PartialModel partial, BlockState referenceState, Direction facing) {
|
||||
return CreateClient.bufferCache.renderDirectionalPartial(partial, referenceState, facing, rotateToFace(facing));
|
||||
}
|
||||
|
||||
public static Supplier<MatrixStack> rotateToFace(Direction facing) {
|
||||
return () -> {
|
||||
MatrixStack stack = new MatrixStack();
|
||||
MatrixStacker.of(stack)
|
||||
.centre()
|
||||
.rotateY(AngleHelper.horizontalAngle(facing))
|
||||
.rotateX(AngleHelper.verticalAngle(facing))
|
||||
.unCentre();
|
||||
return stack;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
|
@ -12,7 +12,7 @@ import org.lwjgl.opengl.GL11;
|
|||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.foundation.render.backend.core.PartialModel;
|
||||
import com.simibubi.create.foundation.utility.VirtualEmptyModelData;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -41,26 +41,26 @@ public class SuperByteBufferCache {
|
|||
return getGeneric(toRender, () -> standardBlockRender(toRender));
|
||||
}
|
||||
|
||||
public SuperByteBuffer renderPartial(AllBlockPartials partial, BlockState referenceState) {
|
||||
public SuperByteBuffer renderPartial(PartialModel partial, BlockState referenceState) {
|
||||
return get(Compartment.PARTIAL, partial, () -> standardModelRender(partial.get(), referenceState));
|
||||
}
|
||||
|
||||
public SuperByteBuffer renderPartial(AllBlockPartials partial, BlockState referenceState,
|
||||
MatrixStack modelTransform) {
|
||||
public SuperByteBuffer renderPartial(PartialModel partial, BlockState referenceState,
|
||||
Supplier<MatrixStack> modelTransform) {
|
||||
return get(Compartment.PARTIAL, partial,
|
||||
() -> standardModelRender(partial.get(), referenceState, modelTransform));
|
||||
() -> standardModelRender(partial.get(), referenceState, modelTransform.get()));
|
||||
}
|
||||
|
||||
public SuperByteBuffer renderDirectionalPartial(AllBlockPartials partial, BlockState referenceState,
|
||||
Direction dir) {
|
||||
public SuperByteBuffer renderDirectionalPartial(PartialModel partial, BlockState referenceState,
|
||||
Direction dir) {
|
||||
return get(Compartment.DIRECTIONAL_PARTIAL, Pair.of(dir, partial),
|
||||
() -> standardModelRender(partial.get(), referenceState));
|
||||
}
|
||||
|
||||
public SuperByteBuffer renderDirectionalPartial(AllBlockPartials partial, BlockState referenceState, Direction dir,
|
||||
MatrixStack modelTransform) {
|
||||
public SuperByteBuffer renderDirectionalPartial(PartialModel partial, BlockState referenceState, Direction dir,
|
||||
Supplier<MatrixStack> modelTransform) {
|
||||
return get(Compartment.DIRECTIONAL_PARTIAL, Pair.of(dir, partial),
|
||||
() -> standardModelRender(partial.get(), referenceState, modelTransform));
|
||||
() -> standardModelRender(partial.get(), referenceState, modelTransform.get()));
|
||||
}
|
||||
|
||||
public SuperByteBuffer renderBlockIn(Compartment<BlockState> compartment, BlockState toRender) {
|
||||
|
|
|
@ -13,75 +13,75 @@ import net.minecraft.client.renderer.BufferBuilder;
|
|||
|
||||
public abstract class BufferedModel extends TemplateBuffer {
|
||||
|
||||
protected GlBuffer modelVBO;
|
||||
protected boolean removed;
|
||||
protected GlBuffer modelVBO;
|
||||
protected boolean removed;
|
||||
|
||||
protected BufferedModel(BufferBuilder buf) {
|
||||
super(buf);
|
||||
if (vertexCount > 0) init();
|
||||
}
|
||||
protected BufferedModel(BufferBuilder buf) {
|
||||
super(buf);
|
||||
if (vertexCount > 0) init();
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
protected void init() {
|
||||
|
||||
modelVBO = new GlBuffer(GL20.GL_ARRAY_BUFFER);
|
||||
modelVBO = new GlBuffer(GL20.GL_ARRAY_BUFFER);
|
||||
|
||||
modelVBO.with(vbo -> initModel());
|
||||
}
|
||||
modelVBO.with(vbo -> initModel());
|
||||
}
|
||||
|
||||
protected void initModel() {
|
||||
int stride = getModelFormat().getStride();
|
||||
int invariantSize = vertexCount * stride;
|
||||
protected void initModel() {
|
||||
int stride = getModelFormat().getStride();
|
||||
int invariantSize = vertexCount * stride;
|
||||
|
||||
// allocate the buffer on the gpu
|
||||
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, invariantSize, GL15.GL_STATIC_DRAW);
|
||||
// allocate the buffer on the gpu
|
||||
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, invariantSize, GL15.GL_STATIC_DRAW);
|
||||
|
||||
// mirror it in system memory so we can write to it
|
||||
modelVBO.map(invariantSize, buffer -> {
|
||||
for (int i = 0; i < vertexCount; i++) {
|
||||
copyVertex(buffer, i);
|
||||
}
|
||||
});
|
||||
}
|
||||
// mirror it in system memory so we can write to it
|
||||
modelVBO.map(invariantSize, buffer -> {
|
||||
for (int i = 0; i < vertexCount; i++) {
|
||||
copyVertex(buffer, i);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract void copyVertex(ByteBuffer to, int index);
|
||||
protected abstract void copyVertex(ByteBuffer to, int index);
|
||||
|
||||
protected abstract VertexFormat getModelFormat();
|
||||
protected abstract VertexFormat getModelFormat();
|
||||
|
||||
protected int getTotalShaderAttributeCount() {
|
||||
return getModelFormat().getShaderAttributeCount();
|
||||
}
|
||||
protected int getTotalShaderAttributeCount() {
|
||||
return getModelFormat().getShaderAttributeCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders this model, checking first if there is anything to render.
|
||||
*/
|
||||
public final void render() {
|
||||
if (vertexCount == 0 || removed) return;
|
||||
/**
|
||||
* Renders this model, checking first if there is anything to render.
|
||||
*/
|
||||
public final void render() {
|
||||
if (vertexCount == 0 || removed) return;
|
||||
|
||||
doRender();
|
||||
}
|
||||
doRender();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up any state and make the draw calls.
|
||||
*/
|
||||
protected abstract void doRender();
|
||||
/**
|
||||
* Set up any state and make the draw calls.
|
||||
*/
|
||||
protected abstract void doRender();
|
||||
|
||||
protected void setupAttributes() {
|
||||
int numAttributes = getTotalShaderAttributeCount();
|
||||
for (int i = 0; i <= numAttributes; i++) {
|
||||
GL20.glEnableVertexAttribArray(i);
|
||||
}
|
||||
protected void setupAttributes() {
|
||||
int numAttributes = getTotalShaderAttributeCount();
|
||||
for (int i = 0; i <= numAttributes; i++) {
|
||||
GL20.glEnableVertexAttribArray(i);
|
||||
}
|
||||
|
||||
getModelFormat().vertexAttribPointers(0);
|
||||
}
|
||||
getModelFormat().vertexAttribPointers(0);
|
||||
}
|
||||
|
||||
public final void delete() {
|
||||
removed = true;
|
||||
if (vertexCount > 0) {
|
||||
RenderWork.enqueue(this::deleteInternal);
|
||||
}
|
||||
}
|
||||
public final void delete() {
|
||||
removed = true;
|
||||
if (vertexCount > 0) {
|
||||
RenderWork.enqueue(this::deleteInternal);
|
||||
}
|
||||
}
|
||||
|
||||
protected void deleteInternal() {
|
||||
modelVBO.delete();
|
||||
}
|
||||
protected void deleteInternal() {
|
||||
modelVBO.delete();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,56 +17,56 @@ import net.minecraft.world.World;
|
|||
|
||||
public class FastRenderDispatcher {
|
||||
|
||||
public static WorldAttached<ConcurrentHashMap.KeySetView<TileEntity, Boolean>> queuedUpdates = new WorldAttached<>(ConcurrentHashMap::newKeySet);
|
||||
public static WorldAttached<ConcurrentHashMap.KeySetView<TileEntity, Boolean>> queuedUpdates = new WorldAttached<>(ConcurrentHashMap::newKeySet);
|
||||
|
||||
public static void enqueueUpdate(TileEntity te) {
|
||||
queuedUpdates.get(te.getWorld()).add(te);
|
||||
}
|
||||
public static void enqueueUpdate(TileEntity te) {
|
||||
queuedUpdates.get(te.getWorld()).add(te);
|
||||
}
|
||||
|
||||
public static void tick() {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
ClientWorld world = mc.world;
|
||||
public static void tick() {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
ClientWorld world = mc.world;
|
||||
|
||||
KineticRenderer kineticRenderer = CreateClient.kineticRenderer.get(world);
|
||||
KineticRenderer kineticRenderer = CreateClient.kineticRenderer.get(world);
|
||||
|
||||
Entity renderViewEntity = mc.renderViewEntity;
|
||||
kineticRenderer.tick(renderViewEntity.getX(), renderViewEntity.getY(), renderViewEntity.getZ());
|
||||
Entity renderViewEntity = mc.renderViewEntity;
|
||||
kineticRenderer.tick(renderViewEntity.getX(), renderViewEntity.getY(), renderViewEntity.getZ());
|
||||
|
||||
ConcurrentHashMap.KeySetView<TileEntity, Boolean> map = queuedUpdates.get(world);
|
||||
map
|
||||
.forEach(te -> {
|
||||
map.remove(te);
|
||||
ConcurrentHashMap.KeySetView<TileEntity, Boolean> map = queuedUpdates.get(world);
|
||||
map
|
||||
.forEach(te -> {
|
||||
map.remove(te);
|
||||
|
||||
kineticRenderer.update(te);
|
||||
});
|
||||
}
|
||||
kineticRenderer.update(te);
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean available() {
|
||||
return Backend.canUseInstancing();
|
||||
}
|
||||
public static boolean available() {
|
||||
return Backend.canUseInstancing();
|
||||
}
|
||||
|
||||
public static boolean available(World world) {
|
||||
return Backend.canUseInstancing() && Backend.isFlywheelWorld(world);
|
||||
}
|
||||
public static boolean available(World world) {
|
||||
return Backend.canUseInstancing() && Backend.isFlywheelWorld(world);
|
||||
}
|
||||
|
||||
public static int getDebugMode() {
|
||||
return KineticDebugger.isActive() ? 1 : 0;
|
||||
}
|
||||
public static int getDebugMode() {
|
||||
return KineticDebugger.isActive() ? 1 : 0;
|
||||
}
|
||||
|
||||
public static void refresh() {
|
||||
RenderWork.enqueue(Minecraft.getInstance().worldRenderer::loadRenderers);
|
||||
}
|
||||
public static void refresh() {
|
||||
RenderWork.enqueue(Minecraft.getInstance().worldRenderer::loadRenderers);
|
||||
}
|
||||
|
||||
public static void renderLayer(RenderType layer, Matrix4f viewProjection, double cameraX, double cameraY, double cameraZ) {
|
||||
if (!Backend.canUseInstancing()) return;
|
||||
public static void renderLayer(RenderType layer, Matrix4f viewProjection, double cameraX, double cameraY, double cameraZ) {
|
||||
if (!Backend.canUseInstancing()) return;
|
||||
|
||||
ClientWorld world = Minecraft.getInstance().world;
|
||||
KineticRenderer kineticRenderer = CreateClient.kineticRenderer.get(world);
|
||||
ClientWorld world = Minecraft.getInstance().world;
|
||||
KineticRenderer kineticRenderer = CreateClient.kineticRenderer.get(world);
|
||||
|
||||
layer.startDrawing();
|
||||
layer.startDrawing();
|
||||
|
||||
kineticRenderer.render(layer, viewProjection, cameraX, cameraY, cameraZ);
|
||||
kineticRenderer.render(layer, viewProjection, cameraX, cameraY, cameraZ);
|
||||
|
||||
layer.endDrawing();
|
||||
}
|
||||
layer.endDrawing();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,6 @@ import com.simibubi.create.foundation.render.backend.core.OrientedData;
|
|||
import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
|
||||
|
||||
public class MaterialTypes {
|
||||
public static final MaterialType<InstancedModel<ModelData>> TRANSFORMED = new MaterialType<>();
|
||||
public static final MaterialType<InstancedModel<OrientedData>> ORIENTED = new MaterialType<>();
|
||||
public static final MaterialType<InstancedModel<ModelData>> TRANSFORMED = new MaterialType<>();
|
||||
public static final MaterialType<InstancedModel<OrientedData>> ORIENTED = new MaterialType<>();
|
||||
}
|
||||
|
|
|
@ -9,77 +9,78 @@ import java.util.Optional;
|
|||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class OptifineHandler {
|
||||
public static final String OPTIFINE_ROOT_PACKAGE = "net.optifine";
|
||||
public static final String SHADER_PACKAGE = "net.optifine.shaders";
|
||||
public static final String OPTIFINE_ROOT_PACKAGE = "net.optifine";
|
||||
public static final String SHADER_PACKAGE = "net.optifine.shaders";
|
||||
|
||||
private static Package optifine;
|
||||
private static OptifineHandler handler;
|
||||
private static Package optifine;
|
||||
private static OptifineHandler handler;
|
||||
|
||||
public final boolean usingShaders;
|
||||
public final boolean usingShaders;
|
||||
|
||||
public OptifineHandler(boolean usingShaders) {
|
||||
this.usingShaders = usingShaders;
|
||||
}
|
||||
public OptifineHandler(boolean usingShaders) {
|
||||
this.usingShaders = usingShaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about the current Optifine configuration.
|
||||
* @return {@link Optional#empty()} if Optifine is not installed.
|
||||
*/
|
||||
public static Optional<OptifineHandler> get() {
|
||||
return Optional.ofNullable(handler);
|
||||
}
|
||||
/**
|
||||
* Get information about the current Optifine configuration.
|
||||
*
|
||||
* @return {@link Optional#empty()} if Optifine is not installed.
|
||||
*/
|
||||
public static Optional<OptifineHandler> get() {
|
||||
return Optional.ofNullable(handler);
|
||||
}
|
||||
|
||||
public static boolean optifineInstalled() {
|
||||
return optifine != null;
|
||||
}
|
||||
public static boolean optifineInstalled() {
|
||||
return optifine != null;
|
||||
}
|
||||
|
||||
public static boolean usingShaders() {
|
||||
return OptifineHandler.get()
|
||||
.map(OptifineHandler::isUsingShaders)
|
||||
.orElse(false);
|
||||
}
|
||||
public static boolean usingShaders() {
|
||||
return OptifineHandler.get()
|
||||
.map(OptifineHandler::isUsingShaders)
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
optifine = Package.getPackage(OPTIFINE_ROOT_PACKAGE);
|
||||
public static void init() {
|
||||
optifine = Package.getPackage(OPTIFINE_ROOT_PACKAGE);
|
||||
|
||||
if (optifine == null) {
|
||||
Backend.log.info("Optifine not detected.");
|
||||
} else {
|
||||
Backend.log.info("Optifine detected.");
|
||||
if (optifine == null) {
|
||||
Backend.log.info("Optifine not detected.");
|
||||
} else {
|
||||
Backend.log.info("Optifine detected.");
|
||||
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public static void refresh() {
|
||||
if (optifine == null) return;
|
||||
public static void refresh() {
|
||||
if (optifine == null) return;
|
||||
|
||||
File dir = Minecraft.getInstance().gameDir;
|
||||
File dir = Minecraft.getInstance().gameDir;
|
||||
|
||||
File shaderOptions = new File(dir, "optionsshaders.txt");
|
||||
File shaderOptions = new File(dir, "optionsshaders.txt");
|
||||
|
||||
boolean shadersOff = true;
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(shaderOptions));
|
||||
boolean shadersOff = true;
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(shaderOptions));
|
||||
|
||||
shadersOff = reader.lines()
|
||||
.anyMatch(it -> {
|
||||
String line = it.replaceAll("\\s", "");
|
||||
if (line.startsWith("shaderPack=")) {
|
||||
String setting = line.substring("shaderPack=".length());
|
||||
shadersOff = reader.lines()
|
||||
.anyMatch(it -> {
|
||||
String line = it.replaceAll("\\s", "");
|
||||
if (line.startsWith("shaderPack=")) {
|
||||
String setting = line.substring("shaderPack=".length());
|
||||
|
||||
return setting.equals("OFF") || setting.equals("(internal)");
|
||||
}
|
||||
return false;
|
||||
});
|
||||
} catch (FileNotFoundException e) {
|
||||
Backend.log.info("No shader config found.");
|
||||
}
|
||||
return setting.equals("OFF") || setting.equals("(internal)");
|
||||
}
|
||||
return false;
|
||||
});
|
||||
} catch (FileNotFoundException e) {
|
||||
Backend.log.info("No shader config found.");
|
||||
}
|
||||
|
||||
handler = new OptifineHandler(!shadersOff);
|
||||
}
|
||||
handler = new OptifineHandler(!shadersOff);
|
||||
}
|
||||
|
||||
public boolean isUsingShaders() {
|
||||
return usingShaders;
|
||||
}
|
||||
public boolean isUsingShaders() {
|
||||
return usingShaders;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
package com.simibubi.create.foundation.render.backend;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.vector.Matrix3f;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
|
||||
|
@ -79,4 +84,16 @@ public class RenderUtil {
|
|||
model.a33,
|
||||
};
|
||||
}
|
||||
|
||||
public static Supplier<MatrixStack> rotateToFace(Direction facing) {
|
||||
return () -> {
|
||||
MatrixStack stack = new MatrixStack();
|
||||
MatrixStacker.of(stack)
|
||||
.centre()
|
||||
.rotateY(AngleHelper.horizontalAngle(facing))
|
||||
.rotateX(AngleHelper.verticalAngle(facing))
|
||||
.unCentre();
|
||||
return stack;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,18 +4,18 @@ import java.util.Queue;
|
|||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
public class RenderWork {
|
||||
private static final Queue<Runnable> runs = new ConcurrentLinkedQueue<>();
|
||||
private static final Queue<Runnable> runs = new ConcurrentLinkedQueue<>();
|
||||
|
||||
public static void runAll() {
|
||||
while (!runs.isEmpty()) {
|
||||
runs.remove().run();
|
||||
}
|
||||
}
|
||||
public static void runAll() {
|
||||
while (!runs.isEmpty()) {
|
||||
runs.remove().run();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Queue work to be executed at the end of a frame
|
||||
*/
|
||||
public static void enqueue(Runnable run) {
|
||||
runs.add(run);
|
||||
}
|
||||
/**
|
||||
* Queue work to be executed at the end of a frame
|
||||
*/
|
||||
public static void enqueue(Runnable run) {
|
||||
runs.add(run);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public class ShaderLoader {
|
|||
}
|
||||
}
|
||||
|
||||
private void loadShaderSources(IResourceManager manager){
|
||||
private void loadShaderSources(IResourceManager manager) {
|
||||
Collection<ResourceLocation> allShaders = manager.getAllResourceLocations(SHADER_DIR, s -> {
|
||||
for (String ext : EXTENSIONS) {
|
||||
if (s.endsWith(ext)) return true;
|
||||
|
@ -173,7 +173,7 @@ public class ShaderLoader {
|
|||
try {
|
||||
bytebuffer = readToBuffer(is);
|
||||
int i = bytebuffer.position();
|
||||
((Buffer)bytebuffer).rewind();
|
||||
((Buffer) bytebuffer).rewind();
|
||||
return MemoryUtil.memASCII(bytebuffer, i);
|
||||
} catch (IOException e) {
|
||||
|
||||
|
@ -190,11 +190,12 @@ public class ShaderLoader {
|
|||
public ByteBuffer readToBuffer(InputStream is) throws IOException {
|
||||
ByteBuffer bytebuffer;
|
||||
if (is instanceof FileInputStream) {
|
||||
FileInputStream fileinputstream = (FileInputStream)is;
|
||||
FileInputStream fileinputstream = (FileInputStream) is;
|
||||
FileChannel filechannel = fileinputstream.getChannel();
|
||||
bytebuffer = MemoryUtil.memAlloc((int)filechannel.size() + 1);
|
||||
bytebuffer = MemoryUtil.memAlloc((int) filechannel.size() + 1);
|
||||
|
||||
while (filechannel.read(bytebuffer) != -1) { }
|
||||
while (filechannel.read(bytebuffer) != -1) {
|
||||
}
|
||||
} else {
|
||||
bytebuffer = MemoryUtil.memAlloc(8192);
|
||||
ReadableByteChannel readablebytechannel = Channels.newChannel(is);
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
package com.simibubi.create.foundation.render.backend;
|
||||
|
||||
public class ShaderLoadingException extends RuntimeException {
|
||||
|
||||
public ShaderLoadingException() {
|
||||
}
|
||||
|
||||
public ShaderLoadingException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ShaderLoadingException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public ShaderLoadingException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public ShaderLoadingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
}
|
|
@ -7,72 +7,72 @@ import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
|
|||
|
||||
public class BasicData extends InstanceData implements IFlatLight<BasicData> {
|
||||
|
||||
protected byte blockLight;
|
||||
protected byte skyLight;
|
||||
protected byte blockLight;
|
||||
protected byte skyLight;
|
||||
|
||||
protected byte r = (byte) 0xFF;
|
||||
protected byte g = (byte) 0xFF;
|
||||
protected byte b = (byte) 0xFF;
|
||||
protected byte a = (byte) 0xFF;
|
||||
protected byte r = (byte) 0xFF;
|
||||
protected byte g = (byte) 0xFF;
|
||||
protected byte b = (byte) 0xFF;
|
||||
protected byte a = (byte) 0xFF;
|
||||
|
||||
public BasicData(InstancedModel<?> owner) {
|
||||
super(owner);
|
||||
}
|
||||
public BasicData(InstancedModel<?> owner) {
|
||||
super(owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicData setBlockLight(int blockLight) {
|
||||
this.blockLight = (byte) (blockLight << 4);
|
||||
markDirty();
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public BasicData setBlockLight(int blockLight) {
|
||||
this.blockLight = (byte) (blockLight << 4);
|
||||
markDirty();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicData setSkyLight(int skyLight) {
|
||||
this.skyLight = (byte) (skyLight << 4);
|
||||
markDirty();
|
||||
return this;
|
||||
}
|
||||
@Override
|
||||
public BasicData setSkyLight(int skyLight) {
|
||||
this.skyLight = (byte) (skyLight << 4);
|
||||
markDirty();
|
||||
return this;
|
||||
}
|
||||
|
||||
public BasicData setColor(int color) {
|
||||
return setColor(color, false);
|
||||
}
|
||||
public BasicData setColor(int color) {
|
||||
return setColor(color, false);
|
||||
}
|
||||
|
||||
public BasicData setColor(int color, boolean alpha) {
|
||||
byte r = (byte) ((color >> 16) & 0xFF);
|
||||
byte g = (byte) ((color >> 8) & 0xFF);
|
||||
byte b = (byte) (color & 0xFF);
|
||||
public BasicData setColor(int color, boolean alpha) {
|
||||
byte r = (byte) ((color >> 16) & 0xFF);
|
||||
byte g = (byte) ((color >> 8) & 0xFF);
|
||||
byte b = (byte) (color & 0xFF);
|
||||
|
||||
if (alpha) {
|
||||
byte a = (byte) ((color >> 24) & 0xFF);
|
||||
return setColor(r, g, b, a);
|
||||
} else {
|
||||
return setColor(r, g, b);
|
||||
}
|
||||
}
|
||||
if (alpha) {
|
||||
byte a = (byte) ((color >> 24) & 0xFF);
|
||||
return setColor(r, g, b, a);
|
||||
} else {
|
||||
return setColor(r, g, b);
|
||||
}
|
||||
}
|
||||
|
||||
public BasicData setColor(int r, int g, int b) {
|
||||
return setColor((byte) r, (byte) g, (byte) b);
|
||||
}
|
||||
public BasicData setColor(int r, int g, int b) {
|
||||
return setColor((byte) r, (byte) g, (byte) b);
|
||||
}
|
||||
|
||||
public BasicData setColor(byte r, byte g, byte b) {
|
||||
this.r = r;
|
||||
this.g = g;
|
||||
this.b = b;
|
||||
markDirty();
|
||||
return this;
|
||||
}
|
||||
public BasicData setColor(byte r, byte g, byte b) {
|
||||
this.r = r;
|
||||
this.g = g;
|
||||
this.b = b;
|
||||
markDirty();
|
||||
return this;
|
||||
}
|
||||
|
||||
public BasicData setColor(byte r, byte g, byte b, byte a) {
|
||||
this.r = r;
|
||||
this.g = g;
|
||||
this.b = b;
|
||||
this.a = a;
|
||||
markDirty();
|
||||
return this;
|
||||
}
|
||||
public BasicData setColor(byte r, byte g, byte b, byte a) {
|
||||
this.r = r;
|
||||
this.g = g;
|
||||
this.b = b;
|
||||
this.a = a;
|
||||
markDirty();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuffer buf) {
|
||||
buf.put(new byte[] { blockLight, skyLight, r, g, b, a });
|
||||
}
|
||||
@Override
|
||||
public void write(ByteBuffer buf) {
|
||||
buf.put(new byte[]{blockLight, skyLight, r, g, b, a});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,44 +10,44 @@ import net.minecraft.util.ResourceLocation;
|
|||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
|
||||
public class BasicProgram extends GlProgram {
|
||||
protected final int uTime;
|
||||
protected final int uViewProjection;
|
||||
protected final int uDebug;
|
||||
protected final int uCameraPos;
|
||||
protected final int uTime;
|
||||
protected final int uViewProjection;
|
||||
protected final int uDebug;
|
||||
protected final int uCameraPos;
|
||||
|
||||
protected final ProgramFogMode fogMode;
|
||||
protected final ProgramFogMode fogMode;
|
||||
|
||||
protected int uBlockAtlas;
|
||||
protected int uLightMap;
|
||||
protected int uBlockAtlas;
|
||||
protected int uLightMap;
|
||||
|
||||
public BasicProgram(ResourceLocation name, int handle, ProgramFogMode.Factory fogFactory) {
|
||||
super(name, handle);
|
||||
uTime = getUniformLocation("uTime");
|
||||
uViewProjection = getUniformLocation("uViewProjection");
|
||||
uDebug = getUniformLocation("uDebug");
|
||||
uCameraPos = getUniformLocation("uCameraPos");
|
||||
public BasicProgram(ResourceLocation name, int handle, ProgramFogMode.Factory fogFactory) {
|
||||
super(name, handle);
|
||||
uTime = getUniformLocation("uTime");
|
||||
uViewProjection = getUniformLocation("uViewProjection");
|
||||
uDebug = getUniformLocation("uDebug");
|
||||
uCameraPos = getUniformLocation("uCameraPos");
|
||||
|
||||
fogMode = fogFactory.create(this);
|
||||
fogMode = fogFactory.create(this);
|
||||
|
||||
bind();
|
||||
registerSamplers();
|
||||
unbind();
|
||||
}
|
||||
bind();
|
||||
registerSamplers();
|
||||
unbind();
|
||||
}
|
||||
|
||||
protected void registerSamplers() {
|
||||
uBlockAtlas = setSamplerBinding("uBlockAtlas", 0);
|
||||
uLightMap = setSamplerBinding("uLightMap", 2);
|
||||
}
|
||||
protected void registerSamplers() {
|
||||
uBlockAtlas = setSamplerBinding("uBlockAtlas", 0);
|
||||
uLightMap = setSamplerBinding("uLightMap", 2);
|
||||
}
|
||||
|
||||
public void bind(Matrix4f viewProjection, double camX, double camY, double camZ, int debugMode) {
|
||||
super.bind();
|
||||
public void bind(Matrix4f viewProjection, double camX, double camY, double camZ, int debugMode) {
|
||||
super.bind();
|
||||
|
||||
GL20.glUniform1i(uDebug, debugMode);
|
||||
GL20.glUniform1f(uTime, AnimationTickHolder.getRenderTime());
|
||||
GL20.glUniform1i(uDebug, debugMode);
|
||||
GL20.glUniform1f(uTime, AnimationTickHolder.getRenderTime());
|
||||
|
||||
uploadMatrixUniform(uViewProjection, viewProjection);
|
||||
GL20.glUniform3f(uCameraPos, (float) camX, (float) camY, (float) camZ);
|
||||
uploadMatrixUniform(uViewProjection, viewProjection);
|
||||
GL20.glUniform3f(uCameraPos, (float) camX, (float) camY, (float) camZ);
|
||||
|
||||
fogMode.bind();
|
||||
}
|
||||
fogMode.bind();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,22 +5,23 @@ import com.simibubi.create.foundation.render.backend.instancing.InstanceData;
|
|||
/**
|
||||
* An interface that implementors of {@link InstanceData} should also implement
|
||||
* if they wish to make use of Flywheel's provided light update methods.
|
||||
*
|
||||
* <p>
|
||||
* This only covers flat lighting, smooth lighting is still TODO.
|
||||
*
|
||||
* @param <D> The name of the class that implements this interface.
|
||||
*/
|
||||
public interface IFlatLight<D extends InstanceData & IFlatLight<D>> {
|
||||
/**
|
||||
* @param blockLight An integer in the range [0, 15] representing the
|
||||
* amount of block light this instance should receive.
|
||||
* @return <code>this</code>
|
||||
*/
|
||||
D setBlockLight(int blockLight);
|
||||
/**
|
||||
* @param blockLight An integer in the range [0, 15] representing the
|
||||
* amount of block light this instance should receive.
|
||||
* @return <code>this</code>
|
||||
*/
|
||||
D setBlockLight(int blockLight);
|
||||
|
||||
/**
|
||||
* @param skyLight An integer in the range [0, 15] representing the
|
||||
* amount of sky light this instance should receive.
|
||||
* @return <code>this</code>
|
||||
*/
|
||||
D setSkyLight(int skyLight);
|
||||
/**
|
||||
* @param skyLight An integer in the range [0, 15] representing the
|
||||
* amount of sky light this instance should receive.
|
||||
* @return <code>this</code>
|
||||
*/
|
||||
D setSkyLight(int skyLight);
|
||||
}
|
||||
|
|
|
@ -6,36 +6,36 @@ import com.simibubi.create.foundation.render.backend.gl.attrib.IVertexAttrib;
|
|||
import com.simibubi.create.foundation.render.backend.gl.attrib.VertexAttribSpec;
|
||||
|
||||
public enum ModelAttributes implements IVertexAttrib {
|
||||
VERTEX_POSITION("aPos", CommonAttributes.VEC3),
|
||||
NORMAL("aNormal", CommonAttributes.NORMAL),
|
||||
TEXTURE("aTexCoords", CommonAttributes.UV),
|
||||
;
|
||||
VERTEX_POSITION("aPos", CommonAttributes.VEC3),
|
||||
NORMAL("aNormal", CommonAttributes.NORMAL),
|
||||
TEXTURE("aTexCoords", CommonAttributes.UV),
|
||||
;
|
||||
|
||||
private final String name;
|
||||
private final VertexAttribSpec spec;
|
||||
private final String name;
|
||||
private final VertexAttribSpec spec;
|
||||
|
||||
ModelAttributes(String name, VertexAttribSpec spec) {
|
||||
this.name = name;
|
||||
this.spec = spec;
|
||||
}
|
||||
ModelAttributes(String name, VertexAttribSpec spec) {
|
||||
this.name = name;
|
||||
this.spec = spec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String attribName() {
|
||||
return name;
|
||||
}
|
||||
@Override
|
||||
public String attribName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAttribSpec attribSpec() {
|
||||
return spec;
|
||||
}
|
||||
@Override
|
||||
public IAttribSpec attribSpec() {
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDivisor() {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int getDivisor() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBufferIndex() {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int getBufferIndex() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,24 +7,24 @@ import com.simibubi.create.foundation.render.backend.RenderUtil;
|
|||
import com.simibubi.create.foundation.render.backend.instancing.InstancedModel;
|
||||
|
||||
public class ModelData extends BasicData {
|
||||
private static final float[] empty = new float[25];
|
||||
private static final float[] empty = new float[25];
|
||||
|
||||
private float[] matrices = empty;
|
||||
private float[] matrices = empty;
|
||||
|
||||
public ModelData(InstancedModel<?> owner) {
|
||||
super(owner);
|
||||
}
|
||||
public ModelData(InstancedModel<?> owner) {
|
||||
super(owner);
|
||||
}
|
||||
|
||||
public ModelData setTransform(MatrixStack stack) {
|
||||
matrices = RenderUtil.writeMatrixStack(stack);
|
||||
markDirty();
|
||||
return this;
|
||||
}
|
||||
public ModelData setTransform(MatrixStack stack) {
|
||||
matrices = RenderUtil.writeMatrixStack(stack);
|
||||
markDirty();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuffer buf) {
|
||||
super.write(buf);
|
||||
buf.asFloatBuffer().put(matrices);
|
||||
buf.position(buf.position() + matrices.length * 4);
|
||||
}
|
||||
@Override
|
||||
public void write(ByteBuffer buf) {
|
||||
super.write(buf);
|
||||
buf.asFloatBuffer().put(matrices);
|
||||
buf.position(buf.position() + matrices.length * 4);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,36 +5,36 @@ import com.simibubi.create.foundation.render.backend.gl.attrib.IAttribSpec;
|
|||
import com.simibubi.create.foundation.render.backend.gl.attrib.IVertexAttrib;
|
||||
|
||||
public enum OrientedAttributes implements IVertexAttrib {
|
||||
INSTANCE_POS("aInstancePos", CommonAttributes.VEC3),
|
||||
PIVOT("aPivot", CommonAttributes.VEC3),
|
||||
ROTATION("aRotation", CommonAttributes.QUATERNION),
|
||||
;
|
||||
INSTANCE_POS("aInstancePos", CommonAttributes.VEC3),
|
||||
PIVOT("aPivot", CommonAttributes.VEC3),
|
||||
ROTATION("aRotation", CommonAttributes.QUATERNION),
|
||||
;
|
||||
|
||||
private final String name;
|
||||
private final IAttribSpec spec;
|
||||
private final String name;
|
||||
private final IAttribSpec spec;
|
||||
|
||||
OrientedAttributes(String name, IAttribSpec spec) {
|
||||
this.name = name;
|
||||
this.spec = spec;
|
||||
}
|
||||
OrientedAttributes(String name, IAttribSpec spec) {
|
||||
this.name = name;
|
||||
this.spec = spec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String attribName() {
|
||||
return name;
|
||||
}
|
||||
@Override
|
||||
public String attribName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAttribSpec attribSpec() {
|
||||
return spec;
|
||||
}
|
||||
@Override
|
||||
public IAttribSpec attribSpec() {
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDivisor() {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int getDivisor() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBufferIndex() {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int getBufferIndex() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ public class OrientedData extends BasicData {
|
|||
public void write(ByteBuffer buf) {
|
||||
super.write(buf);
|
||||
|
||||
buf.asFloatBuffer().put(new float[] {
|
||||
buf.asFloatBuffer().put(new float[]{
|
||||
posX,
|
||||
posY,
|
||||
posZ,
|
||||
|
|
|
@ -7,22 +7,22 @@ import com.simibubi.create.foundation.render.backend.instancing.InstancedTileRen
|
|||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
|
||||
public class OrientedModel extends InstancedModel<OrientedData> {
|
||||
public static final VertexFormat INSTANCE_FORMAT = VertexFormat.builder()
|
||||
.addAttributes(BasicAttributes.class)
|
||||
.addAttributes(OrientedAttributes.class)
|
||||
.build();
|
||||
public static final VertexFormat INSTANCE_FORMAT = VertexFormat.builder()
|
||||
.addAttributes(BasicAttributes.class)
|
||||
.addAttributes(OrientedAttributes.class)
|
||||
.build();
|
||||
|
||||
public OrientedModel(InstancedTileRenderer<?> renderer, BufferBuilder buf) {
|
||||
super(renderer, buf);
|
||||
}
|
||||
public OrientedModel(InstancedTileRenderer<?> renderer, BufferBuilder buf) {
|
||||
super(renderer, buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected OrientedData newInstance() {
|
||||
return new OrientedData(this);
|
||||
}
|
||||
@Override
|
||||
protected OrientedData newInstance() {
|
||||
return new OrientedData(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VertexFormat getInstanceFormat() {
|
||||
return INSTANCE_FORMAT;
|
||||
}
|
||||
@Override
|
||||
protected VertexFormat getInstanceFormat() {
|
||||
return INSTANCE_FORMAT;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package com.simibubi.create.foundation.render.backend.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
|
||||
/**
|
||||
* A helper class for loading and accessing json models.
|
||||
* <p>
|
||||
* Creating a PartialModel will make the associated modelLocation automatically load.
|
||||
* As such, PartialModels must be initialized at or before {@link ModelRegistryEvent}.
|
||||
* Once {@link ModelBakeEvent} finishes, all PartialModels (with valid modelLocations)
|
||||
* will have their bakedModel fields populated.
|
||||
* <p>
|
||||
* Attempting to create a PartialModel after ModelRegistryEvent will cause an error.
|
||||
*/
|
||||
public class PartialModel {
|
||||
|
||||
private static boolean tooLate = false;
|
||||
private static final List<PartialModel> all = new ArrayList<>();
|
||||
|
||||
protected final ResourceLocation modelLocation;
|
||||
protected IBakedModel bakedModel;
|
||||
|
||||
public PartialModel(ResourceLocation modelLocation) {
|
||||
|
||||
if (tooLate) throw new RuntimeException("PartialModel '" + modelLocation + "' loaded after ModelRegistryEvent");
|
||||
|
||||
this.modelLocation = modelLocation;
|
||||
all.add(this);
|
||||
}
|
||||
|
||||
public static void onModelRegistry(ModelRegistryEvent event) {
|
||||
for (PartialModel partial : all)
|
||||
ModelLoader.addSpecialModel(partial.modelLocation);
|
||||
|
||||
tooLate = true;
|
||||
}
|
||||
|
||||
public static void onModelBake(ModelBakeEvent event) {
|
||||
Map<ResourceLocation, IBakedModel> modelRegistry = event.getModelRegistry();
|
||||
for (PartialModel partial : all)
|
||||
partial.bakedModel = modelRegistry.get(partial.modelLocation);
|
||||
}
|
||||
|
||||
public IBakedModel get() {
|
||||
return bakedModel;
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue