Skip to content

Commit

Permalink
1.19.3
Browse files Browse the repository at this point in the history
  • Loading branch information
gliscowo committed Dec 19, 2022
1 parent 8e44114 commit 6e248ca
Showing 26 changed files with 102 additions and 133 deletions.
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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.2
yarn_mappings=1.19.2+build.11
loader_version=0.14.9
minecraft_base_version=1.19.3
minecraft_version=1.19.3
yarn_mappings=1.19.3+build.3
loader_version=0.14.11
# Mod Properties
mod_version=0.4.1
maven_group=com.glisco
archives_base_name=isometric-renders
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.61.0+1.19.2
fabric_version=0.69.1+1.19.3

# https://maven.wispforest.io/io/wispforest/worldmesher/
worldmesher_version=0.2.12+1.19
worldmesher_version=0.2.14+1.19.3

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

# https://maven.wispforest.io/io/wispforest/owo-lib/
owo_version=0.8.5+1.19
owo_version=0.9.3+1.19.3
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
import com.glisco.isometricrenders.IsometricRenders;
import com.glisco.isometricrenders.mixin.access.BlockStateArgumentAccessor;
import com.glisco.isometricrenders.mixin.access.DefaultPosArgumentAccessor;
import com.glisco.isometricrenders.mixin.access.EntitySummonArgumentTypeInvoker;
import com.glisco.isometricrenders.property.GlobalProperties;
import com.glisco.isometricrenders.render.*;
import com.glisco.isometricrenders.screen.RenderScreen;
@@ -26,20 +25,20 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.text.ClickEvent;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.EntityHitResult;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryEntry;

import java.util.ArrayList;
import java.util.List;
import java.util.function.BiConsumer;

@@ -48,7 +47,7 @@

