Initial source import

This commit is contained in:
Cynthia Foxwell 2024-03-13 23:09:55 -06:00
parent 6bc88feb7b
commit 8fcb9f3acc
78 changed files with 3292 additions and 0 deletions

33
.editorconfig Normal file
View File

@ -0,0 +1,33 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
tab_width = 4
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.gradle]
indent_style = tab
[*.java]
indent_style = tab
[*.json]
indent_style = space
indent_size = 2
[quilt.mod.json]
indent_style = tab
tab_width = 2
[*.toml]
indent_style = tab
tab_width = 2
[*.properties]
indent_style = space
indent_size = 2

30
.gitattributes vendored Normal file
View File

@ -0,0 +1,30 @@
*.java text eol=lf diff=java
*.gradle text eol=lf diff=java
*.kt text eol=lf diff=kotlin
*.kts text eol=lf diff=kotlin
gradlew text eol=lf
*.bat text eol=crlf
*.md text eol=lf diff=markdown
.editorconfig text eol=lf
*.json text eol=lf
*.json5 text eol=lf
*.properties text eol=lf
*.toml text eol=lf
*.xml text eol=lf diff=html
# Modding specific
*.accesswidener text eol=lf
# These files are binary and should be left untouched
# (binary is a macro for -text -diff)
*.class binary
*.dll binary
*.ear binary
*.jar binary
*.jks binary
*.png binary
*.so binary
*.war binary

34
.gitignore vendored Normal file
View File

@ -0,0 +1,34 @@
# Gradle
.gradle/
build/
out/
classes/
# Quilt Loom
remappedSrc/
run/
# Eclipse
*.launch
# IntelliJ Idea
.idea/
*.iml
*.ipr
*.iws
# Fleet
.fleet/
# Visual Studio Code
.settings/
.vscode/
bin/
.classpath
.project
# Eclipse JDT LS
workspace/
# macOS
*.DS_Store

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022-2024 Cynthia Foxwell
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

83
build.gradle Normal file
View File

