Adopted new Math and Widget changes
This commit is contained in:
parent
e608bf21fe
commit
ff77134ead
15 changed files with 62 additions and 51 deletions
|
@ -4,7 +4,6 @@ import org.betterx.bclib.BCLib;
|
|||
import org.betterx.bclib.util.BlocksHelper;
|
||||
import org.betterx.bclib.util.MHelper;
|
||||
|
||||
import com.mojang.math.Vector3f;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrides;
|
||||
|
@ -23,6 +22,7 @@ import net.fabricmc.api.Environment;
|
|||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package org.betterx.bclib.client.models;
|
||||
|
||||
import com.mojang.math.Vector3f;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package org.betterx.bclib.client.models;
|
||||
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Vector3f;
|
||||
import com.mojang.math.Vector4f;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.resources.model.ModelState;
|
||||
|
@ -11,6 +8,10 @@ import net.minecraft.core.Direction;
|
|||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class UnbakedQuad {
|
||||
private static final Vector4f POS = new Vector4f();
|
||||
|
@ -55,7 +56,7 @@ public class UnbakedQuad {
|
|||
float y = data[dataIndex++]; // Y
|
||||
float z = data[dataIndex++]; // Z
|
||||
POS.set(x, y, z, 0);
|
||||
POS.transform(matrix);
|
||||
POS.mul(matrix);
|
||||
vertexData[index] = Float.floatToIntBits(POS.x()); // X
|
||||
vertexData[index | 1] = Float.floatToIntBits(POS.y()); // Y
|
||||
vertexData[index | 2] = Float.floatToIntBits(POS.z()); // Z
|
||||
|
|
|
@ -5,7 +5,7 @@ import org.betterx.bclib.client.models.BaseChestBlockModel;
|
|||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Vector3f;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.client.model.geom.ModelPart;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
@ -73,7 +73,7 @@ public class BaseChestBlockEntityRenderer implements BlockEntityRenderer<BaseChe
|
|||
|
||||
matrices.pushPose();
|
||||
matrices.translate(0.5D, 0.5D, 0.5D);
|
||||
matrices.mulPose(Vector3f.YP.rotationDegrees(-f));
|
||||
matrices.mulPose(Axis.YP.rotationDegrees(-f));
|
||||
matrices.translate(-0.5D, -0.5D, -0.5D);
|
||||
|
||||
if (worldExists) {
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.betterx.bclib.blocks.BaseSignBlock;
|
|||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Vector3f;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.model.geom.ModelLayers;
|
||||
|
@ -68,10 +68,10 @@ public class BaseSignBlockEntityRenderer implements BlockEntityRenderer<BaseSign
|
|||
|
||||
BlockState blockState = signBlockEntity.getBlockState();
|
||||
if (blockState.getValue(BaseSignBlock.FLOOR)) {
|
||||
matrixStack.mulPose(Vector3f.YP.rotationDegrees(angle));
|
||||
matrixStack.mulPose(Axis.YP.rotationDegrees(angle));
|
||||
model.stick.visible = true;
|
||||
} else {
|
||||
matrixStack.mulPose(Vector3f.YP.rotationDegrees(angle + 180));
|
||||
matrixStack.mulPose(Axis.YP.rotationDegrees(angle + 180));
|
||||
matrixStack.translate(0.0D, -0.3125D, -0.4375D);
|
||||
model.stick.visible = false;
|
||||
}
|
||||
|
|
|
@ -5,8 +5,7 @@ import org.betterx.bclib.items.boat.CustomBoatTypeOverride;
|
|||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Quaternion;
|
||||
import com.mojang.math.Vector3f;
|
||||
import com.mojang.math.Axis;
|
||||
import net.minecraft.client.model.BoatModel;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
@ -19,6 +18,8 @@ import net.minecraft.world.entity.vehicle.ChestBoat;
|
|||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import org.joml.Quaternionf;
|
||||
|
||||
@Environment(value = EnvType.CLIENT)
|
||||
public class BoatRenderer {
|
||||
|
||||
|
@ -37,22 +38,25 @@ public class BoatRenderer {
|
|||
float k;
|
||||
poseStack.pushPose();
|
||||
poseStack.translate(0.0, 0.375, 0.0);
|
||||
poseStack.mulPose(Vector3f.YP.rotationDegrees(180.0f - f));
|
||||
poseStack.mulPose(Axis.YP.rotationDegrees(180.0f - f));
|
||||
float h = (float) boat.getHurtTime() - g;
|
||||
float j = boat.getDamage() - g;
|
||||
if (j < 0.0f) {
|
||||
j = 0.0f;
|
||||
}
|
||||
if (h > 0.0f) {
|
||||
poseStack.mulPose(Vector3f.XP.rotationDegrees(Mth.sin(h) * h * j / 10.0f * (float) boat.getHurtDir()));
|
||||
poseStack.mulPose(Axis.XP.rotationDegrees(Mth.sin(h) * h * j / 10.0f * (float) boat.getHurtDir()));
|
||||
}
|
||||
if (!Mth.equal(k = boat.getBubbleAngle(g), 0.0f)) {
|
||||
poseStack.mulPose(new Quaternion(new Vector3f(1.0f, 0.0f, 1.0f), boat.getBubbleAngle(g), true));
|
||||
poseStack.mulPose(new Quaternionf().setAngleAxis(
|
||||
boat.getBubbleAngle(g) * ((float) Math.PI / 180),
|
||||
1.0f, 0.0f, 1.0f
|
||||
));
|
||||
}
|
||||
ResourceLocation resourceLocation = hasChest ? type.chestBoatTexture : type.boatTexture;
|
||||
BoatModel boatModel = type.getBoatModel(hasChest);
|
||||
poseStack.scale(-1.0f, -1.0f, 1.0f);
|
||||
poseStack.mulPose(Vector3f.YP.rotationDegrees(90.0f));
|
||||
poseStack.mulPose(Axis.YP.rotationDegrees(90.0f));
|
||||
boatModel.setupAnim(boat, g, 0.0f, -0.1f, 0.0f, 0.0f);
|
||||
VertexConsumer vertexConsumer = multiBufferSource.getBuffer(boatModel.renderType(resourceLocation));
|
||||
boatModel.renderToBuffer(
|
||||
|
|
|
@ -42,8 +42,12 @@ public class AnvilScreenMixin extends ItemCombinerScreen<AnvilMenu> {
|
|||
int x = (width - imageWidth) / 2;
|
||||
int y = (height - imageHeight) / 2;
|
||||
be_buttons.clear();
|
||||
be_buttons.add(new Button(x + 8, y + 45, 15, 20, Component.literal("<"), b -> be_previousRecipe()));
|
||||
be_buttons.add(new Button(x + 154, y + 45, 15, 20, Component.literal(">"), b -> be_nextRecipe()));
|
||||
be_buttons.add(Button.builder(Component.literal("<"), b -> be_previousRecipe())
|
||||
.bounds(x + 8, y + 45, 15, 20)
|
||||
.build());
|
||||
be_buttons.add(Button.builder(Component.literal(">"), b -> be_nextRecipe())
|
||||
.bounds(x + 154, y + 45, 15, 20)
|
||||
.build());
|
||||
|
||||
be_buttons.forEach(button -> addWidget(button));
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.betterx.bclib.sdf.operator;
|
||||
|
||||
import com.mojang.math.Vector3f;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.betterx.bclib.sdf.operator;
|
||||
|
||||
import com.mojang.math.Vector3f;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
|
|
|
@ -1,21 +1,22 @@
|
|||
package org.betterx.bclib.sdf.operator;
|
||||
|
||||
import com.mojang.math.Quaternion;
|
||||
import com.mojang.math.Vector3f;
|
||||
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
public class SDFRotation extends SDFUnary {
|
||||
private final Vector3f pos = new Vector3f();
|
||||
private Quaternion rotation;
|
||||
private Quaternionf rotation;
|
||||
|
||||
public SDFRotation setRotation(Vector3f axis, float rotationAngle) {
|
||||
rotation = new Quaternion(axis, rotationAngle, false);
|
||||
rotation = new Quaternionf().setAngleAxis(rotationAngle, axis.x, axis.y, axis.z);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDistance(float x, float y, float z) {
|
||||
pos.set(x, y, z);
|
||||
pos.transform(rotation);
|
||||
pos.rotate(rotation);
|
||||
return source.getDistance(pos.x(), pos.y(), pos.z());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
package org.betterx.bclib.util;
|
||||
|
||||
import com.mojang.math.Vector3f;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.levelgen.PositionalRandomFactory;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class MHelper {
|
||||
static class ThreadLocalRandomSource implements RandomSource {
|
||||
ThreadLocalRandomSource(long seed) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -230,28 +231,28 @@ public class MHelper {
|
|||
}
|
||||
|
||||
public static Vector3f cross(Vector3f vec1, Vector3f vec2) {
|
||||
float cx = vec1.y() * vec2.z() - vec1.z() * vec2.y();
|
||||
float cy = vec1.z() * vec2.x() - vec1.x() * vec2.z();
|
||||
float cz = vec1.x() * vec2.y() - vec1.y() * vec2.x();
|
||||
float cx = vec1.y * vec2.z - vec1.z * vec2.y;
|
||||
float cy = vec1.z * vec2.x - vec1.x * vec2.z;
|
||||
float cz = vec1.x * vec2.y - vec1.y * vec2.x;
|
||||
return new Vector3f(cx, cy, cz);
|
||||
}
|
||||
|
||||
public static Vector3f normalize(Vector3f vec) {
|
||||
float length = lengthSqr(vec.x(), vec.y(), vec.z());
|
||||
float length = lengthSqr(vec.x, vec.y, vec.z);
|
||||
if (length > 0) {
|
||||
length = (float) Math.sqrt(length);
|
||||
float x = vec.x() / length;
|
||||
float y = vec.y() / length;
|
||||
float z = vec.z() / length;
|
||||
float x = vec.x / length;
|
||||
float y = vec.y / length;
|
||||
float z = vec.z / length;
|
||||
vec.set(x, y, z);
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
public static float angle(Vector3f vec1, Vector3f vec2) {
|
||||
float dot = vec1.x() * vec2.x() + vec1.y() * vec2.y() + vec1.z() * vec2.z();
|
||||
float length1 = lengthSqr(vec1.x(), vec1.y(), vec1.z());
|
||||
float length2 = lengthSqr(vec2.x(), vec2.y(), vec2.z());
|
||||
float dot = vec1.x * vec2.x + vec1.y * vec2.y + vec1.z * vec2.z;
|
||||
float length1 = lengthSqr(vec1.x, vec1.y, vec1.z);
|
||||
float length2 = lengthSqr(vec2.x, vec2.y, vec2.z);
|
||||
return (float) Math.acos(dot / Math.sqrt(length1 * length2));
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import org.betterx.bclib.sdf.SDF;
|
|||
import org.betterx.bclib.sdf.operator.SDFUnion;
|
||||
import org.betterx.bclib.sdf.primitive.SDFLine;
|
||||
|
||||
import com.mojang.math.Vector3f;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||
import net.minecraft.util.Mth;
|
||||
|
@ -13,6 +12,7 @@ import net.minecraft.world.level.WorldGenLevel;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
|
@ -53,15 +53,12 @@ public class Button extends AbstractVanillaComponent<net.minecraft.client.gui.co
|
|||
@Override
|
||||
protected net.minecraft.client.gui.components.Button createVanillaComponent() {
|
||||
Button self = this;
|
||||
return new net.minecraft.client.gui.components.Button(
|
||||
0,
|
||||
0,
|
||||
relativeBounds.width,
|
||||
relativeBounds.height,
|
||||
component,
|
||||
(bt) -> onPress.onPress(self),
|
||||
(bt, stack, x, y) -> onTooltip.onTooltip(self, stack, x, y)
|
||||
);
|
||||
return net.minecraft.client.gui.components.Button
|
||||
.builder(component, (bt) -> onPress.onPress(self))
|
||||
.bounds(0, 0, relativeBounds.width, relativeBounds.height)
|
||||
.tooltip((bt, stack, x, y) -> onTooltip.onTooltip(self, stack, x, y))
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
public boolean isGlowing() {
|
||||
|
|
|
@ -5,7 +5,7 @@ import org.betterx.ui.layout.components.input.RelativeContainerEventHandler;
|
|||
import org.betterx.ui.layout.values.Rectangle;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.components.Widget;
|
||||
import net.minecraft.client.gui.components.Renderable;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.client.gui.narration.NarratableEntry;
|
||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||
|
@ -17,7 +17,7 @@ import java.util.List;
|
|||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class Panel implements ComponentWithBounds, RelativeContainerEventHandler, NarratableEntry, Widget {
|
||||
public class Panel implements ComponentWithBounds, RelativeContainerEventHandler, NarratableEntry, Renderable {
|
||||
protected LayoutComponent<?, ?> child;
|
||||
List<? extends GuiEventListener> listeners = List.of();
|
||||
public final Rectangle bounds;
|
||||
|
|
|
@ -7,11 +7,12 @@ import org.betterx.ui.layout.values.Size;
|
|||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.*;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
public class RenderHelper {
|
||||
public static void outline(PoseStack poseStack, int x0, int y0, int x1, int y1, int color) {
|
||||
outline(poseStack, x0, y0, x1, y1, color, color);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue