Skip to content

Commit

Permalink
Update to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
shedaniel committed Jun 16, 2024
1 parent de36cf8 commit 667c799
Show file tree
Hide file tree
Showing 84 changed files with 342 additions and 381 deletions.
1 change: 1 addition & 0 deletions .github/workflows/curseforge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ on:
- 13.x-1.20.2
- 14.x-1.20.4
- 15.x-1.20.5
- 16.x-1.21

jobs:
build:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
@ApiStatus.NonExtendable
@Environment(EnvType.CLIENT)
public interface BuiltinClientEntryTypes {
ResourceLocation RENDERING_ID = new ResourceLocation("rendering");
ResourceLocation RENDERING_ID = ResourceLocation.withDefaultNamespace("rendering");

EntryType<Renderer> RENDERING = EntryType.deferred(RENDERING_ID);
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ public interface FavoriteEntryType<T extends FavoriteEntry> {
/**
* A builtin type of favorites, wrapping a {@link EntryStack}.
*/
ResourceLocation ENTRY_STACK = new ResourceLocation("roughlyenoughitems", "entry_stack");
ResourceLocation ENTRY_STACK = ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "entry_stack");
/**
* A builtin type of favorites, wrapping a {@link Display}.
*/
@ApiStatus.Experimental
ResourceLocation DISPLAY = new ResourceLocation("roughlyenoughitems", "display");
ResourceLocation DISPLAY = ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "display");