@ -0,0 +1,83 @@
plugins {
alias libs.plugins.quilt.loom
}
base {
archivesName = project.archives_base_name
}
version = "$project.version+${libs.versions.minecraft.get()}"
group = project.maven_group
repositories {
maven {
name = "TerraformersMC"
url = "https://maven.terraformersmc.com/"
}
maven {
name = "Ladysnake Libs"
url = "https://maven.ladysnake.org/releases"
}
maven {
name = "Sleeping Town"
url = "https://repo.sleeping.town"
content {
includeGroup "com.unascribed"
}
}
}
loom {
// Loom and Loader both use this block in order to gather more information about your mod.
mods {
// This should match your mod id.
"scout" {
// Tell Loom about each source set used by your mod here. This ensures that your mod's classes are properly transformed by Loader.
sourceSet("main")
// If you shade (directly include classes, not JiJ) a dependency into your mod, include it here using one of these methods:
// dependency("com.example.shadowedmod:1.2.3")
// configuration("exampleShadedConfigurationName")
}
}
}
dependencies {
minecraft libs.minecraft
mappings variantOf(libs.quilt.mappings) { classifier 'intermediary-v2' }
modImplementation libs.quilt.loader
modImplementation libs.quilted.fabric.api
modApi include("dev.emi:trinkets:${libs.versions.trinkets.get()}")
modApi include("com.unascribed:lib39-core:${libs.versions.lib39.get()}+${libs.versions.minecraft.get()}")
modApi include("com.unascribed:lib39-dessicant:${libs.versions.lib39.get()}+${libs.versions.minecraft.get()}")
modCompileOnly "dev.emi:emi-fabric:${libs.versions.emi.get()}+${libs.versions.minecraft.get()}:api"
modLocalRuntime "dev.emi:emi-fabric:${libs.versions.emi.get()}+${libs.versions.minecraft.get()}"
}
processResources {
inputs.properties 'version': version, 'group': project.group
filesMatching('quilt.mod.json') {
expand 'version': version, 'group': project.group
}
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = 'UTF-8'
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
}
java {
// Still required by IDEs such as Eclipse and Visual Studio Code
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
jar {
from('LICENSE') {
rename { "${it}_${base.archivesName.get()}" }
}
}

10
gradle.properties Normal file
View File

@ -0,0 +1,10 @@
# Gradle Properties
org.gradle.jvmargs = -Xmx1G
org.gradle.parallel = true
# Mod Properties
version = 2.0.0
maven_group = pm.c7.scout
archives_base_name = Scout
# Dependencies are managed at gradle/libs.versions.toml

28
gradle/libs.versions.toml Normal file
View File

@ -0,0 +1,28 @@
[versions]
# The latest versions are available at https://lambdaurora.dev/tools/import_quilt.html
minecraft = "1.20.1"
loom = "1.4.1"
quilt_mappings = "1.20.1+build.23"
quilt_loader = "0.21.0"
quilted_fabric_api = "7.4.0+0.90.0-1.20.1"
trinkets = "3.7.2"
lib39 = "1.5.0-experimental6.1"
emi = "1.1.3"
[libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
quilt_mappings = { module = "org.quiltmc:quilt-mappings", version.ref = "quilt_mappings" }
quilt_loader = { module = "org.quiltmc:quilt-loader", version.ref = "quilt_loader" }
quilted_fabric_api = { module = "org.quiltmc.quilted-fabric-api:quilted-fabric-api", version.ref = "quilted_fabric_api" }
quilted_fabric_api_deprecated = { module = "org.quiltmc.quilted-fabric-api:quilted-fabric-api-deprecated", version.ref = "quilted_fabric_api" }
# If you have multiple similar dependencies, you can declare a dependency bundle and reference it on the build script with "libs.bundles.example".
[bundles]
quilted_fabric_api = ["quilted_fabric_api", "quilted_fabric_api_deprecated"]
[plugins]
quilt_loom = { id = "org.quiltmc.loom", version.ref = "loom" }

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

249
gradlew vendored Normal file
View File

@ -0,0 +1,249 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

92
gradlew.bat vendored Normal file
View File

@ -0,0 +1,92 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

14
settings.gradle Normal file
View File

@ -0,0 +1,14 @@
pluginManagement {
repositories {
maven {
name = 'Quilt'
url = 'https://maven.quiltmc.org/repository/release'
}
// Currently needed for Intermediary and other temporary dependencies
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
gradlePluginPortal()
}
}

View File

@ -0,0 +1,22 @@
package pm.c7.scout;
import com.unascribed.lib39.core.api.AutoRegistry;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.qsl.base.api.entrypoint.ModInitializer;
import org.quiltmc.qsl.item.group.api.QuiltItemGroup;
import pm.c7.scout.config.ScoutConfigHandler;
import pm.c7.scout.registry.ScoutItems;
public class Scout implements ModInitializer {
public static final AutoRegistry AUTOREGISTRY = AutoRegistry.of(ScoutUtil.MOD_ID);
public static final ItemGroup ITEM_GROUP = QuiltItemGroup.createWithIcon(new Identifier("scout", "itemgroup"), () -> new ItemStack(ScoutItems.SATCHEL));
@Override
public void onInitialize(ModContainer mod) {
new ScoutConfigHandler();
ScoutItems.init();
}
}

View File

@ -0,0 +1,53 @@
package pm.c7.scout;
import com.unascribed.lib39.core.api.AutoMixin;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AnnotationNode;
import org.objectweb.asm.tree.ClassNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
import pm.c7.scout.mixinsupport.ClassNodeTransformer;
import java.util.HashMap;
import java.util.Map;
// "you could also embrace chaos" --Una
// https://git.sleeping.town/unascribed/Yttr/src/branch/1.19.2/src/main/java/com/unascribed/yttr/YttrMixin.java
public class ScoutMixin extends AutoMixin {
private static final Logger LOGGER = LoggerFactory.getLogger("Scout:MixinPlugin");
public @interface Transformer {
Class<? extends ClassNodeTransformer> value();
}
private final Map<String, ClassNodeTransformer> transformers = new HashMap<>();
@Override
protected boolean shouldMixinBeSkipped(String name, ClassNode node) {
if (name.endsWith("Transformer")) {
return true;
}
return super.shouldMixinBeSkipped(name, node);
}
@Override
protected boolean shouldAnnotationSkipMixin(String name, AnnotationNode an) {
if (an.desc.equals("Lpm/c7/scout/ScoutMixin$Transformer;")) {
var params = decodeAnnotationParams(an);
Type type = (Type)params.get("value");
try {
transformers.put(name, (ClassNodeTransformer) Class.forName(type.getClassName()).newInstance());
} catch (Exception e) {
LOGGER.error("Transformer class for mixin {} not found", name, e);
}
}
return super.shouldAnnotationSkipMixin(name, an);
}
@Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
transformers.getOrDefault(mixinClassName, (s, cn) -> {}).transform(targetClassName, targetClass);
super.postApply(targetClassName, targetClass, mixinClassName, mixinInfo);
}
}

View File

@ -0,0 +1,7 @@
package pm.c7.scout;
import net.minecraft.util.Identifier;
public class ScoutNetworking {
public static final Identifier ENABLE_SLOTS = new Identifier(ScoutUtil.MOD_ID, "enable_slots");
}

View File

@ -0,0 +1,10 @@
package pm.c7.scout;
import net.minecraft.util.collection.DefaultedList;
import pm.c7.scout.screen.BagSlot;
public interface ScoutScreenHandler {
DefaultedList<BagSlot> scout$getSatchelSlots();
DefaultedList<BagSlot> scout$getLeftPouchSlots();
DefaultedList<BagSlot> scout$getRightPouchSlots();
}

View File

@ -0,0 +1,151 @@
package pm.c7.scout;
import dev.emi.trinkets.api.SlotReference;
import dev.emi.trinkets.api.TrinketComponent;
import dev.emi.trinkets.api.TrinketsApi;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.BeaconScreen;
import net.minecraft.client.gui.screen.ingame.CreativeInventoryScreen;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.gui.screen.ingame.MerchantScreen;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtList;
import net.minecraft.screen.PlayerScreenHandler;
import net.minecraft.screen.slot.Slot;
import net.minecraft.util.Identifier;
import net.minecraft.util.Pair;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.MathHelper;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pm.c7.scout.item.BaseBagItem;
import pm.c7.scout.item.BaseBagItem.BagType;
import pm.c7.scout.screen.BagSlot;
import java.util.Optional;
public class ScoutUtil {
public static final Logger LOGGER = LoggerFactory.getLogger("Scout");
public static final String MOD_ID = "scout";
public static final Identifier SLOT_TEXTURE = new Identifier("scout", "textures/gui/slots.png");
public static final int MAX_SATCHEL_SLOTS = 18;
public static final int MAX_POUCH_SLOTS = 6;
public static final int TOTAL_SLOTS = MAX_SATCHEL_SLOTS + MAX_POUCH_SLOTS + MAX_POUCH_SLOTS;
public static final int SATCHEL_SLOT_START = -1100;
public static final int LEFT_POUCH_SLOT_START = SATCHEL_SLOT_START - MAX_SATCHEL_SLOTS;
public static final int RIGHT_POUCH_SLOT_START = LEFT_POUCH_SLOT_START - MAX_POUCH_SLOTS;
public static final int BAG_SLOTS_END = RIGHT_POUCH_SLOT_START - MAX_POUCH_SLOTS;
public static ItemStack findBagItem(PlayerEntity player, BaseBagItem.BagType type, boolean right) {
ItemStack targetStack = ItemStack.EMPTY;
boolean hasFirstPouch = false;
Optional<TrinketComponent> _component = TrinketsApi.getTrinketComponent(player);
if (_component.isPresent()) {
TrinketComponent component = _component.get();
for (Pair<SlotReference, ItemStack> pair : component.getAllEquipped()) {
ItemStack slotStack = pair.getRight();
if (slotStack.getItem() instanceof BaseBagItem bagItem) {
if (bagItem.getType() == type) {
if (type == BagType.POUCH) {
if (right && !hasFirstPouch) {
hasFirstPouch = true;
} else {
targetStack = slotStack;
break;
}
} else {
targetStack = slotStack;
break;
}
}
}
}
}
return targetStack;
}
public static NbtList inventoryToTag(Inventory inventory) {
NbtList tag = new NbtList();
for(int i = 0; i < inventory.size(); i++) {
NbtCompound stackTag = new NbtCompound();
stackTag.putInt("Slot", i);
stackTag.put("Stack", inventory.getStack(i).writeNbt(new NbtCompound()));
tag.add(stackTag);
}
return tag;
}
public static void inventoryFromTag(NbtList tag, Inventory inventory) {
inventory.clear();
tag.forEach(element -> {
NbtCompound stackTag = (NbtCompound) element;
int slot = stackTag.getInt("Slot");
ItemStack stack = ItemStack.fromNbt(stackTag.getCompound("Stack"));
inventory.setStack(slot, stack);
});
}
public static boolean isBagSlot(int slot) {
return slot <= SATCHEL_SLOT_START && slot > BAG_SLOTS_END;
}
public static @Nullable Slot getBagSlot(int slot, PlayerScreenHandler playerScreenHandler) {
var scoutScreenHandler = (ScoutScreenHandler) playerScreenHandler;
if (slot <= SATCHEL_SLOT_START && slot > LEFT_POUCH_SLOT_START) {
int realSlot = MathHelper.abs(slot - SATCHEL_SLOT_START);
var slots = scoutScreenHandler.scout$getSatchelSlots();
return slots.get(realSlot);
} else if (slot <= LEFT_POUCH_SLOT_START && slot > RIGHT_POUCH_SLOT_START) {
int realSlot = MathHelper.abs(slot - LEFT_POUCH_SLOT_START);
var slots = scoutScreenHandler.scout$getLeftPouchSlots();
return slots.get(realSlot);
} else if (slot <= RIGHT_POUCH_SLOT_START && slot > BAG_SLOTS_END) {
int realSlot = MathHelper.abs(slot - RIGHT_POUCH_SLOT_START);
var slots = scoutScreenHandler.scout$getRightPouchSlots();
return slots.get(realSlot);
} else {
return null;
}
}
public static DefaultedList<Slot> getAllBagSlots(PlayerScreenHandler playerScreenHandler) {
var scoutScreenHandler = (ScoutScreenHandler) playerScreenHandler;
DefaultedList<Slot> out = DefaultedList.ofSize(TOTAL_SLOTS);
out.addAll(scoutScreenHandler.scout$getSatchelSlots());
out.addAll(scoutScreenHandler.scout$getLeftPouchSlots());
out.addAll(scoutScreenHandler.scout$getRightPouchSlots());
return out;
}
public static @Nullable PlayerScreenHandler getPlayerScreenHandler() {
var client = MinecraftClient.getInstance();
if (client != null && client.player != null) {
return client.player.playerScreenHandler;
}
return null;
}
// FIXME: registry system for mods to register their own blacklisted screens
public static boolean isScreenBlacklisted(Screen screen) {
return screen instanceof CreativeInventoryScreen
|| screen instanceof MerchantScreen // FIXME: needs repositioning
|| screen instanceof BeaconScreen; // FIXME: needs repositioning
}
}

View File

@ -0,0 +1,204 @@
package pm.c7.scout.client;
import net.fabricmc.fabric.api.client.rendering.v1.LivingEntityFeatureRendererRegistrationCallback;
import net.minecraft.client.gui.screen.ingame.GenericContainerScreen;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.gui.screen.ingame.ShulkerBoxScreen;
import net.minecraft.entity.EntityType;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.screen.slot.Slot;
import net.minecraft.util.collection.DefaultedList;
import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.qsl.base.api.entrypoint.client.ClientModInitializer;
import org.quiltmc.qsl.networking.api.client.ClientPlayNetworking;
import org.quiltmc.qsl.screen.api.client.ScreenEvents;
import org.quiltmc.qsl.tooltip.api.client.TooltipComponentCallback;
import pm.c7.scout.ScoutNetworking;
import pm.c7.scout.ScoutScreenHandler;
import pm.c7.scout.ScoutUtil;
import pm.c7.scout.client.gui.BagTooltipComponent;
import pm.c7.scout.client.render.SatchelFeatureRenderer;
import pm.c7.scout.item.BagTooltipData;
import pm.c7.scout.item.BaseBagItem;
import pm.c7.scout.item.BaseBagItem.BagType;
import pm.c7.scout.client.render.PouchFeatureRenderer;
import pm.c7.scout.mixin.client.HandledScreenAccessor;
import pm.c7.scout.screen.BagSlot;
public class ScoutClient implements ClientModInitializer {
@Override
public void onInitializeClient(ModContainer mod) {
ClientPlayNetworking.registerGlobalReceiver(ScoutNetworking.ENABLE_SLOTS, (client, handler, packet, sender) -> {
client.execute(() -> {
assert client.player != null;
ScoutScreenHandler screenHandler = (ScoutScreenHandler) client.player.playerScreenHandler;
ItemStack satchelStack = ScoutUtil.findBagItem(client.player, BagType.SATCHEL, false);
DefaultedList<BagSlot> satchelSlots = screenHandler.scout$getSatchelSlots();
for (int i = 0; i < ScoutUtil.MAX_SATCHEL_SLOTS; i++) {
BagSlot slot = satchelSlots.get(i);
slot.setInventory(null);
slot.setEnabled(false);
}
if (!satchelStack.isEmpty()) {
BaseBagItem satchelItem = (BaseBagItem) satchelStack.getItem();
Inventory satchelInv = satchelItem.getInventory(satchelStack);
for (int i = 0; i < satchelItem.getSlotCount(); i++) {
BagSlot slot = satchelSlots.get(i);
slot.setInventory(satchelInv);
slot.setEnabled(true);
}
}
ItemStack leftPouchStack = ScoutUtil.findBagItem(client.player, BagType.POUCH, false);
DefaultedList<BagSlot> leftPouchSlots = screenHandler.scout$getLeftPouchSlots();
for (int i = 0; i < ScoutUtil.MAX_POUCH_SLOTS; i++) {
BagSlot slot = leftPouchSlots.get(i);
slot.setInventory(null);
slot.setEnabled(false);
}
if (!leftPouchStack.isEmpty()) {
BaseBagItem leftPouchItem = (BaseBagItem) leftPouchStack.getItem();
Inventory leftPouchInv = leftPouchItem.getInventory(leftPouchStack);
for (int i = 0; i < leftPouchItem.getSlotCount(); i++) {
BagSlot slot = leftPouchSlots.get(i);
slot.setInventory(leftPouchInv);
slot.setEnabled(true);
}
}
ItemStack rightPouchStack = ScoutUtil.findBagItem(client.player, BagType.POUCH, true);
DefaultedList<BagSlot> rightPouchSlots = screenHandler.scout$getRightPouchSlots();
for (int i = 0; i < ScoutUtil.MAX_POUCH_SLOTS; i++) {
BagSlot slot = rightPouchSlots.get(i);
slot.setInventory(null);
slot.setEnabled(false);
}
if (!rightPouchStack.isEmpty()) {
BaseBagItem rightPouchItem = (BaseBagItem) rightPouchStack.getItem();
Inventory rightPouchInv = rightPouchItem.getInventory(rightPouchStack);
for (int i = 0; i < rightPouchItem.getSlotCount(); i++) {
BagSlot slot = rightPouchSlots.get(i);
slot.setInventory(rightPouchInv);
slot.setEnabled(true);
}
}
});
});
TooltipComponentCallback.EVENT.register(data -> {
if (data instanceof BagTooltipData d) {
return new BagTooltipComponent(d);
}
return null;
});
LivingEntityFeatureRendererRegistrationCallback.EVENT.register((entityType, entityRenderer, registrationHelper, context) -> {
if (entityType == EntityType.PLAYER) {
registrationHelper.register(new PouchFeatureRenderer<>(entityRenderer, context.getHeldItemRenderer()));
registrationHelper.register(new SatchelFeatureRenderer<>(entityRenderer));
}
});
ScreenEvents.AFTER_INIT.register((screen, client, scaledWidth, scaledHeight) -> {
if (screen instanceof HandledScreen<?> handledScreen && client.player != null) {
if (ScoutUtil.isScreenBlacklisted(screen)) {
// realistically no one is going to have a screen bigger than 2147483647 pixels
for (Slot slot : ScoutUtil.getAllBagSlots(client.player.playerScreenHandler)) {
BagSlot bagSlot = (BagSlot) slot;
bagSlot.setX(Integer.MAX_VALUE);
bagSlot.setY(Integer.MAX_VALUE);
}
return;
}
var handledScreenAccessor = (HandledScreenAccessor) handledScreen;
var sx = handledScreenAccessor.getX();
var sy = handledScreenAccessor.getY();
var sw = handledScreenAccessor.getBackgroundWidth();
var sh = handledScreenAccessor.getBackgroundHeight();
// satchel
int x = sx;
int y = sy + sh + 2;
if (screen instanceof GenericContainerScreen || screen instanceof ShulkerBoxScreen) {
y -= 1;
}
for (int i = 0; i < ScoutUtil.MAX_SATCHEL_SLOTS; i++) {
if (i % 9 == 0) {
x = sx + 8;
}
BagSlot slot = (BagSlot) ScoutUtil.getBagSlot(ScoutUtil.SATCHEL_SLOT_START - i, client.player.playerScreenHandler);
if (slot != null) {
slot.setX(x - sx);
slot.setY(y - sy);
}
x += 18;
if ((i + 1) % 9 == 0) {
y += 18;
}
}
// left pouch
x = sx + 8;
y = (sy + sh) - 100;
if (screen instanceof GenericContainerScreen || screen instanceof ShulkerBoxScreen) {
y -= 1;
}
for (int i = 0; i < ScoutUtil.MAX_POUCH_SLOTS; i++) {
if (i % 3 == 0) {
x -= 18;
y += 54;
}
BagSlot slot = (BagSlot) ScoutUtil.getBagSlot(ScoutUtil.LEFT_POUCH_SLOT_START - i, client.player.playerScreenHandler);
if (slot != null) {
slot.setX(x - sx);
slot.setY(y - sy);
}
y -= 18;
}
// right pouch
x = sx + sw - 24;
y = (sy + sh) - 100;
if (screen instanceof GenericContainerScreen || screen instanceof ShulkerBoxScreen) {
y -= 1;
}
for (int i = 0; i < ScoutUtil.MAX_POUCH_SLOTS; i++) {
if (i % 3 == 0) {
x += 18;
y += 54;
}
BagSlot slot = (BagSlot) ScoutUtil.getBagSlot(ScoutUtil.RIGHT_POUCH_SLOT_START - i, client.player.playerScreenHandler);
if (slot != null) {
slot.setX(x - sx);
slot.setY(y - sy);
}
y -= 18;
}
}
});
}
}

View File

@ -0,0 +1,45 @@
package pm.c7.scout.client.compat;
import dev.emi.emi.api.EmiPlugin;
import dev.emi.emi.api.EmiRegistry;
import dev.emi.emi.api.widget.Bounds;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
import net.minecraft.item.ItemStack;
import pm.c7.scout.ScoutUtil;
import pm.c7.scout.item.BaseBagItem;
import pm.c7.scout.item.BaseBagItem.BagType;
import pm.c7.scout.mixin.client.HandledScreenAccessor;
public class ScoutEmiPlugin implements EmiPlugin {
@Override
public void register(EmiRegistry registry) {
registry.addExclusionArea(InventoryScreen.class, (screen, consumer) -> {
MinecraftClient client = MinecraftClient.getInstance();
ItemStack leftPouchStack = ScoutUtil.findBagItem(client.player, BagType.POUCH, false);
if (!leftPouchStack.isEmpty()) {
BaseBagItem bagItem = (BaseBagItem) leftPouchStack.getItem();
int slots = bagItem.getSlotCount();
int columns = (int) Math.ceil(slots / 3);
int x = ((HandledScreenAccessor) screen).getX() - (columns * 18);
int y = ((HandledScreenAccessor) screen).getY() + 76;
consumer.accept(new Bounds(x, y, columns * 18, 68));
}
ItemStack rightPouchStack = ScoutUtil.findBagItem(client.player, BagType.POUCH, true);
if (!rightPouchStack.isEmpty()) {
BaseBagItem bagItem = (BaseBagItem) rightPouchStack.getItem();
int slots = bagItem.getSlotCount();
int columns = (int) Math.ceil(slots / 3);
int x = ((HandledScreenAccessor) screen).getX() + 176;
int y = ((HandledScreenAccessor) screen).getY() + 76;
consumer.accept(new Bounds(x, y, columns * 18, 68));
}
});
}
}

View File

@ -0,0 +1,60 @@
package pm.c7.scout.client.gui;
import com.google.common.math.IntMath;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.tooltip.TooltipComponent;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
import net.minecraft.util.collection.DefaultedList;
import pm.c7.scout.ScoutUtil;
import pm.c7.scout.item.BagTooltipData;
import java.math.RoundingMode;
public class BagTooltipComponent implements TooltipComponent {
private final DefaultedList<ItemStack> inventory;
private final int slotCount;
public BagTooltipComponent(BagTooltipData data) {
this.inventory = data.getInventory();
this.slotCount = data.getSlotCount();
}
@Override
public int getHeight() {
return (18 * IntMath.divide(slotCount, 6, RoundingMode.UP)) + 2;
}
@Override
public int getWidth(TextRenderer textRenderer) {
return 18 * (Math.min(slotCount, 6));
}
@Override
public void drawItems(TextRenderer textRenderer, int x, int y, MatrixStack matrices, ItemRenderer itemRenderer, int z) {
int originalX = x;
for (int i = 0; i < slotCount; i++) {
ItemStack itemStack = this.inventory.get(i);
this.drawSlot(matrices, x, y, z);
itemRenderer.renderInGuiWithOverrides(itemStack, x + 1, y + 1, i);
itemRenderer.renderGuiItemOverlay(textRenderer, itemStack, x + 1, y + 1);
x += 18;
if ((i + 1) % 6 == 0) {
y += 18;
x = originalX;
}
}
}
private void drawSlot(MatrixStack matrices, int x, int y, int z) {
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderTexture(0, ScoutUtil.SLOT_TEXTURE);
DrawableHelper.drawTexture(matrices, x, y, z, 46, 7, 18, 18, 256, 256);
}
}

View File

@ -0,0 +1,45 @@
package pm.c7.scout.client.model;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.model.*;
import net.minecraft.client.render.entity.model.SinglePartEntityModel;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.LivingEntity;
public class SatchelModel<T extends LivingEntity> extends SinglePartEntityModel<T> {
private final ModelPart root;
private final ModelPart satchel;
private final ModelPart strap;
public SatchelModel(ModelPart root) {
super();
this.root = root;
this.satchel = root.getChild("satchel");
this.strap = this.satchel.getChild("strap");
}
public static TexturedModelData getTexturedModelData() {
ModelData modelData = new ModelData();
ModelPartData root = modelData.getRoot();
ModelPartData satchel = root.addChild("satchel", ModelPartBuilder.create().uv(10, 0).cuboid(-6.0F, -12.0F, -2.5F, 2.0F, 3.0F, 5.0F, new Dilation(0.275F)), ModelTransform.pivot(0.0F, 24.0F, 0.0F));
ModelPartData strap = satchel.addChild("strap", ModelPartBuilder.create().uv(0, 0).cuboid(-1.0F, -13.0F, -2.0F, 1.0F, 14.0F, 4.0F, new Dilation(0.275F)), ModelTransform.of(-3.0F, -13.0F, 0.0F, 0.0F, 0.0F, 0.5672F));
return TexturedModelData.of(modelData, 32, 32);
}
@Override
public void render(MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) {
satchel.render(matrices, vertices, light, overlay, red, green, blue, alpha);
}
@Override
public ModelPart getPart() {
return this.root;
}
@Override
public void setAngles(T entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) {
}
}

View File

@ -0,0 +1,50 @@
package pm.c7.scout.client.render;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.feature.FeatureRenderer;
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.render.entity.model.PlayerEntityModel;
import net.minecraft.client.render.item.HeldItemRenderer;
import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.Vec3f;
import pm.c7.scout.ScoutUtil;
import pm.c7.scout.item.BaseBagItem;
public class PouchFeatureRenderer<T extends LivingEntity, M extends EntityModel<T>> extends FeatureRenderer<T, M> {
private final HeldItemRenderer heldItemRenderer;
public PouchFeatureRenderer(FeatureRendererContext<T, M> context, HeldItemRenderer heldItemRenderer) {
super(context);
this.heldItemRenderer = heldItemRenderer;
}
@Override
public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, T entity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) {
var leftPouch = ScoutUtil.findBagItem((PlayerEntity) entity, BaseBagItem.BagType.POUCH, false);
var rightPouch = ScoutUtil.findBagItem((PlayerEntity) entity, BaseBagItem.BagType.POUCH, true);
if (!leftPouch.isEmpty()) {
matrices.push();
((PlayerEntityModel<?>) this.getContextModel()).leftLeg.rotate(matrices);
matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(180.0F));
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-90.0F));
matrices.scale(0.325F, 0.325F, 0.325F);
matrices.translate(0F, -0.325F, -0.475F);
this.heldItemRenderer.renderItem(entity, leftPouch, ModelTransformation.Mode.FIXED, false, matrices, vertexConsumers, light);
matrices.pop();
}
if (!rightPouch.isEmpty()) {
matrices.push();
((PlayerEntityModel<?>) this.getContextModel()).rightLeg.rotate(matrices);
matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(180.0F));
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-90.0F));
matrices.scale(0.325F, 0.325F, 0.325F);
matrices.translate(0F, -0.325F, 0.475F);
this.heldItemRenderer.renderItem(entity, rightPouch, ModelTransformation.Mode.FIXED, false, matrices, vertexConsumers, light);
matrices.pop();
}
}
}

