Revert "Remove unready code, for now"

This reverts commit b626e3fa8f83013e5b4a68e787ffed9b75d8a679.
This commit is contained in:
ah-OOG-ah committed 2024-02-29 21:17:46 -05:00
1 parent 85ed121158
commit 2fea614a45
8 files changed
+840

No files matched your search

@@ -0,0 +1,101 @@
package com.gtnewhorizons.angelica.models.unready.common;
import com.gtnewhorizons.angelica.api.QuadProvider;
import com.gtnewhorizons.angelica.compat.mojang.BlockPos;
import com.gtnewhorizons.angelica.compat.nd.Quad;
import com.gtnewhorizons.angelica.models.unready.json.JsonModel;
import com.gtnewhorizons.angelica.models.unready.json.Loader;
import com.gtnewhorizons.angelica.models.unready.json.Variant;
import com.gtnewhorizons.angelica.utils.ObjectPooler;
import it.unimi.dsi.fastutil.objects.ObjectImmutableList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import org.jetbrains.annotations.NotNull;
public class BlockTest extends Block implements QuadProvider {
public static final Variant[] modelId = {
new Variant(
new ResourceLocation("blocks/lectern"),
0,
0,
false
),
new Variant(
new ResourceLocation("blocks/lectern"),
180,
0,
false
),
new Variant(
new ResourceLocation("blocks/lectern"),
90,
0,
false
),
new Variant(
new ResourceLocation("blocks/lectern"),
270,
0,
false
),
};
public static final List<Quad> EMPTY = ObjectImmutableList.of();
private static final JsonModel[] model = new JsonModel[4];
public BlockTest() {
super(Material.rock);
}
public static void loadModel() {
for (int i = 0; i < 4; ++i)
model[i] = Loader.getModel(modelId[i]);
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public void registerBlockIcons(IIconRegister reg) {
reg.registerIcon("angelica:test_block");
reg.registerIcon("lectern_base");
reg.registerIcon("lectern_front");
reg.registerIcon("lectern_sides");
reg.registerIcon("lectern_top");
reg.registerIcon("oak_planks");
}
@Override
public List<Quad> getQuads(IBlockAccess world, BlockPos pos, Block block, int meta, ForgeDirection dir, Random random, ObjectPooler<Quad> quadPool) {
if (meta < 2 || meta > 5) meta = 2;
return (model[meta - 2] != null) ? model[meta - 2].getQuads(world, pos, block, meta, dir, random, quadPool) : EMPTY;
}
/**
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata
*/
@Override
public int onBlockPlaced(@NotNull World worldIn, int x, int y, int z, int side, float subX, float subY, float subZ, int meta) {
// Face NORTH if placed up or down
final ForgeDirection s = ForgeDirection.values()[side];
if (s == ForgeDirection.UP || s == ForgeDirection.DOWN)
return 2;
// Face the placed side
return side;
}
}
@@ -0,0 +1,355 @@
package com.gtnewhorizons.angelica.models.unready.json;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.gtnewhorizons.angelica.api.QuadProvider;
import com.gtnewhorizons.angelica.compat.mojang.Axis;
import com.gtnewhorizons.angelica.compat.mojang.BlockPos;
import com.gtnewhorizons.angelica.compat.nd.Quad;
import com.gtnewhorizons.angelica.models.NdQuadBuilder;
import com.gtnewhorizons.angelica.utils.DirUtil;
import com.gtnewhorizons.angelica.utils.ObjectPooler;
import it.unimi.dsi.fastutil.Function;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import it.unimi.dsi.fastutil.objects.ObjectImmutableList;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import org.jetbrains.annotations.Nullable;
import org.joml.Matrix4f;
import org.joml.Vector3f;
import org.joml.Vector4f;
import static com.gtnewhorizons.angelica.utils.JsonUtil.loadBool;
import static com.gtnewhorizons.angelica.utils.JsonUtil.loadFloat;
import static com.gtnewhorizons.angelica.utils.JsonUtil.loadInt;
import static com.gtnewhorizons.angelica.utils.JsonUtil.loadStr;
public class JsonModel implements QuadProvider {
@Nullable
private final ResourceLocation parentId;
@Nullable
private JsonModel parent;
private final boolean useAO;
private final Map<ModelDisplay.Position, ModelDisplay> display;
private final Map<String, String> textures;
private List<ModelElement> elements;
private List<Quad> bakedQuadStore = new ObjectArrayList<>();
JsonModel(@Nullable ResourceLocation parentId, boolean useAO, Map<ModelDisplay.Position, ModelDisplay> display, Map<String, String> textures, List<ModelElement> elements) {
this.parentId = parentId;
this.useAO = useAO;
this.display = display;
this.textures = textures;
this.elements = elements;
}
/**
* Makes a shallow copy of og. This allows you to bake the same model multiple times with various transformations.
*/
JsonModel(JsonModel og) {
this.parentId = og.parentId;
this.parent = og.parent;
this.useAO = og.useAO;
this.display = og.display;
this.textures = og.textures;
this.elements = og.elements;
}
public void bake(Variant v) {
final Matrix4f vRot = v.getAffineMatrix();
final NdQuadBuilder builder = new NdQuadBuilder();
// Append faces from each element
for (ModelElement e : this.elements) {
final Matrix4f rot = (e.getRotation() == null) ? ModelElement.Rotation.NOOP.getAffineMatrix() : e.getRotation().getAffineMatrix();
//rot.mulLocal(vRot);
final Vector3f from = e.getFrom();
final Vector3f to = e.getTo();
for (ModelElement.Face f : e.getFaces()) {
// Assign vertexes
for (int i = 0; i < 4; ++i) {
final Vector3f vert = rot.transformPosition(NdQuadBuilder.mapSideToVertex(from, to, i, f.getName()));
vRot.transformPosition(vert);
builder.pos(i, vert.x, vert.y, vert.z);
}
// Set culling and nominal faces
builder.cullFace(f.getCullFace());
builder.nominalFace(f.getName());
// Set bake flags
int flags = switch(f.getRotation()) {
case 90 -> NdQuadBuilder.BAKE_ROTATE_90;
case 180 -> NdQuadBuilder.BAKE_ROTATE_180;
case 270 -> NdQuadBuilder.BAKE_ROTATE_270;
default -> NdQuadBuilder.BAKE_ROTATE_NONE;
};
// Set UV
final Vector4f uv = f.getUv();
if (uv != null) {
builder.uv(0, uv.x, uv.y);
builder.uv(1, uv.x, uv.w);
builder.uv(2, uv.z, uv.w);
builder.uv(3, uv.z, uv.y);
} else {
// Not sure if this is correct, but it seems to fix things
flags |= NdQuadBuilder.BAKE_LOCK_UV;
}
// Set the sprite
builder.spriteBake(this.textures.get(f.getTexture()), flags);
// Set the tint index
final int tint = f.getTintIndex();
builder.color(tint, tint, tint, tint);
// Bake and add it
this.bakedQuadStore.add(builder.build(new Quad()));
}
}
this.bakedQuadStore = new ObjectImmutableList<>(this.bakedQuadStore);
}
public List<ResourceLocation> getParents() {
return Arrays.asList(parentId);
}
@Override
public List<Quad> getQuads(IBlockAccess world, BlockPos pos, Block block, int meta, ForgeDirection dir, Random random, ObjectPooler<Quad> quadPool) {
final List<Quad> ret = new ObjectArrayList<>(this.bakedQuadStore.size());
//noinspection ForLoopReplaceableByForEach
for (int i = 0; i < bakedQuadStore.size(); ++i) {
final Quad q = quadPool.getInstance();
q.copyFrom(this.bakedQuadStore.get(i));
ret.add(q);
}
return ret;
}
public void resolveParents(Function<ResourceLocation, JsonModel> modelLoader) {
if (this.parentId != null && this.parent == null) {
final JsonModel p = modelLoader.apply(this.parentId);
p.resolveParents(modelLoader);
// Inherit properties
this.parent = p;
if (this.elements.isEmpty()) this.elements = this.parent.elements;
// Resolve texture variables
// Add parent texture mappings, but prioritize ours.
for (Map.Entry<String, String> e : this.parent.textures.entrySet()) {
this.textures.putIfAbsent(e.getKey(), e.getValue());
}
// Flatten them, merging s -> s1, s1 -> s2 to s -> s2, s1 -> s2.
boolean flat = false;
final Map<String, String> tmp = new Object2ObjectOpenHashMap<>();
while (!flat) {
flat = true;
for (Map.Entry<String, String> e : this.textures.entrySet()) {
// If there is a value in the key set, replace with the value it points to
// Also avoid adding a loop
if (this.textures.containsKey(e.getValue())) {
if (!e.getKey().equals(e.getValue()))
tmp.put(e.getKey(), this.textures.get(e.getValue()));
else tmp.put(e.getKey(), "");
flat = false;
} else {
tmp.put(e.getKey(), e.getValue());
}
}
this.textures.putAll(tmp);
}
}
}
static class Deserializer implements JsonDeserializer<JsonModel> {
private Vector3f loadVec3(JsonObject in, String name) {
final JsonArray arr = in.getAsJsonArray(name);
final Vector3f ret = new Vector3f();
for (int i = 0; i < 3; ++i) {
ret.setComponent(i, arr.get(i).getAsFloat());
}
return ret;
}
private Vector4f loadVec4(JsonObject in, String name) {
final JsonArray arr = in.getAsJsonArray(name);
final Vector4f ret = new Vector4f();
for (int i = 0; i < 4; ++i) {
ret.setComponent(i, arr.get(i).getAsFloat());
}
return ret;
}
private ModelDisplay loadADisplay(JsonObject in) {
final Vector3f rotation = loadVec3(in, "rotation");
final Vector3f translation = loadVec3(in, "translation");
final Vector3f scale = loadVec3(in, "scale");
return new ModelDisplay(rotation, translation, scale);
}
private Map<ModelDisplay.Position, ModelDisplay> loadDisplay(JsonObject in) {
// wow such long
final Map<ModelDisplay.Position, ModelDisplay> ret = new Object2ObjectOpenHashMap<>(ModelDisplay.Position.values().length);
if (in.has("display")) {
final JsonObject display = in.getAsJsonObject("display");
for (Map.Entry<String, JsonElement> j : display.entrySet()) {
final String name = j.getKey();
final ModelDisplay.Position pos = ModelDisplay.Position.getByName(name);
ret.put(pos, loadADisplay(j.getValue().getAsJsonObject()));
}
}
for (ModelDisplay.Position p : ModelDisplay.Position.values()) {
ret.putIfAbsent(p, ModelDisplay.DEFAULT);
}
return ret;
}
private Map<String, String> loadTextures(JsonObject in) {
final Map<String, String> textures = new Object2ObjectOpenHashMap<>();
if (in.has("textures")) {
for (Map.Entry<String, JsonElement> e : in.getAsJsonObject("textures").entrySet()) {
// Trim leading octothorpes. They indicate a texture variable, but I don't actually care.
String s = e.getValue().getAsString();
if (s.startsWith("#")) s = s.substring(1);
textures.put(e.getKey(), s);
}
}
return textures;
}
private ModelElement.Rotation loadRotation(JsonObject in) {
if (in.has("rotation")) {
final JsonObject json = in.getAsJsonObject("rotation");
final Vector3f origin = loadVec3(json, "origin").div(16);
final Axis axis = Axis.fromName(loadStr(json, "axis"));
final float angle = loadFloat(json, "angle");
final boolean rescale = loadBool(json, "rescale", false);
return new ModelElement.Rotation(origin, axis, angle, rescale);
} else {
return null;
}
}
private List<ModelElement.Face> loadFaces(JsonObject in) {
final List<ModelElement.Face> ret = new ObjectArrayList<>();
final JsonObject json = in.getAsJsonObject("faces");
for (Map.Entry<String, JsonElement> e : json.entrySet()) {
final ForgeDirection side = DirUtil.fromName(e.getKey());
final JsonObject face = e.getValue().getAsJsonObject();
final Vector4f uv = (face.has("uv")) ? loadVec4(face, "uv") : null;
String texture = loadStr(face, "texture");
if (texture.startsWith("#")) texture = texture.substring(1);
final ForgeDirection cullFace = DirUtil.fromName(loadStr(face, "cullface", "unknown"));
final int rotation = loadInt(face, "rotation", 0);
final int tintIndex = loadInt(face, "tintindex", -1);
ret.add(new ModelElement.Face(side, uv, texture, cullFace, rotation, tintIndex));
}
return ret;
}
private List<ModelElement> loadElements(JsonObject in) {
final List<ModelElement> ret = new ObjectArrayList<>();
if (in.has("elements")) {
final JsonArray arr = in.getAsJsonArray("elements");
for (JsonElement e : arr) {
final JsonObject json = e.getAsJsonObject();
final Vector3f from = loadVec3(json, "from").div(16);
final Vector3f to = loadVec3(json, "to").div(16);
final ModelElement.Rotation rotation = loadRotation(json);
final boolean shade = loadBool(json, "shade", true);
final List<ModelElement.Face> faces = loadFaces(json);
ret.add(new ModelElement(from, to, rotation, shade, faces));
}
}
return ret;
}
@Override
public JsonModel deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
final JsonObject in = json.getAsJsonObject();
final String parent = loadStr(in, "parent", "");
final ResourceLocation parentId = (parent.isEmpty()) ? null : new ResourceLocation(parent);
final boolean useAO = loadBool(in, "ambientocclusion", true);
final Map<ModelDisplay.Position, ModelDisplay> display = loadDisplay(in);
final Map<String, String> textures = loadTextures(in);
final List<ModelElement> elements = loadElements(in);
return new JsonModel(parentId, useAO, display, textures, elements);
}
}
}
@@ -0,0 +1,118 @@
package com.gtnewhorizons.angelica.models.unready.json;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
import com.gtnewhorizons.angelica.utils.Callback;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.util.ResourceLocation;
/**
* Model loading should proceed as follows: <ul>
* <li>Models to load are registered in PREINIT.</li>
* <li>All registered models are recursively loaded in INIT.</li>
* <li>Models registered for baking are baked on the first tick of the game.</li>
*</ul>
* <p>Alternatively, you can register blocks with blockstate variants in preinit, and the rest is handled by
* {@link Loader}.
* <p>As for icons, register them in {@link Block#registerBlockIcons}. Whatever gets them in the block texture atlas.
*/
public class Loader {
static final Gson GSON = new GsonBuilder()
.registerTypeAdapter(JsonModel.class, new JsonModel.Deserializer()).create();
private static final List<ResourceLocation> unloadedModels = new ObjectArrayList<>();
private static final Map<ResourceLocation, JsonModel> loadedModels = new Object2ObjectOpenHashMap<>();
private static final Map<Variant, JsonModel> modelsToBake = new Object2ObjectOpenHashMap<>();
private static final List<Callback> postBakeCallbacks = new ObjectArrayList<>();
/**
* Pass the variant you want to load, and if needed a callback which puts the models in a useful place, e.g. saving
* them to a static field after baking.
*/
public static void registerModel(Variant loc, Callback loader) {
unloadedModels.add(loc.getModel());
modelsToBake.put(loc, null);
postBakeCallbacks.add(loader);
}
/**
* Convenience method to register multiple variants. See {@link #registerModel}.
*/
public static void registerModels(Callback loader, Variant... variants) {
registerModels(Arrays.asList(variants), loader);
}
/**
* Convenience method to register multiple variants. See {@link #registerModel}.
*/
public static void registerModels(Collection<Variant> variants, Callback loader) {
for (Variant v : variants) {
unloadedModels.add(v.getModel());
modelsToBake.put(v, null);
}
postBakeCallbacks.add(loader);
}
public static void loadModels() {
for (ResourceLocation l : unloadedModels) {
if (l == null) continue;
if (loadedModels.containsKey(l)) continue;
final JsonModel model = loadJson(
"/assets/" + l.getResourceDomain() + "/models/" + l.getResourcePath() + ".json", JsonModel.class);
unloadedModels.addAll(model.getParents());
loadedModels.put(l, model);
}
}
private static <T> T loadJson(String path, Class<T> clazz) {
try (final InputStream is = Loader.class.getResourceAsStream(path)) {
return GSON.fromJson(new InputStreamReader(is), clazz);
} catch (IOException | NullPointerException e) {
AngelicaTweaker.LOGGER.fatal("Could not find " + path);
throw new RuntimeException(e);
}
}
public static void bakeModels() {
for (Map.Entry<Variant, JsonModel> l : modelsToBake.entrySet()) {
final JsonModel dough = new JsonModel(loadedModels.get(l.getKey().getModel()));
// Resolve the parent chain
dough.resolveParents(loadedModels::get);
// Bake
dough.bake(l.getKey());
l.setValue(dough);
}
for (Callback c : postBakeCallbacks)
c.run();
}
public static JsonModel getModel(Variant loc) {
return modelsToBake.get(loc);
}
}
@@ -0,0 +1,48 @@
package com.gtnewhorizons.angelica.models.unready.json;
import org.joml.Vector3f;
public class ModelDisplay {
public static final ModelDisplay DEFAULT = new ModelDisplay(
new Vector3f(0, 0, 0),
new Vector3f(0, 0, 0),
new Vector3f(1, 1, 1)
);
private final Vector3f rotation;
private final Vector3f translation;
private final Vector3f scale;
public ModelDisplay(Vector3f rotation, Vector3f translation, Vector3f scale) {
this.rotation = rotation;
this.translation = translation;
this.scale = scale;
}
enum Position {
thirdperson_righthand,
thirdperson_lefthand,
firstperson_righthand,
firstperson_lefthand,
gui,
head,
ground,
fixed;
public static Position getByName(String name) {
return switch (name) {
case "thirdperson_righthand" -> thirdperson_righthand;
case "thirdperson_lefthand" -> thirdperson_lefthand;
case "firstperson_righthand" -> firstperson_righthand;
case "firstperson_lefthand" -> firstperson_lefthand;
case "gui" -> gui;
case "head" -> head;
case "ground" -> ground;
case "fixed" -> fixed;
default -> null;
};
}
}
}
@@ -0,0 +1,96 @@
package com.gtnewhorizons.angelica.models.unready.json;
import com.gtnewhorizons.angelica.compat.mojang.Axis;
import java.util.List;
import lombok.Getter;
import net.minecraftforge.common.util.ForgeDirection;
import org.jetbrains.annotations.Nullable;
import org.joml.Matrix4f;
import org.joml.Vector3f;
import org.joml.Vector4f;
public class ModelElement {
@Getter
private final Vector3f from;
@Getter
private final Vector3f to;
@Nullable
@Getter
private final Rotation rotation;
private final boolean shade;
@Getter
private final List<Face> faces;
ModelElement(Vector3f from, Vector3f vector3f, @Nullable Rotation rotation, boolean shade, List<Face> faces) {
this.from = from;
to = vector3f;
this.rotation = rotation;
this.shade = shade;
this.faces = faces;
}
static class Face {
@Getter
private final ForgeDirection name;
@Getter
private final Vector4f uv;
@Getter
private final String texture;
@Getter
private final ForgeDirection cullFace;
@Getter
private final int rotation;
@Getter
private final int tintIndex;
Face(ForgeDirection name, Vector4f uv, String texture, ForgeDirection cullFace, int rotation, int tintIndex) {
this.name = name;
this.uv = uv;
this.texture = texture;
this.cullFace = cullFace;
this.rotation = rotation;
this.tintIndex = tintIndex;
}
}
static class Rotation {
static final Rotation NOOP = new Rotation(
new Vector3f(0, 0, 0),
Axis.X,
0,
false
);
private final Vector3f origin;
private final Axis axis;
private final float angle;
private final boolean rescale;
Rotation(Vector3f origin, Axis axis, float angle, boolean rescale) {
this.origin = origin;
this.axis = axis;
this.angle = (float) Math.toRadians(angle);
this.rescale = rescale;
}
Matrix4f getAffineMatrix() {
// Subtract origin
final Matrix4f ret = new Matrix4f().translation(-this.origin.x, -this.origin.y, -this.origin.z);
// Rotate
switch (this.axis) {
case X -> ret.rotateLocalX(angle);
case Y -> ret.rotateLocalY(angle);
case Z -> ret.rotateLocalZ(angle);
}
// Add the origin back in
return ret.translateLocal(this.origin.x, this.origin.y, this.origin.z);
}
}
}
@@ -0,0 +1,90 @@
package com.gtnewhorizons.angelica.models.unready.json;
import com.gtnewhorizons.angelica.api.QuadProvider;
import com.gtnewhorizons.angelica.compat.mojang.BlockPos;
import com.gtnewhorizons.angelica.compat.nd.Quad;
import com.gtnewhorizons.angelica.models.NdQuadBuilder;
import com.gtnewhorizons.angelica.models.unready.json.JsonModel;
import com.gtnewhorizons.angelica.utils.ObjectPooler;
import it.unimi.dsi.fastutil.objects.ObjectImmutableList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Random;
import java.util.function.Function;
import net.minecraft.block.Block;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
/**
* This is a half-baked port of Fabric's sample custom model, for reference.
*/
public class TestBakedModel implements QuadProvider {
private static final String[] SPRITE_IDS = new String[]{
"furnace_front_on",
"furnace_top"
};
private final IIcon[] sprites = new IIcon[SPRITE_IDS.length];
// Some constants to avoid magic numbers, these need to match the SPRITE_IDS
private static final int SPRITE_SIDE = 0;
private static final int SPRITE_TOP = 1;
private final Quad[] quadStore = new Quad[6];
private static final List<Quad> EMPTY = ObjectImmutableList.of();
//@Override
public Collection<ResourceLocation> getModelDependencies() {
return Arrays.asList(); // This model does not depend on other models.
}
public void setParents(Function<ResourceLocation, JsonModel> modelLoader) {
// This is related to model parents, it's not required for our use case
}
public void bake() {
// Get the sprites
for(int i = 0; i < SPRITE_IDS.length; ++i) {
//sprites[i] = getBlockIcon(SPRITE_IDS[i]);
}
// Build the mesh using my API
final NdQuadBuilder builder = new NdQuadBuilder();
// This is a cube, it only has sides on VALID_DIRECTIONS
// But something like tall grass will need to go over UNKNOWN too
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
// UP and DOWN share the Y axis
int spriteIdx = direction == ForgeDirection.UP || direction == ForgeDirection.DOWN ? SPRITE_TOP : SPRITE_SIDE;
// Add a new face to the mesh
builder.square(direction, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f);
// Set the sprite of the face, must be called after .square()
// We haven't specified any UV coordinates, so we want to use the whole texture. BAKE_LOCK_UV does exactly that.
builder.spriteBake(sprites[spriteIdx], NdQuadBuilder.BAKE_LOCK_UV);
// Enable texture usage
builder.color(-1, -1, -1, -1);
// Add the quad to the mesh
quadStore[direction.ordinal()] = builder.build(new Quad());
}
}
@Override
public List<Quad> getQuads(IBlockAccess world, BlockPos pos, Block block, int meta, ForgeDirection dir, Random random, ObjectPooler<Quad> quadPool) {
if (dir == ForgeDirection.UNKNOWN)
return EMPTY;
final Quad q = quadPool.getInstance();
//q.copyFrom(this.quadStore[dir.ordinal()]);
final List<Quad> ret = new ArrayList<>();
ret.add(q);
return ret;
}
}
@@ -0,0 +1,29 @@
package com.gtnewhorizons.angelica.models.unready.json;
import lombok.Getter;
import net.minecraft.util.ResourceLocation;
import org.joml.Matrix4f;
import static java.lang.Math.toRadians;
public class Variant {
@Getter
private final ResourceLocation model;
private final float x;
private final float y;
private final boolean uvLock;
public Variant(ResourceLocation model, int x, int y, boolean uvLock) {
this.model = model;
this.x = (float) toRadians(x);
this.y = (float) toRadians(y);
this.uvLock = uvLock;
}
Matrix4f getAffineMatrix() {
return new Matrix4f()
.translation(-.5f, -.5f, -.5f).rotateLocalY(x).rotateLocalX(y).translateLocal(.5f, .5f, .5f);
}
}
@@ -1,8 +1,11 @@
package com.gtnewhorizons.angelica.proxy;
import com.gtnewhorizons.angelica.models.unready.common.BlockTest;
import com.gtnewhorizons.angelica.config.AngelicaConfig;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
public class CommonProxy {