mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-27 11:57:38 +00:00
Update to latest Fabric
- Overhaul model loading to work with the new API. This allows for using the emissive texture system in a more generic way, which is nice! - Convert some of our custom models to use Fabric's model hooks (i.e. emitItemQuads). We don't make use of this right now, but might be useful for rendering tools with enchantment glints. Note this does /not/ change any of the turtle block entity rendering code to use Fabric/Forge's model code. This will be a change we want to make in the future. - Some cleanup of our config API. This fixes us printing lots of warnings when creating a new config file on Fabric (same bug also occurs on Forge, but that's a loader problem). - Fix a few warnings
This commit is contained in:
@@ -12,7 +12,6 @@ import dev.emi.emi.api.EmiEntrypoint;
|
||||
import dev.emi.emi.api.EmiPlugin;
|
||||
import dev.emi.emi.api.EmiRegistry;
|
||||
import dev.emi.emi.api.stack.Comparison;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import java.util.function.BiPredicate;
|
||||
@@ -36,7 +35,7 @@ public class EMIComputerCraft implements EmiPlugin {
|
||||
private static final Comparison pocketComparison = compareStacks((left, right) ->
|
||||
left.getItem() instanceof PocketComputerItem && PocketComputerItem.getUpgrade(left) == PocketComputerItem.getUpgrade(right));
|
||||
|
||||
private static <T extends Item> Comparison compareStacks(BiPredicate<ItemStack, ItemStack> test) {
|
||||
private static Comparison compareStacks(BiPredicate<ItemStack, ItemStack> test) {
|
||||
return Comparison.of((left, right) -> {
|
||||
ItemStack leftStack = left.getItemStack(), rightStack = right.getItemStack();
|
||||
return leftStack.getItem() == rightStack.getItem() && test.test(leftStack, rightStack);
|
||||
|
||||
@@ -26,13 +26,15 @@ import java.util.List;
|
||||
* <p>
|
||||
* This is typically used with a {@link BakedModel} subclass - see the loader-specific projects.
|
||||
*/
|
||||
public final class ModelTransformer {
|
||||
public static final int[] ORDER = new int[]{ 3, 2, 1, 0 };
|
||||
public class ModelTransformer {
|
||||
@SuppressWarnings("MutablePublicArray") // It's not nice, but is efficient.
|
||||
public static final int[] INVERSE_ORDER = new int[]{ 3, 2, 1, 0 };
|
||||
|
||||
public static final int STRIDE = DefaultVertexFormat.BLOCK.getIntegerSize();
|
||||
private static final int POS_OFFSET = findOffset(DefaultVertexFormat.BLOCK, DefaultVertexFormat.ELEMENT_POSITION);
|
||||
|
||||
private final Matrix4f transformation;
|
||||
private final boolean invert;
|
||||
protected final Matrix4f transformation;
|
||||
protected final boolean invert;
|
||||
private @Nullable TransformedQuads cache;
|
||||
|
||||
public ModelTransformer(Transformation transformation) {
|
||||
@@ -60,7 +62,7 @@ public final class ModelTransformer {
|
||||
for (var i = 0; i < 4; i++) {
|
||||
var inStart = STRIDE * i;
|
||||
// Reverse the order of the quads if we're inverting
|
||||
var outStart = STRIDE * (invert ? ORDER[i] : i);
|
||||
var outStart = STRIDE * (invert ? INVERSE_ORDER[i] : i);
|
||||
System.arraycopy(inputData, inStart, outputData, outStart, STRIDE);
|
||||
|
||||
// Apply the matrix to our position
|
||||
|
||||
@@ -212,7 +212,7 @@ public class TurtleBlockEntityRenderer implements BlockEntityRenderer<TurtleBloc
|
||||
var normal = matrix.transform(new Vector4f(dirNormal.getX(), dirNormal.getY(), dirNormal.getZ(), 0.0f)).normalize();
|
||||
|
||||
var vertices = quad.getVertices();
|
||||
for (var vertex : ModelTransformer.ORDER) {
|
||||
for (var vertex : ModelTransformer.INVERSE_ORDER) {
|
||||
var i = vertex * ModelTransformer.STRIDE;
|
||||
|
||||
var x = Float.intBitsToFloat(vertices[i]);
|
||||
|
||||
@@ -286,8 +286,8 @@ public final class LanguageProvider implements DataProvider {
|
||||
turtleUpgrades.getGeneratedUpgrades().stream().map(UpgradeBase::getUnlocalisedAdjective),
|
||||
pocketUpgrades.getGeneratedUpgrades().stream().map(UpgradeBase::getUnlocalisedAdjective),
|
||||
Metric.metrics().values().stream().map(x -> AggregatedMetric.TRANSLATION_PREFIX + x.name() + ".name"),
|
||||
getConfigEntries(ConfigSpec.serverSpec).map(ConfigFile.Entry::translationKey),
|
||||
getConfigEntries(ConfigSpec.clientSpec).map(ConfigFile.Entry::translationKey)
|
||||
ConfigSpec.serverSpec.entries().map(ConfigFile.Entry::translationKey),
|
||||
ConfigSpec.clientSpec.entries().map(ConfigFile.Entry::translationKey)
|
||||
).flatMap(x -> x);
|
||||
}
|
||||
|
||||
@@ -321,16 +321,4 @@ public final class LanguageProvider implements DataProvider {
|
||||
add(value.translationKey(), text);
|
||||
add(value.translationKey() + ".tooltip", value.comment());
|
||||
}
|
||||
|
||||
private static Stream<ConfigFile.Entry> getConfigEntries(ConfigFile spec) {
|
||||
return spec.entries().flatMap(LanguageProvider::getConfigEntries);
|
||||
}
|
||||
|
||||
private static Stream<ConfigFile.Entry> getConfigEntries(ConfigFile.Entry entry) {
|
||||
if (entry instanceof ConfigFile.Value<?>) return Stream.of(entry);
|
||||
if (entry instanceof ConfigFile.Group group) {
|
||||
return Stream.concat(Stream.of(entry), group.children().flatMap(LanguageProvider::getConfigEntries));
|
||||
}
|
||||
throw new IllegalStateException("Invalid config entry " + entry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,12 +54,6 @@ public interface ConfigFile {
|
||||
* A group of config entries.
|
||||
*/
|
||||
non-sealed interface Group extends Entry {
|
||||
/**
|
||||
* Get all entries in this group.
|
||||
*
|
||||
* @return All child entries.
|
||||
*/
|
||||
Stream<Entry> children();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,6 @@ package dan200.computercraft.shared.util;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
@@ -38,12 +37,6 @@ public class Trie<K, V> {
|
||||
getChild(key).current = value;
|
||||
}
|
||||
|
||||
public Stream<V> children() {
|
||||
return children == null
|
||||
? Stream.empty()
|
||||
: children.values().stream().map(x -> x.current).filter(Objects::nonNull);
|
||||
}
|
||||
|
||||
public Stream<V> stream() {
|
||||
return Stream.concat(
|
||||
current == null ? Stream.empty() : Stream.of(current),
|
||||
|
||||
@@ -1,16 +1,7 @@
|
||||
{
|
||||
"parent": "minecraft:block/block",
|
||||
"parent": "minecraft:block/orientable",
|
||||
"render_type": "cutout",
|
||||
"textures": {
|
||||
"particle": "#front"
|
||||
},
|
||||
"display": {
|
||||
"firstperson_righthand": {
|
||||
"rotation": [ 0, 135, 0 ],
|
||||
"translation": [ 0, 0, 0 ],
|
||||
"scale": [ 0.40, 0.40, 0.40 ]
|
||||
}
|
||||
},
|
||||
"computercraft:emissive_texture": "cursor",
|
||||
"elements": [
|
||||
{
|
||||
"from": [ 0, 0, 0 ],
|
||||
|
||||
Reference in New Issue
Block a user