View File

@ -0,0 +1,53 @@
package pm.c7.scout.client.render;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.model.TexturedModelData;
import net.minecraft.client.render.OverlayTexture;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.feature.FeatureRenderer;
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
import net.minecraft.client.render.entity.model.EntityModel;
import net.minecraft.client.render.entity.model.PlayerEntityModel;
import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Identifier;
import pm.c7.scout.ScoutUtil;
import pm.c7.scout.client.model.SatchelModel;
import pm.c7.scout.item.BaseBagItem;
public class SatchelFeatureRenderer<T extends LivingEntity, M extends EntityModel<T>> extends FeatureRenderer<T, M> {
private static final Identifier SATCHEL_TEXTURE = new Identifier(ScoutUtil.MOD_ID, "textures/entity/satchel.png");
private static final Identifier UPGRADED_SATCHEL_TEXTURE = new Identifier(ScoutUtil.MOD_ID, "textures/entity/upgraded_satchel.png");
private final SatchelModel<T> satchel;
public SatchelFeatureRenderer(FeatureRendererContext<T, M> context) {
super(context);
TexturedModelData modelData = SatchelModel.getTexturedModelData();
this.satchel = new SatchelModel<>(modelData.createModel());
}
@Override
public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, T entity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) {
var satchel = ScoutUtil.findBagItem((PlayerEntity) entity, BaseBagItem.BagType.SATCHEL, false);
if (!satchel.isEmpty()) {
BaseBagItem satchelItem = (BaseBagItem) satchel.getItem();
var texture = SATCHEL_TEXTURE;
if (satchelItem.getSlotCount() == ScoutUtil.MAX_SATCHEL_SLOTS)
texture = UPGRADED_SATCHEL_TEXTURE;
matrices.push();
((PlayerEntityModel<?>) this.getContextModel()).body.rotate(matrices);
this.getContextModel().copyStateTo(this.satchel);
VertexConsumer vertexConsumer = ItemRenderer.getArmorGlintConsumer(
vertexConsumers, RenderLayer.getArmorCutoutNoCull(texture), false, satchel.hasGlint()
);
this.satchel.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F);
matrices.pop();
}
}
}