public class IsorenderCommand {

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

@@ -66,7 +65,7 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
.executes(IsorenderCommand::renderBlockWithArgument)))
.then(literal("entity")
.executes(IsorenderCommand::renderTargetedEntity)
.then(argument("entity", EntitySummonArgumentType.entitySummon())
.then(argument("entity", RegistryEntryArgumentType.registryEntry(access, RegistryKeys.ENTITY_TYPE))
.suggests(CLIENT_SUMMONABLE_ENTITIES)
.executes(IsorenderCommand::renderEntityWithoutNbt)
.then(argument("nbt", NbtCompoundArgumentType.nbtCompound())
@@ -241,26 +240,24 @@ private static int renderHeldItemTooltip(CommandContext<FabricClientCommandSourc
return 0;
}

@SuppressWarnings("unchecked")
private static int renderEntityWithNbt(CommandContext<FabricClientCommandSource> context) {
final var entityNbt = NbtCompoundArgumentType.getNbtCompound(context, "nbt");
final var entityId = EntitySummonArgumentTypeInvoker.isometric$validate(
context.getArgument("entity", Identifier.class)
);
final var entityReference = (RegistryEntry.Reference<EntityType<?>>) context.getArgument("entity", RegistryEntry.Reference.class);

ScreenScheduler.schedule(new RenderScreen(
EntityRenderable.of(Registry.ENTITY_TYPE.get(entityId), entityNbt)
EntityRenderable.of(entityReference.value(), entityNbt)
));

return 0;
}

@SuppressWarnings("unchecked")
private static int renderEntityWithoutNbt(CommandContext<FabricClientCommandSource> context) {
final var entityId = EntitySummonArgumentTypeInvoker.isometric$validate(
context.getArgument("entity", Identifier.class)
);
final var entityReference = (RegistryEntry.Reference<EntityType<?>>) context.getArgument("entity", RegistryEntry.Reference.class);

ScreenScheduler.schedule(new RenderScreen(
EntityRenderable.of(Registry.ENTITY_TYPE.get(entityId), null)
EntityRenderable.of(entityReference.value(), null)
));

return 0;
@@ -333,9 +330,8 @@ private static int renderAreaSelection(CommandContext<FabricClientCommandSource>

private static <S> void withItemGroupFromContext(CommandContext<S> context, BiConsumer<List<ItemStack>, String> action) {
final var itemGroup = ItemGroupArgumentType.getItemGroup("itemgroup", context);
final var stacks = DefaultedList.<ItemStack>of();
itemGroup.appendStacks(stacks);
action.accept(stacks, "creative-tab_" + itemGroup.getName());
final var stacks = new ArrayList<>(itemGroup.getDisplayStacks());
action.accept(stacks, "creative-tab_" + itemGroup.getId().toShortTranslationKey());
}

public static BlockPos getPosFromArgument(DefaultPosArgument argument, FabricClientCommandSource source) {
Original file line number Diff line number Diff line change
@@ -9,8 +9,9 @@
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import net.minecraft.command.CommandSource;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemGroups;
import net.minecraft.util.Identifier;

import java.util.Arrays;
import java.util.concurrent.CompletableFuture;

public class ItemGroupArgumentType implements ArgumentType<ItemGroup> {
@@ -29,12 +30,12 @@ public static <S> ItemGroup getItemGroup(String name, CommandContext<S> context)

@Override
public ItemGroup parse(StringReader reader) throws CommandSyntaxException {
String name = reader.readString();
return Arrays.stream(ItemGroup.GROUPS).filter(itemGroup -> itemGroup.getName().equals(name)).findAny().orElseThrow(() -> NO_ITEMGROUP.create(name));
var id = Identifier.fromCommandInput(reader);
return ItemGroups.getGroups().stream().filter(itemGroup -> itemGroup.getId().equals(id)).findAny().orElseThrow(() -> NO_ITEMGROUP.create(id));
}

@Override
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> context, SuggestionsBuilder builder) {
return CommandSource.suggestMatching(Arrays.stream(ItemGroup.GROUPS).map(ItemGroup::getName), builder);
return CommandSource.suggestIdentifiers(ItemGroups.getGroups().stream().map(ItemGroup::getId), builder);
}
}
Original file line number Diff line number Diff line change
@@ -11,8 +11,8 @@
import net.minecraft.command.CommandSource;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.registry.Registries;
import net.minecraft.registry.entry.RegistryEntry;

import java.util.HashSet;
import java.util.List;
@@ -51,15 +51,15 @@ public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> cont

private Set<String> getNamespaces() {
final var set = new HashSet<String>();
for (var id : Registry.ITEM.getIds()) {
for (var id : Registries.ITEM.getIds()) {
set.add(id.getNamespace());
}
return set;
}

public record Namespace(String name) {
public List<ItemStack> getContent() {
return Registry.ITEM.streamEntries()
return Registries.ITEM.streamEntries()
.filter(entry -> Objects.equals(entry.registryKey().getValue().getNamespace(), this.name))
.map(RegistryEntry.Reference::value)
.map(Item::getDefaultStack)
Original file line number Diff line number Diff line change
@@ -8,14 +8,14 @@
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.registry.RegistryKeys;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.entry.RegistryEntryList;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryEntryList;

import java.util.concurrent.CompletableFuture;

@@ -25,10 +25,10 @@ public class TagArgumentType implements ArgumentType<TagArgumentType.TagArgument
tag -> Text.translatable("arguments.item.tag.unknown", tag)
);

private final CommandRegistryWrapper<Item> registryWrapper;
private final RegistryWrapper<Item> registryWrapper;

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

public static <S> TagArgument getTag(String name, CommandContext<S> context) {
@@ -39,14 +39,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 registryWrapper.getOptional(TagKey.of(RegistryKeys.ITEM, 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(this.registryWrapper.streamTags().map(named -> named.getTag().id()), builder, String.valueOf('#'));
}

public record TagArgument(Identifier id, RegistryEntryList<Item> entries) {}
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
import com.glisco.isometricrenders.IsometricRenders;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.tooltip.TooltipComponent;
import net.minecraft.client.gui.tooltip.TooltipPositioner;
import net.minecraft.client.util.math.MatrixStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
@@ -21,7 +22,7 @@ public class ScreenMixin {
@Unique private int isometric$tooltipHeight = 0;

@Inject(method = "renderTooltipFromComponents", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;push()V"), locals = LocalCapture.CAPTURE_FAILHARD)
private void captureTooltipDimensions(MatrixStack matrices, List<TooltipComponent> components, int x, int y, CallbackInfo ci, int width, int height) {
private void captureTooltipDimensions(MatrixStack matrices, List<TooltipComponent> components, int x, int y, TooltipPositioner positioner, CallbackInfo ci, int width, int height) {
this.isometric$tooltipWidth = width;
this.isometric$tooltipHeight = height;
}
@@ -35,11 +36,11 @@ 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 + 8 - isometric$tooltipHeight / 2;
}

@Inject(method = "renderTooltipFromComponents", at = @At("TAIL"))
private void resetCenterState(MatrixStack matrices, List<TooltipComponent> components, int x, int y, CallbackInfo ci) {
private void resetCenterState(MatrixStack matrices, List<TooltipComponent> components, int x, int y, TooltipPositioner positioner, CallbackInfo ci) {
IsometricRenders.centerNextTooltip = false;
}

Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
import net.minecraft.client.render.LightmapTextureManager;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.Matrix4f;
import org.joml.Matrix4f;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
import io.wispforest.owo.ui.core.Sizing;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.Vec3f;
import net.minecraft.util.math.RotationAxis;

public class DefaultPropertyBundle implements PropertyBundle {

@@ -69,8 +69,8 @@ public void applyToViewMatrix(MatrixStack modelViewStack) {

modelViewStack.translate(this.xOffset.get() / 26000d, this.yOffset.get() / -26000d, 0);

modelViewStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(this.slant.get()));
modelViewStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(this.rotation.get()));
modelViewStack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(this.slant.get()));
modelViewStack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(this.rotation.get()));

this.updateAndApplyRotationOffset(modelViewStack);
}
@@ -85,7 +85,7 @@ protected void updateAndApplyRotationOffset(MatrixStack modelViewStack) {
rotationOffset += MinecraftClient.getInstance().getLastFrameDuration() * rotationSpeed.get() * .1f;
this.rotationOffsetUpdated = true;
}
modelViewStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(rotationOffset));
modelViewStack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(rotationOffset));
} else {
rotationOffset = 0;
}
Original file line number Diff line number Diff line change
@@ -17,7 +17,11 @@
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.RotationAxis;
import net.minecraft.util.math.Vec3d;
import org.joml.Matrix4f;

public class AreaRenderable extends DefaultRenderable<AreaRenderable.AreaPropertyBundle> {

@@ -166,8 +170,8 @@ public void applyToViewMatrix(MatrixStack modelViewStack) {

modelViewStack.translate(this.xOffset.get() / 2600d, this.yOffset.get() / -2600d, 0);

modelViewStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(this.slant.get()));
modelViewStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(this.rotation.get()));
modelViewStack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(this.slant.get()));
modelViewStack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(this.rotation.get()));

this.updateAndApplyRotationOffset(modelViewStack);
}
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
import io.wispforest.owo.ui.core.Sizing;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.Matrix4f;
import org.joml.Matrix4f;

import java.util.List;

Original file line number Diff line number Diff line change
@@ -16,8 +16,8 @@
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.registry.Registries;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

@@ -118,7 +118,7 @@ public ParticleRestriction<?> particleRestriction() {
@Override
public ExportPathSpec exportPath() {
return ExportPathSpec.ofIdentified(
Registry.BLOCK.getId(this.state.getBlock()),
Registries.BLOCK.getId(this.state.getBlock()),
"block"
);
}
Loading

0 comments on commit 6e248ca

Please sign in to comment.