Skip to content

Commit

Permalink
Merge pull request #182 from BasiqueEvangelist/1.20.2
Browse files Browse the repository at this point in the history
1.20.2
  • Loading branch information
gliscowo authored Oct 2, 2023
2 parents deff18c + fb02f3b commit a3cdd02
Show file tree
Hide file tree
Showing 42 changed files with 293 additions and 261 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
plugins {
id 'fabric-loom' version '1.2-SNAPSHOT'
id 'maven-publish'
id 'io.github.juuxel.loom-quiltflower' version '1.10.0'
id 'io.github.juuxel.loom-vineflower' version '1.11.0'
}

allprojects {
Expand Down Expand Up @@ -128,7 +128,7 @@ dependencies {
modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:${project.rei_version}")

modCompileOnly("dev.emi:emi-fabric:${project.emi_version}")
modLocalRuntime("dev.emi:emi-fabric:${project.emi_version}")
// modLocalRuntime("dev.emi:emi-fabric:${project.emi_version}")

modCompileOnly("com.terraformersmc:modmenu:${project.modmenu_version}")
modLocalRuntime("com.terraformersmc:modmenu:${project.modmenu_version}")
Expand Down
22 changes: 11 additions & 11 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@
org.gradle.jvmargs=-Xmx2G
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_base_version=1.20
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.2
loader_version=0.14.21
minecraft_base_version=1.20.2
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.1
loader_version=0.14.22
# Mod Properties
mod_version=0.11.2-pre.14
mod_version=0.11.3
maven_group=io.wispforest
archives_base_name=owo-lib
# Dependencies
fabric_version=0.85.0+1.20.1
fabric_version=0.89.2+1.20.2

# https://maven.shedaniel.me/me/shedaniel/RoughlyEnoughItems-fabric/
rei_version=12.0.625
rei_version=13.0.661

# https://maven.terraformersmc.com/releases/dev/emi/emi/
emi_version=1.0.3+1.20
# https://maven.terraformersmc.com/releases/dev/emi/emi-fabric/
emi_version=1.0.19+1.20.1

# https://search.maven.org/artifact/blue.endless/jankson
jankson_version=1.2.2

# https://maven.terraformersmc.com/releases/com/terraformersmc/modmenu
modmenu_version=7.0.1
modmenu_version=8.0.0

# https://maven.nucleoid.xyz/fr/catcore/server-translations-api/
# https://maven.nucleoid.xyz/xyz/nucleoid/server-translations-api/
stapi_version=2.0.0+1.20
4 changes: 2 additions & 2 deletions src/main/java/io/wispforest/owo/compat/rei/ReiUIAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
}

@Override
public boolean mouseScrolled(double mouseX, double mouseY, double amount) {
return this.adapter.mouseScrolled(mouseX - this.adapter.x(), mouseY - this.adapter.y(), amount);
public boolean mouseScrolled(double mouseX, double mouseY, double horizontalAmount, double verticalAmount) {
return this.adapter.mouseScrolled(mouseX - this.adapter.x(), mouseY - this.adapter.y(), horizontalAmount, verticalAmount);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public boolean onMouseUp(double mouseX, double mouseY, int button) {

@Override
public boolean onMouseScroll(double mouseX, double mouseY, double amount) {
return this.widget.mouseScrolled(this.x + mouseX, this.y + mouseY, amount)
return this.widget.mouseScrolled(this.x + mouseX, this.y + mouseY, 0, amount)
| super.onMouseScroll(mouseX, mouseY, amount);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.google.common.collect.HashMultimap;
import io.wispforest.owo.Owo;
import io.wispforest.owo.mixin.ServerPlayNetworkHandlerAccessor;
import io.wispforest.owo.mixin.ServerCommonNetworkHandlerAccessor;
import io.wispforest.owo.ops.TextOps;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
Expand Down Expand Up @@ -56,7 +56,7 @@ static void register(ConfigWrapper<?> config) {
* or {@code null} if no config with the given name was synced
*/
public static @Nullable Map<Option.Key, ?> getClientOptions(ServerPlayerEntity player, String configName) {
var storage = CLIENT_OPTION_STORAGE.get(((ServerPlayNetworkHandlerAccessor) player.networkHandler).owo$getConnection());
var storage = CLIENT_OPTION_STORAGE.get(((ServerCommonNetworkHandlerAccessor) player.networkHandler).owo$getConnection());
if (storage == null) return null;

return storage.get(configName);
Expand Down Expand Up @@ -188,7 +188,7 @@ private static void applyClient(MinecraftClient client, ClientPlayNetworkHandler

private static void applyServer(MinecraftServer server, ServerPlayerEntity player, ServerPlayNetworkHandler handler, PacketByteBuf buf, PacketSender sender) {
Owo.LOGGER.info("Receiving client config");
var connection = ((ServerPlayNetworkHandlerAccessor) player.networkHandler).owo$getConnection();
var connection = ((ServerCommonNetworkHandlerAccessor) player.networkHandler).owo$getConnection();

read(buf, (option, optionBuf) -> {
var config = CLIENT_OPTION_STORAGE.computeIfAbsent(connection, $ -> new HashMap<>()).computeIfAbsent(option.configName(), s -> new HashMap<>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ protected void refreshOptions() {

final var box = new ConfigTextBox();
box.setText(this.backingList.get(i).toString());
box.setCursorToStart();
box.setCursorToStart(false);
box.setDrawsBackground(false);
box.margins(Insets.vertical(2));
box.horizontalSizing(Sizing.fill(95));
Expand Down
46 changes: 37 additions & 9 deletions src/main/java/io/wispforest/owo/itemgroup/OwoItemGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,25 @@ public abstract class OwoItemGroup extends ItemGroup {
private final IntSet activeTabsView = IntSets.unmodifiable(this.activeTabs);
private boolean initialized = false;

private final @Nullable Identifier backgroundTexture;
private final @Nullable ScrollerTextures scrollerTextures;
private final @Nullable TabTextures tabTextures;

private final int tabStackHeight;
private final int buttonStackHeight;
private final Identifier customTexture;
private final boolean useDynamicTitle;
private final boolean displaySingleTab;
private final boolean allowMultiSelect;

protected OwoItemGroup(Identifier id, Consumer<OwoItemGroup> initializer, Supplier<Icon> iconSupplier, int tabStackHeight, int buttonStackHeight, @Nullable Identifier customTexture, boolean useDynamicTitle, boolean displaySingleTab, boolean allowMultiSelect) {
protected OwoItemGroup(Identifier id, Consumer<OwoItemGroup> initializer, Supplier<Icon> iconSupplier, int tabStackHeight, int buttonStackHeight, @Nullable Identifier backgroundTexture, @Nullable ScrollerTextures scrollerTextures, @Nullable TabTextures tabTextures, boolean useDynamicTitle, boolean displaySingleTab, boolean allowMultiSelect) {
super(null, -1, Type.CATEGORY, Text.translatable("itemGroup.%s.%s".formatted(id.getNamespace(), id.getPath())), () -> ItemStack.EMPTY, (displayContext, entries) -> {});
this.initializer = initializer;
this.iconSupplier = iconSupplier;
this.tabStackHeight = tabStackHeight;
this.buttonStackHeight = buttonStackHeight;
this.customTexture = customTexture;
this.backgroundTexture = backgroundTexture;
this.scrollerTextures = scrollerTextures;
this.tabTextures = tabTextures;
this.useDynamicTitle = useDynamicTitle;
this.displaySingleTab = displaySingleTab;
this.allowMultiSelect = allowMultiSelect;
Expand Down Expand Up @@ -308,8 +313,16 @@ public boolean isTabSelected(int tab) {
return this.activeTabs.contains(tab);
}

public Identifier getCustomTexture() {
return customTexture;
public @Nullable Identifier getBackgroundTexture() {
return this.backgroundTexture;
}

public @Nullable ScrollerTextures getScrollerTextures() {
return this.scrollerTextures;
}

public @Nullable TabTextures getTabTextures() {
return this.tabTextures;
}

public int getTabStackHeight() {
Expand Down Expand Up @@ -363,7 +376,9 @@ public static class Builder {
private Consumer<OwoItemGroup> initializer = owoItemGroup -> {};
private int tabStackHeight = 4;
private int buttonStackHeight = 4;
private @Nullable Identifier customTexture = null;
private @Nullable Identifier backgroundTexture = null;
private @Nullable ScrollerTextures scrollerTextures = null;
private @Nullable TabTextures tabTextures = null;
private boolean useDynamicTitle = true;
private boolean displaySingleTab = false;
private boolean allowMultiSelect = true;
Expand All @@ -388,8 +403,18 @@ public Builder buttonStackHeight(int buttonStackHeight) {
return this;
}

public Builder customTexture(@Nullable Identifier customTexture) {
this.customTexture = customTexture;
public Builder backgroundTexture(@Nullable Identifier backgroundTexture) {
this.backgroundTexture = backgroundTexture;
return this;
}

public Builder scrollerTextures(ScrollerTextures scrollerTextures) {
this.scrollerTextures = scrollerTextures;
return this;
}

public Builder tabTextures(TabTextures tabTextures) {
this.tabTextures = tabTextures;
return this;
}

Expand All @@ -409,7 +434,7 @@ public Builder withoutMultipleSelection() {
}

public OwoItemGroup build() {
final var group = new OwoItemGroup(id, initializer, iconSupplier, tabStackHeight, buttonStackHeight, customTexture, useDynamicTitle, displaySingleTab, allowMultiSelect) {};
final var group = new OwoItemGroup(id, initializer, iconSupplier, tabStackHeight, buttonStackHeight, backgroundTexture, scrollerTextures, tabTextures, useDynamicTitle, displaySingleTab, allowMultiSelect) {};
Registry.register(Registries.ITEM_GROUP, this.id, group);
return group;
}
Expand All @@ -428,6 +453,9 @@ public void add(ItemStack stack, StackVisibility visibility) {
}
}

public record ScrollerTextures(Identifier enabled, Identifier disabled) {}
public record TabTextures(Identifier topSelected, Identifier topSelectedFirstColumn, Identifier topUnselected, Identifier bottomSelected, Identifier bottomSelectedFirstColumn, Identifier bottomUnselected) {}

// Utility

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import io.wispforest.owo.mixin.itemgroup.ItemGroupAccessor;
import io.wispforest.owo.mixin.ui.SimpleRegistryAccessor;
import net.minecraft.item.ItemGroup;
import net.minecraft.registry.MutableRegistry;
import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.SimpleRegistry;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.ApiStatus;

Expand All @@ -30,13 +30,13 @@ public class WrapperGroup extends OwoItemGroup {

@SuppressWarnings("unchecked")
public WrapperGroup(ItemGroup parent, Identifier parentId, List<ItemGroupTab> tabs, List<ItemGroupButton> buttons) {
super(parentId, owoItemGroup -> {}, () -> Icon.of(parent.getIcon()), 4, 4, null, true, false, false);
super(parentId, owoItemGroup -> {}, () -> Icon.of(parent.getIcon()), 4, 4, null, null, null, true, false, false);

int parentRawId = Registries.ITEM_GROUP.getRawId(parent);

((SimpleRegistryAccessor<ItemGroup>) Registries.ITEM_GROUP).owo$getValueToEntry().remove(parent);
((SimpleRegistryAccessor<ItemGroup>) Registries.ITEM_GROUP).owo$getEntryToLifecycle().remove(parent);
((MutableRegistry<ItemGroup>) Registries.ITEM_GROUP).set(parentRawId, RegistryKey.of(RegistryKeys.ITEM_GROUP, parentId), this, Lifecycle.stable());
((SimpleRegistry<ItemGroup>) Registries.ITEM_GROUP).set(parentRawId, RegistryKey.of(RegistryKeys.ITEM_GROUP, parentId), this, Lifecycle.stable());

((ItemGroupAccessor) this).owo$setDisplayName(parent.getDisplayName());
((ItemGroupAccessor) this).owo$setColumn(parent.getColumn());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.wispforest.owo.mixin;

import net.minecraft.client.network.ClientCommonNetworkHandler;
import net.minecraft.network.ClientConnection;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(ClientCommonNetworkHandler.class)
public interface ClientCommonNetworkHandlerAccessor {
@Accessor
ClientConnection getConnection();
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package io.wispforest.owo.mixin;

import net.minecraft.network.ClientConnection;
import net.minecraft.server.network.ServerCommonNetworkHandler;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(ServerPlayNetworkHandler.class)
public interface ServerPlayNetworkHandlerAccessor {
@Mixin(ServerCommonNetworkHandler.class)
public interface ServerCommonNetworkHandlerAccessor {

@Accessor("connection")
ClientConnection owo$getConnection();
Expand Down

This file was deleted.

Loading

0 comments on commit a3cdd02

Please sign in to comment.