Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some work done on updating to 1.21 and is running - new branch if this work is useful? #1661

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.tryParse("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 @@ -241,38 +241,34 @@ 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());
return consumer.setNormal(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.tryParse(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.tryParse(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.tryParse("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.tryParse("item"));
EntryType<FluidStack> FLUID = EntryType.deferred(ResourceLocation.tryParse("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.tryParse(tag.getString(key))).orElse(null);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,33 @@
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) {
this.display = display;
}

@Override
public int getCraftingResultSlotIndex(T menu) {
return menu.getResultSlotIndex();
}

@Override
public int getCraftingWidth(T menu) {
return menu.getGridWidth();
}

@Override
public int getCraftingHeight(T menu) {
return menu.getGridHeight();
}

@Override
public void clearInputSlots(T menu) {
menu.clearCraftingContent();
}

@Override
public void populateRecipeFinder(MenuInfoContext<T, ?, D> context, RecipeFinder finder) {
context.getMenu().fillCraftSlotsStackedContents(new StackedContents() {
Expand All @@ -67,7 +67,7 @@ public void accountSimpleStack(ItemStack stack) {
}
});
}

@Override
public D getDisplay() {
return 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 @@ -198,20 +198,18 @@ 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);
}

@Override
Expand Down Expand Up @@ -283,17 +281,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,33 +429,6 @@ 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 -> {
if (enchantment.getMaxLevel() - enchantment.getMinLevel() >= 10) {
return IntStream.of(enchantment.getMinLevel(), enchantment.getMaxLevel())
.mapToObj(lvl -> new EnchantmentInstance(enchantment, lvl));
} else {
return IntStream.rangeClosed(enchantment.getMinLevel(), enchantment.getMaxLevel())
.mapToObj(lvl -> new EnchantmentInstance(enchantment, lvl));
}
})
.map(instance -> {
return Pair.of(instance, EnchantedBookItem.createForEnchantment(instance));
})
.toList();
EntryRegistry.getInstance().getEntryStacks().forEach(stack -> {
if (stack.getType() != VanillaEntryTypes.ITEM) return;
ItemStack itemStack = stack.castValue();
if (!itemStack.isEnchantable()) return;
for (Pair<EnchantmentInstance, ItemStack> pair : enchantmentBooks) {
if (!pair.getKey().enchantment.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())),
Collections.singletonList(EntryIngredients.of(output.get().getLeft())), Optional.empty(), OptionalInt.of(output.get().getRight())));
}
});

for (Registry<?> reg : BuiltInRegistries.REGISTRY) {
reg.getTags().forEach(tagPair -> registry.add(tagPair.getFirst()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,12 @@
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) {
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.build());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public Collection<Display> apply(RecipeHolder<BannerDuplicateRecipe> recipe) {
Map<DyeColor, Pair<EntryIngredient.Builder, EntryStack<?>>> displayMap = new HashMap<>();

for (Pair<DyeColor, ItemStack> pair : ShieldDecorationRecipeFiller.randomizeBanners()) {
Optional<Item> bannerOptional = BuiltInRegistries.ITEM.getOptional(new ResourceLocation(pair.getFirst().getName() + "_banner"));
Optional<Item> bannerOptional = BuiltInRegistries.ITEM.getOptional(ResourceLocation.tryParse(pair.getFirst().getName() + "_banner"));
if (bannerOptional.isEmpty()) continue;
Pair<EntryIngredient.Builder, EntryStack<?>> builderPair = displayMap.computeIfAbsent(pair.getFirst(), color -> Pair.of(EntryIngredient.builder(), EntryStacks.of(bannerOptional.get())));
builderPair.getFirst().add(EntryStacks.of(pair.getSecond()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ default Widget createInfoWidget(Rectangle rectangle, DefaultCraftingDisplay<?> d
if (display.isShapeless()) {
bounds.x -= 10;
}
Widget widget = Widgets.createTexturedWidget(new ResourceLocation("roughlyenoughitems:textures/gui/info.png"), bounds.getX(), bounds.getY(), 0, 0, bounds.getWidth(), bounds.getHeight(), 1, 1, 1, 1);
Widget widget = Widgets.createTexturedWidget(ResourceLocation.tryParse("roughlyenoughitems:textures/gui/info.png"), bounds.getX(), bounds.getY(), 0, 0, bounds.getWidth(), bounds.getHeight(), 1, 1, 1, 1);
return Widgets.withTooltip(Widgets.withBounds(widget, bounds), texts);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static List<Pair<DyeColor, ItemStack>> randomizeBanners() {
Random random = new Random();

for (DyeColor color : colors) {
Optional<Item> bannerOptional = BuiltInRegistries.ITEM.getOptional(new ResourceLocation(color.getName() + "_banner"));
Optional<Item> bannerOptional = BuiltInRegistries.ITEM.getOptional(ResourceLocation.tryParse(color.getName() + "_banner"));
if (bannerOptional.isEmpty()) continue;
out.add(Pair.of(color, new ItemStack(bannerOptional.get())));

Expand Down
Loading