First blood

- Make a quick pass resolving conflicts
- Mostly joml related, or to do with the world -> level rename
- Basically left model builders and virtual levels alone
- There are also some forge events that seem to no longer exist
This commit is contained in:
Jozufozu 2023-11-22 21:30:58 -08:00
parent 5fc346ad7a
commit 99be0ad281
38 changed files with 194 additions and 345 deletions

View file

@ -36,14 +36,12 @@ import com.jozufozu.flywheel.vanilla.VanillaVisuals;
import com.mojang.logging.LogUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.synchronization.ArgumentTypes;
import net.minecraft.commands.synchronization.EmptyArgumentSerializer;
import net.minecraft.core.Vec3i;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.event.level.LevelEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.IExtensionPoint;
@ -51,7 +49,6 @@ import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.network.NetworkConstants;
@Mod(Flywheel.ID)
public class Flywheel {
@ -101,7 +98,7 @@ public class Flywheel {
forgeEventBus.addListener(LightUpdater::onClientTick);
forgeEventBus.addListener((ReloadRenderersEvent e) -> ModelCache.onReloadRenderers(e));
forgeEventBus.addListener(ModelHolder::onReloadRenderers);
forgeEventBus.addListener((WorldEvent.Unload e) -> LevelAttached.onUnloadLevel(e));
forgeEventBus.addListener((LevelEvent.Unload e) -> LevelAttached.onUnloadLevel(e));
modEventBus.addListener(PartialModel::onModelRegistry);
modEventBus.addListener(PartialModel::onModelBake);
@ -155,7 +152,7 @@ public class Flywheel {
info.add("Origin: " + renderOrigin.getX() + ", " + renderOrigin.getY() + ", " + renderOrigin.getZ());
}
info.add("Memory Usage: CPU: " + StringUtil.formatBytes(FlwMemoryTracker.getCPUMemory()) + ", GPU: " + StringUtil.formatBytes(FlwMemoryTracker.getGPUMemory()));
info.add("Memory Usage: CPU: " + StringUtil.formatBytes(FlwMemoryTracker.getCPUMemory()) + ", GPU: " + StringUtil.formatBytes(FlwMemoryTracker.getGPUMemory()));
}
public static ArtifactVersion getVersion() {

View file

@ -1,7 +1,8 @@
package com.jozufozu.flywheel.api.event;
import org.joml.Matrix4f;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix4f;
import net.minecraft.client.Camera;
import net.minecraft.client.multiplayer.ClientLevel;
@ -11,8 +12,9 @@ import net.minecraft.client.renderer.RenderBuffers;
public record RenderContext(LevelRenderer renderer, ClientLevel level, RenderBuffers buffers, PoseStack stack,
Matrix4f projection, Matrix4f viewProjection, Camera camera, float partialTick) {
public static RenderContext create(LevelRenderer renderer, ClientLevel level, RenderBuffers buffers, PoseStack stack, Matrix4f projection, Camera camera, float partialTick) {
Matrix4f viewProjection = projection.copy();
viewProjection.multiply(stack.last().pose());
Matrix4f viewProjection = new Matrix4f(projection);
viewProjection.mul(stack.last()
.pose());
return new RenderContext(renderer, level, buffers, stack, projection, viewProjection, camera, partialTick);
}

View file

@ -1,7 +1,8 @@
package com.jozufozu.flywheel.api.event;
import org.joml.Matrix4f;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix4f;
import net.minecraft.client.Camera;
import net.minecraft.client.multiplayer.ClientLevel;

View file

@ -27,7 +27,7 @@ public interface VisualizationManager {
}
/**
* Call this when you want to run {@link Visual#update()}.
* Call this when you want to run {@link Visual#update}.
* @param blockEntity The block entity whose visual you want to update.
*/
static void queueUpdate(BlockEntity blockEntity) {
@ -41,11 +41,11 @@ public interface VisualizationManager {
}
/**
* Call this when you want to run {@link Visual#update()}.
* Call this when you want to run {@link Visual#update}.
* @param entity The entity whose visual you want to update.
*/
static void queueUpdate(Entity entity) {
Level level = entity.level;
Level level = entity.level();
VisualizationManager manager = get(level);
if (manager == null) {
return;
@ -55,7 +55,7 @@ public interface VisualizationManager {
}
/**
* Call this when you want to run {@link Visual#update()}.
* Call this when you want to run {@link Visual#update}.
* @param effect The effect whose visual you want to update.
*/
static void queueUpdate(LevelAccessor level, Effect effect) {

View file

@ -1,5 +1,6 @@
package com.jozufozu.flywheel.backend;
import com.jozufozu.flywheel.Flywheel;
import com.jozufozu.flywheel.api.backend.Backend;
import com.jozufozu.flywheel.backend.compile.IndirectPrograms;
@ -13,14 +14,15 @@ import com.jozufozu.flywheel.lib.context.Contexts;
import com.jozufozu.flywheel.lib.util.ShadersModHandler;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.Component;
public class Backends {
/**
* Use a thread pool to buffer instances in parallel on the CPU.
*/
public static final Backend BATCHING = SimpleBackend.builder()
.engineMessage(new TextComponent("Using Batching Engine").withStyle(ChatFormatting.GREEN))
.engineMessage(Component.literal("Using Batching Engine")
.withStyle(ChatFormatting.GREEN))
.engineFactory(level -> new BatchingEngine(256))
.supported(() -> !ShadersModHandler.isShaderPackInUse())
.register(Flywheel.rl("batching"));
@ -29,7 +31,8 @@ public class Backends {
* Use GPU instancing to render everything.
*/
public static final Backend INSTANCING = SimpleBackend.builder()
.engineMessage(new TextComponent("Using Instancing Engine").withStyle(ChatFormatting.GREEN))
.engineMessage(Component.literal("Using Instancing Engine")
.withStyle(ChatFormatting.GREEN))
.engineFactory(level -> new InstancingEngine(256, Contexts.WORLD))
.fallback(() -> Backends.BATCHING)
.supported(() -> !ShadersModHandler.isShaderPackInUse() && GlCompat.supportsInstancing() && InstancingPrograms.allLoaded())
@ -39,7 +42,8 @@ public class Backends {
* Use Compute shaders to cull instances.
*/
public static final Backend INDIRECT = SimpleBackend.builder()
.engineMessage(new TextComponent("Using Indirect Engine").withStyle(ChatFormatting.GREEN))
.engineMessage(Component.literal("Using Indirect Engine")
.withStyle(ChatFormatting.GREEN))
.engineFactory(level -> new IndirectEngine(256))
.fallback(() -> Backends.INSTANCING)
.supported(() -> !ShadersModHandler.isShaderPackInUse() && GlCompat.supportsIndirect() && IndirectPrograms.allLoaded())

View file

@ -27,7 +27,7 @@ public abstract class AbstractEngine implements Engine {
return false;
}
renderOrigin = new BlockPos(cameraPos);
renderOrigin = BlockPos.containing(cameraPos);
onRenderOriginChanged();
return true;
}

View file

@ -71,7 +71,9 @@ public class BatchedDrawTracker {
if (buffer.hasVertices()) {
BufferBuilderExtension scratch = (BufferBuilderExtension) this.scratch;
buffer.inject(scratch);
buffer.getRenderType().end(this.scratch, 0, 0, 0);
// FIXME: Maybe we shouldn't pass null.
buffer.getRenderType()
.end(this.scratch, null);
}
buffer.reset();
}

View file

@ -3,6 +3,8 @@ package com.jozufozu.flywheel.backend.engine.batching;
import java.util.concurrent.atomic.AtomicInteger;
import org.joml.FrustumIntersection;
import org.joml.Matrix3f;
import org.joml.Matrix4f;
import org.joml.Vector4f;
import org.joml.Vector4fc;
@ -17,8 +19,6 @@ import com.jozufozu.flywheel.api.vertex.ReusableVertexList;
import com.jozufozu.flywheel.lib.task.ForEachSlicePlan;
import com.jozufozu.flywheel.lib.vertex.VertexTransformations;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix3f;
import com.mojang.math.Matrix4f;
import net.minecraft.client.multiplayer.ClientLevel;

View file

@ -14,14 +14,14 @@ import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
public class BackendArgument implements ArgumentType<Backend> {
private static final List<String> STRING_IDS = Backend.REGISTRY.getAllIds().stream().map(ResourceLocation::toString).toList();
public static final DynamicCommandExceptionType ERROR_UNKNOWN_BACKEND = new DynamicCommandExceptionType(arg -> {
return new TextComponent("Unknown backend '" + arg + "'");
return Component.literal("Unknown backend '" + arg + "'");
});
public static final BackendArgument INSTANCE = new BackendArgument();

View file

@ -19,7 +19,6 @@ import net.minecraft.commands.arguments.coordinates.BlockPosArgument;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
import net.minecraftforge.client.event.RegisterClientCommandsEvent;
@ -42,13 +41,13 @@ public class FlwCommands {
try {
backendId = new ResourceLocation(backendIdStr);
} catch (ResourceLocationException e) {
player.displayClientMessage(new TextComponent("Config contains invalid backend ID '" + backendIdStr + "'!"), false);
player.displayClientMessage(Component.literal("Config contains invalid backend ID '" + backendIdStr + "'!"), false);
return 0;
}
Backend backend = Backend.REGISTRY.get(backendId);
if (backend == null) {
player.displayClientMessage(new TextComponent("Config contains non-existent backend with ID '" + backendId + "'!"), false);
player.displayClientMessage(Component.literal("Config contains non-existent backend with ID '" + backendId + "'!"), false);
return 0;
}
@ -71,7 +70,8 @@ public class FlwCommands {
var actualBackend = BackendManager.getBackend();
if (actualBackend != requestedBackend) {
player.displayClientMessage(new TextComponent("'" + requestedId + "' not available").withStyle(ChatFormatting.RED), false);
player.displayClientMessage(Component.literal("'" + requestedId + "' not available")
.withStyle(ChatFormatting.RED), false);
}
Component message = actualBackend.engineMessage();
@ -85,14 +85,16 @@ public class FlwCommands {
LocalPlayer player = Minecraft.getInstance().player;
if (player == null) return;
Component text = new TextComponent("Update limiting is currently: ").append(boolToText(bool));
Component text = Component.literal("Update limiting is currently: ")
.append(boolToText(bool));
player.displayClientMessage(text, false);
},
(source, bool) -> {
LocalPlayer player = Minecraft.getInstance().player;
if (player == null) return;
Component text = boolToText(bool).append(new TextComponent(" update limiting.").withStyle(ChatFormatting.WHITE));
Component text = boolToText(bool).append(Component.literal(" update limiting.")
.withStyle(ChatFormatting.WHITE));
player.displayClientMessage(text, false);
Minecraft.getInstance().levelRenderer.allChanged();
@ -105,7 +107,7 @@ public class FlwCommands {
LocalPlayer player = Minecraft.getInstance().player;
if (player == null) return 0;
player.displayClientMessage(new TextComponent("This command is not yet implemented."), false);
player.displayClientMessage(Component.literal("This command is not yet implemented."), false);
return Command.SINGLE_SUCCESS;
});
@ -124,7 +126,8 @@ public class FlwCommands {
return 0;
}
executor.level.destroyBlockProgress(executor.getId(), pos, value);
executor.level()
.destroyBlockProgress(executor.getId(), pos, value);
return Command.SINGLE_SUCCESS;
}))));
@ -176,6 +179,8 @@ public class FlwCommands {
}
public static MutableComponent boolToText(boolean b) {
return b ? new TextComponent("enabled").withStyle(ChatFormatting.DARK_GREEN) : new TextComponent("disabled").withStyle(ChatFormatting.RED);
return b ? Component.literal("enabled")
.withStyle(ChatFormatting.DARK_GREEN) : Component.literal("disabled")
.withStyle(ChatFormatting.RED);
}
}

View file

@ -63,6 +63,14 @@ sealed public interface LoadError {
}
}
record ResourceError(ResourceLocation location) implements LoadError {
@Override
public ErrorBuilder generateMessage() {
return ErrorBuilder.create()
.error("\"" + location + "\" was not found");
}
}
record MalformedInclude(ResourceLocationException exception) implements LoadError {
@Override
public ErrorBuilder generateMessage() {

View file

@ -15,7 +15,6 @@ import org.jetbrains.annotations.VisibleForTesting;
import com.jozufozu.flywheel.lib.util.ResourceUtil;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.Resource;
import net.minecraft.server.packs.resources.ResourceManager;
/**
@ -68,12 +67,15 @@ public class ShaderSources {
@NotNull
protected LoadResult load(ResourceLocation loc) {
try (Resource resource = manager.getResource(ResourceUtil.prefixed(SHADER_DIR, loc))) {
InputStream stream = resource.getInputStream();
String sourceString = new String(stream.readAllBytes(), StandardCharsets.UTF_8);
return SourceFile.parse(this, loc, sourceString);
} catch (IOException e) {
return new LoadResult.Failure(new LoadError.IOError(loc, e));
}
return manager.getResource(ResourceUtil.prefixed(SHADER_DIR, loc))
.map(resource -> {
try (InputStream stream = resource.open()) {
String sourceString = new String(stream.readAllBytes(), StandardCharsets.UTF_8);
return SourceFile.parse(this, loc, sourceString);
} catch (IOException e) {
return new LoadResult.Failure(new LoadError.IOError(loc, e));
}
})
.orElseGet(() -> new LoadResult.Failure(new LoadError.ResourceError(loc)));
}
}

View file

@ -14,7 +14,7 @@ import com.mojang.logging.LogUtils;
import net.minecraft.ChatFormatting;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.fml.CrashReportCallables;
@ -22,7 +22,8 @@ public final class BackendManagerImpl {
private static final Logger LOGGER = LogUtils.getLogger();
private static final Backend OFF_BACKEND = SimpleBackend.builder()
.engineMessage(new TextComponent("Disabled Flywheel").withStyle(ChatFormatting.RED))
.engineMessage(Component.literal("Disabled Flywheel")
.withStyle(ChatFormatting.RED))
.engineFactory(level -> {
throw new UnsupportedOperationException("Cannot create engine when backend is off.");
})

View file

@ -10,8 +10,8 @@ import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.EntityLeaveWorldEvent;
import net.minecraftforge.event.entity.EntityJoinLevelEvent;
import net.minecraftforge.event.entity.EntityLeaveLevelEvent;
public final class VisualizationEventHandler {
private VisualizationEventHandler() {
@ -32,7 +32,7 @@ public final class VisualizationEventHandler {
return;
}
Level level = cameraEntity.level;
Level level = cameraEntity.level();
VisualizationManagerImpl manager = VisualizationManagerImpl.get(level);
if (manager == null) {
return;
@ -65,8 +65,8 @@ public final class VisualizationEventHandler {
manager.renderStage(event.getContext(), event.getStage());
}
public static void onEntityJoinWorld(EntityJoinWorldEvent event) {
Level level = event.getWorld();
public static void onEntityJoinWorld(EntityJoinLevelEvent event) {
Level level = event.getLevel();
VisualizationManager manager = VisualizationManager.get(level);
if (manager == null) {
return;
@ -75,8 +75,8 @@ public final class VisualizationEventHandler {
manager.getEntities().queueAdd(event.getEntity());
}
public static void onEntityLeaveWorld(EntityLeaveWorldEvent event) {
Level level = event.getWorld();
public static void onEntityLeaveWorld(EntityLeaveLevelEvent event) {
Level level = event.getLevel();
VisualizationManager manager = VisualizationManager.get(level);
if (manager == null) {
return;

View file

@ -49,7 +49,7 @@ public class EntityVisualManager extends AbstractVisualManager<Entity> {
return false;
}
Level level = entity.level;
Level level = entity.level();
return level != null;
}
}

View file

@ -1,9 +1,10 @@
package com.jozufozu.flywheel.lib.instance;
import org.joml.Quaternionf;
import org.joml.Vector3f;
import com.jozufozu.flywheel.api.instance.InstanceHandle;
import com.jozufozu.flywheel.api.instance.InstanceType;
import com.mojang.math.Quaternion;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
@ -63,8 +64,8 @@ public class OrientedInstance extends ColoredLitInstance {
return this;
}
public OrientedInstance setRotation(Quaternion q) {
return setRotation(q.i(), q.j(), q.k(), q.r());
public OrientedInstance setRotation(Quaternionf q) {
return setRotation(q.x, q.y, q.z, q.w);
}
public OrientedInstance setRotation(float x, float y, float z, float w) {

View file

@ -1,5 +1,7 @@
package com.jozufozu.flywheel.lib.instance;
import org.joml.Matrix3f;
import org.joml.Matrix4f;
import org.joml.Quaternionf;
import com.jozufozu.flywheel.api.instance.InstanceBoundingSphereTransformer;
@ -11,9 +13,6 @@ import com.jozufozu.flywheel.api.layout.BufferLayout;
import com.jozufozu.flywheel.lib.layout.CommonItems;
import com.jozufozu.flywheel.lib.math.RenderMath;
import com.jozufozu.flywheel.lib.vertex.VertexTransformations;
import com.mojang.math.Matrix3f;
import com.mojang.math.Matrix4f;
import com.mojang.math.Quaternion;
import net.minecraft.resources.ResourceLocation;
@ -49,15 +48,15 @@ public class OrientedType implements InstanceType<OrientedInstance> {
@Override
public InstanceVertexTransformer<OrientedInstance> getVertexTransformer() {
return (vertexList, instance) -> {
Quaternion q = new Quaternion(instance.qX, instance.qY, instance.qZ, instance.qW);
Quaternionf q = new Quaternionf(instance.qX, instance.qY, instance.qZ, instance.qW);
Matrix4f modelMatrix = new Matrix4f();
modelMatrix.setIdentity();
modelMatrix.multiplyWithTranslation(instance.posX + instance.pivotX, instance.posY + instance.pivotY, instance.posZ + instance.pivotZ);
modelMatrix.multiply(q);
modelMatrix.multiplyWithTranslation(-instance.pivotX, -instance.pivotY, -instance.pivotZ);
modelMatrix.translate(instance.posX + instance.pivotX, instance.posY + instance.pivotY, instance.posZ + instance.pivotZ);
modelMatrix.rotate(q);
modelMatrix.translate(-instance.pivotX, -instance.pivotY, -instance.pivotZ);
Matrix3f normalMatrix = new Matrix3f(q);
Matrix3f normalMatrix = new Matrix3f();
normalMatrix.set(q);
float r = RenderMath.uf(instance.r);
float g = RenderMath.uf(instance.g);

View file

@ -1,12 +1,13 @@
package com.jozufozu.flywheel.lib.instance;
import org.joml.Matrix3f;
import org.joml.Matrix4f;
import org.joml.Quaternionf;
import com.jozufozu.flywheel.api.instance.InstanceHandle;
import com.jozufozu.flywheel.api.instance.InstanceType;
import com.jozufozu.flywheel.lib.transform.Transform;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix3f;
import com.mojang.math.Matrix4f;
import com.mojang.math.Quaternion;
import net.minecraft.util.Mth;
@ -17,11 +18,6 @@ public class TransformedInstance extends ColoredLitInstance implements Transform
public final Matrix4f model = new Matrix4f();
public final Matrix3f normal = new Matrix3f();
{
model.setIdentity();
normal.setIdentity();
}
public TransformedInstance(InstanceType<? extends TransformedInstance> type, InstanceHandle handle) {
super(type, handle);
}
@ -29,9 +25,9 @@ public class TransformedInstance extends ColoredLitInstance implements Transform
public TransformedInstance setTransform(PoseStack stack) {
setChanged();
this.model.load(stack.last()
this.model.set(stack.last()
.pose());
this.normal.load(stack.last()
this.normal.set(stack.last()
.normal());
return this;
}
@ -46,25 +42,25 @@ public class TransformedInstance extends ColoredLitInstance implements Transform
public TransformedInstance setEmptyTransform() {
setChanged();
model.load(ZERO_MATRIX_4f);
normal.load(ZERO_MATRIX_3f);
model.set(ZERO_MATRIX_4f);
normal.set(ZERO_MATRIX_3f);
return this;
}
public TransformedInstance loadIdentity() {
setChanged();
model.setIdentity();
normal.setIdentity();
model.identity();
normal.identity();
return this;
}
@Override
public TransformedInstance multiply(Quaternion quaternion) {
public TransformedInstance multiply(Quaternionf quaternion) {
setChanged();
model.multiply(quaternion);
normal.mul(quaternion);
model.rotate(quaternion);
normal.rotate(quaternion);
return this;
}
@ -72,11 +68,11 @@ public class TransformedInstance extends ColoredLitInstance implements Transform
public TransformedInstance scale(float x, float y, float z) {
setChanged();
model.multiply(Matrix4f.createScaleMatrix(x, y, z));
model.scale(x, y, z);
if (x == y && y == z) {
if (x < 0.0f) {
normal.mul(-1.0f);
normal.scale(-1.0f);
}
return this;
@ -86,7 +82,7 @@ public class TransformedInstance extends ColoredLitInstance implements Transform
float invY = 1.0f / y;
float invZ = 1.0f / z;
float f = Mth.fastInvCubeRoot(Math.abs(invX * invY * invZ));
normal.mul(Matrix3f.createScaleMatrix(f * invX, f * invY, f * invZ));
normal.scale(f * invX, f * invY, f * invZ);
return this;
}
@ -94,7 +90,7 @@ public class TransformedInstance extends ColoredLitInstance implements Transform
public TransformedInstance translate(double x, double y, double z) {
setChanged();
model.multiplyWithTranslation((float) x, (float) y, (float) z);
model.translate((float) x, (float) y, (float) z);
return this;
}
@ -102,7 +98,7 @@ public class TransformedInstance extends ColoredLitInstance implements Transform
public TransformedInstance mulPose(Matrix4f pose) {
setChanged();
model.multiply(pose);
this.model.mul(pose);
return this;
}
@ -110,7 +106,7 @@ public class TransformedInstance extends ColoredLitInstance implements Transform
public TransformedInstance mulNormal(Matrix3f normal) {
setChanged();
normal.mul(normal);
this.normal.mul(normal);
return this;
}
}

View file

@ -5,139 +5,88 @@ import static org.joml.Math.fma;
import java.nio.ByteBuffer;
import org.joml.Math;
import org.joml.Matrix3f;
import org.joml.Matrix4f;
import org.lwjgl.system.MemoryUtil;
import com.jozufozu.flywheel.mixin.matrix.Matrix3fAccessor;
import com.jozufozu.flywheel.mixin.matrix.Matrix4fAccessor;
import com.mojang.math.Matrix3f;
import com.mojang.math.Matrix4f;
public final class MatrixUtil {
public static float transformPositionX(Matrix4f matrix, float x, float y, float z) {
Matrix4fAccessor m = (Matrix4fAccessor) (Object) matrix;
return fma(m.flywheel$m00(), x, fma(m.flywheel$m01(), y, fma(m.flywheel$m02(), z, m.flywheel$m03())));
return fma(matrix.m00(), x, fma(matrix.m01(), y, fma(matrix.m02(), z, matrix.m03())));
}
public static float transformPositionY(Matrix4f matrix, float x, float y, float z) {
Matrix4fAccessor m = (Matrix4fAccessor) (Object) matrix;
return fma(m.flywheel$m10(), x, fma(m.flywheel$m11(), y, fma(m.flywheel$m12(), z, m.flywheel$m13())));
return fma(matrix.m10(), x, fma(matrix.m11(), y, fma(matrix.m12(), z, matrix.m13())));
}
public static float transformPositionZ(Matrix4f matrix, float x, float y, float z) {
Matrix4fAccessor m = (Matrix4fAccessor) (Object) matrix;
return fma(m.flywheel$m20(), x, fma(m.flywheel$m21(), y, fma(m.flywheel$m22(), z, m.flywheel$m23())));
return fma(matrix.m20(), x, fma(matrix.m21(), y, fma(matrix.m22(), z, matrix.m23())));
}
public static float transformNormalX(Matrix3f matrix, float x, float y, float z) {
Matrix3fAccessor m = (Matrix3fAccessor) (Object) matrix;
return fma(m.flywheel$m00(), x, fma(m.flywheel$m01(), y, m.flywheel$m02() * z));
return fma(matrix.m00(), x, fma(matrix.m01(), y, matrix.m02() * z));
}
public static float transformNormalY(Matrix3f matrix, float x, float y, float z) {
Matrix3fAccessor m = (Matrix3fAccessor) (Object) matrix;
return fma(m.flywheel$m10(), x, fma(m.flywheel$m11(), y, m.flywheel$m12() * z));
return fma(matrix.m10(), x, fma(matrix.m11(), y, matrix.m12() * z));
}
public static float transformNormalZ(Matrix3f matrix, float x, float y, float z) {
Matrix3fAccessor m = (Matrix3fAccessor) (Object) matrix;
return fma(m.flywheel$m20(), x, fma(m.flywheel$m21(), y, m.flywheel$m22() * z));
return fma(matrix.m20(), x, fma(matrix.m21(), y, matrix.m22() * z));
}
public static void write(Matrix4f matrix, ByteBuffer buf) {
Matrix4fAccessor m = (Matrix4fAccessor) (Object) matrix;
buf.putFloat(m.flywheel$m00());
buf.putFloat(m.flywheel$m10());
buf.putFloat(m.flywheel$m20());
buf.putFloat(m.flywheel$m30());
buf.putFloat(m.flywheel$m01());
buf.putFloat(m.flywheel$m11());
buf.putFloat(m.flywheel$m21());
buf.putFloat(m.flywheel$m31());
buf.putFloat(m.flywheel$m02());
buf.putFloat(m.flywheel$m12());
buf.putFloat(m.flywheel$m22());
buf.putFloat(m.flywheel$m32());
buf.putFloat(m.flywheel$m03());
buf.putFloat(m.flywheel$m13());
buf.putFloat(m.flywheel$m23());
buf.putFloat(m.flywheel$m33());
matrix.get(buf);
}
public static void writeUnsafe(Matrix4f matrix, long ptr) {
Matrix4fAccessor m = (Matrix4fAccessor) (Object) matrix;
MemoryUtil.memPutFloat(ptr, m.flywheel$m00());
MemoryUtil.memPutFloat(ptr + 4, m.flywheel$m10());
MemoryUtil.memPutFloat(ptr + 8, m.flywheel$m20());
MemoryUtil.memPutFloat(ptr + 12, m.flywheel$m30());
MemoryUtil.memPutFloat(ptr + 16, m.flywheel$m01());
MemoryUtil.memPutFloat(ptr + 20, m.flywheel$m11());
MemoryUtil.memPutFloat(ptr + 24, m.flywheel$m21());
MemoryUtil.memPutFloat(ptr + 28, m.flywheel$m31());
MemoryUtil.memPutFloat(ptr + 32, m.flywheel$m02());
MemoryUtil.memPutFloat(ptr + 36, m.flywheel$m12());
MemoryUtil.memPutFloat(ptr + 40, m.flywheel$m22());
MemoryUtil.memPutFloat(ptr + 44, m.flywheel$m32());
MemoryUtil.memPutFloat(ptr + 48, m.flywheel$m03());
MemoryUtil.memPutFloat(ptr + 52, m.flywheel$m13());
MemoryUtil.memPutFloat(ptr + 56, m.flywheel$m23());
MemoryUtil.memPutFloat(ptr + 60, m.flywheel$m33());
MemoryUtil.memPutFloat(ptr, matrix.m00());
MemoryUtil.memPutFloat(ptr + 4, matrix.m10());
MemoryUtil.memPutFloat(ptr + 8, matrix.m20());
MemoryUtil.memPutFloat(ptr + 12, matrix.m30());
MemoryUtil.memPutFloat(ptr + 16, matrix.m01());
MemoryUtil.memPutFloat(ptr + 20, matrix.m11());
MemoryUtil.memPutFloat(ptr + 24, matrix.m21());
MemoryUtil.memPutFloat(ptr + 28, matrix.m31());
MemoryUtil.memPutFloat(ptr + 32, matrix.m02());
MemoryUtil.memPutFloat(ptr + 36, matrix.m12());
MemoryUtil.memPutFloat(ptr + 40, matrix.m22());
MemoryUtil.memPutFloat(ptr + 44, matrix.m32());
MemoryUtil.memPutFloat(ptr + 48, matrix.m03());
MemoryUtil.memPutFloat(ptr + 52, matrix.m13());
MemoryUtil.memPutFloat(ptr + 56, matrix.m23());
MemoryUtil.memPutFloat(ptr + 60, matrix.m33());
}
public static void write(Matrix3f matrix, ByteBuffer buf) {
Matrix3fAccessor m = (Matrix3fAccessor) (Object) matrix;
buf.putFloat(m.flywheel$m00());
buf.putFloat(m.flywheel$m10());
buf.putFloat(m.flywheel$m20());
buf.putFloat(m.flywheel$m01());
buf.putFloat(m.flywheel$m11());
buf.putFloat(m.flywheel$m21());
buf.putFloat(m.flywheel$m02());
buf.putFloat(m.flywheel$m12());
buf.putFloat(m.flywheel$m22());
matrix.get(buf);
}
public static void writeUnsafe(Matrix3f matrix, long ptr) {
Matrix3fAccessor m = (Matrix3fAccessor) (Object) matrix;
MemoryUtil.memPutFloat(ptr, m.flywheel$m00());
MemoryUtil.memPutFloat(ptr + 4, m.flywheel$m10());
MemoryUtil.memPutFloat(ptr + 8, m.flywheel$m20());
MemoryUtil.memPutFloat(ptr + 12, m.flywheel$m01());
MemoryUtil.memPutFloat(ptr + 16, m.flywheel$m11());
MemoryUtil.memPutFloat(ptr + 20, m.flywheel$m21());
MemoryUtil.memPutFloat(ptr + 24, m.flywheel$m02());
MemoryUtil.memPutFloat(ptr + 28, m.flywheel$m12());
MemoryUtil.memPutFloat(ptr + 32, m.flywheel$m22());
MemoryUtil.memPutFloat(ptr, matrix.m00());
MemoryUtil.memPutFloat(ptr + 4, matrix.m10());
MemoryUtil.memPutFloat(ptr + 8, matrix.m20());
MemoryUtil.memPutFloat(ptr + 12, matrix.m01());
MemoryUtil.memPutFloat(ptr + 16, matrix.m11());
MemoryUtil.memPutFloat(ptr + 20, matrix.m21());
MemoryUtil.memPutFloat(ptr + 24, matrix.m02());
MemoryUtil.memPutFloat(ptr + 28, matrix.m12());
MemoryUtil.memPutFloat(ptr + 32, matrix.m22());
}
public static void store(Matrix4f matrix, org.joml.Matrix4f jomlMatrix) {
Matrix4fAccessor m = (Matrix4fAccessor) (Object) matrix;
jomlMatrix.set(
m.flywheel$m00(), m.flywheel$m10(), m.flywheel$m20(), m.flywheel$m30(),
m.flywheel$m01(), m.flywheel$m11(), m.flywheel$m21(), m.flywheel$m31(),
m.flywheel$m02(), m.flywheel$m12(), m.flywheel$m22(), m.flywheel$m32(),
m.flywheel$m03(), m.flywheel$m13(), m.flywheel$m23(), m.flywheel$m33()
);
public static void store(Matrix4f matrix, Matrix4f jomlMatrix) {
jomlMatrix.set(matrix);
}
public static org.joml.Matrix4f toJoml(Matrix4f matrix) {
Matrix4fAccessor m = (Matrix4fAccessor) (Object) matrix;
return new org.joml.Matrix4f(
m.flywheel$m00(), m.flywheel$m10(), m.flywheel$m20(), m.flywheel$m30(),
m.flywheel$m01(), m.flywheel$m11(), m.flywheel$m21(), m.flywheel$m31(),
m.flywheel$m02(), m.flywheel$m12(), m.flywheel$m22(), m.flywheel$m32(),
m.flywheel$m03(), m.flywheel$m13(), m.flywheel$m23(), m.flywheel$m33()
);
public static Matrix4f toJoml(Matrix4f matrix) {
return new Matrix4f(matrix);
}
public static void store(Matrix3f matrix, org.joml.Matrix3f jomlMatrix) {
Matrix3fAccessor m = (Matrix3fAccessor) (Object) matrix;
jomlMatrix.set(
m.flywheel$m00(), m.flywheel$m10(), m.flywheel$m20(), m.flywheel$m01(), m.flywheel$m11(), m.flywheel$m21(), m.flywheel$m02(), m.flywheel$m12(), m.flywheel$m22());
jomlMatrix.set(matrix);
}
public static org.joml.Matrix3f toJoml(Matrix3f matrix) {
Matrix3fAccessor m = (Matrix3fAccessor) (Object) matrix;
return new org.joml.Matrix3f(m.flywheel$m00(), m.flywheel$m10(), m.flywheel$m20(), m.flywheel$m01(), m.flywheel$m11(), m.flywheel$m21(), m.flywheel$m02(), m.flywheel$m12(), m.flywheel$m22());
public static Matrix3f toJoml(Matrix3f matrix) {
return new Matrix3f(matrix);
}
/**
@ -147,10 +96,9 @@ public final class MatrixUtil {
* @return The greatest scale factor across all axes.
*/
public static float extractScale(Matrix4f matrix) {
Matrix4fAccessor m = (Matrix4fAccessor) (Object) matrix;
float scaleSqrX = m.flywheel$m00() * m.flywheel$m00() + m.flywheel$m01() * m.flywheel$m01() + m.flywheel$m02() * m.flywheel$m02();
float scaleSqrY = m.flywheel$m10() * m.flywheel$m10() + m.flywheel$m11() * m.flywheel$m11() + m.flywheel$m12() * m.flywheel$m12();
float scaleSqrZ = m.flywheel$m20() * m.flywheel$m20() + m.flywheel$m21() * m.flywheel$m21() + m.flywheel$m22() * m.flywheel$m22();
return (float) Math.sqrt(Math.max(Math.max(scaleSqrX, scaleSqrY), scaleSqrZ));
float scaleSqrX = matrix.m00() * matrix.m00() + matrix.m01() * matrix.m01() + matrix.m02() * matrix.m02();
float scaleSqrY = matrix.m10() * matrix.m10() + matrix.m11() * matrix.m11() + matrix.m12() * matrix.m12();
float scaleSqrZ = matrix.m20() * matrix.m20() + matrix.m21() * matrix.m21() + matrix.m22() * matrix.m22();
return Math.sqrt(Math.max(Math.max(scaleSqrX, scaleSqrY), scaleSqrZ));
}
}

View file

@ -1,19 +1,19 @@
package com.jozufozu.flywheel.lib.transform;
import com.mojang.math.Quaternion;
import com.mojang.math.Vector3f;
import org.joml.AxisAngle4f;
import org.joml.Quaternionf;
import org.joml.Vector3f;
import net.minecraft.core.Direction;
public interface Rotate<Self> {
Self multiply(Quaternion quaternion);
Self multiply(Quaternionf quaternion);
@SuppressWarnings("unchecked")
default Self rotate(Direction axis, float radians) {
if (radians == 0)
return (Self) this;
return multiply(axis.step()
.rotation(radians));
return multiplyRadians(axis.step(), radians);
}
default Self rotate(double angle, Direction.Axis axis) {
@ -57,7 +57,7 @@ public interface Rotate<Self> {
default Self multiplyRadians(Vector3f axis, double angle) {
if (angle == 0)
return (Self) this;
return multiply(axis.rotation((float) angle));
return multiply(new Quaternionf(new AxisAngle4f((float) angle, axis)));
}
@SuppressWarnings("unchecked")

View file

@ -1,9 +1,10 @@
package com.jozufozu.flywheel.lib.transform;
import org.joml.Matrix3f;
import org.joml.Matrix4f;
import org.joml.Quaternionf;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix3f;
import com.mojang.math.Matrix4f;
import com.mojang.math.Quaternion;
import net.minecraft.core.Direction;
@ -30,7 +31,7 @@ public interface Transform<Self extends Transform<Self>> extends Translate<Self>
}
@SuppressWarnings("unchecked")
default Self rotateCentered(Quaternion q) {
default Self rotateCentered(Quaternionf q) {
translate(.5f, .5f, .5f).multiply(q)
.translate(-.5f, -.5f, -.5f);
return (Self) this;

View file

@ -1,6 +1,6 @@
package com.jozufozu.flywheel.lib.transform;
import com.mojang.math.Vector3f;
import org.joml.Vector3f;
import net.minecraft.core.Vec3i;
import net.minecraft.world.phys.Vec3;

View file

@ -2,6 +2,7 @@ package com.jozufozu.flywheel.lib.uniform;
import java.util.function.Consumer;
import org.joml.Matrix4f;
import org.lwjgl.system.MemoryUtil;
import com.jozufozu.flywheel.Flywheel;
@ -83,9 +84,8 @@ public class FlwShaderUniforms implements ShaderUniforms {
var camZ = (float) (camera.z - renderOrigin.getZ());
// don't want to mutate viewProjection
var vp = context.viewProjection()
.copy();
vp.multiplyWithTranslation(-camX, -camY, -camZ);
var vp = new Matrix4f(context.viewProjection());
vp.translate(-camX, -camY, -camZ);
MatrixUtil.writeUnsafe(vp, ptr + 32);
MemoryUtil.memPutFloat(ptr + 96, camX);

View file

@ -25,11 +25,11 @@ public final class FlwUtil {
PoseStack copy = new PoseStack();
copy.last()
.pose()
.load(stack.last()
.set(stack.last()
.pose());
copy.last()
.normal()
.load(stack.last()
.set(stack.last()
.normal());
return copy;
}

View file

@ -14,7 +14,7 @@ import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import net.minecraft.world.level.LevelAccessor;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.event.level.LevelEvent;
public final class LevelAttached<T> {
private static final ConcurrentLinkedDeque<WeakReference<LevelAttached<?>>> ALL = new ConcurrentLinkedDeque<>();
@ -43,8 +43,8 @@ public final class LevelAttached<T> {
}
@ApiStatus.Internal
public static void onUnloadLevel(WorldEvent.Unload event) {
invalidateLevel(event.getWorld());
public static void onUnloadLevel(LevelEvent.Unload event) {
invalidateLevel(event.getLevel());
}
public static void invalidateLevel(LevelAccessor level) {

View file

@ -1,9 +1,10 @@
package com.jozufozu.flywheel.lib.vertex;
import org.joml.Matrix3f;
import org.joml.Matrix4f;
import com.jozufozu.flywheel.api.vertex.MutableVertexList;
import com.jozufozu.flywheel.lib.math.MatrixUtil;
import com.mojang.math.Matrix3f;
import com.mojang.math.Matrix4f;
public final class VertexTransformations {
private VertexTransformations() {

View file

@ -1,6 +1,7 @@
package com.jozufozu.flywheel.lib.visual;
import org.joml.FrustumIntersection;
import org.joml.Vector3f;
import com.jozufozu.flywheel.api.visual.DynamicVisual;
import com.jozufozu.flywheel.api.visual.EntityVisual;
@ -10,7 +11,6 @@ import com.jozufozu.flywheel.api.visualization.VisualizationManager;
import com.jozufozu.flywheel.lib.box.Box;
import com.jozufozu.flywheel.lib.box.MutableBox;
import com.jozufozu.flywheel.lib.light.TickingLightListener;
import com.mojang.math.Vector3f;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
@ -38,7 +38,7 @@ public abstract class AbstractEntityVisual<T extends Entity> extends AbstractVis
protected final EntityVisibilityTester visibilityTester;
public AbstractEntityVisual(VisualizationContext ctx, T entity) {
super(ctx, entity.level);
super(ctx, entity.level());
this.entity = entity;
bounds = MutableBox.from(entity.getBoundingBox());
visibilityTester = new EntityVisibilityTester(entity, ctx.renderOrigin());

View file

@ -1,5 +1,6 @@
package com.jozufozu.flywheel.mixin;
import org.joml.Matrix4f;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@ -16,7 +17,6 @@ import com.jozufozu.flywheel.api.event.RenderContext;
import com.jozufozu.flywheel.api.event.RenderStage;
import com.jozufozu.flywheel.api.event.RenderStageEvent;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix4f;
import net.minecraft.client.Camera;
import net.minecraft.client.multiplayer.ClientLevel;

View file

@ -1,36 +0,0 @@
package com.jozufozu.flywheel.mixin.matrix;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import com.mojang.math.Matrix3f;
@Mixin(Matrix3f.class)
public interface Matrix3fAccessor {
@Accessor("m00")
float flywheel$m00();
@Accessor("m01")
float flywheel$m01();
@Accessor("m02")
float flywheel$m02();
@Accessor("m10")
float flywheel$m10();
@Accessor("m11")
float flywheel$m11();
@Accessor("m12")
float flywheel$m12();
@Accessor("m20")
float flywheel$m20();
@Accessor("m21")
float flywheel$m21();
@Accessor("m22")
float flywheel$m22();
}

View file

@ -1,57 +0,0 @@
package com.jozufozu.flywheel.mixin.matrix;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import com.mojang.math.Matrix4f;
@Mixin(Matrix4f.class)
public interface Matrix4fAccessor {
@Accessor("m00")
float flywheel$m00();
@Accessor("m01")
float flywheel$m01();
@Accessor("m02")
float flywheel$m02();
@Accessor("m03")
float flywheel$m03();
@Accessor("m10")
float flywheel$m10();
@Accessor("m11")
float flywheel$m11();
@Accessor("m12")
float flywheel$m12();
@Accessor("m13")
float flywheel$m13();
@Accessor("m20")
float flywheel$m20();
@Accessor("m21")
float flywheel$m21();
@Accessor("m22")
float flywheel$m22();
@Accessor("m23")
float flywheel$m23();
@Accessor("m30")
float flywheel$m30();
@Accessor("m31")
float flywheel$m31();
@Accessor("m32")
float flywheel$m32();
@Accessor("m33")
float flywheel$m33();
}

View file

@ -1,15 +1,15 @@
package com.jozufozu.flywheel.mixin.matrix;
import org.joml.Quaternionf;
import org.spongepowered.asm.mixin.Mixin;
import com.jozufozu.flywheel.lib.transform.TransformStack;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Quaternion;
@Mixin(PoseStack.class)
public abstract class PoseStackMixin implements TransformStack {
@Override
public TransformStack multiply(Quaternion quaternion) {
public TransformStack multiply(Quaternionf quaternion) {
((PoseStack) (Object) this).mulPose(quaternion);
return this;
}

View file

@ -1,24 +0,0 @@
package com.jozufozu.flywheel.mixin.sodium;
import java.util.Collection;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import me.jellysquid.mods.sodium.client.compat.FlywheelCompat;
import net.minecraft.world.level.block.entity.BlockEntity;
/**
* Overwrite all methods in this class with stubs. These methods use Flywheel classes that no longer exist and would cause a NoClassDefFoundError if invoked.
*/
@Mixin(value = FlywheelCompat.class, remap = false)
public class FlywheelCompatMixin {
@Overwrite
public static boolean addAndFilterBEs(BlockEntity blockEntity) {
return true;
}
@Overwrite
public static void filterBlockEntityList(Collection<BlockEntity> blockEntities) {
}
}

View file

@ -2,6 +2,10 @@ package com.jozufozu.flywheel.vanilla;
import java.util.List;
import org.joml.AxisAngle4f;
import org.joml.Quaternionf;
import org.joml.Vector3f;
import com.jozufozu.flywheel.api.event.RenderStage;
import com.jozufozu.flywheel.api.instance.Instance;
import com.jozufozu.flywheel.api.visual.DynamicVisual;
@ -14,8 +18,6 @@ import com.jozufozu.flywheel.lib.model.ModelHolder;
import com.jozufozu.flywheel.lib.model.SimpleModel;
import com.jozufozu.flywheel.lib.model.part.ModelPartConverter;
import com.jozufozu.flywheel.lib.visual.AbstractBlockEntityVisual;
import com.mojang.math.Quaternion;
import com.mojang.math.Vector3f;
import net.minecraft.client.model.geom.ModelLayers;
import net.minecraft.client.renderer.blockentity.BellRenderer;
@ -73,9 +75,9 @@ public class BellVisual extends AbstractBlockEntityVisual<BellBlockEntity> imple
Vector3f ringAxis = blockEntity.clickDirection.getCounterClockWise()
.step();
bell.setRotation(ringAxis.rotation(angle));
bell.setRotation(new Quaternionf(new AxisAngle4f(angle, ringAxis)));
} else {
bell.setRotation(Quaternion.ONE);
bell.setRotation(new Quaternionf());
}
}

View file

@ -5,6 +5,8 @@ import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import org.joml.Quaternionf;
import com.jozufozu.flywheel.api.event.RenderStage;
import com.jozufozu.flywheel.api.instance.Instance;
import com.jozufozu.flywheel.api.visual.DynamicVisual;
@ -19,8 +21,6 @@ import com.jozufozu.flywheel.lib.model.SimpleModel;
import com.jozufozu.flywheel.lib.model.part.ModelPartConverter;
import com.jozufozu.flywheel.lib.util.Pair;
import com.jozufozu.flywheel.lib.visual.AbstractBlockEntityVisual;
import com.mojang.math.Quaternion;
import com.mojang.math.Vector3f;
import it.unimi.dsi.fastutil.floats.Float2FloatFunction;
import net.minecraft.client.model.geom.ModelLayerLocation;
@ -60,7 +60,7 @@ public class ChestVisual<T extends BlockEntity & LidBlockEntity> extends Abstrac
private ChestType chestType;
private Material texture;
private Quaternion baseRotation;
private Quaternionf baseRotation;
private Float2FloatFunction lidProgress;
private float lastProgress = Float.NaN;

View file

@ -15,7 +15,6 @@ import com.jozufozu.flywheel.lib.model.SimpleModel;
import com.jozufozu.flywheel.lib.model.part.ModelPartConverter;
import com.jozufozu.flywheel.lib.visual.AbstractEntityVisual;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import net.minecraft.client.model.geom.ModelLayers;
import net.minecraft.util.Mth;
@ -124,7 +123,7 @@ public class MinecartVisual<T extends AbstractMinecart> extends AbstractEntityVi
if (pos != null) {
Vec3 offset1 = entity.getPosOffs(posX, posY, posZ, 0.3F);
Vec3 offset2 = entity.getPosOffs(posX, posY, posZ, -0.3F);
if (offset1 == null) {
offset1 = pos;
}

View file

@ -2,6 +2,8 @@ package com.jozufozu.flywheel.vanilla;
import java.util.List;
import org.joml.Quaternionf;
import com.jozufozu.flywheel.api.event.RenderStage;
import com.jozufozu.flywheel.api.instance.Instance;
import com.jozufozu.flywheel.api.visual.DynamicVisual;
@ -16,8 +18,6 @@ import com.jozufozu.flywheel.lib.model.part.ModelPartConverter;
import com.jozufozu.flywheel.lib.transform.TransformStack;
import com.jozufozu.flywheel.lib.visual.AbstractBlockEntityVisual;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Quaternion;
import com.mojang.math.Vector3f;
import net.minecraft.client.model.geom.ModelLayers;
import net.minecraft.client.renderer.Sheets;
@ -56,7 +56,7 @@ public class ShulkerBoxVisual extends AbstractBlockEntityVisual<ShulkerBoxBlockE
texture = Sheets.SHULKER_TEXTURE_LOCATION.get(color.getId());
}
Quaternion rotation = getDirection().getRotation();
var rotation = getDirection().getRotation();
TransformStack tstack = TransformStack.cast(stack);
tstack.translate(getVisualPosition())
@ -102,7 +102,7 @@ public class ShulkerBoxVisual extends AbstractBlockEntityVisual<ShulkerBoxBlockE
}
lastProgress = progress;
Quaternion spin = Vector3f.YP.rotationDegrees(270.0f * progress);
Quaternionf spin = Vector3f.YP.rotationDegrees(270.0f * progress);
TransformStack.cast(stack)
.pushPose()

View file

@ -19,8 +19,6 @@
"VertexFormatMixin",
"fix.FixFabulousDepthMixin",
"fix.FixNormalScalingMixin",
"matrix.Matrix3fAccessor",
"matrix.Matrix4fAccessor",
"matrix.PoseStackMixin",
"visualmanage.ChunkRebuildHooksMixin",
"visualmanage.VisualAddMixin",

View file

@ -6,8 +6,7 @@
"refmap": "flywheel.refmap.json",
"plugin": "com.jozufozu.flywheel.compat.SodiumMixinPlugin",
"client": [
"ChunkRenderRebuildTaskMixin",
"FlywheelCompatMixin"
"ChunkRenderRebuildTaskMixin"
],
"injectors": {
"defaultRequire": 1