Create/src/main/java/com/simibubi/create/content/schematics/client/tools/RotateTool.java
simibubi 2e3c906ce0 Create in the far lands
- Fixed couplings, schematics and in-world overlays not rendering correctly at coordinates far from the origin
2023-05-08 13:05:16 +02:00

45 lines
1.3 KiB
Java

package com.simibubi.create.content.schematics.client.tools;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.render.SuperRenderTypeBuffer;
import com.simibubi.create.foundation.utility.AnimationTickHolder;
import com.simibubi.create.foundation.utility.outliner.LineOutline;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
public class RotateTool extends PlacementToolBase {
private LineOutline line = new LineOutline();
@Override
public boolean handleMouseWheel(double delta) {
schematicHandler.getTransformation()
.rotate90(delta > 0);
schematicHandler.markDirty();
return true;
}
@Override
public void renderOnSchematic(PoseStack ms, SuperRenderTypeBuffer buffer) {
AABB bounds = schematicHandler.getBounds();
double height = bounds.getYsize() + Math.max(20, bounds.getYsize());
Vec3 center = bounds.getCenter()
.add(schematicHandler.getTransformation()
.getRotationOffset(false));
Vec3 start = center.subtract(0, height / 2, 0);
Vec3 end = center.add(0, height / 2, 0);
line.getParams()
.disableCull()
.disableLineNormals()
.colored(0xdddddd)
.lineWidth(1 / 16f);
line.set(start, end)
.render(ms, buffer, Vec3.ZERO, AnimationTickHolder.getPartialTicks());
super.renderOnSchematic(ms, buffer);
}
}