mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-06-02 18:59:19 +02:00
b2fe04a3c8
- move SuperByteBuffer and its caching to catnip - move sprite shifter to catnip - no longer use StitchedSprites for (ct) sprite shifts - fix ponder fluid rendering by using SBB for WorldSectionElement again - allow catnip-forge to load without being present on the server
81 lines
3.1 KiB
Java
81 lines
3.1 KiB
Java
package com.simibubi.create.foundation.render;
|
|
|
|
import static net.minecraft.world.level.block.state.properties.BlockStateProperties.FACING;
|
|
|
|
import java.util.function.Supplier;
|
|
|
|
import org.apache.commons.lang3.tuple.Pair;
|
|
|
|
import com.jozufozu.flywheel.core.PartialModel;
|
|
import com.jozufozu.flywheel.util.transform.TransformStack;
|
|
import com.mojang.blaze3d.vertex.PoseStack;
|
|
|
|
import net.createmod.catnip.render.SuperBufferFactory;
|
|
import net.createmod.catnip.render.SuperByteBuffer;
|
|
import net.createmod.catnip.render.SuperByteBufferCache;
|
|
import net.createmod.catnip.render.SuperByteBufferCache.Compartment;
|
|
import net.createmod.catnip.utility.math.AngleHelper;
|
|
import net.minecraft.core.Direction;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
|
|
public class CachedPartialBuffers {
|
|
public static final Compartment<PartialModel> PARTIAL = new Compartment<>();
|
|
public static final Compartment<Pair<Direction, PartialModel>> DIRECTIONAL_PARTIAL = new Compartment<>();
|
|
|
|
public static SuperByteBuffer partial(PartialModel partial, BlockState referenceState) {
|
|
return SuperByteBufferCache.getInstance().get(PARTIAL, partial,
|
|
() -> SuperBufferFactory.getInstance().createForBlock(partial.get(), referenceState));
|
|
}
|
|
|
|
public static SuperByteBuffer partial(PartialModel partial, BlockState referenceState,
|
|
Supplier<PoseStack> modelTransform) {
|
|
return SuperByteBufferCache.getInstance().get(PARTIAL, partial,
|
|
() -> SuperBufferFactory.getInstance().createForBlock(partial.get(), referenceState, modelTransform.get()));
|
|
}
|
|
|
|
public static SuperByteBuffer partialFacing(PartialModel partial, BlockState referenceState) {
|
|
Direction facing = referenceState.getValue(FACING);
|
|
return partialFacing(partial, referenceState, facing);
|
|
}
|
|
|
|
public static SuperByteBuffer partialFacing(PartialModel partial, BlockState referenceState, Direction facing) {
|
|
return partialDirectional(partial, referenceState, facing,
|
|
rotateToFace(facing));
|
|
}
|
|
|
|
public static SuperByteBuffer partialFacingVertical(PartialModel partial, BlockState referenceState, Direction facing) {
|
|
return partialDirectional(partial, referenceState, facing,
|
|
rotateToFaceVertical(facing));
|
|
}
|
|
|
|
public static SuperByteBuffer partialDirectional(PartialModel partial, BlockState referenceState, Direction dir,
|
|
Supplier<PoseStack> modelTransform) {
|
|
return SuperByteBufferCache.getInstance().get(DIRECTIONAL_PARTIAL, Pair.of(dir, partial),
|
|
() -> SuperBufferFactory.getInstance().createForBlock(partial.get(), referenceState, modelTransform.get()));
|
|
}
|
|
|
|
public static Supplier<PoseStack> rotateToFace(Direction facing) {
|
|
return () -> {
|
|
PoseStack stack = new PoseStack();
|
|
TransformStack.cast(stack)
|
|
.centre()
|
|
.rotateY(AngleHelper.horizontalAngle(facing))
|
|
.rotateX(AngleHelper.verticalAngle(facing))
|
|
.unCentre();
|
|
return stack;
|
|
};
|
|
}
|
|
|
|
public static Supplier<PoseStack> rotateToFaceVertical(Direction facing) {
|
|
return () -> {
|
|
PoseStack stack = new PoseStack();
|
|
TransformStack.cast(stack)
|
|
.centre()
|
|
.rotateY(AngleHelper.horizontalAngle(facing))
|
|
.rotateX(AngleHelper.verticalAngle(facing) + 90)
|
|
.unCentre();
|
|
return stack;
|
|
};
|
|
}
|
|
}
|