commit c4a2e8e52977be84983447c62d21a3be29af7846 Author: TheBrokenRail Date: Sat Jun 13 23:04:21 2020 -0400 Initial Commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..550b373 --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +# gradle + +.gradle/ +build/ +out/ +classes/ + +# eclipse + +*.launch + +# idea + +.idea/ +*.iml +*.ipr +*.iws + +# vscode + +.settings/ +.vscode/ +bin/ +.classpath +.project + +# fabric + +run/ diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..1673e44 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,19 @@ +pipeline { + agent { + docker { + image 'openjdk:8-jdk' + } + } + stages { + stage('Build') { + steps { + sh './gradlew build' + } + post { + success { + archiveArtifacts artifacts: 'build/libs/*', fingerprint: true + } + } + } + } +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..886b254 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 TheBrokenRail + +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. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e4a0719 --- /dev/null +++ b/README.md @@ -0,0 +1,49 @@ +# Twine +A simple survival mod for Minecraft encouraging a nomadic lifestyle. + +## Backpacks +A backpack can only hold one type of item or only hold unstackable items. + +### Small Backpack Recipe + + + + +
StickLeatherStick
LeatherIron IngotLeather
StickLeatherStick
+ +### Large Backpack Recipe +Combine a Small Backpack with a Gold Ingot in the Smithing Table. + +### Dye Backpack Recipe +Combine a Backpack with a dye in the Crafting Table. + +## Glowing Obsidian +Glowing Obsidian heals monsters and hurts everything else. It naturally generates in small patches underground. + +### Recipe + + + + +
Redstone
RedstoneObsidianRedstone
Redstone
+ +## Difficulty Stages + +### Stage 1 +- Normal Gameplay + +### Stage 2 + +### Stage 3 +- Hostile Mobs Attack Passive Mobs + +### Stage 4 +- Villages Kick You Out (Using Iron Golems) + +### Stage 5 +- Neural Mobs Are Always Hostile + +### Stage 6 + +### Technical Details +Each player has a 6-element long list in their data. Each element in the list has a chunk position and time value. Every tick the player will first, find the stage element its current position is in, and increase the time value of that stage element. If the time value when increased is over 24,000 ticks the next stage element will have its chunk set to the players current position, have its time value reset, the old stage element will have the next stage element's old chunk, and have its time value reset. To determine if a player is in a stage element, it checks if the player is within 16 chunks of the stage element's chunk, it starts searching at the last element, ending at the first. The "global" stage element of a chunk can be found by searching every player for their stage element for the chunk and then picking the highest value. \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..940f839 --- /dev/null +++ b/build.gradle @@ -0,0 +1,76 @@ +plugins { + id 'fabric-loom' version '0.4-SNAPSHOT' + id 'maven-publish' +} + +sourceCompatibility = JavaVersion.VERSION_1_8 +targetCompatibility = JavaVersion.VERSION_1_8 + +version = project.mod_version +group = project.maven_group + +repositories { + maven { + name = "Ladysnake Libs" + url = 'https://dl.bintray.com/ladysnake/libs' + } +} + +dependencies { + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings "net.fabricmc:yarn:${project.minecraft_version}+build.${project.yarn_build}:v2" + modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_version}" + + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}" +} + +processResources { + inputs.property "version", project.version + + from(sourceSets.main.resources.srcDirs) { + include "fabric.mod.json" + expand "version": project.version + } + + from(sourceSets.main.resources.srcDirs) { + exclude "fabric.mod.json" + } +} + +// ensure that the encoding is set to UTF-8, no matter what the system default is +// this fixes some edge cases with special characters not displaying correctly +// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html +tasks.withType(JavaCompile) { + options.encoding = "UTF-8" +} + +// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task +// if it is present. +// If you remove this task, sources will not be generated. +task sourcesJar(type: Jar, dependsOn: classes) { + classifier "sources" + from sourceSets.main.allSource +} + +jar { + from "LICENSE" +} + +// configure the maven publication +publishing { + publications { + mavenJava(MavenPublication) { + artifact(remapJar) { + builtBy remapJar + } + artifact(sourcesJar) { + builtBy remapSourcesJar + } + } + } + repositories { + maven { + url "/data/maven" + } + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..db6c0f4 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,17 @@ +# Done to increase the memory available to gradle. +org.gradle.jvmargs = -Xmx1G + +# Fabric Properties + # check these on https://fabricmc.net/use + minecraft_version = 1.16-pre5 + yarn_build = 1 + fabric_loader_version = 0.8.7+build.201 + +# Mod Properties + mod_version = 1.0.0 + maven_group = com.thebrokenrail + +# Dependencies + # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api + fabric_api_version = 0.12.1+build.361-1.16 + cardinal_components_version = 2.4.0-nightly.1.16-pre4 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..490fda8 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..f6c09cc --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jun 12 20:49:10 EDT 2020 +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..2fe81a7 --- /dev/null +++ b/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or 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 UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# 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"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# 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 + ;; + 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" + which java >/dev/null 2>&1 || 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 + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..62bd9b9 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,103 @@ +@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=. +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%" == "0" goto init + +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 init + +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 + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +: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 %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="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! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..df54f09 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,12 @@ +pluginManagement { + repositories { + jcenter() + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + gradlePluginPortal() + } +} + +rootProject.name = "twine" diff --git a/src/main/java/com/thebrokenrail/twine/Twine.java b/src/main/java/com/thebrokenrail/twine/Twine.java new file mode 100644 index 0000000..10e96ce --- /dev/null +++ b/src/main/java/com/thebrokenrail/twine/Twine.java @@ -0,0 +1,47 @@ +package com.thebrokenrail.twine; + +import com.thebrokenrail.twine.block.GlowingObsidianBlock; +import com.thebrokenrail.twine.item.BackpackItem; +import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder; +import net.fabricmc.fabric.api.container.ContainerProviderRegistry; +import net.minecraft.item.BlockItem; +import net.minecraft.item.Item; +import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemStack; +import net.minecraft.screen.GenericContainerScreenHandler; +import net.minecraft.screen.ScreenHandlerType; +import net.minecraft.util.Hand; +import net.minecraft.util.Identifier; +import net.minecraft.util.registry.Registry; + +public class Twine implements ModInitializer { + public static final String NAMESPACE = "twine"; + + public static final GlowingObsidianBlock GLOWING_OBSIDIAN = new GlowingObsidianBlock(); + + public static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.build(new Identifier(NAMESPACE, "item_group"), () -> new ItemStack(GLOWING_OBSIDIAN)); + + public static final Identifier BACKPACK_SCREEN = new Identifier(NAMESPACE, "backpack"); + public static final Item SMALL_BACKPACK = new BackpackItem(false); + public static final Item LARGE_BACKPACK = new BackpackItem(true); + + public static final int STAGE_COUNT = 6; + public static final int STAGE_TIME = 24000; + + @Override + public void onInitialize() { + ContainerProviderRegistry.INSTANCE.registerFactory(BACKPACK_SCREEN, (i, identifier, playerEntity, buf) -> { + boolean large = buf.readBoolean(); + Hand hand = buf.readEnumConstant(Hand.class); + int rows = large ? 6 : 3; + ItemStack stack = playerEntity.getStackInHand(hand); + return new GenericContainerScreenHandler(ScreenHandlerType.STONECUTTER, i, playerEntity.inventory, new BackpackItem.ItemInventory(9 * rows, stack, hand), rows); + }); + Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "small_backpack"), SMALL_BACKPACK); + Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "large_backpack"), LARGE_BACKPACK); + + Registry.register(Registry.BLOCK, new Identifier(NAMESPACE, "glowing_obsidian"), GLOWING_OBSIDIAN); + Registry.register(Registry.ITEM, new Identifier(NAMESPACE, "glowing_obsidian"), new BlockItem(GLOWING_OBSIDIAN, new Item.Settings().group(ITEM_GROUP))); + } +} diff --git a/src/main/java/com/thebrokenrail/twine/block/GlowingObsidianBlock.java b/src/main/java/com/thebrokenrail/twine/block/GlowingObsidianBlock.java new file mode 100644 index 0000000..6317aee --- /dev/null +++ b/src/main/java/com/thebrokenrail/twine/block/GlowingObsidianBlock.java @@ -0,0 +1,31 @@ +package com.thebrokenrail.twine.block; + +import net.minecraft.block.Block; +import net.minecraft.block.Material; +import net.minecraft.block.MaterialColor; +import net.minecraft.entity.AreaEffectCloudEntity; +import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.damage.DamageSource; +import net.minecraft.entity.mob.Monster; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +public class GlowingObsidianBlock extends Block { + public GlowingObsidianBlock() { + super(Settings.of(Material.STONE, MaterialColor.BLACK).requiresTool().strength(50.0F, 1200.0F).lightLevel(state -> 4)); + } + + @Override + public void onSteppedOn(World world, BlockPos pos, Entity entity) { + super.onSteppedOn(world, pos, entity); + if (entity instanceof LivingEntity && entity.age % 5 == 0) { + final float amount = 1f; + if (entity instanceof Monster) { + ((LivingEntity) entity).heal(amount); + } else { + entity.damage(DamageSource.MAGIC, amount); + } + } + } +} diff --git a/src/main/java/com/thebrokenrail/twine/client/TwineClient.java b/src/main/java/com/thebrokenrail/twine/client/TwineClient.java new file mode 100644 index 0000000..ee3019e --- /dev/null +++ b/src/main/java/com/thebrokenrail/twine/client/TwineClient.java @@ -0,0 +1,27 @@ +package com.thebrokenrail.twine.client; + +import com.thebrokenrail.twine.Twine; +import com.thebrokenrail.twine.item.BackpackItem; +import net.fabricmc.api.ClientModInitializer; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; +import net.fabricmc.fabric.api.client.screen.ScreenProviderRegistry; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.ingame.GenericContainerScreen; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.DyeableItem; +import net.minecraft.screen.GenericContainerScreenHandler; + +@Environment(EnvType.CLIENT) +public class TwineClient implements ClientModInitializer { + @Override + public void onInitializeClient() { + ScreenProviderRegistry.INSTANCE.registerFactory(Twine.BACKPACK_SCREEN, screenHandler -> { + PlayerEntity player = MinecraftClient.getInstance().player; + assert player != null; + return new GenericContainerScreen((GenericContainerScreenHandler) screenHandler, player.inventory, ((BackpackItem.ItemInventory) ((GenericContainerScreenHandler) screenHandler).getInventory()).getHolder().getName()); + }); + ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex > 0 ? -1 : ((DyeableItem) stack.getItem()).getColor(stack), Twine.SMALL_BACKPACK, Twine.LARGE_BACKPACK); + } +} diff --git a/src/main/java/com/thebrokenrail/twine/component/StageDataComponent.java b/src/main/java/com/thebrokenrail/twine/component/StageDataComponent.java new file mode 100644 index 0000000..ba4f468 --- /dev/null +++ b/src/main/java/com/thebrokenrail/twine/component/StageDataComponent.java @@ -0,0 +1,110 @@ +package com.thebrokenrail.twine.component; + +import com.thebrokenrail.twine.Twine; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.Tag; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.ChunkPos; +import net.minecraft.world.PersistentState; + +import java.util.*; + +public class StageDataComponent extends PersistentState { + public StageDataComponent(String key) { + super(key); + } + + public static class StageData { + public int x; + public int z; + public long time = 0; + } + + private final Map data = new HashMap<>(); + + public StageData[] getData(UUID uuid) { + return data.computeIfAbsent(uuid, k -> new StageData[Twine.STAGE_COUNT]); + } + + private static final int CHUNK_RADIUS = 16; + private static final String STAGE_DATA_ID = "twine_stage_data"; + + public static int findStageOfChunk(ChunkPos pos, StageDataComponent.StageData[] data) { + for (int i = Twine.STAGE_COUNT - 1; i >= 0; i--) { + StageDataComponent.StageData stage = data[i]; + if (stage != null && Math.abs(stage.x - pos.x) <= CHUNK_RADIUS && Math.abs(stage.z - pos.z) <= CHUNK_RADIUS) { + return i; + } + } + data[0] = new StageDataComponent.StageData(); + data[0].x = pos.x; + data[0].z = pos.z; + return 0; + } + + public int findStageOfChunk(ChunkPos pos) { + Collection values = data.values(); + int stage = 0; + for (StageData[] value : values) { + stage = Math.max(stage, findStageOfChunk(pos, value)); + } + return stage; + } + + public static StageDataComponent getFromWorld(ServerWorld world) { + return world.getPersistentStateManager().getOrCreate(() -> new StageDataComponent(STAGE_DATA_ID), STAGE_DATA_ID); + } + + @Override + public void fromTag(CompoundTag compoundTag) { + data.clear(); + Tag uuidTag = compoundTag.get("Data"); + if (uuidTag instanceof ListTag) { + for (int i = 0 ; i < ((ListTag) uuidTag).size(); i++) { + CompoundTag obj = ((ListTag) uuidTag).getCompound(i); + UUID uuid = obj.getUuid("UUID"); + + Tag tag = obj.get("Stages"); + StageData[] newData = new StageData[Twine.STAGE_COUNT]; + if (tag instanceof ListTag) { + for (int k = 0; k < ((ListTag) tag).size(); k++) { + Tag newTag = ((ListTag) tag).get(k); + if (newTag instanceof CompoundTag) { + StageData stage = new StageData(); + stage.x = ((CompoundTag) newTag).getInt("X"); + stage.z = ((CompoundTag) newTag).getInt("Z"); + stage.time = ((CompoundTag) newTag).getLong("Time"); + newData[((CompoundTag) newTag).getInt("Index")] = stage; + } + } + data.put(uuid, newData); + } + } + } + } + + @Override + public CompoundTag toTag(CompoundTag compoundTag) { + ListTag list = new ListTag(); + for (Map.Entry entry : data.entrySet()) { + CompoundTag obj = new CompoundTag(); + obj.putUuid("UUID", entry.getKey()); + ListTag newList = new ListTag(); + for (int i = 0; i < Twine.STAGE_COUNT; i++) { + if (entry.getValue()[i] != null) { + CompoundTag tag = new CompoundTag(); + tag.putInt("X", entry.getValue()[i].x); + tag.putInt("Z", entry.getValue()[i].z); + tag.putLong("Time", entry.getValue()[i].time); + tag.putInt("Index", i); + newList.add(tag); + } + } + obj.put("Stages", newList); + list.add(obj); + } + compoundTag.put("Data", list); + return compoundTag; + } +} diff --git a/src/main/java/com/thebrokenrail/twine/entity/FollowPassiveEntityGoal.java b/src/main/java/com/thebrokenrail/twine/entity/FollowPassiveEntityGoal.java new file mode 100644 index 0000000..1a302cc --- /dev/null +++ b/src/main/java/com/thebrokenrail/twine/entity/FollowPassiveEntityGoal.java @@ -0,0 +1,32 @@ +package com.thebrokenrail.twine.entity; + +import com.thebrokenrail.twine.component.StageDataComponent; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.ai.goal.FollowTargetGoal; +import net.minecraft.entity.mob.Angerable; +import net.minecraft.entity.mob.HostileEntity; +import net.minecraft.entity.mob.MobEntity; +import net.minecraft.entity.passive.PassiveEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.ChunkPos; + +public class FollowPassiveEntityGoal extends FollowTargetGoal { + public FollowPassiveEntityGoal(MobEntity mob) { + super(mob, LivingEntity.class, 10, false, false, entity -> { + StageDataComponent component = StageDataComponent.getFromWorld((ServerWorld) mob.getEntityWorld()); + ChunkPos chunkPos = new ChunkPos(mob.getBlockPos()); + int stage = component.findStageOfChunk(chunkPos); + + return entity instanceof PassiveEntity || (entity instanceof PlayerEntity && stage >= 4); + }); + } + + public boolean canStart() { + StageDataComponent component = StageDataComponent.getFromWorld((ServerWorld) mob.getEntityWorld()); + ChunkPos chunkPos = new ChunkPos(mob.getBlockPos()); + int stage = component.findStageOfChunk(chunkPos); + + return mob instanceof HostileEntity && (!(mob instanceof Angerable) || stage >= 4) && stage >= 2 && super.canStart(); + } +} diff --git a/src/main/java/com/thebrokenrail/twine/entity/StandOnGlowingObsidian.java b/src/main/java/com/thebrokenrail/twine/entity/StandOnGlowingObsidian.java new file mode 100644 index 0000000..a0a8c1c --- /dev/null +++ b/src/main/java/com/thebrokenrail/twine/entity/StandOnGlowingObsidian.java @@ -0,0 +1,30 @@ +package com.thebrokenrail.twine.entity; + +import com.thebrokenrail.twine.Twine; +import net.minecraft.entity.ai.goal.MoveToTargetPosGoal; +import net.minecraft.entity.mob.MobEntityWithAi; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.WorldView; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.ChunkStatus; + +public class StandOnGlowingObsidian extends MoveToTargetPosGoal { + public StandOnGlowingObsidian(MobEntityWithAi mob) { + super(mob, 1d, 24); + } + + @Override + protected boolean isTargetPos(WorldView world, BlockPos pos) { + Chunk chunk = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.FULL, false); + if (chunk == null) { + return false; + } else { + return chunk.getBlockState(pos).isOf(Twine.GLOWING_OBSIDIAN) && chunk.getBlockState(pos.up()).isAir() && chunk.getBlockState(pos.up(2)).isAir(); + } + } + + @Override + public boolean canStart() { + return super.canStart() && (mob.getHealth() / mob.getMaxHealth()) <= 0.5; + } +} diff --git a/src/main/java/com/thebrokenrail/twine/item/BackpackItem.java b/src/main/java/com/thebrokenrail/twine/item/BackpackItem.java new file mode 100644 index 0000000..bb7eca3 --- /dev/null +++ b/src/main/java/com/thebrokenrail/twine/item/BackpackItem.java @@ -0,0 +1,134 @@ +package com.thebrokenrail.twine.item; + +import com.thebrokenrail.twine.Twine; +import com.thebrokenrail.twine.component.StageDataComponent; +import net.fabricmc.fabric.api.container.ContainerProviderRegistry; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.inventory.Inventories; +import net.minecraft.inventory.Inventory; +import net.minecraft.item.DyeableItem; +import net.minecraft.item.Item; +import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemStack; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.text.LiteralText; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; +import net.minecraft.util.TypedActionResult; +import net.minecraft.util.collection.DefaultedList; +import net.minecraft.util.math.ChunkPos; +import net.minecraft.world.World; + +public class BackpackItem extends Item implements DyeableItem { + public static class ItemInventory implements Inventory { + private final int size; + private final ItemStack stack; + private final Hand hand; + private final DefaultedList inv; + + public ItemInventory(int size, ItemStack stack, Hand hand) { + this.size = size; + this.stack = stack; + this.hand = hand; + inv = getInv(); + } + + public ItemStack getHolder() { + return stack; + } + + private DefaultedList getInv() { + DefaultedList list = DefaultedList.ofSize(size, ItemStack.EMPTY); + Inventories.fromTag(stack.getOrCreateTag(), list); + return list; + } + + private void setInv(DefaultedList list) { + Inventories.toTag(stack.getOrCreateTag(), list); + } + + @Override + public int size() { + return size; + } + + @Override + public boolean isEmpty() { + for (ItemStack item : inv) { + if (item != ItemStack.EMPTY) { + return false; + } + } + return true; + } + + @Override + public ItemStack getStack(int slot) { + return inv.get(slot); + } + + @Override + public ItemStack removeStack(int slot, int amount) { + return inv.get(slot).split(amount); + } + + @Override + public ItemStack removeStack(int slot) { + ItemStack item = inv.get(slot); + return item.split(item.getCount()); + } + + @Override + public void setStack(int slot, ItemStack stack) { + inv.set(slot, stack); + } + + @Override + public void markDirty() { + setInv(inv); + } + + @Override + public boolean canPlayerUse(PlayerEntity player) { + return player.getStackInHand(hand) == stack; + } + + @Override + public void clear() { + for (int i = 0; i < size; i++) { + inv.set(i, ItemStack.EMPTY); + } + } + } + + private final boolean large; + + public BackpackItem(boolean large) { + super(new Settings().maxCount(1).group(Twine.ITEM_GROUP)); + this.large = large; + } + + @Override + public TypedActionResult use(World world, PlayerEntity user, Hand hand) { + ItemStack stack = user.getStackInHand(hand); + if (!world.isClient()) { + ContainerProviderRegistry.INSTANCE.openContainer(Twine.BACKPACK_SCREEN, user, buf -> { + buf.writeBoolean(large); + buf.writeEnumConstant(hand); + }); + + StageDataComponent component = StageDataComponent.getFromWorld((ServerWorld) world); + ChunkPos chunkPos = new ChunkPos(user.getBlockPos()); + + int stage = component.findStageOfChunk(chunkPos); + user.sendMessage(new LiteralText("Global Stage: " + stage), false); + + StageDataComponent.StageData[] personalData = component.getData(user.getUuid()); + int personalStage = StageDataComponent.findStageOfChunk(chunkPos, personalData); + user.sendMessage(new LiteralText("Personal Stage: " + personalStage), false); + user.sendMessage(new LiteralText("Personal Center Chunk X: " + personalData[personalStage].x + " Personal Center Chunk Z: " + personalData[personalStage].z), false); + user.sendMessage(new LiteralText("Time To Personal Stage Increase: " + (Twine.STAGE_TIME - personalData[personalStage].time) + " Ticks"), false); + } + return new TypedActionResult<>(ActionResult.CONSUME, stack); + } +} diff --git a/src/main/java/com/thebrokenrail/twine/mixin/MixinDefaultBiomeFeatures.java b/src/main/java/com/thebrokenrail/twine/mixin/MixinDefaultBiomeFeatures.java new file mode 100644 index 0000000..778cec0 --- /dev/null +++ b/src/main/java/com/thebrokenrail/twine/mixin/MixinDefaultBiomeFeatures.java @@ -0,0 +1,22 @@ +package com.thebrokenrail.twine.mixin; + +import com.thebrokenrail.twine.Twine; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.gen.GenerationStep; +import net.minecraft.world.gen.decorator.Decorator; +import net.minecraft.world.gen.decorator.RangeDecoratorConfig; +import net.minecraft.world.gen.feature.DefaultBiomeFeatures; +import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.OreFeatureConfig; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(DefaultBiomeFeatures.class) +public class MixinDefaultBiomeFeatures { + @Inject(at = @At("RETURN"), method = "addMineables") + private static void addMineables(Biome biome, CallbackInfo info) { + biome.addFeature(GenerationStep.Feature.UNDERGROUND_ORES, Feature.ORE.configure(new OreFeatureConfig(OreFeatureConfig.Target.NATURAL_STONE, Twine.GLOWING_OBSIDIAN.getDefaultState(), 14)).createDecoratedFeature(Decorator.COUNT_RANGE.configure(new RangeDecoratorConfig(8, 0, 0, 32)))); + } +} diff --git a/src/main/java/com/thebrokenrail/twine/mixin/MixinMobEntity.java b/src/main/java/com/thebrokenrail/twine/mixin/MixinMobEntity.java new file mode 100644 index 0000000..834150e --- /dev/null +++ b/src/main/java/com/thebrokenrail/twine/mixin/MixinMobEntity.java @@ -0,0 +1,52 @@ +package com.thebrokenrail.twine.mixin; + +import com.thebrokenrail.twine.component.StageDataComponent; +import com.thebrokenrail.twine.entity.FollowPassiveEntityGoal; +import com.thebrokenrail.twine.entity.StandOnGlowingObsidian; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.ai.goal.FollowTargetGoal; +import net.minecraft.entity.ai.goal.GoalSelector; +import net.minecraft.entity.mob.*; +import net.minecraft.entity.passive.IronGolemEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.ChunkPos; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@SuppressWarnings("ConstantConditions") +@Mixin(MobEntity.class) +public class MixinMobEntity { + @Shadow + @Final + protected GoalSelector targetSelector; + + @Shadow + @Final + protected GoalSelector goalSelector; + + @Inject(at = @At("RETURN"), method = "") + public void initGoals(EntityType entityType, World world, CallbackInfo info) { + if (world != null && !world.isClient()) { + if (this instanceof Monster) { + if ((Object) this instanceof MobEntityWithAi) { + goalSelector.add(1, new StandOnGlowingObsidian((MobEntityWithAi) (Object) this)); + } + targetSelector.add(2, new FollowPassiveEntityGoal((MobEntity) (Object) this)); + } else if ((Object) this instanceof IronGolemEntity) { + targetSelector.add(3, new FollowTargetGoal<>((IronGolemEntity) (Object) this, PlayerEntity.class, 10, true, false, entity -> { + StageDataComponent component = StageDataComponent.getFromWorld((ServerWorld) ((IronGolemEntity) (Object) this).getEntityWorld()); + ChunkPos chunkPos = new ChunkPos(((IronGolemEntity) (Object) this).getBlockPos()); + int stage = component.findStageOfChunk(chunkPos); + + return stage >= 3 && !((IronGolemEntity) (Object) this).isPlayerCreated(); + })); + } + } + } +} diff --git a/src/main/java/com/thebrokenrail/twine/mixin/MixinServerPlayerEntity.java b/src/main/java/com/thebrokenrail/twine/mixin/MixinServerPlayerEntity.java new file mode 100644 index 0000000..f926ffb --- /dev/null +++ b/src/main/java/com/thebrokenrail/twine/mixin/MixinServerPlayerEntity.java @@ -0,0 +1,56 @@ +package com.thebrokenrail.twine.mixin; + +import com.thebrokenrail.twine.Twine; +import com.thebrokenrail.twine.component.StageDataComponent; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.ChunkPos; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(ServerPlayerEntity.class) +public abstract class MixinServerPlayerEntity { + @Shadow + public abstract ServerWorld getServerWorld(); + + @Unique + private ChunkPos getChunkPos() { + return new ChunkPos(((ServerPlayerEntity) (Object) this).getBlockPos()); + } + + @Unique + private long lastTime = -1L; + + @Inject(at = @At("RETURN"), method = "tick") + public void tick(CallbackInfo info) { + StageDataComponent component = StageDataComponent.getFromWorld(getServerWorld()); + StageDataComponent.StageData[] data = component.getData(((ServerPlayerEntity) (Object) this).getUuid()); + int stage = StageDataComponent.findStageOfChunk(getChunkPos(), data); + StageDataComponent.StageData stageObj = data[stage]; + if (lastTime != -1) { + long diff = Math.max(0, getServerWorld().getTime() - lastTime); + if (diff > 5) { + System.out.println(diff); + } + stageObj.time = stageObj.time + Math.max(0, getServerWorld().getTime() - lastTime); + } + lastTime = getServerWorld().getTime(); + if (stageObj.time >= 24000 && stage + 1 < Twine.STAGE_COUNT) { + StageDataComponent.StageData old = data[stage + 1]; + if (old != null) { + old.time = 0; + } + StageDataComponent.StageData newData = new StageDataComponent.StageData(); + ChunkPos pos = getChunkPos(); + newData.x = pos.x; + newData.z = pos.z; + data[stage + 1] = newData; + data[stage] = old; + } + component.markDirty(); + } +} diff --git a/src/main/java/com/thebrokenrail/twine/mixin/MixinSlot.java b/src/main/java/com/thebrokenrail/twine/mixin/MixinSlot.java new file mode 100644 index 0000000..98fceb6 --- /dev/null +++ b/src/main/java/com/thebrokenrail/twine/mixin/MixinSlot.java @@ -0,0 +1,36 @@ +package com.thebrokenrail.twine.mixin; + +import com.thebrokenrail.twine.item.BackpackItem; +import net.minecraft.inventory.Inventory; +import net.minecraft.item.ItemStack; +import net.minecraft.screen.slot.Slot; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(Slot.class) +public class MixinSlot { + @Shadow + @Final + public Inventory inventory; + + @Inject(at = @At("HEAD"), method = "canInsert", cancellable = true) + public void canInsert(ItemStack stack, CallbackInfoReturnable info) { + if (inventory instanceof BackpackItem.ItemInventory) { + if (stack.getItem() instanceof BackpackItem) { + info.setReturnValue(false); + return; + } + for (int i = 0; i < inventory.size(); i++) { + ItemStack item = inventory.getStack(i); + if (item != ItemStack.EMPTY && (item.getItem() != stack.getItem() && (item.getMaxCount() != 1 || stack.getMaxCount() != 1))) { + info.setReturnValue(false); + return; + } + } + } + } +} diff --git a/src/main/resources/assets/twine/blockstates/glowing_obsidian.json b/src/main/resources/assets/twine/blockstates/glowing_obsidian.json new file mode 100644 index 0000000..7621ba7 --- /dev/null +++ b/src/main/resources/assets/twine/blockstates/glowing_obsidian.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "twine:block/glowing_obsidian" + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/twine/lang/en_us.json b/src/main/resources/assets/twine/lang/en_us.json new file mode 100644 index 0000000..42e19a2 --- /dev/null +++ b/src/main/resources/assets/twine/lang/en_us.json @@ -0,0 +1,6 @@ +{ + "item.twine.large_backpack": "Large Backpack", + "item.twine.small_backpack": "Small Backpack", + "itemGroup.twine.item_group": "Twine", + "block.twine.glowing_obsidian": "Glowing Obsidian" +} \ No newline at end of file diff --git a/src/main/resources/assets/twine/models/block/glowing_obsidian.json b/src/main/resources/assets/twine/models/block/glowing_obsidian.json new file mode 100644 index 0000000..8c5832f --- /dev/null +++ b/src/main/resources/assets/twine/models/block/glowing_obsidian.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "twine:block/glowing_obsidian" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/twine/models/item/glowing_obsidian.json b/src/main/resources/assets/twine/models/item/glowing_obsidian.json new file mode 100644 index 0000000..f63d5c6 --- /dev/null +++ b/src/main/resources/assets/twine/models/item/glowing_obsidian.json @@ -0,0 +1,3 @@ +{ + "parent": "twine:block/glowing_obsidian" +} \ No newline at end of file diff --git a/src/main/resources/assets/twine/models/item/large_backpack.json b/src/main/resources/assets/twine/models/item/large_backpack.json new file mode 100644 index 0000000..30518b6 --- /dev/null +++ b/src/main/resources/assets/twine/models/item/large_backpack.json @@ -0,0 +1,7 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "twine:item/backpack", + "layer1": "twine:item/backpack_overlay_large" + } +} diff --git a/src/main/resources/assets/twine/models/item/small_backpack.json b/src/main/resources/assets/twine/models/item/small_backpack.json new file mode 100644 index 0000000..739fb2d --- /dev/null +++ b/src/main/resources/assets/twine/models/item/small_backpack.json @@ -0,0 +1,7 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "twine:item/backpack", + "layer1": "twine:item/backpack_overlay_small" + } +} diff --git a/src/main/resources/assets/twine/textures/block/glowing_obsidian.png b/src/main/resources/assets/twine/textures/block/glowing_obsidian.png new file mode 100644 index 0000000..311d4e0 Binary files /dev/null and b/src/main/resources/assets/twine/textures/block/glowing_obsidian.png differ diff --git a/src/main/resources/assets/twine/textures/item/backpack.png b/src/main/resources/assets/twine/textures/item/backpack.png new file mode 100644 index 0000000..fc4f488 Binary files /dev/null and b/src/main/resources/assets/twine/textures/item/backpack.png differ diff --git a/src/main/resources/assets/twine/textures/item/backpack_overlay_large.png b/src/main/resources/assets/twine/textures/item/backpack_overlay_large.png new file mode 100644 index 0000000..5d7a0f4 Binary files /dev/null and b/src/main/resources/assets/twine/textures/item/backpack_overlay_large.png differ diff --git a/src/main/resources/assets/twine/textures/item/backpack_overlay_small.png b/src/main/resources/assets/twine/textures/item/backpack_overlay_small.png new file mode 100644 index 0000000..af953dd Binary files /dev/null and b/src/main/resources/assets/twine/textures/item/backpack_overlay_small.png differ diff --git a/src/main/resources/data/twine/loot_tables/blocks/glowing_obsidian.json b/src/main/resources/data/twine/loot_tables/blocks/glowing_obsidian.json new file mode 100644 index 0000000..1312b36 --- /dev/null +++ b/src/main/resources/data/twine/loot_tables/blocks/glowing_obsidian.json @@ -0,0 +1,29 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "twine:glowing_obsidian" + } + ], + "conditions": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/twine/recipes/glowing_obsidian.json b/src/main/resources/data/twine/recipes/glowing_obsidian.json new file mode 100644 index 0000000..aaf48fd --- /dev/null +++ b/src/main/resources/data/twine/recipes/glowing_obsidian.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + " R ", + "ROR", + " R " + ], + "key": { + "R": { + "item": "minecraft:redstone" + }, + "O": { + "item": "minecraft:obsidian" + } + }, + "result": { + "item": "twine:glowing_obsidian", + "count": 1 + } +} \ No newline at end of file diff --git a/src/main/resources/data/twine/recipes/large_backpack.json b/src/main/resources/data/twine/recipes/large_backpack.json new file mode 100644 index 0000000..bf27803 --- /dev/null +++ b/src/main/resources/data/twine/recipes/large_backpack.json @@ -0,0 +1,12 @@ +{ + "type": "minecraft:smithing", + "base": { + "item": "twine:small_backpack" + }, + "addition": { + "item": "minecraft:gold_ingot" + }, + "result": { + "item": "twine:large_backpack" + } +} \ No newline at end of file diff --git a/src/main/resources/data/twine/recipes/small_backpack.json b/src/main/resources/data/twine/recipes/small_backpack.json new file mode 100644 index 0000000..dbb6228 --- /dev/null +++ b/src/main/resources/data/twine/recipes/small_backpack.json @@ -0,0 +1,23 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "SLS", + "LIL", + "SLS" + ], + "key": { + "S": { + "item": "minecraft:stick" + }, + "L": { + "item": "minecraft:leather" + }, + "I": { + "item": "minecraft:iron_ingot" + } + }, + "result": { + "item": "twine:small_backpack", + "count": 1 + } +} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..8247ee7 --- /dev/null +++ b/src/main/resources/fabric.mod.json @@ -0,0 +1,34 @@ +{ + "schemaVersion": 1, + "id": "twine", + "version": "${version}", + "name": "Twine", + "description": "A simple survival mod for Minecraft encouraging a nomadic lifestyle.", + "authors": [ + "TheBrokenRail" + ], + "contact": { + "homepage": "https://thebrokenrail.com/", + "sources": "https://gitea.thebrokenrail.com/TheBrokenRail/Twine.git", + "issues": "https://gitea.thebrokenrail.com/TheBrokenRail/Twine/issues" + }, + "license": "MIT", + "icon": "assets/twine/icon.png", + "environment": "*", + "mixins": [ + "twine.mixins.json" + ], + "entrypoints": { + "main": [ + "com.thebrokenrail.twine.Twine" + ], + "client": [ + "com.thebrokenrail.twine.client.TwineClient" + ] + }, + "depends": { + "fabricloader": ">=0.7.4", + "fabric": "*", + "minecraft": "1.16.x" + } +} diff --git a/src/main/resources/twine.mixins.json b/src/main/resources/twine.mixins.json new file mode 100644 index 0000000..6bf73e6 --- /dev/null +++ b/src/main/resources/twine.mixins.json @@ -0,0 +1,15 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "com.thebrokenrail.twine.mixin", + "compatibilityLevel": "JAVA_8", + "mixins": [ + "MixinDefaultBiomeFeatures", + "MixinMobEntity", + "MixinServerPlayerEntity", + "MixinSlot" + ], + "injectors": { + "defaultRequire": 1 + } +}