aboutsummaryrefslogtreecommitdiff
path: root/api/src/main
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-10-22 22:39:04 +0800
committershedaniel <daniel@shedaniel.me>2022-10-22 22:39:04 +0800
commit83b7f0488de9cc91951f4d9b2017f6ca1c0fa17e (patch)
treedb95f347f2e784c4adf17e7ce0acd9a1fe239f08 /api/src/main
parent438d2387f330ffe8b328c4990498efa175b88a68 (diff)
downloadRoughlyEnoughItems-83b7f0488de9cc91951f4d9b2017f6ca1c0fa17e.tar.gz
RoughlyEnoughItems-83b7f0488de9cc91951f4d9b2017f6ca1c0fa17e.tar.bz2
RoughlyEnoughItems-83b7f0488de9cc91951f4d9b2017f6ca1c0fa17e.zip
Support 22w42a
Diffstat (limited to 'api/src/main')
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/util/SpriteRenderer.java7
-rw-r--r--api/src/main/java/me/shedaniel/rei/impl/VersionAdapter.java86
2 files changed, 90 insertions, 3 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/client/util/SpriteRenderer.java b/api/src/main/java/me/shedaniel/rei/api/client/util/SpriteRenderer.java
index f673a3356..d700051ad 100644
--- a/api/src/main/java/me/shedaniel/rei/api/client/util/SpriteRenderer.java
+++ b/api/src/main/java/me/shedaniel/rei/api/client/util/SpriteRenderer.java
@@ -28,6 +28,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Matrix3f;
import com.mojang.math.Matrix4f;
+import me.shedaniel.rei.impl.VersionAdapter;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.renderer.MultiBufferSource;
@@ -191,7 +192,7 @@ public class SpriteRenderer {
throw new RuntimeException("Invalid Sprite!");
}
- next(sprite.getName());
+ next(VersionAdapter.INSTANCE.spriteName(sprite));
}
public void next(ResourceLocation texture) {
@@ -212,8 +213,8 @@ public class SpriteRenderer {
this.normal = this.matrices.last().normal();
}
- float sX = sprite.getWidth();
- float sY = sprite.getHeight();
+ float sX = VersionAdapter.INSTANCE.spriteWidth(sprite);
+ float sY = VersionAdapter.INSTANCE.spriteHeight(sprite);
RenderSystem.setShaderTexture(0, texture);
diff --git a/api/src/main/java/me/shedaniel/rei/impl/VersionAdapter.java b/api/src/main/java/me/shedaniel/rei/impl/VersionAdapter.java
new file mode 100644
index 000000000..12a91f0df
--- /dev/null
+++ b/api/src/main/java/me/shedaniel/rei/impl/VersionAdapter.java
@@ -0,0 +1,86 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020, 2021, 2022 shedaniel
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.shedaniel.rei.impl;
+
+import me.shedaniel.rei.api.common.entry.EntryStack;
+import net.fabricmc.api.EnvType;
+import net.fabricmc.api.Environment;
+import net.minecraft.client.renderer.texture.TextureAtlasSprite;
+import net.minecraft.core.Holder;
+import net.minecraft.core.Registry;
+import net.minecraft.resources.ResourceKey;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.world.item.Item;
+import net.minecraft.world.item.ItemStack;
+
+import java.util.Comparator;
+import java.util.List;
+import java.util.Optional;
+
+public interface VersionAdapter {
+ VersionAdapter INSTANCE = load();
+
+ private static VersionAdapter load() {
+ try {
+ Class.forName("me.shedaniel.rei.impl.init.versions.Version1_19_3AdapterCheck");
+ return (VersionAdapter) Class.forName("me.shedaniel.rei.impl.init.versions.Version1_19_3Adapter").getDeclaredConstructor().newInstance();
+ } catch (Throwable throwable) {
+ }
+ try {
+ Class.forName("me.shedaniel.rei.impl.init.versions.Version1_19_1AdapterCheck");
+ return (VersionAdapter) Class.forName("me.shedaniel.rei.impl.init.versions.Version1_19_1Adapter").getDeclaredConstructor().newInstance();
+ } catch (Throwable throwable) {
+ }
+ try {
+ return (VersionAdapter) Class.forName("me.shedaniel.rei.impl.init.versions.Version1_19Adapter").getDeclaredConstructor().newInstance();
+ } catch (Throwable throwable) {
+ throw new RuntimeException(throwable);
+ }
+ }
+
+ @Environment(EnvType.CLIENT)
+ List<ItemStack> appendStacksForItem(Item item, Comparator<ItemStack> comparator);
+
+ @Environment(EnvType.CLIENT)
+ ResourceLocation spriteAtlasLocation(TextureAtlasSprite sprite);
+
+ @Environment(EnvType.CLIENT)
+ ResourceLocation spriteName(TextureAtlasSprite sprite);
+
+ @Environment(EnvType.CLIENT)
+ int spriteWidth(TextureAtlasSprite sprite);
+
+ @Environment(EnvType.CLIENT)
+ int spriteHeight(TextureAtlasSprite sprite);
+
+ <T> Optional<Holder<T>> getHolder(Registry<T> registry, ResourceKey<T> key);
+
+ <T> Optional<Holder<T>> getHolder(Registry<T> registry, int id);
+
+ @Environment(EnvType.CLIENT)
+ void sendCommand(String command);
+
+ @Environment(EnvType.CLIENT)
+ Comparator<? super EntryStack<?>> getEntryGroupComparator();
+}