static Registry registry() {
return PluginManager.getClientInstance().get(FavoriteEntryType.Registry.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import java.util.stream.Stream;

public class SimpleDisplayRenderer extends DisplayRenderer implements WidgetHolder {
protected static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("roughlyenoughitems", "textures/gui/recipecontainer.png");
protected static final ResourceLocation CHEST_GUI_TEXTURE = ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "textures/gui/recipecontainer.png");
protected List<Slot> inputWidgets;
protected List<Slot> outputWidgets;
protected List<GuiEventListener> widgets;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ public void next() {
next(sprite.contents().name());
}

private static VertexConsumer normal(VertexConsumer consumer, Matrix3f var1, float var2, float var3, float var4) {
Vector3f var5 = var1.transform(new Vector3f(var2, var3, var4));
return consumer.setNormal(var5.x(), var5.y(), var5.z());
}

public void next(ResourceLocation texture) {
if (this.consumer == null) {
throw new RuntimeException("Invalid VertexConsumer!");
Expand Down Expand Up @@ -241,38 +246,29 @@ public void next(ResourceLocation texture) {

this.consumer = consumers.getBuffer(layer);

normal(this.consumer.vertex(this.model, x, y + nSY, z1)
.color(this.r, this.g, this.b, this.a)
.uv(this.uStart, this.vEnd - dY)
.overlayCoords(this.u, this.v)
.uv2(this.l), this.normal, this.nX, this.nY, this.nZ)
.endVertex();
normal(this.consumer.vertex(this.model, x + nSX, y + nSY, z1)
.color(this.r, this.g, this.b, this.a)
.uv(this.uEnd - dX, this.vEnd - dY)
.overlayCoords(this.u, this.v)
.uv2(this.l), this.normal, this.nX, this.nY, this.nZ)
.endVertex();
normal(this.consumer.vertex(this.model, x + nSX, y, z1)
.color(this.r, this.g, this.b, this.a)
.uv(this.uEnd - dX, this.vStart)
.overlayCoords(this.u, this.v)
.uv2(this.l), this.normal, this.nX, this.nY, this.nZ)
.endVertex();
normal(this.consumer.vertex(this.model, x, y, z1)
.color(this.r, this.g, this.b, this.a)
.uv(this.uStart, this.vStart)
.overlayCoords(this.u, this.v)
.uv2(this.l), this.normal, this.nX, this.nY, this.nZ)
.endVertex();
normal(this.consumer.addVertex(this.model, x, y + nSY, z1)
.setColor(this.r, this.g, this.b, this.a)
.setUv(this.uStart, this.vEnd - dY)
.setUv2(this.u, this.v)
.setOverlay(this.l), this.normal, this.nX, this.nY, this.nZ);
normal(this.consumer.addVertex(this.model, x + nSX, y + nSY, z1)
.setColor(this.r, this.g, this.b, this.a)
.setUv(this.uEnd - dX, this.vEnd - dY)
.setUv2(this.u, this.v)
.setOverlay(this.l), this.normal, this.nX, this.nY, this.nZ);
normal(this.consumer.addVertex(this.model, x + nSX, y, z1)
.setColor(this.r, this.g, this.b, this.a)
.setUv(this.uEnd - dX, this.vStart)
.setUv2(this.u, this.v)
.setOverlay(this.l), this.normal, this.nX, this.nY, this.nZ);
normal(this.consumer.addVertex(this.model, x, y, z1)
.setColor(this.r, this.g, this.b, this.a)
.setUv(this.uStart, this.vStart)
.setUv2(this.u, this.v)
.setOverlay(this.l), this.normal, this.nX, this.nY, this.nZ);
}
}

}

private static VertexConsumer normal(VertexConsumer consumer, Matrix3f var1, float var2, float var3, float var4) {
Vector3f var5 = var1.transform(new Vector3f(var2, var3, var4));
return consumer.normal(var5.x(), var5.y(), var5.z());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public P read(CompoundTag tag) {
List<EntryIngredient> output = EntryIngredients.read(tag.getList("output", Tag.TAG_LIST));
ResourceLocation location;
if (tag.contains("location", Tag.TAG_STRING)) {
location = new ResourceLocation(tag.getString("location"));
location = ResourceLocation.parse(tag.getString("location"));
} else {
location = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ static <T> EntryStack<T> of(EntryType<T> type, T value) {
* @see EntryIngredient#read(ListTag)
*/
static EntryStack<?> read(CompoundTag tag) {
ResourceLocation type = new ResourceLocation(tag.getString("type"));
ResourceLocation type = ResourceLocation.parse(tag.getString("type"));
EntryDefinition<?> definition = EntryTypeRegistry.getInstance().get(type);
if (definition == null) throw new NullPointerException("Read missing entry type: " + type);
EntrySerializer<?> serializer = definition.getSerializer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

@ApiStatus.NonExtendable
public interface BuiltinEntryTypes {
ResourceLocation EMPTY_ID = new ResourceLocation("empty");
ResourceLocation EMPTY_ID = ResourceLocation.withDefaultNamespace("empty");

EntryType<Unit> EMPTY = EntryType.deferred(EMPTY_ID);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@

@ApiStatus.NonExtendable
public interface VanillaEntryTypes {
EntryType<ItemStack> ITEM = EntryType.deferred(new ResourceLocation("item"));
EntryType<FluidStack> FLUID = EntryType.deferred(new ResourceLocation("fluid"));
EntryType<ItemStack> ITEM = EntryType.deferred(ResourceLocation.withDefaultNamespace("item"));
EntryType<FluidStack> FLUID = EntryType.deferred(ResourceLocation.withDefaultNamespace("fluid"));
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static RecipeManagerContext<REIPlugin<?>> getInstance() {
@Nullable
default RecipeHolder<?> byId(CompoundTag tag, String key) {
if (tag.contains(key, Tag.TAG_STRING)) {
return getRecipeManager().byKey(new ResourceLocation(tag.getString(key))).orElse(null);
return getRecipeManager().byKey(ResourceLocation.parse(tag.getString(key))).orElse(null);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import net.minecraft.world.item.ItemStack;

@Deprecated(forRemoval = true)
public class RecipeBookGridMenuInfo<T extends RecipeBookMenu<?>, D extends SimpleGridMenuDisplay> implements SimpleGridMenuInfo<T, D> {
public class RecipeBookGridMenuInfo<T extends RecipeBookMenu<?, ?>, D extends SimpleGridMenuDisplay> implements SimpleGridMenuInfo<T, D> {
private final D display;

public RecipeBookGridMenuInfo(D display) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public ApplicabilityResult checkApplicable(Context context) {
if (context.getDisplay() instanceof SimpleGridMenuDisplay && ClientHelper.getInstance().canUseMovePackets())
return ApplicabilityResult.createNotApplicable();
Display display = context.getDisplay();
if (!(context.getMenu() instanceof RecipeBookMenu<?> container))
if (!(context.getMenu() instanceof RecipeBookMenu<?, ?> container))
return ApplicabilityResult.createNotApplicable();
if (container == null)
return ApplicabilityResult.createNotApplicable();
Expand All @@ -58,7 +58,7 @@ public ApplicabilityResult checkApplicable(Context context) {

@Override
public Result handle(Context context) {
RecipeBookMenu<?> container = (RecipeBookMenu<?>) context.getMenu();
RecipeBookMenu<?, ?> container = (RecipeBookMenu<?, ?>) context.getMenu();
Display display = context.getDisplay();
if (display instanceof DefaultCraftingDisplay<?> craftingDisplay) {
if (craftingDisplay.getOptionalRecipe().isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry;
import me.shedaniel.rei.api.client.registry.transfer.TransferHandlerRegistry;
import me.shedaniel.rei.api.client.registry.transfer.simple.SimpleTransferHandler;
import me.shedaniel.rei.api.common.display.basic.BasicDisplay;
import me.shedaniel.rei.api.common.entry.EntryIngredient;
import me.shedaniel.rei.api.common.entry.EntryStack;
import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes;
Expand Down Expand Up @@ -97,6 +98,7 @@
import net.minecraft.world.item.alchemy.PotionBrewing;
import net.minecraft.world.item.alchemy.PotionContents;
import net.minecraft.world.item.crafting.*;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.enchantment.EnchantmentInstance;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.block.Block;
Expand Down Expand Up @@ -198,20 +200,20 @@ private static Map<CreativeModeTab, Collection<ItemStack>> collectTabs() {

@Override
public void registerCollapsibleEntries(CollapsibleEntryRegistry registry) {
registry.group(new ResourceLocation("roughlyenoughitems", "enchanted_book"), Component.translatable("item.minecraft.enchanted_book"),
registry.group(ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "enchanted_book"), Component.translatable("item.minecraft.enchanted_book"),
stack -> stack.getType() == VanillaEntryTypes.ITEM && stack.<ItemStack>castValue().is(Items.ENCHANTED_BOOK));
registry.group(new ResourceLocation("roughlyenoughitems", "potion"), Component.translatable("item.minecraft.potion"),
registry.group(ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "potion"), Component.translatable("item.minecraft.potion"),
stack -> stack.getType() == VanillaEntryTypes.ITEM && stack.<ItemStack>castValue().is(Items.POTION));
registry.group(new ResourceLocation("roughlyenoughitems", "splash_potion"), Component.translatable("item.minecraft.splash_potion"),
registry.group(ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "splash_potion"), Component.translatable("item.minecraft.splash_potion"),
stack -> stack.getType() == VanillaEntryTypes.ITEM && stack.<ItemStack>castValue().is(Items.SPLASH_POTION));
registry.group(new ResourceLocation("roughlyenoughitems", "lingering_potion"), Component.translatable("item.minecraft.lingering_potion"),
registry.group(ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "lingering_potion"), Component.translatable("item.minecraft.lingering_potion"),
stack -> stack.getType() == VanillaEntryTypes.ITEM && stack.<ItemStack>castValue().is(Items.LINGERING_POTION));
registry.group(new ResourceLocation("roughlyenoughitems", "spawn_egg"), Component.translatable("text.rei.spawn_egg"),
registry.group(ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "spawn_egg"), Component.translatable("text.rei.spawn_egg"),
stack -> stack.getType() == VanillaEntryTypes.ITEM && stack.<ItemStack>castValue().getItem() instanceof SpawnEggItem);
registry.group(new ResourceLocation("roughlyenoughitems", "tipped_arrow"), Component.translatable("item.minecraft.tipped_arrow"),
registry.group(ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "tipped_arrow"), Component.translatable("item.minecraft.tipped_arrow"),
stack -> stack.getType() == VanillaEntryTypes.ITEM && stack.<ItemStack>castValue().is(Items.TIPPED_ARROW));
registry.group(new ResourceLocation("roughlyenoughitems", "music_disc"), Component.translatable("text.rei.music_disc"),
stack -> stack.getType() == VanillaEntryTypes.ITEM && stack.<ItemStack>castValue().getItem() instanceof RecordItem);
registry.group(ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "music_disc"), Component.translatable("text.rei.music_disc"),
stack -> stack.getType() == VanillaEntryTypes.ITEM && stack.<ItemStack>castValue().has(DataComponents.JUKEBOX_PLAYABLE));
}

@Override
Expand Down Expand Up @@ -283,17 +285,17 @@ public void registerCategories(CategoryRegistry registry) {
registry.addWorkstations(PATHING, EntryStacks.of(item));
}
});
for (EntryStack<?> stack : getTag(new ResourceLocation("c", "axes"))) {
for (EntryStack<?> stack : getTag(ResourceLocation.fromNamespaceAndPath("c", "axes"))) {
if (axes.add(stack.<ItemStack>castValue().getItem())) {
registry.addWorkstations(STRIPPING, stack);
registry.addWorkstations(WAX_SCRAPING, stack);
registry.addWorkstations(OXIDATION_SCRAPING, stack);
}
}
for (EntryStack<?> stack : getTag(new ResourceLocation("c", "hoes"))) {
for (EntryStack<?> stack : getTag(ResourceLocation.fromNamespaceAndPath("c", "hoes"))) {
if (hoes.add(stack.<ItemStack>castValue().getItem())) registry.addWorkstations(TILLING, stack);
}
for (EntryStack<?> stack : getTag(new ResourceLocation("c", "shovels"))) {
for (EntryStack<?> stack : getTag(ResourceLocation.fromNamespaceAndPath("c", "shovels"))) {
if (shovels.add(stack.<ItemStack>castValue().getItem())) registry.addWorkstations(PATHING, stack);
}
}
Expand Down Expand Up @@ -431,14 +433,18 @@ public void registerDisplays(DisplayRegistry registry) {
Collections.singletonList(EntryIngredients.of(output.get().getLeft())), Optional.empty(), OptionalInt.of(output.get().getRight())));
}
}
List<Pair<EnchantmentInstance, ItemStack>> enchantmentBooks = BuiltInRegistries.ENCHANTMENT.stream()
.flatMap(enchantment -> {
List<Pair<EnchantmentInstance, ItemStack>> enchantmentBooks = BasicDisplay.registryAccess().registry(Registries.ENCHANTMENT)
.stream()
.flatMap(Registry::holders)
.flatMap(holder -> {
if (!holder.isBound()) return Stream.empty();
Enchantment enchantment = holder.value();
if (enchantment.getMaxLevel() - enchantment.getMinLevel() >= 10) {
return IntStream.of(enchantment.getMinLevel(), enchantment.getMaxLevel())
.mapToObj(lvl -> new EnchantmentInstance(enchantment, lvl));
.mapToObj(lvl -> new EnchantmentInstance(holder, lvl));
} else {
return IntStream.rangeClosed(enchantment.getMinLevel(), enchantment.getMaxLevel())
.mapToObj(lvl -> new EnchantmentInstance(enchantment, lvl));
.mapToObj(lvl -> new EnchantmentInstance(holder, lvl));
}
})
.map(instance -> {
Expand All @@ -450,7 +456,7 @@ public void registerDisplays(DisplayRegistry registry) {
ItemStack itemStack = stack.castValue();
if (!itemStack.isEnchantable()) return;
for (Pair<EnchantmentInstance, ItemStack> pair : enchantmentBooks) {
if (!pair.getKey().enchantment.canEnchant(itemStack)) continue;
if (!pair.getKey().enchantment.value().canEnchant(itemStack)) continue;
Optional<Pair<ItemStack, Integer>> output = DefaultAnvilDisplay.calculateOutput(itemStack, pair.getValue());
if (output.isEmpty()) continue;
registry.add(new DefaultAnvilDisplay(List.of(EntryIngredients.of(itemStack), EntryIngredients.of(pair.getValue())),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,14 @@

@Environment(EnvType.CLIENT)
public class DefaultInformationCategory implements DisplayCategory<DefaultInformationDisplay> {
protected static void innerBlit(Matrix4f matrix4f, int xStart, int xEnd, int yStart, int yEnd, int z, float uStart, float uEnd, float vStart, float vEnd) {
protected static void innerBlit(GuiGraphics graphics, Matrix4f matrix4f, int xStart, int xEnd, int yStart, int yEnd, int z, float uStart, float uEnd, float vStart, float vEnd) {
RenderSystem.setShader(GameRenderer::getPositionTexShader);
BufferBuilder bufferBuilder = Tesselator.getInstance().getBuilder();
bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
bufferBuilder.vertex(matrix4f, xStart, yEnd, z).uv(uStart, vEnd).endVertex();
bufferBuilder.vertex(matrix4f, xEnd, yEnd, z).uv(uEnd, vEnd).endVertex();
bufferBuilder.vertex(matrix4f, xEnd, yStart, z).uv(uEnd, vStart).endVertex();
bufferBuilder.vertex(matrix4f, xStart, yStart, z).uv(uStart, vStart).endVertex();
BufferUploader.drawWithShader(bufferBuilder.end());
BufferBuilder bufferBuilder = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
bufferBuilder.addVertex(matrix4f, xStart, yEnd, z).setUv(uStart, vEnd);
bufferBuilder.addVertex(matrix4f, xEnd, yEnd, z).setUv(uEnd, vEnd);
bufferBuilder.addVertex(matrix4f, xEnd, yStart, z).setUv(uEnd, vStart);
bufferBuilder.addVertex(matrix4f, xStart, yStart, z).setUv(uStart, vStart);
BufferUploader.drawWithShader(bufferBuilder.buildOrThrow());
}

@Override
Expand Down Expand Up @@ -104,7 +103,7 @@ public void render(GuiGraphics graphics, Rectangle bounds, int mouseX, int mouse
graphics.pose().pushPose();
graphics.pose().translate(-1.2f, -1, 0);
Matrix4f matrix = graphics.pose().last().pose();
DefaultInformationCategory.innerBlit(matrix, bounds.getCenterX() - 8, bounds.getCenterX() + 8, bounds.getCenterY() - 8, bounds.getCenterY() + 8, 0, 116f / 256f, (116f + 16f) / 256f, 0f, 16f / 256f);
DefaultInformationCategory.innerBlit(graphics, matrix, bounds.getCenterX() - 8, bounds.getCenterX() + 8, bounds.getCenterY() - 8, bounds.getCenterY() + 8, 0, 116f / 256f, (116f + 16f) / 256f, 0f, 16f / 256f);
graphics.pose().popPose();
}
};
Expand Down
Loading

0 comments on commit 667c799

Please sign in to comment.