Skip to content

Commit

Permalink
backport 0.3.0 to 1.18.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gliscowo committed Jun 15, 2022
1 parent 2e5bd51 commit 6e47de5
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 60 deletions.
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_base_version=1.19
minecraft_version=1.19
yarn_mappings=1.19+build.2
minecraft_base_version=1.18
minecraft_version=1.18.2
yarn_mappings=1.18.2+build.3
loader_version=0.14.7
# Mod Properties
mod_version=0.3.0
maven_group=com.glisco
archives_base_name=isometric-renders
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.55.3+1.19
fabric_version=0.56.0+1.18.2

# https://maven.wispforest.io/io/wispforest/worldmesher/
worldmesher_version=0.2.10+1.19
worldmesher_version=0.2.10+1.18

# https://maven.wispforest.io/io/wispforest/exo/
exo_version=0.1.5+1.19
exo_version=0.1.4+1.18

# https://maven.wispforest.io/io/wispforest/owo-lib/
owo_version=0.7.3+1.19
owo_version=0.7.3-pre9+1.18
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
Expand Down Expand Up @@ -38,7 +38,7 @@ public class IsometricRenders implements ClientModInitializer {

@Override
public void onInitializeClient() {
ClientCommandRegistrationCallback.EVENT.register(IsorenderCommand::register);
IsorenderCommand.register(ClientCommandManager.DISPATCHER);

ClientLifecycleEvents.CLIENT_STARTED.register(newClient -> {
TooltipRenderable.TooltipScreen.INSTANCE.init(newClient, 10000, 10000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.suggestion.SuggestionProvider;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
import net.minecraft.client.MinecraftClient;
import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.command.CommandSource;
import net.minecraft.command.argument.*;
import net.minecraft.entity.EntityType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.text.ClickEvent;
import net.minecraft.text.Text;
import net.minecraft.text.LiteralText;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
Expand All @@ -39,16 +39,16 @@
import java.util.List;
import java.util.function.BiConsumer;

import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.argument;
import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.literal;
import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.argument;
import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.literal;

public class IsorenderCommand {

private static final SuggestionProvider<FabricClientCommandSource> CLIENT_SUMMONABLE_ENTITIES = (context, builder) -> CommandSource.suggestFromIdentifier(Registry.ENTITY_TYPE.stream().filter(EntityType::isSummonable),
builder, EntityType::getId, entityType -> Text.translatable(Util.createTranslationKey("entity", EntityType.getId(entityType)))
builder, EntityType::getId, entityType -> new TranslatableText(Util.createTranslationKey("entity", EntityType.getId(entityType)))
);

public static void register(CommandDispatcher<FabricClientCommandSource> dispatcher, CommandRegistryAccess access) {
public static void register(CommandDispatcher<FabricClientCommandSource> dispatcher) {
dispatcher.register(literal("isorender")
.executes(IsorenderCommand::showRootNodeHelp)
.then(literal("area")
Expand All @@ -58,7 +58,7 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
.executes(IsorenderCommand::renderAreaWithArguments))))
.then(literal("block")
.executes(IsorenderCommand::renderTargetedBlock)
.then(argument("block", BlockStateArgumentType.blockState(access))
.then(argument("block", BlockStateArgumentType.blockState())
.executes(IsorenderCommand::renderBlockWithArgument)))
.then(literal("entity")
.executes(IsorenderCommand::renderTargetedEntity)
Expand All @@ -69,11 +69,11 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
.executes(IsorenderCommand::renderEntityWithNbt))))
.then(literal("item")
.executes(IsorenderCommand::renderHeldItem)
.then(argument("item", ItemStackArgumentType.itemStack(access))
.then(argument("item", ItemStackArgumentType.itemStack())
.executes(IsorenderCommand::renderItemWithArgument)))
.then(literal("tooltip")
.executes(IsorenderCommand::renderHeldItemTooltip)
.then(argument("item", ItemStackArgumentType.itemStack(access))
.then(argument("item", ItemStackArgumentType.itemStack())
.executes(IsorenderCommand::renderItemTooltipWithArgument)))
.then(literal("namespace")
.then(argument("namespace", NamespaceArgumentType.namespace())
Expand All @@ -84,7 +84,7 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
.then(argument("task", new RenderTaskArgumentType())
.executes(IsorenderCommand::renderCreativeTab))))
.then(literal("tag")
.then(argument("tag", new TagArgumentType(access))
.then(argument("tag", new TagArgumentType())
.then(argument("task", new RenderTaskArgumentType())
.executes(IsorenderCommand::renderTagContents))))
.then(literal("unsafe")
Expand All @@ -97,7 +97,7 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
private static int showRootNodeHelp(CommandContext<FabricClientCommandSource> context) {
final var source = context.getSource();

source.sendFeedback(Translate.prefixed(Translate.make("version", Text.literal(IsometricRenders.VERSION).formatted(Formatting.DARK_GRAY)).formatted(Formatting.GRAY)));
source.sendFeedback(Translate.prefixed(Translate.make("version", new LiteralText(IsometricRenders.VERSION).formatted(Formatting.DARK_GRAY)).formatted(Formatting.GRAY)));
source.sendFeedback(Translate.prefixed(Translate.make("command_hint").styled(
style -> style
.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://docs.wispforest.io/isometric-renders/slash_isorender/"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.command.CommandRegistryWrapper;
import net.minecraft.command.CommandSource;
import net.minecraft.item.Item;
import net.minecraft.tag.TagKey;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryEntryList;
Expand All @@ -22,15 +20,9 @@
public class TagArgumentType implements ArgumentType<TagArgumentType.TagArgument> {

private static final DynamicCommandExceptionType UNKNOWN_TAG_EXCEPTION = new DynamicCommandExceptionType(
tag -> Text.translatable("arguments.item.tag.unknown", tag)
tag -> new TranslatableText("arguments.item.tag.unknown", tag)
);

private final CommandRegistryWrapper<Item> registryWrapper;

public TagArgumentType(CommandRegistryAccess registryAccess) {
this.registryWrapper = registryAccess.createWrapper(Registry.ITEM_KEY);
}

public static <S> TagArgument getTag(String name, CommandContext<S> context) {
return context.getArgument(name, TagArgument.class);
}
Expand All @@ -39,14 +31,14 @@ public static <S> TagArgument getTag(String name, CommandContext<S> context) {
public TagArgument parse(StringReader reader) throws CommandSyntaxException {
reader.expect('#');
final var tagId = Identifier.fromCommandInput(reader);
return registryWrapper.getEntryList(TagKey.of(Registry.ITEM_KEY, tagId))
return Registry.ITEM.getEntryList(TagKey.of(Registry.ITEM_KEY, tagId))
.map(entryList -> new TagArgument(tagId, entryList))
.orElseThrow(() -> UNKNOWN_TAG_EXCEPTION.createWithContext(reader, tagId));
}

@Override
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
return CommandSource.suggestIdentifiers(this.registryWrapper.streamTags().map(TagKey::id), builder, String.valueOf('#'));
return CommandSource.suggestIdentifiers(Registry.ITEM.streamTags().map(TagKey::id), builder, String.valueOf('#'));
}

public record TagArgument(Identifier id, RegistryEntryList<Item> entries) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private int centerXIfNeeded(int orig) {
@ModifyVariable(method = "renderTooltipFromComponents", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;push()V"), ordinal = 5)
private int centerYIfNeeded(int orig) {
if (!IsometricRenders.centerNextTooltip) return orig;
return orig - 8 - isometric$tooltipHeight / 2;
return orig + 12 - isometric$tooltipHeight / 2;
}

@Inject(method = "renderTooltipFromComponents", at = @At("TAIL"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ItemRenderable extends DefaultRenderable<DefaultPropertyBundle> {

static {
PROPERTIES.slant.setDefaultValue(0).setToDefault();
PROPERTIES.rotation.setDefaultValue(180).setToDefault();
PROPERTIES.rotation.setDefaultValue(0).setToDefault();
}

private final ItemStack stack;
Expand All @@ -42,6 +42,8 @@ public void emitVertices(MatrixStack matrices, VertexConsumerProvider vertexCons
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-this.properties().rotation.get()));
matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(30));
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(this.properties().rotation.get() + 135));
} else {
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(180));
}

itemRenderer.renderItem(this.stack, ModelTransformation.Mode.FIXED, LightmapTextureManager.MAX_LIGHT_COORDINATE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static class TooltipScreen extends Screen {
public static final TooltipScreen INSTANCE = new TooltipScreen();

private TooltipScreen() {
super(Text.empty());
super(Text.of(""));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.option.Perspective;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.Util;
import org.lwjgl.glfw.GLFW;
Expand Down Expand Up @@ -232,7 +233,7 @@ protected void init() {

rightBuilder.dynamicLabel(() -> {
return this.remainingAnimationFrames == 0
? Text.empty()
? Text.of("")
: Translate.gui("export_remaining_frames", this.remainingAnimationFrames);
});

Expand All @@ -243,7 +244,9 @@ protected void init() {
@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
if (this.guiRebuildScheduled) {
this.clearAndInit();
this.clearChildren();
this.setFocused(null);
this.init();
this.guiRebuildScheduled = false;
}

Expand Down Expand Up @@ -298,7 +301,7 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
this.notificationStack.add(
() -> Util.getOperatingSystem().open(file),
Translate.gui("exported_as"),
Text.literal(ExportPathSpec.exportRoot().relativize(file.toPath()).toString())
new LiteralText(ExportPathSpec.exportRoot().relativize(file.toPath()).toString())
);
});

Expand All @@ -311,7 +314,7 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
IsometricRenders.skipNextWorldRender();

if (--this.remainingAnimationFrames == 0) {
this.client.getWindow().setFramerateLimit(this.client.options.getMaxFps().getValue());
this.client.getWindow().setFramerateLimit(this.client.options.maxFps);

final var overwriteValue = overwriteLatest.get();
overwriteLatest.set(false);
Expand Down Expand Up @@ -346,7 +349,7 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
this.notificationStack.add(
() -> Util.getOperatingSystem().open(animationFile),
Translate.gui("animation_saved"),
Text.literal(ExportPathSpec.exportRoot().relativize(animationFile.toPath()).toString())
new LiteralText(ExportPathSpec.exportRoot().relativize(animationFile.toPath()).toString())
);
});
});
Expand Down Expand Up @@ -466,7 +469,7 @@ public void removed() {
this.renderable.dispose();
this.client.keyboard.setRepeatEvents(false);
IsometricRenders.particleRestriction = ParticleRestriction.always();
this.client.getWindow().setFramerateLimit(this.client.options.getMaxFps().getValue());
this.client.getWindow().setFramerateLimit(this.client.options.maxFps);
}

public void scheduleCapture() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class SelectRenderTaskScreen extends Screen {
private final Collection<ItemStack> items;

public SelectRenderTaskScreen(Collection<ItemStack> items) {
super(Text.empty());
super(Text.of(""));
this.items = items;
}

Expand Down
15 changes: 8 additions & 7 deletions src/main/java/com/glisco/isometricrenders/util/MemoryGuard.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.glisco.isometricrenders.util;

import net.minecraft.text.LiteralText;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
Expand Down Expand Up @@ -44,7 +45,7 @@ public List<Text> getStatusTooltip(int memoryMB) {
tooltip.add(this.usageText("ram", memoryMB, this.availableRamMB(), this.canFitInRam(memoryMB)));

if (!this.isSupported()) {
tooltip.add(Text.empty());
tooltip.add(Text.of(" "));
tooltip.add(Translate.gui("no_vram_info_warning").formatted(Formatting.YELLOW));
}

Expand All @@ -59,16 +60,16 @@ private MutableText usageText(String key, int usage, int available, boolean fits
if (fits) {
return Translate.gui(
key,
Text.literal(usage + "").formatted(Formatting.GRAY),
Text.literal(available + "").formatted(Formatting.GRAY),
Text.literal(usage * 100 / available + "%").formatted(Formatting.GRAY)
new LiteralText(usage + "").formatted(Formatting.GRAY),
new LiteralText(available + "").formatted(Formatting.GRAY),
new LiteralText(usage * 100 / available + "%").formatted(Formatting.GRAY)
);
} else {
return Translate.gui(
key,
Text.literal(usage + "").formatted(Formatting.RED),
Text.literal(available + "").formatted(Formatting.GRAY),
Text.literal(usage * 100 / available + "%").formatted(Formatting.RED)
new LiteralText(usage + "").formatted(Formatting.RED),
new LiteralText(available + "").formatted(Formatting.GRAY),
new LiteralText(usage * 100 / available + "%").formatted(Formatting.RED)
);
}
}
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/com/glisco/isometricrenders/util/Translate.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.glisco.isometricrenders.util;

import com.mojang.brigadier.context.CommandContext;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
import net.minecraft.client.MinecraftClient;
import net.minecraft.text.LiteralText;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.MathHelper;

Expand All @@ -13,11 +15,11 @@ public class Translate {
private static final Text PREFIX = generatePrefix("Isometric Renders", 190, 155);

public static MutableText make(String key, Object... args) {
return Text.translatable("message.isometric-renders." + key, args);
return new TranslatableText("message.isometric-renders." + key, args);
}

public static MutableText gui(String key, Object... args) {
return Text.translatable("gui.isometric-renders." + key, args);
return new TranslatableText("gui.isometric-renders." + key, args);
}

public static MutableText msg(String key, Object... args) {
Expand All @@ -33,9 +35,9 @@ public static void commandError(CommandContext<FabricClientCommandSource> contex
}

public static MutableText prefixed(Text text) {
return Text.empty()
return new LiteralText("")
.append(PREFIX)
.append(Text.literal(" > ").formatted(Formatting.DARK_GRAY))
.append(new LiteralText(" > ").formatted(Formatting.DARK_GRAY))
.append(text);
}

Expand All @@ -44,11 +46,11 @@ private static Text generatePrefix(String text, int startHue, int endHue) {
int hueSpan = endHue - startHue;
char[] chars = text.toCharArray();

var prefixText = Text.empty();
var prefixText = new LiteralText("");

for (int i = 0; i < chars.length; i++) {
float index = i;
prefixText.append(Text.literal(String.valueOf(chars[i])).styled(style ->
prefixText.append(new LiteralText(String.valueOf(chars[i])).styled(style ->
style.withColor(MathHelper.hsvToRgb((startHue + (index / chars.length) * hueSpan) / 360, 1, 0.96f))
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class PropertyTextField extends TextFieldWidget {
private String content = "";

public PropertyTextField(int x, int y, IntProperty setting) {
super(MinecraftClient.getInstance().textRenderer, x, y, 35, 20, Text.empty());
super(MinecraftClient.getInstance().textRenderer, x, y, 35, 20, Text.of(""));
this.setting = setting;

this.setText(String.valueOf(setting.get()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public TextFieldWidget labeledTextField(String content, int width, String labelK
this.currentY(),
width,
20,
Text.empty()
Text.of("")
),
20
);
Expand Down
Loading

0 comments on commit 6e47de5

Please sign in to comment.