View File

@ -0,0 +1,12 @@
package pm.c7.scout.config;
import org.quiltmc.config.api.WrappedConfig;
import org.quiltmc.config.api.annotations.Comment;
public class ScoutConfig extends WrappedConfig {
@Comment("Allow shulker boxes to be placed in bags. Bags are already blacklisted from shulker boxes with no toggle.")
public final boolean allowShulkers = true;
@Comment("Allow bags to act as a quiver and pull arrows.")
public final boolean useArrows = true;
}

View File

@ -0,0 +1,17 @@
package pm.c7.scout.config;
import org.quiltmc.config.api.values.TrackedValue;
import org.quiltmc.loader.api.config.QuiltConfig;
import pm.c7.scout.ScoutUtil;
import java.util.List;
public class ScoutConfigHandler {
public static final ScoutConfig CONFIG = QuiltConfig.create("", ScoutUtil.MOD_ID, ScoutConfig.class);
public ScoutConfigHandler() {}
public static TrackedValue<?> getConfigValue(String key) {
return CONFIG.getValue(List.of(key));
}
}

View File

@ -0,0 +1,23 @@
package pm.c7.scout.item;
import net.minecraft.client.item.TooltipData;
import net.minecraft.item.ItemStack;
import net.minecraft.util.collection.DefaultedList;
public class BagTooltipData implements TooltipData {
private final DefaultedList<ItemStack> inventory;
private final int slotCount;
public BagTooltipData(DefaultedList<ItemStack> inventory, int slots) {
this.inventory = inventory;
this.slotCount = slots;
}
public DefaultedList<ItemStack> getInventory() {
return this.inventory;
}
public int getSlotCount() {
return this.slotCount;
}
}

View File

@ -0,0 +1,226 @@
package pm.c7.scout.item;
import dev.emi.trinkets.api.SlotReference;
import dev.emi.trinkets.api.TrinketItem;
import io.netty.buffer.Unpooled;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.client.item.TooltipData;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import