Add latest revisions after getting it functional
This commit is contained in:
parent
9653e273e4
commit
ffcecb8e8e
1443 changed files with 258988 additions and 6046 deletions
266
build.gradle
266
build.gradle
|
@ -1,252 +1,94 @@
|
|||
plugins {
|
||||
id 'eclipse'
|
||||
id 'idea'
|
||||
id 'dev.architectury.loom' version '1.6-SNAPSHOT'
|
||||
id 'maven-publish'
|
||||
id 'java-library'
|
||||
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
|
||||
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
|
||||
}
|
||||
|
||||
version = mod_version
|
||||
group = mod_group_id
|
||||
group = project.maven_group
|
||||
version = project.mod_version
|
||||
|
||||
base {
|
||||
archivesName = mod_id
|
||||
archivesName = project.archives_name
|
||||
}
|
||||
|
||||
java {
|
||||
loom {
|
||||
silentMojangMappingsLicense()
|
||||
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
configurations {
|
||||
provided
|
||||
minecraftLibrary.extendsFrom(provided)
|
||||
}
|
||||
|
||||
// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
||||
|
||||
println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
|
||||
minecraft {
|
||||
// The mappings can be changed at any time and must be in the following format.
|
||||
// Channel: Version:
|
||||
// official MCVersion Official field/method names from Mojang mapping files
|
||||
// parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official
|
||||
//
|
||||
// You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
|
||||
// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
|
||||
//
|
||||
// Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
|
||||
// Additional setup is needed to use their mappings: https://github.com/ParchmentMC/Parchment/wiki/Getting-Started
|
||||
//
|
||||
// Use non-default mappings at your own risk. They may not always work.
|
||||
// Simply re-run your setup task after changing the mappings to update your workspace.
|
||||
mappings channel: mapping_channel, version: "${parchment_version}-${minecraft_version}"
|
||||
|
||||
// When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game.
|
||||
// In most cases, it is not necessary to enable.
|
||||
// enableEclipsePrepareRuns = true
|
||||
// enableIdeaPrepareRuns = true
|
||||
|
||||
// This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
|
||||
// It is REQUIRED to be set to true for this template to function.
|
||||
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
|
||||
copyIdeResources = true
|
||||
|
||||
// When true, this property will add the folder name of all declared run configurations to generated IDE run configurations.
|
||||
// The folder name can be set on a run configuration using the "folderName" property.
|
||||
// By default, the folder name of a run configuration is the name of the Gradle project containing it.
|
||||
// generateRunFolders = true
|
||||
|
||||
// This property enables access transformers for use in development.
|
||||
// They will be applied to the Minecraft artifact.
|
||||
// The access transformer file can be anywhere in the project.
|
||||
// However, it must be at "META-INF/accesstransformer.cfg" in the final mod jar to be loaded by Forge.
|
||||
// This default location is a best practice to automatically put the file in the right place in the final jar.
|
||||
// See https://docs.minecraftforge.net/en/latest/advanced/accesstransformers/ for more information.
|
||||
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
|
||||
// Default run configurations.
|
||||
// These can be tweaked, removed, or duplicated as needed.
|
||||
runs {
|
||||
// applies to all the run configs below
|
||||
configureEach {
|
||||
workingDirectory project.file('run')
|
||||
|
||||
// Recommended logging data for a userdev environment
|
||||
// The markers can be added/remove as needed separated by commas.
|
||||
// "SCAN": For mods scan.
|
||||
// "REGISTRIES": For firing of registry events.
|
||||
// "REGISTRYDUMP": For getting the contents of all registries.
|
||||
property 'forge.logging.markers', 'REGISTRIES'
|
||||
|
||||
// Recommended logging level for the console
|
||||
// You can set various levels here.
|
||||
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
|
||||
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
|
||||
property 'forge.enabledGameTestNamespaces', mod_id
|
||||
|
||||
mods {
|
||||
"${mod_id}" {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
client {
|
||||
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
|
||||
property 'forge.enabledGameTestNamespaces', mod_id
|
||||
}
|
||||
|
||||
server {
|
||||
property 'forge.enabledGameTestNamespaces', mod_id
|
||||
args '--nogui'
|
||||
}
|
||||
|
||||
// This run config launches GameTestServer and runs all registered gametests, then exits.
|
||||
// By default, the server will crash when no gametests are provided.
|
||||
// The gametest system is also enabled by default for other run configs under the /test command.
|
||||
gameTestServer {
|
||||
property 'forge.enabledGameTestNamespaces', mod_id
|
||||
}
|
||||
|
||||
data {
|
||||
// example of overriding the workingDirectory set in configureEach above
|
||||
workingDirectory project.file('run-data')
|
||||
|
||||
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
|
||||
args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
|
||||
}
|
||||
forge {
|
||||
mixinConfig 'ariasessentials.mixins.json'
|
||||
}
|
||||
}
|
||||
|
||||
// Include resources generated by data generators.
|
||||
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
// Put repositories for dependencies here
|
||||
// ForgeGradle automatically adds the Forge maven and Maven Central for you
|
||||
|
||||
// If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
|
||||
flatDir {
|
||||
dir 'libs'
|
||||
}
|
||||
|
||||
//maven {
|
||||
// name = "CurseMaven"
|
||||
// url = "https://cursemaven.com"
|
||||
//}
|
||||
// Add repositories to retrieve artifacts from in here.
|
||||
// You should only use this when depending on other mods because
|
||||
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
||||
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
||||
// for more information about repositories.
|
||||
|
||||
maven {
|
||||
name = "zontreck Maven"
|
||||
url = "https://git.zontreck.com/api/packages/MinecraftMods/maven"
|
||||
// location of the maven that hosts JEI files before January 2023
|
||||
name = "Progwml6's maven"
|
||||
url = "https://dvs1.progwml6.com/files/maven/"
|
||||
}
|
||||
maven {
|
||||
// location of the maven that hosts JEI files since January 2023
|
||||
name = "Jared's maven"
|
||||
url = "https://maven.blamejared.com/"
|
||||
}
|
||||
maven {
|
||||
// location of a maven mirror for JEI files, as a fallback
|
||||
name = "ModMaven"
|
||||
url = "https://modmaven.dev"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Specify the version of Minecraft to use.
|
||||
// Any artifact can be supplied so long as it has a "userdev" classifier artifact and is a compatible patcher artifact.
|
||||
// The "userdev" classifier will be requested and setup by ForgeGradle.
|
||||
// If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"],
|
||||
// then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
|
||||
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
||||
minecraft "net.minecraft:minecraft:$project.minecraft_version"
|
||||
mappings loom.officialMojangMappings()
|
||||
forge "net.minecraftforge:forge:$project.forge_version"
|
||||
|
||||
provided "dev.zontreck:MinecraftMods_LibZontreck_1.19.2:${libzontreck}"
|
||||
|
||||
// Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings
|
||||
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
|
||||
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}")
|
||||
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}-forge-api:${jei_version}")
|
||||
// runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}-forge:${jei_version}")
|
||||
|
||||
// Example mod dependency using a mod jar from ./libs with a flat dir repository
|
||||
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
|
||||
// The group id is ignored when searching -- in this case, it is "blank"
|
||||
// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
|
||||
|
||||
// For more info:
|
||||
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
|
||||
// http://www.gradle.org/docs/current/userguide/dependency_management.html
|
||||
// compile against the JEI API but do not include it at runtime
|
||||
modCompileOnly "mezz.jei:jei-${minecraft_version}-forge-api:${jei_version}"
|
||||
// at runtime, use the full JEI jar
|
||||
modRuntimeOnly "mezz.jei:jei-${minecraft_version}-forge:${jei_version}"
|
||||
}
|
||||
|
||||
// This block of code expands all declared replace properties in the specified resource targets.
|
||||
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
|
||||
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
|
||||
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
|
||||
tasks.named('processResources', ProcessResources).configure {
|
||||
var replaceProperties = [
|
||||
minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
|
||||
forge_version: forge_version, forge_version_range: forge_version_range,
|
||||
loader_version_range: loader_version_range,
|
||||
mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
|
||||
mod_authors: mod_authors, mod_description: mod_description, libzontreck_id: libzontreck_id, libzontreck_range: libzontreck_range
|
||||
]
|
||||
inputs.properties replaceProperties
|
||||
processResources {
|
||||
inputs.property 'version', project.version
|
||||
|
||||
filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
|
||||
expand replaceProperties + [project: project]
|
||||
filesMatching('META-INF/mods.toml') {
|
||||
expand version: project.version
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
|
||||
// if it is present.
|
||||
// If you remove this line, sources will not be generated.
|
||||
withSourcesJar()
|
||||
|
||||
// Example for how to get properties into the manifest for reading at runtime.
|
||||
tasks.named('jar', Jar).configure {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
|
||||
manifest {
|
||||
attributes([
|
||||
'Specification-Title' : mod_id,
|
||||
'Specification-Vendor' : mod_authors,
|
||||
'Specification-Version' : '1', // We are version 1 of ourselves
|
||||
'Implementation-Title' : project.name,
|
||||
'Implementation-Version' : project.jar.archiveVersion,
|
||||
'Implementation-Vendor' : mod_authors,
|
||||
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
||||
])
|
||||
}
|
||||
|
||||
// This is the preferred method to reobfuscate your jar file
|
||||
finalizedBy 'reobfJar'
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing:
|
||||
// tasks.named('publish').configure {
|
||||
// dependsOn 'reobfJar'
|
||||
// }
|
||||
|
||||
|
||||
def MAVEN_PASSWORD = "AriasCreationsMavenPassword"
|
||||
def MAVEN_USER = "AriasCreationsMavenUser"
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.release = 17
|
||||
}
|
||||
|
||||
// Configure Maven publishing.
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
artifact jar
|
||||
artifact sourcesJar
|
||||
artifact javadocJar
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
|
||||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||
repositories {
|
||||
maven {
|
||||
url = "https://git.zontreck.com/api/packages/MinecraftMods/maven"
|
||||
name = "ariascreations"
|
||||
|
||||
credentials {
|
||||
username = project.findProperty(MAVEN_USER)
|
||||
password = project.findProperty(MAVEN_PASSWORD)
|
||||
}
|
||||
}
|
||||
// Add repositories to publish to here.
|
||||
// Notice: This block does NOT have the same function as the block in the top level.
|
||||
// The repositories here will be used for publishing your artifact, not for
|
||||
// retrieving dependencies.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
|
||||
}
|
|
@ -1,62 +1,15 @@
|
|||
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
|
||||
# This is required to provide enough memory for the Minecraft decompilation process.
|
||||
org.gradle.jvmargs=-Xmx3G -Dfile.encoding=utf-8
|
||||
org.gradle.daemon=false
|
||||
# Done to increase the memory available to Gradle.
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
loom.platform = forge
|
||||
|
||||
libzontreck=1192.13.100924.2250
|
||||
libzontreck_id=libzontreck
|
||||
libzontreck_range=[1192.13,1192.14)
|
||||
# Mod properties
|
||||
mod_version = 1192.2.102824.1841
|
||||
maven_group = com.zontreck
|
||||
archives_name = ariasessentials
|
||||
|
||||
## Environment Properties
|
||||
# Minecraft properties
|
||||
minecraft_version = 1.19.2
|
||||
|
||||
# The Minecraft version must agree with the Forge version to get a valid artifact
|
||||
minecraft_version=1.19.2
|
||||
# The Minecraft version range can use any release version of Minecraft as bounds.
|
||||
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
|
||||
# as they do not follow standard versioning conventions.
|
||||
minecraft_version_range=[1.19.2,1.20)
|
||||
# The Forge version must agree with the Minecraft version to get a valid artifact
|
||||
forge_version=43.4.2
|
||||
# The Forge version range can use any version of Forge as bounds or match the loader version range
|
||||
forge_version_range=[43,)
|
||||
# The loader version range can only use the major version of Forge/FML as bounds
|
||||
loader_version_range=[43,)
|
||||
# The mapping channel to use for mappings.
|
||||
# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"].
|
||||
# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin.
|
||||
#
|
||||
# | Channel | Version | |
|
||||
# |-----------|----------------------|--------------------------------------------------------------------------------|
|
||||
# | official | MCVersion | Official field/method names from Mojang mapping files |
|
||||
# | parchment | YYYY.MM.DD-MCVersion | Open community-sourced parameter names and javadocs layered on top of official |
|
||||
#
|
||||
# You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
|
||||
# See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
|
||||
#
|
||||
# Parchment is an unofficial project maintained by ParchmentMC, separate from Minecraft Forge.
|
||||
# Additional setup is needed to use their mappings, see https://parchmentmc.org/docs/getting-started
|
||||
mapping_channel=parchment
|
||||
# The mapping version to query from the mapping channel.
|
||||
# This must match the format required by the mapping channel.
|
||||
parchment_version=2022.11.27
|
||||
# luckperms_api_version=5.4
|
||||
|
||||
## Mod Properties
|
||||
|
||||
# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
|
||||
# Must match the String constant located in the main mod class annotated with @Mod.
|
||||
mod_id=ariasessentials
|
||||
# The human-readable display name for the mod.
|
||||
mod_name=Aria's Essentials
|
||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||
mod_license=GPLv3
|
||||
# The mod version. See https://semver.org/
|
||||
mod_version=1192.3.100924.2300
|
||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||
# This should match the base package used for the mod sources.
|
||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
mod_group_id=dev.zontreck
|
||||
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
|
||||
mod_authors=zontreck
|
||||
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
|
||||
mod_description=A mod with custom commands that are essential
|
||||
# Dependencies
|
||||
forge_version = 1.19.2-43.4.0
|
||||
jei_version = 11.6.0.1024
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
1
gradle/wrapper/gradle-wrapper.properties
vendored
1
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -2,5 +2,6 @@ distributionBase=GRADLE_USER_HOME
|
|||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
35
gradlew
vendored
35
gradlew
vendored
|
@ -55,7 +55,7 @@
|
|||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# 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/.
|
||||
|
@ -80,13 +80,11 @@ do
|
|||
esac
|
||||
done
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${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"'
|
||||
# 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
|
||||
|
@ -133,22 +131,29 @@ 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.
|
||||
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
|
||||
|
@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then
|
|||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
# 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" \
|
||||
|
|
21
gradlew.bat
vendored
21
gradlew.bat
vendored
|
@ -26,6 +26,7 @@ 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%
|
||||
|
||||
|
@ -42,11 +43,11 @@ 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.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
|
@ -56,11 +57,11 @@ 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.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
pluginManagement {
|
||||
repositories {
|
||||
maven { url "https://maven.fabricmc.net/" }
|
||||
maven { url "https://maven.architectury.dev/" }
|
||||
maven { url "https://files.minecraftforge.net/maven/" }
|
||||
gradlePluginPortal()
|
||||
maven {
|
||||
name = 'MinecraftForge'
|
||||
url = 'https://maven.minecraftforge.net/'
|
||||
}
|
||||
maven { url = 'https://maven.parchmentmc.org' } // Add this line
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
|
||||
}
|
||||
rootProject.name = 'ariasessentials'
|
||||
|
|
71
src/main/java/com/zontreck/AriasEssentials.java
Normal file
71
src/main/java/com/zontreck/AriasEssentials.java
Normal file
|
@ -0,0 +1,71 @@
|
|||
package com.zontreck;
|
||||
|
||||
import com.zontreck.block.DeprecatedModBlocks;
|
||||
import com.zontreck.block.ModBlocks;
|
||||
import com.zontreck.client.TimeBoostEntityRenderer;
|
||||
import com.zontreck.commands.CommandRegistry;
|
||||
import com.zontreck.configs.client.AEClientConfig;
|
||||
import com.zontreck.configs.server.AEServerConfig;
|
||||
import com.zontreck.effects.ModEffects;
|
||||
import com.zontreck.effects.ModPotions;
|
||||
import com.zontreck.enchantments.ModEnchantments;
|
||||
import com.zontreck.entities.ModEntities;
|
||||
import com.zontreck.items.DeprecatedModItems;
|
||||
import com.zontreck.items.ModItems;
|
||||
import com.zontreck.libzontreck.config.ServerConfig;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderers;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import org.slf4j.ILoggerFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Random;
|
||||
import java.util.logging.LogManager;
|
||||
|
||||
@Mod(AriasEssentials.MOD_ID)
|
||||
public final class AriasEssentials {
|
||||
public static Logger LOGGER = LoggerFactory.getLogger("ariaessentials");
|
||||
public static final String MOD_ID = "ariasessentials";
|
||||
public static final Random random = new Random(Instant.now().getEpochSecond());
|
||||
|
||||
public AriasEssentials() {
|
||||
// This code runs as soon as Minecraft is in a mod-load-ready state.
|
||||
// However, some things (like registries and resources) may still be uninitialized.
|
||||
// Proceed with mild caution.
|
||||
|
||||
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
LOGGER.info("/!\\ Loading Aria's Essentials Configuration Files /!\\");
|
||||
AEServerConfig.loadFromFile();
|
||||
AEClientConfig.loadFromFile();
|
||||
ServerConfig.init();
|
||||
LOGGER.info("/!\\ DONE LOADING AECONFIG /!\\");
|
||||
|
||||
ModItems.ITEMS.register(bus);
|
||||
ModEntities.register(bus);
|
||||
ModEffects.register(bus);
|
||||
ModPotions.register(bus);
|
||||
DeprecatedModItems.register(bus);
|
||||
ModEnchantments.register(bus);
|
||||
DeprecatedModBlocks.register(bus);
|
||||
ModBlocks.register(bus);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
||||
public static class ClientModEvents {
|
||||
@SubscribeEvent
|
||||
public static void onClientSetup(FMLClientSetupEvent ev) {
|
||||
EntityRenderers.register(ModEntities.TIAB_ENTITY.get(), TimeBoostEntityRenderer::new);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package dev.zontreck.essentials;
|
||||
package com.zontreck;
|
||||
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
|
||||
|
@ -80,6 +79,21 @@ public class Messages {
|
|||
public static final String TP_EFFECTS_TOGGLED;
|
||||
|
||||
|
||||
|
||||
public static final String PREFIX_UPDATED;
|
||||
public static final String PREFIX_COLOR_UPDATED;
|
||||
public static final String NICK_UPDATED;
|
||||
public static final String NAME_COLOR_UPDATED;
|
||||
public static final String CHAT_COLOR_UPDATED;
|
||||
public static final String CONSOLE_ERROR;
|
||||
public static final String STARTER_FAILURE_PERMISSIONS;
|
||||
public static final String STARTER_KIT_GIVEN;
|
||||
|
||||
public static final String FLIGHT_GIVEN;
|
||||
public static final String FLIGHT_REMOVED;
|
||||
public static final String BUILDER_DIMENSION_DISALLOWED;
|
||||
|
||||
|
||||
static{
|
||||
ESSENTIALS_PREFIX = "!Gray![!Dark_Green!AE!Gray!] ";
|
||||
|
||||
|
@ -172,5 +186,19 @@ public class Messages {
|
|||
COOLDOWN_IN_PROGRESS = ESSENTIALS_PREFIX + "!Dark_Red!The command [0] is still on cooldown for another [1]";
|
||||
|
||||
TP_EFFECTS_TOGGLED = ESSENTIALS_PREFIX + "!Dark_Purple!The teleport effects preferences have been toggled to: [0]";
|
||||
|
||||
|
||||
|
||||
PREFIX_UPDATED = ESSENTIALS_PREFIX + " !Dark_Purple!Your prefix has been updated";
|
||||
PREFIX_COLOR_UPDATED = ESSENTIALS_PREFIX + "!Dark_Purple!Your prefix color has been updated";
|
||||
NICK_UPDATED = ESSENTIALS_PREFIX + "!Dark_Purple! Your nickname has been updated";
|
||||
NAME_COLOR_UPDATED = ESSENTIALS_PREFIX + "!Dark_Purple!Your name color has been updated";
|
||||
CHAT_COLOR_UPDATED = ESSENTIALS_PREFIX + "!Dark_Purple!Your chat color has been updated";
|
||||
CONSOLE_ERROR = ESSENTIALS_PREFIX + "!Dark_Red!This command can only be executed from within the game, and by a player";
|
||||
STARTER_FAILURE_PERMISSIONS = ESSENTIALS_PREFIX + "!Dark_Red!This command can only be executed by server operators";
|
||||
STARTER_KIT_GIVEN = ESSENTIALS_PREFIX + "!Dark_Purple!You have been given a starter kit. Welcome to the server.";
|
||||
FLIGHT_GIVEN = ESSENTIALS_PREFIX + "!Dark_Green!You start to feel lighter than a feather";
|
||||
FLIGHT_REMOVED = ESSENTIALS_PREFIX + "!Dark_Red!You have a sinking feeling you are no longer lighter than a feather.";
|
||||
BUILDER_DIMENSION_DISALLOWED = ESSENTIALS_PREFIX+"!Dark_Red!The builder dimension is disallowed for regular users. You must be a server operator.";
|
||||
}
|
||||
}
|
9
src/main/java/com/zontreck/ariaslib/http/HTTPMethod.java
Normal file
9
src/main/java/com/zontreck/ariaslib/http/HTTPMethod.java
Normal file
|
@ -0,0 +1,9 @@
|
|||
package dev.zontreck.ariaslib.http;
|
||||
|
||||
public enum HTTPMethod
|
||||
{
|
||||
GET,
|
||||
POST,
|
||||
PUT,
|
||||
DELETE
|
||||
}
|
15
src/main/java/com/zontreck/ariaslib/http/HTTPRequest.java
Normal file
15
src/main/java/com/zontreck/ariaslib/http/HTTPRequest.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package dev.zontreck.ariaslib.http;
|
||||
|
||||
public class HTTPRequest
|
||||
{
|
||||
|
||||
public String url;
|
||||
|
||||
public String method;
|
||||
public String body;
|
||||
public String contentType;
|
||||
|
||||
protected HTTPRequest(){
|
||||
|
||||
}
|
||||
}
|
134
src/main/java/com/zontreck/ariaslib/http/HTTPRequestBuilder.java
Normal file
134
src/main/java/com/zontreck/ariaslib/http/HTTPRequestBuilder.java
Normal file
|
@ -0,0 +1,134 @@
|
|||
package dev.zontreck.ariaslib.http;
|
||||
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
public class HTTPRequestBuilder
|
||||
{
|
||||
|
||||
private HttpURLConnection connection;
|
||||
private URL url;
|
||||
private HTTPRequest request = new HTTPRequest();
|
||||
|
||||
public static HTTPRequestBuilder builder()
|
||||
{
|
||||
return new HTTPRequestBuilder();
|
||||
}
|
||||
|
||||
protected HTTPRequestBuilder()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the url in this request to the one supplied
|
||||
* @param url The url to connect to
|
||||
* @return Builder instance
|
||||
* @throws MalformedURLException If the URL supplied was invalid
|
||||
*/
|
||||
public HTTPRequestBuilder withURL( String url) throws MalformedURLException {
|
||||
request.url = url;
|
||||
this.url = new URL(url);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the HTTP Request method
|
||||
* @param method The method you want to use
|
||||
* @see HTTPMethod
|
||||
* @return Builder instance
|
||||
*/
|
||||
public HTTPRequestBuilder withMethod(HTTPMethod method)
|
||||
{
|
||||
switch(method)
|
||||
{
|
||||
case GET:
|
||||
{
|
||||
request.method = "GET";
|
||||
break;
|
||||
}
|
||||
case POST: {
|
||||
request.method = "POST";
|
||||
if(request.contentType.isEmpty()) request.contentType = "application/x-www-form-urlencoded";
|
||||
break;
|
||||
}
|
||||
case DELETE:{
|
||||
request.method = "DELETE";
|
||||
break;
|
||||
}
|
||||
case PUT:{
|
||||
request.method = "PUT";
|
||||
if(request.contentType.isEmpty()) request.contentType = "application/x-www-form-urlencoded";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the request body. This may only be processed by the server when using POST or PUT, depending on the server's setup
|
||||
* @param body The body to upload
|
||||
* @return Builder Instance
|
||||
*/
|
||||
public HTTPRequestBuilder withBody(String body)
|
||||
{
|
||||
request.body = body;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the content type header
|
||||
* Default: application/x-www-form-urlencoded for POST/PUT, and null/not present for GET
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public HTTPRequestBuilder withContentType(String type)
|
||||
{
|
||||
request.contentType = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public HTTPResponse build()
|
||||
{
|
||||
try {
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod(request.method);
|
||||
byte[] array = request.body.getBytes("UTF-8");
|
||||
connection.setRequestProperty("Content-Length" , "" + array.length);
|
||||
connection.setRequestProperty("Content-Type", request.contentType);
|
||||
connection.setDoInput(true);
|
||||
connection.setUseCaches(false);
|
||||
connection.setDoOutput(true);
|
||||
DataOutputStream dos = new DataOutputStream(connection.getOutputStream());
|
||||
dos.write(array);
|
||||
dos.flush();
|
||||
dos.close();
|
||||
|
||||
|
||||
// Get the response body
|
||||
InputStream inputStream = connection.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
StringBuilder response = new StringBuilder();
|
||||
String line;
|
||||
|
||||
while ((line = reader.readLine()) != null) {
|
||||
response.append(line);
|
||||
}
|
||||
reader.close();
|
||||
inputStream.close();
|
||||
|
||||
String responseBody = response.toString();
|
||||
|
||||
return new HTTPResponse(connection.getContentType(), connection.getResponseCode(), responseBody, request);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}finally {
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
33
src/main/java/com/zontreck/ariaslib/http/HTTPResponse.java
Normal file
33
src/main/java/com/zontreck/ariaslib/http/HTTPResponse.java
Normal file
|
@ -0,0 +1,33 @@
|
|||
package dev.zontreck.ariaslib.http;
|
||||
|
||||
public class HTTPResponse
|
||||
{
|
||||
private String ContentType;
|
||||
private int ResponseCode;
|
||||
private String ResponseBody;
|
||||
private HTTPRequest OriginalRequest;
|
||||
|
||||
protected HTTPResponse(String contentType, int code, String body, HTTPRequest request){
|
||||
this.ContentType = contentType;
|
||||
this.ResponseCode = code;
|
||||
this.ResponseBody = body;
|
||||
this.OriginalRequest = request;
|
||||
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return ContentType;
|
||||
}
|
||||
|
||||
public int getResponseCode() {
|
||||
return ResponseCode;
|
||||
}
|
||||
|
||||
public String getResponseBody() {
|
||||
return ResponseBody;
|
||||
}
|
||||
|
||||
public HTTPRequest getOriginalRequest() {
|
||||
return OriginalRequest;
|
||||
}
|
||||
}
|
47
src/main/java/com/zontreck/ariaslib/terminal/Banners.java
Normal file
47
src/main/java/com/zontreck/ariaslib/terminal/Banners.java
Normal file
|
@ -0,0 +1,47 @@
|
|||
package com.zontreck.ariaslib.terminal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Banners
|
||||
{
|
||||
|
||||
public static String generateBanner(String text) {
|
||||
int maxLength = calculateMaxLength(text);
|
||||
List<String> bannerLines = new ArrayList<>();
|
||||
StringBuilder border = new StringBuilder();
|
||||
for (int i = 0; i < maxLength + 4; i++) {
|
||||
border.append("*");
|
||||
}
|
||||
bannerLines.add(border.toString());
|
||||
bannerLines.add("* " + centerText(text, maxLength) + " *");
|
||||
bannerLines.add(border.toString());
|
||||
return String.join("\n", bannerLines);
|
||||
}
|
||||
|
||||
private static String centerText(String text, int maxLength) {
|
||||
StringBuilder centeredText = new StringBuilder();
|
||||
int spacesToAdd = (maxLength - text.length()) / 2;
|
||||
for (int i = 0; i < spacesToAdd; i++) {
|
||||
centeredText.append(" ");
|
||||
}
|
||||
centeredText.append(text);
|
||||
for (int i = 0; i < spacesToAdd; i++) {
|
||||
centeredText.append(" ");
|
||||
}
|
||||
if (centeredText.length() < maxLength) {
|
||||
centeredText.append(" ");
|
||||
}
|
||||
return centeredText.toString();
|
||||
}
|
||||
|
||||
private static int calculateMaxLength(String text) {
|
||||
int maxLength = 0;
|
||||
for (String line : text.split("\n")) {
|
||||
if (line.length() > maxLength) {
|
||||
maxLength = line.length();
|
||||
}
|
||||
}
|
||||
return maxLength;
|
||||
}
|
||||
}
|
86
src/main/java/com/zontreck/ariaslib/terminal/Task.java
Normal file
86
src/main/java/com/zontreck/ariaslib/terminal/Task.java
Normal file
|
@ -0,0 +1,86 @@
|
|||
package com.zontreck.ariaslib.terminal;
|
||||
|
||||
import com.zontreck.ariaslib.util.Progress;
|
||||
|
||||
import java.util.TimerTask;
|
||||
|
||||
public abstract class Task extends TimerTask implements Runnable {
|
||||
public final String TASK_NAME;
|
||||
private TaskCompletionToken token = new TaskCompletionToken ( );
|
||||
|
||||
public static final String CHECK = "P";
|
||||
public static final String FAIL = "F";
|
||||
// Else use the progress spinner from the Progress class
|
||||
private boolean isSilent = false;
|
||||
|
||||
public Task ( String name ) {
|
||||
TASK_NAME = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor is meant to be used to create silent tasks that do not output to the console. (Example usage: DelayedExecutionService)
|
||||
*
|
||||
* @param name Task name
|
||||
* @param silent Whether to print to the terminal
|
||||
*/
|
||||
public Task ( String name , boolean silent ) {
|
||||
this ( name );
|
||||
isSilent = silent;
|
||||
}
|
||||
|
||||
|
||||
public boolean isComplete ( ) {
|
||||
return token.get ( );
|
||||
}
|
||||
|
||||
public void startTask ( ) {
|
||||
Thread tx = new Thread(this);
|
||||
tx.start();
|
||||
|
||||
if(! isSilent)
|
||||
{
|
||||
Thread tx2 = new Thread(new SpinnerTask(token, this));
|
||||
tx2.start();
|
||||
}
|
||||
}
|
||||
|
||||
public void stopTask ( ) {
|
||||
if ( token.get ( ) && ! isSilent ) {
|
||||
System.out.printf ( "\r" + TASK_NAME + "\t\t[" + token.status + "]\n" );
|
||||
}
|
||||
}
|
||||
|
||||
public void setSuccess ( ) {
|
||||
token.completed ( CHECK );
|
||||
}
|
||||
|
||||
public void setFail ( ) {
|
||||
token.completed ( FAIL );
|
||||
}
|
||||
|
||||
public class SpinnerTask extends Task {
|
||||
public final Task task;
|
||||
public final TaskCompletionToken token;
|
||||
private final Progress spinner = new Progress ( 100 );
|
||||
|
||||
public SpinnerTask ( TaskCompletionToken token , Task parent ) {
|
||||
super ( "spinner" , true );
|
||||
this.token = token;
|
||||
this.task = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run ( ) {
|
||||
while ( ! task.isComplete ( ) ) {
|
||||
try {
|
||||
Thread.sleep ( 50L );
|
||||
|
||||
if ( ! task.isSilent && ! task.isComplete ( ) )
|
||||
System.out.printf ( "\r" + task.TASK_NAME + "\t\t" + spinner.getSpinnerTick ( ) + "\r" );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace ( );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.zontreck.ariaslib.terminal;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* Should not be re-used for multiple tasks!!!
|
||||
*/
|
||||
public class TaskCompletionToken
|
||||
{
|
||||
private AtomicBoolean complete = new AtomicBoolean(false);
|
||||
public String status = "";
|
||||
public void completed(String reason){
|
||||
status=reason;
|
||||
complete.set(true);
|
||||
}
|
||||
|
||||
public boolean get(){
|
||||
return complete.get();
|
||||
}
|
||||
}
|
51
src/main/java/com/zontreck/ariaslib/util/FileIO.java
Normal file
51
src/main/java/com/zontreck/ariaslib/util/FileIO.java
Normal file
|
@ -0,0 +1,51 @@
|
|||
package com.zontreck.ariaslib.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class FileIO
|
||||
{
|
||||
|
||||
public static String readFile(String filePath) {
|
||||
try {
|
||||
byte[] fileBytes = Files.readAllBytes(Paths.get(filePath));
|
||||
return new String(fileBytes);
|
||||
} catch (IOException e) {
|
||||
return "An error occurred: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
public static void writeFile(String filePath, String newContent) {
|
||||
try {
|
||||
Files.write(Paths.get(filePath), newContent.getBytes());
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Recursively delete a directory
|
||||
* @param directory The folder to delete
|
||||
*/
|
||||
public static void deleteDirectory(File directory) {
|
||||
if (directory.exists()) {
|
||||
File[] files = directory.listFiles();
|
||||
if (files != null) {
|
||||
for (File file : files) {
|
||||
if (file.isDirectory()) {
|
||||
deleteDirectory(file);
|
||||
} else {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
// Now directory is empty, so delete it
|
||||
directory.delete();
|
||||
System.out.println("Directory deleted: " + directory.getAbsolutePath());
|
||||
} else {
|
||||
System.out.println("Directory does not exist: " + directory.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
120
src/main/java/com/zontreck/ariaslib/util/Hashing.java
Normal file
120
src/main/java/com/zontreck/ariaslib/util/Hashing.java
Normal file
|
@ -0,0 +1,120 @@
|
|||
package com.zontreck.ariaslib.util;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class Hashing
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* A md5 hashing function that is compatible with literally every other hashing function out there
|
||||
* @param input The string to hash
|
||||
* @return The hash
|
||||
*/
|
||||
public static String md5(String input) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
md.update(input.getBytes());
|
||||
|
||||
byte[] byteData = md.digest();
|
||||
|
||||
// Convert the byte array to a hexadecimal string
|
||||
StringBuilder hexString = new StringBuilder();
|
||||
for (byte aByteData : byteData) {
|
||||
String hex = Integer.toHexString(0xff & aByteData);
|
||||
if (hex.length() == 1) {
|
||||
hexString.append('0');
|
||||
}
|
||||
hexString.append(hex);
|
||||
}
|
||||
return hexString.toString();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A md5 hashing function that is compatible with literally every other hashing function out there
|
||||
* @param input The bytes to hash
|
||||
* @return The hash
|
||||
*/
|
||||
public static String md5(byte[] input) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
md.update(input);
|
||||
|
||||
byte[] byteData = md.digest();
|
||||
|
||||
// Convert the byte array to a hexadecimal string
|
||||
StringBuilder hexString = new StringBuilder();
|
||||
for (byte aByteData : byteData) {
|
||||
String hex = Integer.toHexString(0xff & aByteData);
|
||||
if (hex.length() == 1) {
|
||||
hexString.append('0');
|
||||
}
|
||||
hexString.append(hex);
|
||||
}
|
||||
return hexString.toString();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A sha256 hashing function that is compatible with literally every other hashing function out there
|
||||
* @param input The string to hash
|
||||
* @return The hash
|
||||
*/
|
||||
public static String sha256(String input) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA256");
|
||||
md.update(input.getBytes());
|
||||
|
||||
byte[] byteData = md.digest();
|
||||
|
||||
// Convert the byte array to a hexadecimal string
|
||||
StringBuilder hexString = new StringBuilder();
|
||||
for (byte aByteData : byteData) {
|
||||
String hex = Integer.toHexString(0xff & aByteData);
|
||||
if (hex.length() == 1) {
|
||||
hexString.append('0');
|
||||
}
|
||||
hexString.append(hex);
|
||||
}
|
||||
return hexString.toString();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* A sha256 hashing function that is compatible with literally every other hashing function out there
|
||||
* @param input The bytes to hash
|
||||
* @return The hash
|
||||
*/
|
||||
public static String sha256(byte[] input) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA256");
|
||||
md.update(input);
|
||||
|
||||
byte[] byteData = md.digest();
|
||||
|
||||
// Convert the byte array to a hexadecimal string
|
||||
StringBuilder hexString = new StringBuilder();
|
||||
for (byte aByteData : byteData) {
|
||||
String hex = Integer.toHexString(0xff & aByteData);
|
||||
if (hex.length() == 1) {
|
||||
hexString.append('0');
|
||||
}
|
||||
hexString.append(hex);
|
||||
}
|
||||
return hexString.toString();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
94
src/main/java/com/zontreck/ariaslib/util/Lists.java
Normal file
94
src/main/java/com/zontreck/ariaslib/util/Lists.java
Normal file
|
@ -0,0 +1,94 @@
|
|||
package com.zontreck.ariaslib.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Lists
|
||||
{
|
||||
/**
|
||||
* Programatically constructs a list
|
||||
* @param values The list of values
|
||||
* @return The new list
|
||||
* @param <T> An arbitrary type parameter
|
||||
*/
|
||||
public static <T> List<T> of(T... values)
|
||||
{
|
||||
List<T> arr = new ArrayList<>();
|
||||
for(T value : values)
|
||||
{
|
||||
arr.add(value);
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Splits a string into a list
|
||||
* @param input The string to split
|
||||
* @param delimiters The list of delimiters
|
||||
* @return A non-strided list
|
||||
*/
|
||||
public static List<String> split(String input, String... delimiters) {
|
||||
List<String> result = new ArrayList<>();
|
||||
StringBuilder regex = new StringBuilder("(");
|
||||
|
||||
// Constructing the regular expression pattern with provided delimiters
|
||||
for (String delimiter : delimiters) {
|
||||
regex.append(delimiter).append("|");
|
||||
}
|
||||
regex.deleteCharAt(regex.length() - 1); // Remove the extra '|' character
|
||||
regex.append(")");
|
||||
|
||||
String[] tokens = input.split(regex.toString());
|
||||
|
||||
// Add non-empty tokens to the result list
|
||||
for (String token : tokens) {
|
||||
if (!token.isEmpty()) {
|
||||
result.add(token);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Split a string, and keep the delimiters
|
||||
* @param input The string to be parsed and split
|
||||
* @param delimiters A list of delimiters
|
||||
* @return A strided list containing the parsed options, and the delimiters
|
||||
*/
|
||||
public static List<String> splitWithDelim(String input, String... delimiters) {
|
||||
List<String> result = new ArrayList<>();
|
||||
StringBuilder regex = new StringBuilder("(");
|
||||
|
||||
// Constructing the regular expression pattern with provided delimiters
|
||||
for (String delimiter : delimiters) {
|
||||
regex.append(delimiter).append("|");
|
||||
}
|
||||
regex.deleteCharAt(regex.length() - 1); // Remove the extra '|' character
|
||||
regex.append(")");
|
||||
|
||||
// Splitting the input string using the regex pattern
|
||||
String[] tokens = input.split(regex.toString());
|
||||
|
||||
// Adding tokens and delimiters to the result list in a strided manner
|
||||
for (int i = 0; i < tokens.length; i++) {
|
||||
if (!tokens[i].isEmpty()) {
|
||||
result.add(tokens[i]);
|
||||
}
|
||||
// Adding delimiter if it exists and it's not the last token
|
||||
if (i < tokens.length - 1) {
|
||||
result.add(input.substring(input.indexOf(tokens[i]) + tokens[i].length(), input.indexOf(tokens[i + 1])));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private Lists(){
|
||||
|
||||
}
|
||||
}
|
49
src/main/java/com/zontreck/ariaslib/util/Maps.java
Normal file
49
src/main/java/com/zontreck/ariaslib/util/Maps.java
Normal file
|
@ -0,0 +1,49 @@
|
|||
package com.zontreck.ariaslib.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Utility class to assist in creating a dictionary programmatically in one line of code.
|
||||
*/
|
||||
public class Maps
|
||||
{
|
||||
/**
|
||||
* This takes a list of entries and returns a HashMap
|
||||
* @param entries The entries you want in your hashmap
|
||||
* @return The map itself
|
||||
* @param <A> Any typed parameter
|
||||
* @param <B> Any typed parameter
|
||||
*/
|
||||
public static <A,B> Map<A,B> of(Entry<A,B>... entries) {
|
||||
Map<A,B> map = new HashMap<>();
|
||||
for(Entry<A,B> E : entries)
|
||||
{
|
||||
map.put(E.key, E.value);
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* A virtual entry used only by the Maps#of function.
|
||||
* @see Maps#of(Entry[])
|
||||
* @param <A> Any typed parameter
|
||||
* @param <B> Any typed parameter
|
||||
*/
|
||||
public static class Entry<A,B> {
|
||||
public final A key;
|
||||
public final B value;
|
||||
|
||||
/**
|
||||
* Initializes the readonly entry
|
||||
* @param a The dictionary key
|
||||
* @param b The value
|
||||
*/
|
||||
public Entry(A a, B b)
|
||||
{
|
||||
this.key=a;
|
||||
this.value=b;
|
||||
}
|
||||
}
|
||||
}
|
18
src/main/java/com/zontreck/ariaslib/util/MathUtil.java
Normal file
18
src/main/java/com/zontreck/ariaslib/util/MathUtil.java
Normal file
|
@ -0,0 +1,18 @@
|
|||
package com.zontreck.ariaslib.util;
|
||||
|
||||
/**
|
||||
* This class will be used to house math helper functions
|
||||
*/
|
||||
public class MathUtil
|
||||
{
|
||||
/**
|
||||
* A newer helper function to get the percentage with large number support
|
||||
* @param current Min value
|
||||
* @param max Maximum value for progress
|
||||
* @return Percentage
|
||||
*/
|
||||
public static int getPercent(long current, long max)
|
||||
{
|
||||
return Math.round(current*100/max);
|
||||
}
|
||||
}
|
23
src/main/java/com/zontreck/ariaslib/util/Percent.java
Normal file
23
src/main/java/com/zontreck/ariaslib/util/Percent.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
package com.zontreck.ariaslib.util;
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
||||
public class Percent
|
||||
{
|
||||
int current;
|
||||
int maximum;
|
||||
|
||||
public Percent(int cur, int max)
|
||||
{
|
||||
current=cur;
|
||||
maximum=max;
|
||||
}
|
||||
|
||||
|
||||
public int get()
|
||||
{
|
||||
return ((current * 100) / maximum);
|
||||
}
|
||||
|
||||
|
||||
}
|
56
src/main/java/com/zontreck/ariaslib/util/Progress.java
Normal file
56
src/main/java/com/zontreck/ariaslib/util/Progress.java
Normal file
|
@ -0,0 +1,56 @@
|
|||
package com.zontreck.ariaslib.util;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class Progress
|
||||
{
|
||||
private int maximum;
|
||||
private int current;
|
||||
private AtomicInteger tickNum = new AtomicInteger(0);
|
||||
private static final String TICKS="-\\|/";
|
||||
|
||||
public String getSpinnerTick()
|
||||
{
|
||||
if(tickNum.get()>=TICKS.length()) tickNum.set(0);
|
||||
|
||||
return "[" + TICKS.substring(tickNum.getAndIncrement(), tickNum.get()) + "]";
|
||||
}
|
||||
|
||||
public Progress(int maximum)
|
||||
{
|
||||
current=0;
|
||||
this.maximum=maximum;
|
||||
}
|
||||
|
||||
public int getPercent(){
|
||||
return (current*100/maximum);
|
||||
}
|
||||
|
||||
public String getPercentStr()
|
||||
{
|
||||
return (getPercent()+"%");
|
||||
}
|
||||
|
||||
public static int getPercentOf(int current, int max)
|
||||
{
|
||||
return (current*100/max);
|
||||
}
|
||||
|
||||
public void increment(){
|
||||
current++;
|
||||
sanity();
|
||||
}
|
||||
private void sanity(){
|
||||
if(current > maximum) current = maximum;
|
||||
if(current < 0)current = 0;
|
||||
}
|
||||
public void decrement(){
|
||||
current--;
|
||||
sanity();
|
||||
}
|
||||
|
||||
public void setCurrent(int cur)
|
||||
{
|
||||
current=cur;
|
||||
}
|
||||
}
|
66
src/main/java/com/zontreck/ariaslib/util/ProgressBar.java
Normal file
66
src/main/java/com/zontreck/ariaslib/util/ProgressBar.java
Normal file
|
@ -0,0 +1,66 @@
|
|||
package com.zontreck.ariaslib.util;
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
||||
/**
|
||||
* Utility to create an ascii progress bar
|
||||
*/
|
||||
public class ProgressBar
|
||||
{
|
||||
|
||||
private static final int DEFAULT_BAR_WIDTH = 50;
|
||||
|
||||
/**
|
||||
* Reserved spaces for the brackets, and the carrot, and the percent value.
|
||||
*/
|
||||
private static final int PROGRESS_BAR_RESERVED=5;
|
||||
|
||||
/**
|
||||
* Always will return 80
|
||||
* @return 80
|
||||
*/
|
||||
private static int getConsoleWidth() {
|
||||
return 80; // Default console width, can be adjusted for different consoles
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a progress bar
|
||||
* <br><br>
|
||||
* your text here [========= ] 40% your text here
|
||||
* @param percent The percentage
|
||||
* @param beforeText
|
||||
* @param afterText
|
||||
* @return ProgressBar as a String
|
||||
*/
|
||||
public static String printProgressBar(int percent, String beforeText, String afterText) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int consoleWidth = getConsoleWidth();
|
||||
int barWidth = Math.min(consoleWidth - beforeText.length() - afterText.length() - PROGRESS_BAR_RESERVED, DEFAULT_BAR_WIDTH);
|
||||
|
||||
// Calculate progress
|
||||
int progressBarLength = (int) ((double) percent / 100 * barWidth);
|
||||
|
||||
// Print before text
|
||||
sb.append(beforeText);
|
||||
|
||||
// Print progress bar
|
||||
sb.append("[");
|
||||
for (int i = 0; i < barWidth; i++) {
|
||||
if (i < progressBarLength) {
|
||||
sb.append("=");
|
||||
}else if(i==progressBarLength) sb.append(">");
|
||||
else {
|
||||
sb.append(" ");
|
||||
}
|
||||
}
|
||||
sb.append("]");
|
||||
|
||||
// Print percentage
|
||||
sb.append(" " + percent + "%");
|
||||
|
||||
// Print after text
|
||||
sb.append(afterText);
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
161
src/main/java/com/zontreck/ariaslib/util/TimeNotation.java
Normal file
161
src/main/java/com/zontreck/ariaslib/util/TimeNotation.java
Normal file
|
@ -0,0 +1,161 @@
|
|||
package com.zontreck.ariaslib.util;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Contains useful structures and functions for dealing with, and manipulation of, time.
|
||||
*/
|
||||
public class TimeNotation
|
||||
{
|
||||
public int Years;
|
||||
public int Months;
|
||||
public int Weeks;
|
||||
public int Days;
|
||||
public int Hours;
|
||||
public int Minutes;
|
||||
public int Seconds;
|
||||
|
||||
public TimeNotation(int years, int months, int weeks, int days, int hours, int minutes, int seconds)
|
||||
{
|
||||
Years=years;
|
||||
Months=months;
|
||||
Weeks=weeks;
|
||||
Days=days;
|
||||
Hours=hours;
|
||||
Minutes=minutes;
|
||||
Seconds = seconds;
|
||||
}
|
||||
|
||||
private TimeNotation(){}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String str =
|
||||
someOrNone(Years,Pluralize(Years, "year") + ", ") +
|
||||
someOrNone(Months, Pluralize(Months, "month") + ", ") +
|
||||
someOrNone(Weeks, Pluralize(Weeks, "week") + ", ") +
|
||||
someOrNone(Days, Pluralize(Days, "day") + ", ") +
|
||||
someOrNone(Hours, Pluralize(Hours, "hour") + ", ") +
|
||||
someOrNone(Minutes, Pluralize(Minutes, "minute") + ", ") +
|
||||
someOrNone(Seconds, Pluralize(Seconds, "second"));
|
||||
|
||||
if(str == ""){
|
||||
return "No Seconds";
|
||||
} else return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a plural version for a number
|
||||
* @param num The number to prefix
|
||||
* @param str The singular form of the string
|
||||
* @return Combined string, num + str in plural form if necessary
|
||||
*/
|
||||
private String Pluralize(int num, String str)
|
||||
{
|
||||
return num + " " + ((num > 1) ? str+"s" : str);
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple function to test a number, return a string, or return nothing at all.
|
||||
* @param num The number to check
|
||||
* @param str The string to return if the number is greater than zero
|
||||
* @return Str if num >1, or empty string
|
||||
*/
|
||||
private String someOrNone(int num, String str)
|
||||
{
|
||||
if(num > 0) return str;
|
||||
else return "";
|
||||
}
|
||||
/**
|
||||
* A simple function to test a number, return a string, or return something else.
|
||||
* @param num The number to check
|
||||
* @param str The string to return if the number is greater than zero
|
||||
* @return Str if num >1, or other string
|
||||
*/
|
||||
private String someOrOther(int num, String str, String other)
|
||||
{
|
||||
if(num > 0) return str;
|
||||
else return other;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes time notation!
|
||||
* @return A program readable string that can be decoded back to a time notation
|
||||
*/
|
||||
public String toNotation()
|
||||
{
|
||||
return Years + "Y" + Months + "M" + Weeks + "W" + Days + "d" + Hours + "h" + Minutes + "m" + Seconds + "s";
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a time notation string
|
||||
* @param notation Serialized time notation
|
||||
* @return The deserialized time notation object
|
||||
*/
|
||||
public static TimeNotation fromNotation(String notation)
|
||||
{
|
||||
TimeNotation notationX = new TimeNotation();
|
||||
String[] delims = new String[]{"Y", "M", "W", "d", "h", "m", "s"};
|
||||
List<String> opts = Lists.split(notation, delims);
|
||||
|
||||
|
||||
int index = 0;
|
||||
for(String dlim : delims)
|
||||
{
|
||||
if(notation.contains(dlim))
|
||||
{
|
||||
switch (dlim)
|
||||
{
|
||||
case "Y":
|
||||
{
|
||||
notationX.Years = Integer.parseInt(opts.get(index));
|
||||
|
||||
break;
|
||||
}
|
||||
case "M":
|
||||
{
|
||||
notationX.Months = Integer.parseInt(opts.get(index));
|
||||
|
||||
break;
|
||||
}
|
||||
case "W":
|
||||
{
|
||||
notationX.Weeks = Integer.parseInt(opts.get(index));
|
||||
|
||||
break;
|
||||
}
|
||||
case "d":
|
||||
{
|
||||
notationX.Days = Integer.parseInt(opts.get(index));
|
||||
|
||||
break;
|
||||
}
|
||||
case "h":
|
||||
{
|
||||
notationX.Hours = Integer.parseInt(opts.get(index));
|
||||
|
||||
break;
|
||||
}
|
||||
case "m":
|
||||
{
|
||||
notationX.Minutes = Integer.parseInt(opts.get(index));
|
||||
|
||||
break;
|
||||
}
|
||||
case "s":
|
||||
{
|
||||
notationX.Seconds = Integer.parseInt(opts.get(index));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
return notationX;
|
||||
|
||||
}
|
||||
}
|
96
src/main/java/com/zontreck/ariaslib/util/TimeUtil.java
Normal file
96
src/main/java/com/zontreck/ariaslib/util/TimeUtil.java
Normal file
|
@ -0,0 +1,96 @@
|
|||
package com.zontreck.ariaslib.util;
|
||||
|
||||
/**
|
||||
* This class is a helper with some minecraft specific functions
|
||||
*/
|
||||
public class TimeUtil
|
||||
{
|
||||
/**
|
||||
* Converts seconds to ticks. (seconds*ticks)
|
||||
* @param seconds Number of seconds
|
||||
* @param ticks Number of ticks in a single second
|
||||
* @return Number of ticks
|
||||
*/
|
||||
public static int secondsToTicks(int seconds, int ticks)
|
||||
{
|
||||
return seconds*ticks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the number of ticks to seconds
|
||||
* @param ticks The number of ticks to convert
|
||||
* @param ticksInASecond The number of ticks in a single second
|
||||
* @return Number of seconds
|
||||
*/
|
||||
public static int ticksToSeconds(int ticks, int ticksInASecond)
|
||||
{
|
||||
return ticks / ticksInASecond;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes a LibAC Time Notation
|
||||
* @param seconds Number of seconds to convert
|
||||
* @return Time Notation
|
||||
*/
|
||||
public static TimeNotation secondsToTimeNotation(int seconds)
|
||||
{
|
||||
int years = seconds / YEAR;
|
||||
if(years > 0) seconds -= YEAR * years;
|
||||
|
||||
int month = seconds / MONTH;
|
||||
if(month > 0) seconds -= MONTH * month;
|
||||
|
||||
int week = seconds / WEEK;
|
||||
if(week > 0) seconds -= WEEK * week;
|
||||
|
||||
int day = seconds / DAY;
|
||||
if(day > 0) seconds -= DAY * day;
|
||||
|
||||
int hour = seconds / HOUR;
|
||||
if(hour > 0) seconds -= HOUR * hour;
|
||||
|
||||
int minute = seconds / MINUTE;
|
||||
if(minute > 0) seconds -= MINUTE * minute;
|
||||
|
||||
return new TimeNotation(years, month, week, day, hour, minute, seconds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a time notation to seconds
|
||||
* @param notation Notation to convert
|
||||
* @return Total seconds
|
||||
*/
|
||||
public static int notationToSeconds(TimeNotation notation)
|
||||
{
|
||||
int seconds = 0;
|
||||
|
||||
seconds += (notation.Years * YEAR);
|
||||
seconds += (notation.Months * MONTH);
|
||||
seconds += (notation.Weeks * WEEK);
|
||||
seconds += (notation.Days * DAY);
|
||||
seconds += (notation.Hours * HOUR);
|
||||
seconds += (notation.Minutes * MINUTE);
|
||||
seconds += (notation.Seconds);
|
||||
|
||||
return seconds;
|
||||
}
|
||||
|
||||
|
||||
public static final int SECOND;
|
||||
public static final int MINUTE;
|
||||
public static final int HOUR;
|
||||
public static final int DAY;
|
||||
public static final int WEEK;
|
||||
public static final int MONTH;
|
||||
public static final int YEAR;
|
||||
|
||||
static {
|
||||
SECOND = 1;
|
||||
MINUTE = SECOND * 60;
|
||||
HOUR = MINUTE * 60;
|
||||
DAY = HOUR*24;
|
||||
WEEK = DAY*7;
|
||||
MONTH = WEEK*4;
|
||||
YEAR = DAY*365;
|
||||
}
|
||||
}
|
15
src/main/java/com/zontreck/block/DeprecatedBlock.java
Normal file
15
src/main/java/com/zontreck/block/DeprecatedBlock.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package com.zontreck.block;
|
||||
|
||||
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
|
||||
@Deprecated
|
||||
public class DeprecatedBlock extends Block
|
||||
{
|
||||
public DeprecatedBlock(){
|
||||
super(BlockBehaviour.Properties.copy(Blocks.STONE).instabreak());
|
||||
}
|
||||
}
|
||||
|
45
src/main/java/com/zontreck/block/DeprecatedBlockItem.java
Normal file
45
src/main/java/com/zontreck/block/DeprecatedBlockItem.java
Normal file
|
@ -0,0 +1,45 @@
|
|||
package com.zontreck.block;
|
||||
|
||||
|
||||
import com.zontreck.libzontreck.util.ChatHelpers;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Deprecated
|
||||
public class DeprecatedBlockItem extends BlockItem
|
||||
{
|
||||
public DeprecatedBlockItem(Block a)
|
||||
{
|
||||
super(a, new Item.Properties().fireResistant());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFoil(ItemStack p_41453_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is to give a use to an otherwise useless item. The piglins will exchange the item and it gets removed in that way.
|
||||
* @param stack
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isPiglinCurrency(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack p_41421_, Level p_41422_, List<Component> p_41423_, TooltipFlag p_41424_) {
|
||||
p_41423_.add(ChatHelpers.macro("!Dark_Red!This block is deprecated"));
|
||||
p_41423_.add(ChatHelpers.macro("!Dark_Green!It would appear this block smells faintly of gold. Maybe piglins will accept it?"));
|
||||
p_41423_.add(ChatHelpers.macro("!Dark_Red!This block is scheduled for removal in a future version. You should use it before it is too late."));
|
||||
}
|
||||
}
|
||||
|
87
src/main/java/com/zontreck/block/DeprecatedModBlocks.java
Normal file
87
src/main/java/com/zontreck/block/DeprecatedModBlocks.java
Normal file
|
@ -0,0 +1,87 @@
|
|||
package com.zontreck.block;
|
||||
|
||||
|
||||
import com.zontreck.AriasEssentials;
|
||||
import com.zontreck.items.CreativeModeTabs;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
@Deprecated
|
||||
public class DeprecatedModBlocks
|
||||
{
|
||||
|
||||
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, AriasEssentials.MOD_ID);
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, AriasEssentials.MOD_ID);
|
||||
|
||||
|
||||
public static void register(IEventBus bus){
|
||||
BLOCKS.register(bus);
|
||||
ITEMS.register(bus);
|
||||
AriasEssentials.LOGGER.info("Registering all deprecated blocks...");
|
||||
}
|
||||
|
||||
private static boolean never(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos) {
|
||||
return false;
|
||||
}
|
||||
private static boolean always(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static BlockBehaviour.Properties standardBehavior()
|
||||
{
|
||||
return BlockBehaviour.Properties.of(Material.STONE).requiresCorrectToolForDrops().strength(7F).destroyTime(6);
|
||||
}
|
||||
private static BlockBehaviour.Properties stoneLikeBehavior()
|
||||
{
|
||||
return BlockBehaviour.Properties.copy(Blocks.COBBLESTONE);
|
||||
}
|
||||
|
||||
private static BlockBehaviour.Properties explosionResistance()
|
||||
{
|
||||
return standardBehavior().explosionResistance(1200);
|
||||
}
|
||||
|
||||
private static BlockBehaviour.Properties noViewBlocking()
|
||||
{
|
||||
return standardBehavior().noOcclusion().isViewBlocking(DeprecatedModBlocks::never);
|
||||
}
|
||||
|
||||
private static BlockBehaviour.Properties fullBright()
|
||||
{
|
||||
return standardBehavior().lightLevel((X)->{
|
||||
return 15;
|
||||
}).noOcclusion();
|
||||
}
|
||||
|
||||
private static BlockBehaviour.Properties standard = standardBehavior();
|
||||
|
||||
private static BlockBehaviour.Properties explosionResistance = explosionResistance();
|
||||
|
||||
private static BlockBehaviour.Properties noViewBlocking = noViewBlocking();
|
||||
|
||||
private static BlockBehaviour.Properties stone = stoneLikeBehavior();
|
||||
|
||||
private static BlockBehaviour.Properties poolLightClean = BlockBehaviour.Properties.copy(Blocks.GLASS).lightLevel((X) -> 15);
|
||||
private static BlockBehaviour.Properties poolLightDirty = BlockBehaviour.Properties.copy(Blocks.GLASS).lightLevel((X) -> 12);
|
||||
private static BlockBehaviour.Properties poolLightFilthy = BlockBehaviour.Properties.copy(Blocks.GLASS).lightLevel((X) -> 4);
|
||||
|
||||
public static RegistryObject<Block> registerDeprecated(RegistryObject<Block> blk)
|
||||
{
|
||||
CreativeModeTabs.addToAETab(ITEMS.register(blk.getId().getPath(), ()->new DeprecatedBlockItem(blk.get())));
|
||||
|
||||
return blk;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
19
src/main/java/com/zontreck/block/FoiledBlockItem.java
Normal file
19
src/main/java/com/zontreck/block/FoiledBlockItem.java
Normal file
|
@ -0,0 +1,19 @@
|
|||
package com.zontreck.block;
|
||||
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
public class FoiledBlockItem extends BlockItem {
|
||||
|
||||
public FoiledBlockItem(Block pBlock, Properties pProperties) {
|
||||
super(pBlock, pProperties);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFoil(ItemStack pStack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
382
src/main/java/com/zontreck/block/ModBlocks.java
Normal file
382
src/main/java/com/zontreck/block/ModBlocks.java
Normal file
|
@ -0,0 +1,382 @@
|
|||
package com.zontreck.block;
|
||||
|
||||
|
||||
import com.zontreck.AriasEssentials;
|
||||
import com.zontreck.items.CreativeModeTabs;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class ModBlocks {
|
||||
|
||||
private static BlockBehaviour.StatePredicate shulkerState = (p_152653_, p_152654_, p_152655_) -> {
|
||||
BlockEntity blockentity = p_152654_.getBlockEntity(p_152655_);
|
||||
if (!(blockentity instanceof ShulkerBoxBlockEntity)) {
|
||||
return true;
|
||||
} else {
|
||||
ShulkerBoxBlockEntity shulkerboxblockentity = (ShulkerBoxBlockEntity)blockentity;
|
||||
return shulkerboxblockentity.isClosed();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, AriasEssentials.MOD_ID);
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, AriasEssentials.MOD_ID);
|
||||
|
||||
private static boolean never(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos) {
|
||||
return false;
|
||||
}
|
||||
private static boolean always(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private static boolean neverSpawn(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, EntityType<?> entityType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void register(IEventBus bus){
|
||||
BLOCKS.register(bus);
|
||||
ITEMS.register(bus);
|
||||
AriasEssentials.LOGGER.info("Registering all blocks...");
|
||||
}
|
||||
|
||||
private static BlockBehaviour.Properties standardBehavior()
|
||||
{
|
||||
return BlockBehaviour.Properties.of(Material.STONE).requiresCorrectToolForDrops().strength(7F).destroyTime(6).isValidSpawn(ModBlocks::neverSpawn);
|
||||
}
|
||||
private static BlockBehaviour.Properties gratingBlock()
|
||||
{
|
||||
return standardBehavior()
|
||||
.noOcclusion()
|
||||
.strength(0.5f, 2000f)
|
||||
.isViewBlocking(ModBlocks::never);
|
||||
}
|
||||
|
||||
private static BlockBehaviour.Properties stoneLikeBehavior()
|
||||
{
|
||||
return BlockBehaviour.Properties.copy(Blocks.COBBLESTONE).isValidSpawn(ModBlocks::neverSpawn);
|
||||
}
|
||||
|
||||
private static BlockBehaviour.Properties explosionResistance()
|
||||
{
|
||||
return standardBehavior().explosionResistance(1200);
|
||||
}
|
||||
|
||||
private static BlockBehaviour.Properties noViewBlocking()
|
||||
{
|
||||
return standardBehavior().noOcclusion().isViewBlocking(ModBlocks::never);
|
||||
}
|
||||
|
||||
private static BlockBehaviour.Properties fullBright()
|
||||
{
|
||||
return standardBehavior().lightLevel((X)->{
|
||||
return 15;
|
||||
}).noOcclusion();
|
||||
}
|
||||
|
||||
private static BlockBehaviour.Properties standard = standardBehavior();
|
||||
|
||||
private static BlockBehaviour.Properties explosionResistance = explosionResistance();
|
||||
|
||||
private static BlockBehaviour.Properties noViewBlocking = noViewBlocking();
|
||||
|
||||
private static BlockBehaviour.Properties stone = stoneLikeBehavior();
|
||||
|
||||
private static BlockBehaviour.Properties gratingBlock = gratingBlock();
|
||||
|
||||
private static BlockBehaviour.Properties poolLightClean = BlockBehaviour.Properties.copy(Blocks.GLASS).lightLevel((X) -> 15);
|
||||
private static BlockBehaviour.Properties poolLightDirty = BlockBehaviour.Properties.copy(Blocks.GLASS).lightLevel((X) -> 12);
|
||||
private static BlockBehaviour.Properties poolLightFilthy = BlockBehaviour.Properties.copy(Blocks.GLASS).lightLevel((X) -> 4);
|
||||
|
||||
|
||||
public static RegistryObject<Block> registerWithItem(RegistryObject<Block> blk, Item.Properties props)
|
||||
{
|
||||
CreativeModeTabs.addToAETab(ITEMS.register(blk.getId().getPath(), ()->new BlockItem(blk.get(), props.tab(CreativeModeTabs.AETAB))));
|
||||
|
||||
return blk;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static final RegistryObject<Block> DARK_RED_WOOL = registerWithItem(BLOCKS.register("dark_red_wool", ()->new Block(BlockBehaviour.Properties.copy(Blocks.RED_WOOL))), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> DARK_RED_CARPET = registerWithItem(BLOCKS.register("dark_red_carpet", ()->new CarpetBlock(BlockBehaviour.Properties.copy(Blocks.RED_CARPET))), new Item.Properties());
|
||||
|
||||
|
||||
public static final RegistryObject<Block> ETERNIUM_ORE_BLOCK = registerWithItem(BLOCKS.register("eternium_ore_block", ()->new DropExperienceBlock(explosionResistance)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> ETERNIUM_BLOCK = registerWithItem(BLOCKS.register("eternium_block", ()->new Block(explosionResistance)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> DEEPSLATE_ETERNIUM_ORE_BLOCK = registerWithItem(BLOCKS.register("deepslate_eternium_ore_block", ()->new DropExperienceBlock(explosionResistance)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> VOID = registerWithItem(BLOCKS.register("void", ()->new Block(fullBright().noCollission())), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> WHITEOUT = registerWithItem(BLOCKS.register("whiteout", ()->new Block(fullBright().noCollission())), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> BLOOD_RED = registerWithItem(BLOCKS.register("blood_red", ()->new Block(fullBright())), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> RED_TILE = registerWithItem(BLOCKS.register("red_tile", ()-> new Block(fullBright())), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> RED_STAIRS = registerWithItem(BLOCKS.register("red_stairs", ()-> new StairBlock(BLOOD_RED.get()::defaultBlockState, fullBright())), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> RED_TILE_BR = registerWithItem(BLOCKS.register("red_tile_br", ()->new RotatableBlock(fullBright())), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> RED_TILE_TO_WALL = registerWithItem(BLOCKS.register("red_tile_to_wall", ()->new Block(fullBright())), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> RED_WALL_V1 = registerWithItem(BLOCKS.register("red_wall_variant_1", ()->new Block(fullBright())), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> RED_WALL_V2 = registerWithItem(BLOCKS.register("red_wall_variant_2", ()->new Block(fullBright())), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> CYAN = registerWithItem(BLOCKS.register("cyan", ()->new Block(fullBright())), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> CYAN_TILE = registerWithItem(BLOCKS.register("cyan_tile", ()->new Block(fullBright())), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> CYAN_STAIRS = registerWithItem(BLOCKS.register("cyan_stairs", ()->new StairBlock(CYAN.get()::defaultBlockState, fullBright())), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> CYAN_TILE_BR = registerWithItem(BLOCKS.register("cyan_tile_br", ()->new RotatableBlock(fullBright())), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> CYAN_TILE_TO_WALL = registerWithItem(BLOCKS.register("cyan_tile_to_wall", ()->new Block(fullBright())), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> CYAN_WALL_V1 = registerWithItem(BLOCKS.register("cyan_wall_variant_1", ()->new Block(fullBright())), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> CYAN_WALL_V2 = registerWithItem(BLOCKS.register("cyan_wall_variant_2", ()->new Block(fullBright())), new Item.Properties());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static final RegistryObject<Block> POOL_TILE = registerWithItem(BLOCKS.register("pool_tile", ()->new Block(stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> POOL_TILE_STAIRS = registerWithItem(BLOCKS.register("pool_tile_stairs", ()->new StairBlock(POOL_TILE.get()::defaultBlockState, stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> POOL_TILE_SLAB = registerWithItem(BLOCKS.register("pool_tile_slab", ()->new SlabBlock(stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> POOL_TILE_WALL = registerWithItem(BLOCKS.register("pool_tile_wall", ()->new WallBlock(stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> POOL_LIGHT = registerWithItem(BLOCKS.register("pool_light", ()->new Block(poolLightClean)), new Item.Properties());
|
||||
|
||||
|
||||
|
||||
public static final RegistryObject<Block> DIRTY_POOL_TILE = registerWithItem(BLOCKS.register("dirty_pool_tile", ()->new Block(stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> DIRTY_POOL_TILE_STAIRS = registerWithItem(BLOCKS.register("dirty_pool_tile_stairs", ()->new StairBlock(DIRTY_POOL_TILE.get()::defaultBlockState, stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> DIRTY_POOL_TILE_SLAB = registerWithItem(BLOCKS.register("dirty_pool_tile_slab", ()-> new SlabBlock(stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> DIRTY_POOL_TILE_WALL = registerWithItem(BLOCKS.register("dirty_pool_tile_wall", ()->new WallBlock(stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> DIRTY_POOL_LIGHT = registerWithItem(BLOCKS.register("dirty_pool_light", ()->new Block(poolLightDirty)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> FILTHY_POOL_LIGHT = registerWithItem(BLOCKS.register("filthy_pool_light", ()->new Block(poolLightFilthy)), new Item.Properties());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static final RegistryObject<Block> DARK_POOL_TILE = registerWithItem(BLOCKS.register("dark_pool_tile", ()->new Block(stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> DARK_POOL_LIGHT = registerWithItem(BLOCKS.register("dark_pool_light", ()->new Block(poolLightClean)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> DARK_POOL_TILE_STAIRS = registerWithItem(BLOCKS.register("dark_pool_tile_stairs", ()->new StairBlock(DARK_POOL_TILE.get()::defaultBlockState, stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> DARK_POOL_TILE_SLAB = registerWithItem(BLOCKS.register("dark_pool_tile_slab",()-> new SlabBlock(stone)), new Item.Properties());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static final RegistryObject<Block> BLUE_POOL_TILE = registerWithItem(BLOCKS.register("blue_pool_tile",()-> new Block(stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> BLUE_POOL_TILE_STAIRS = registerWithItem(BLOCKS.register("blue_pool_tile_stairs", ()->new StairBlock(BLUE_POOL_TILE.get()::defaultBlockState, stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> BLUE_POOL_TILE_SLAB = registerWithItem(BLOCKS.register("blue_pool_tile_slab",()-> new SlabBlock(stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> BLUE_POOL_TILE_WALL = registerWithItem(BLOCKS.register("blue_pool_tile_wall", ()->new WallBlock(stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> BLUE_POOL_LIGHT = registerWithItem(BLOCKS.register("blue_pool_light", ()->new Block(poolLightClean)), new Item.Properties());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static final RegistryObject<Block> DIRTY_BLUE_POOL_TILE = registerWithItem(BLOCKS.register("dirty_blue_pool_tile", ()->new Block(stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> DIRTY_BLUE_POOL_TILE_STAIRS = registerWithItem(BLOCKS.register("dirty_blue_pool_tile_stairs", ()->new StairBlock(DIRTY_BLUE_POOL_TILE.get()::defaultBlockState, stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> DIRTY_BLUE_POOL_TILE_SLAB = registerWithItem(BLOCKS.register("dirty_blue_pool_tile_slab", ()->new SlabBlock(stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> DIRTY_BLUE_POOL_TILE_WALL = registerWithItem(BLOCKS.register("dirty_blue_pool_tile_wall", ()->new WallBlock(stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> DIRTY_BLUE_POOL_LIGHT = registerWithItem(BLOCKS.register("dirty_blue_pool_light", ()->new Block(poolLightDirty)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> FILTHY_BLUE_POOL_LIGHT = registerWithItem(BLOCKS.register("filthy_blue_pool_light", ()->new Block(poolLightFilthy)), new Item.Properties());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static final RegistryObject<Block> RED_POOL_TILE = registerWithItem(BLOCKS.register("red_pool_tile", ()->new Block(stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> RED_POOL_TILE_STAIRS = registerWithItem(BLOCKS.register("red_pool_tile_stairs", ()->new StairBlock(RED_POOL_TILE.get()::defaultBlockState, stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> RED_POOL_TILE_SLAB = registerWithItem(BLOCKS.register("red_pool_tile_slab", ()->new SlabBlock(stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> RED_POOL_TILE_WALL = registerWithItem(BLOCKS.register("red_pool_tile_wall", ()->new WallBlock(stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> RED_POOL_LIGHT = registerWithItem(BLOCKS.register("red_pool_light", ()->new Block(poolLightClean)), new Item.Properties());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static final RegistryObject<Block> DIRTY_RED_POOL_TILE = registerWithItem(BLOCKS.register("dirty_red_pool_tile", ()->new Block(stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> DIRTY_RED_POOL_LIGHT = registerWithItem(BLOCKS.register("dirty_red_pool_light", ()->new Block(poolLightDirty)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> FILTHY_RED_POOL_LIGHT = registerWithItem(BLOCKS.register("filthy_red_pool_light", ()->new Block(poolLightFilthy)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> DIRTY_RED_POOL_TILE_STAIRS = registerWithItem(BLOCKS.register("dirty_red_pool_tile_stairs", ()->new StairBlock(DIRTY_RED_POOL_TILE.get()::defaultBlockState, stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> DIRTY_RED_POOL_TILE_SLAB = registerWithItem(BLOCKS.register("dirty_red_pool_tile_slab", ()->new SlabBlock(stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> DIRTY_RED_POOL_TILE_WALL = registerWithItem(BLOCKS.register("dirty_red_pool_tile_wall", ()->new WallBlock(stone)), new Item.Properties());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static final RegistryObject<Block> GREEN_POOL_TILE = registerWithItem(BLOCKS.register("green_pool_tile", ()->new Block(stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> GREEN_POOL_TILE_STAIRS = registerWithItem(BLOCKS.register("green_pool_tile_stairs", ()->new StairBlock(GREEN_POOL_TILE.get()::defaultBlockState, stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> GREEN_POOL_TILE_SLAB = registerWithItem(BLOCKS.register("green_pool_tile_slab", ()->new SlabBlock(stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> GREEN_POOL_TILE_WALL = registerWithItem(BLOCKS.register("green_pool_tile_wall", ()->new WallBlock(stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> GREEN_POOL_LIGHT = registerWithItem(BLOCKS.register("green_pool_light", ()->new Block(poolLightClean)), new Item.Properties());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static final RegistryObject<Block> DIRTY_GREEN_POOL_TILE = registerWithItem(BLOCKS.register("dirty_green_pool_tile", ()->new Block(stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> DIRTY_GREEN_POOL_LIGHT = registerWithItem(BLOCKS.register("dirty_green_pool_light", ()->new Block(poolLightDirty)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> FILTHY_GREEN_POOL_LIGHT = registerWithItem(BLOCKS.register("filthy_green_pool_light", ()->new Block(poolLightFilthy)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> DIRTY_GREEN_POOL_TILE_STAIRS = registerWithItem(BLOCKS.register("dirty_green_pool_tile_stairs", ()->new StairBlock(DIRTY_GREEN_POOL_TILE.get()::defaultBlockState, stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> DIRTY_GREEN_POOL_TILE_SLAB = registerWithItem(BLOCKS.register("dirty_green_pool_tile_slab", ()->new SlabBlock(stone)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> DIRTY_GREEN_POOL_TILE_WALL = registerWithItem(BLOCKS.register("dirty_green_pool_tile_wall", ()->new WallBlock(stone)), new Item.Properties());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
ENGINEERS DECOR BLOCKS
|
||||
|
||||
*/
|
||||
|
||||
public static final RegistryObject<Block> CLINKER_BRICK_BLOCK = registerWithItem(BLOCKS.register("clinker_brick_block", ()->new Block(standardBehavior().strength(0.5f, 7f).sound(SoundType.STONE)
|
||||
)), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> CLINKER_BRICK_SLAB = registerWithItem(BLOCKS.register("clinker_brick_slab", ()->new SlabBlock(BlockBehaviour.Properties.copy(Blocks.STONE_SLAB))), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> CLINKER_BRICK_STAIRS = registerWithItem(BLOCKS.register("clinker_brick_stairs", ()->new StairBlock(CLINKER_BRICK_BLOCK.get()::defaultBlockState, BlockBehaviour.Properties.copy(Blocks.STONE_STAIRS))), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> CLINKER_BRICK_WALL = registerWithItem(BLOCKS.register("clinker_brick_wall", ()->new WallBlock(BlockBehaviour.Properties.copy(Blocks.STONE_BRICK_WALL))), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> CLINKER_BRICK_STAINED_BLOCK = registerWithItem(BLOCKS.register("clinker_brick_stained_block", ()->new Block(BlockBehaviour.Properties.copy(Blocks.STONE))), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> CLINKER_BRICK_STAINED_SLAB = registerWithItem(BLOCKS.register("clinker_brick_stained_slab", ()-> new SlabBlock(BlockBehaviour.Properties.copy(Blocks.STONE))), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> CLINKER_BRICK_STAINED_STAIRS = registerWithItem(BLOCKS.register("clinker_brick_stained_stairs", ()-> new StairBlock(CLINKER_BRICK_STAINED_BLOCK.get()::defaultBlockState, BlockBehaviour.Properties.copy(Blocks.STONE))), new Item.Properties());
|
||||
|
||||
/*public static final RegistryObject<Block> CLINKER_BRICK_VERTICAL_SLAB_STRUCTURED = registerWithItem(BLOCKS.register("clinker_brick_vertical_slab_structured", () -> new StandardBlocks.HorizontalWaterLoggable(
|
||||
StandardBlocks.CFG_CUTOUT | StandardBlocks.CFG_HORIZIONTAL | StandardBlocks.CFG_LOOK_PLACEMENT,
|
||||
BlockBehaviour.Properties.of().strength(0.5f, 7f).sound(SoundType.STONE),
|
||||
new AABB[]{
|
||||
Auxiliaries.getPixeledAABB(0, 0, 0, 16, 16, 8),
|
||||
}
|
||||
)), new Item.Properties());*/
|
||||
|
||||
public static final RegistryObject<Block> SLAG_BRICK_BLOCK = registerWithItem(BLOCKS.register("slag_brick_block", ()-> new Block(BlockBehaviour.Properties.copy(Blocks.STONE))), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> SLAG_BRICK_SLAB = registerWithItem(BLOCKS.register("slag_brick_slab", ()-> new SlabBlock(BlockBehaviour.Properties.copy(Blocks.STONE))), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> SLAG_BRICK_STAIRS = registerWithItem(BLOCKS.register("slag_brick_stairs", ()-> new StairBlock(SLAG_BRICK_BLOCK.get()::defaultBlockState, BlockBehaviour.Properties.copy(Blocks.STONE))), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> SLAG_BRICK_WALL = registerWithItem(BLOCKS.register("slag_brick_wall", ()-> new WallBlock(BlockBehaviour.Properties.copy(Blocks.STONE_BRICK_WALL))), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> REBAR_CONCRETE_BLOCK = registerWithItem(BLOCKS.register("rebar_concrete", ()-> new Block(BlockBehaviour.Properties.copy(Blocks.STONE).isValidSpawn(ModBlocks::neverSpawn).strength(1f, 2000f))), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> REBAR_CONCRETE_SLAB = registerWithItem(BLOCKS.register("rebar_concrete_slab", ()-> new SlabBlock(BlockBehaviour.Properties.copy(Blocks.STONE).strength(1f, 2000f).isValidSpawn(ModBlocks::neverSpawn))), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> REBAR_CONCRETE_STAIRS = registerWithItem(BLOCKS.register("rebar_concrete_stairs", ()-> new StairBlock(ModBlocks.REBAR_CONCRETE_BLOCK.get()::defaultBlockState, BlockBehaviour.Properties.copy(Blocks.STONE).strength(1f, 2000f).isValidSpawn(ModBlocks::neverSpawn))), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> REBAR_CONCRETE_WALL = registerWithItem(BLOCKS.register("rebar_concrete_wall", ()-> new WallBlock(BlockBehaviour.Properties.copy(Blocks.STONE).strength(1f, 2000f).isValidSpawn(ModBlocks::neverSpawn))), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> REBAR_CONCRETE_TILE_BLOCK = registerWithItem(BLOCKS.register("rebar_concrete_tile", ()-> new Block(BlockBehaviour.Properties.copy(Blocks.STONE).isValidSpawn(ModBlocks::neverSpawn).strength(1f, 2000f))), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> REBAR_CONCRETE_TILE_SLAB = registerWithItem(BLOCKS.register("rebar_concrete_tile_slab", ()-> new SlabBlock(BlockBehaviour.Properties.copy(Blocks.STONE).strength(1f, 2000f).isValidSpawn(ModBlocks::neverSpawn))), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> REBAR_CONCRETE_TILE_STAIRS = registerWithItem(BLOCKS.register("rebar_concrete_tile_stairs", ()-> new StairBlock(ModBlocks.REBAR_CONCRETE_BLOCK.get()::defaultBlockState, BlockBehaviour.Properties.copy(Blocks.STONE).strength(1f, 2000f).isValidSpawn(ModBlocks::neverSpawn))), new Item.Properties());
|
||||
|
||||
/*public static final RegistryObject<Block> REBAR_CONCRETE_HALFSLAB = registerWithItem(BLOCKS.register("halfslab_rebar_concrete", () -> new SlabSliceBlock(
|
||||
StandardBlocks.CFG_CUTOUT,
|
||||
BlockBehaviour.Properties.of().strength(1.0f, 2000f).sound(SoundType.STONE).isValidSpawn(ModBlocks::neverSpawn)
|
||||
)), new Item.Properties());*/
|
||||
|
||||
public static final RegistryObject<Block> PANZER_GLASS_BLOCK = registerWithItem(BLOCKS.register("panzerglass_block", ()-> new Block(noViewBlocking().noOcclusion().strength(0.5f, 2000f).isValidSpawn(ModBlocks::neverSpawn).sound(SoundType.METAL))), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> PANZER_GLASS_SLAB = registerWithItem(BLOCKS.register("panzerglass_slab", ()-> new SlabBlock(noViewBlocking().noOcclusion().strength(0.5f, 2000f).isValidSpawn(ModBlocks::neverSpawn).sound(SoundType.METAL))), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> OLD_INDUSTRIAL_WOOD_PLANKS = registerWithItem(BLOCKS.register("old_industrial_wood_planks", ()-> new Block(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS).strength(0.5f, 6f).sound(SoundType.WOOD))), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> OLD_INDUSTRIAL_WOOD_SLAB = registerWithItem(BLOCKS.register("old_industrial_wood_slab", ()-> new SlabBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS).strength(0.5f, 6f).sound(SoundType.WOOD))), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> OLD_INDUSTRIAL_WOOD_STAIRS = registerWithItem(BLOCKS.register("old_industrial_wood_stairs", ()-> new StairBlock(ModBlocks.OLD_INDUSTRIAL_WOOD_PLANKS.get()::defaultBlockState, BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS).strength(0.5f, 6f).sound(SoundType.WOOD))), new Item.Properties());
|
||||
|
||||
public static final RegistryObject<Block> OLD_INDUSTRIAL_WOOD_DOOR = registerWithItem(BLOCKS.register("old_industrial_wood_door", ()-> new DoorBlock(BlockBehaviour.Properties.copy(Blocks.OAK_PLANKS).strength(0.5f, 6f).noOcclusion().sound(SoundType.WOOD))), new Item.Properties());
|
||||
|
||||
}
|
||||
|
19
src/main/java/com/zontreck/block/RegistryObj.java
Normal file
19
src/main/java/com/zontreck/block/RegistryObj.java
Normal file
|
@ -0,0 +1,19 @@
|
|||
package com.zontreck.block;
|
||||
|
||||
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class RegistryObj
|
||||
{
|
||||
public RegistryObject<Block> block;
|
||||
public RegistryObject<? extends Item> item;
|
||||
|
||||
public RegistryObj(RegistryObject<Block> blk, RegistryObject<? extends Item> item)
|
||||
{
|
||||
this.block=blk;
|
||||
this.item=item;
|
||||
}
|
||||
}
|
||||
|
27
src/main/java/com/zontreck/block/RotatableBlock.java
Normal file
27
src/main/java/com/zontreck/block/RotatableBlock.java
Normal file
|
@ -0,0 +1,27 @@
|
|||
package com.zontreck.block;
|
||||
|
||||
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
|
||||
public class RotatableBlock extends HorizontalDirectionalBlock
|
||||
{
|
||||
protected RotatableBlock(Properties pProperties) {
|
||||
super(pProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) {
|
||||
super.createBlockStateDefinition(pBuilder);
|
||||
pBuilder.add(FACING);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext pContext) {
|
||||
return defaultBlockState().setValue(FACING, pContext.getHorizontalDirection());
|
||||
}
|
||||
}
|
13
src/main/java/com/zontreck/block/VoidBlock.java
Normal file
13
src/main/java/com/zontreck/block/VoidBlock.java
Normal file
|
@ -0,0 +1,13 @@
|
|||
package com.zontreck.block;
|
||||
|
||||
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
public class VoidBlock extends Block
|
||||
{
|
||||
public VoidBlock(Properties pProperties) {
|
||||
super(pProperties);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package com.zontreck.block.types;
|
||||
|
||||
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.block.IronBarsBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
/** Pane block with sensible culling */
|
||||
public class AlternatePaneBlock extends IronBarsBlock {
|
||||
public static final EnumMap<Direction, BooleanProperty> DIRECTIONS;
|
||||
static {
|
||||
DIRECTIONS = new EnumMap<>(Direction.class);
|
||||
DIRECTIONS.put(Direction.NORTH, NORTH);
|
||||
DIRECTIONS.put(Direction.EAST, EAST);
|
||||
DIRECTIONS.put(Direction.SOUTH, SOUTH);
|
||||
DIRECTIONS.put(Direction.WEST, WEST);
|
||||
}
|
||||
|
||||
public AlternatePaneBlock(Properties builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean skipRendering(BlockState state, BlockState adjacentBlockState, Direction side) {
|
||||
// cull top and bottom if all props that we have are contained in the above or below
|
||||
if (adjacentBlockState.getBlock() == this && side.getAxis().isVertical()) {
|
||||
for (Direction dir : Direction.Plane.HORIZONTAL) {
|
||||
BooleanProperty prop = DIRECTIONS.get(dir);
|
||||
if (state.getValue(prop) && !adjacentBlockState.getValue(prop)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return super.skipRendering(state, adjacentBlockState, side);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package dev.zontreck.essentials.client.renderer;
|
||||
package com.zontreck.client;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Quaternion;
|
||||
import com.mojang.math.Vector3f;
|
||||
import dev.zontreck.essentials.entities.TimeBoostEntity;
|
||||
import com.zontreck.entities.TimeBoostEntity;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
|
@ -12,8 +12,7 @@ import net.minecraft.client.renderer.entity.EntityRenderer;
|
|||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class TimeBoostEntityRenderer extends EntityRenderer<TimeBoostEntity>
|
||||
{
|
||||
public class TimeBoostEntityRenderer extends EntityRenderer<TimeBoostEntity> {
|
||||
|
||||
public TimeBoostEntityRenderer(EntityRendererProvider.Context erp) {
|
||||
super(erp);
|
31
src/main/java/com/zontreck/commands/CommandRegistry.java
Normal file
31
src/main/java/com/zontreck/commands/CommandRegistry.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
package com.zontreck.commands;
|
||||
|
||||
import com.zontreck.commands.homes.DelHomeCommand;
|
||||
import com.zontreck.commands.homes.HomeCommand;
|
||||
import com.zontreck.commands.homes.HomesCommand;
|
||||
import com.zontreck.commands.homes.SetHomeCommand;
|
||||
import com.zontreck.commands.items.ShareItemInChatCommand;
|
||||
import com.zontreck.commands.items.TIABDebug;
|
||||
import com.zontreck.commands.teleport.*;
|
||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE)
|
||||
public class CommandRegistry
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void onCommandRegister(RegisterCommandsEvent ev) {
|
||||
TPACommand.register(ev.getDispatcher());
|
||||
TPAcceptCommand.register(ev.getDispatcher());
|
||||
TPDenyCommand.register(ev.getDispatcher());
|
||||
TPCancelCommand.register(ev.getDispatcher());
|
||||
TPAHereCommand.register(ev.getDispatcher());
|
||||
HomesCommand.register(ev.getDispatcher());
|
||||
SetHomeCommand.register(ev.getDispatcher());
|
||||
DelHomeCommand.register(ev.getDispatcher());
|
||||
HomeCommand.register(ev.getDispatcher());
|
||||
ShareItemInChatCommand.register(ev.getDispatcher());
|
||||
//TIABDebug.register(ev.getDispatcher());
|
||||
}
|
||||
}
|
|
@ -1,16 +1,14 @@
|
|||
package dev.zontreck.essentials.commands.homes;
|
||||
package com.zontreck.commands.homes;
|
||||
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
|
||||
import dev.zontreck.essentials.AriasEssentials;
|
||||
import dev.zontreck.essentials.Messages;
|
||||
import dev.zontreck.essentials.events.CommandExecutionEvent;
|
||||
import dev.zontreck.essentials.homes.HomesSuggestionProvider;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import com.zontreck.Messages;
|
||||
import com.zontreck.events.CommandExecutionEvent;
|
||||
import com.zontreck.libzontreck.profiles.Profile;
|
||||
import com.zontreck.libzontreck.util.ChatHelpers;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.commands.FunctionCommand;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
|
@ -21,20 +19,21 @@ public class DelHomeCommand {
|
|||
Commands.literal("rmhome")
|
||||
.executes(c->rmHome(c.getSource(), "default"))
|
||||
.then(Commands.argument("nickname", StringArgumentType.string())
|
||||
.executes(c->rmHome(c.getSource(), StringArgumentType.getString(c, "nickname")))
|
||||
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
private static int rmHome(CommandSourceStack ctx, String homeName)
|
||||
{
|
||||
|
||||
var exec = new CommandExecutionEvent(ctx.getPlayer(), "delhome");
|
||||
var exec = new CommandExecutionEvent(ctx.getPlayer(), "rmhome");
|
||||
if(MinecraftForge.EVENT_BUS.post(exec))
|
||||
{
|
||||
return 0;
|
||||
|
@ -47,7 +46,10 @@ public class DelHomeCommand {
|
|||
try{
|
||||
ServerPlayer p = ctx.getPlayerOrException();
|
||||
|
||||
AriasEssentials.player_homes.get(p.getUUID()).delete(homeName);
|
||||
Profile prof = Profile.factory(p);
|
||||
prof.homes.delete(homeName);
|
||||
|
||||
prof.commit();
|
||||
|
||||
|
||||
ChatHelpers.broadcastTo(p, ChatHelpers.macro(Messages.HOME_DELETE_SUCCESS), ctx.getServer());
|
|
@ -1,19 +1,18 @@
|
|||
package dev.zontreck.essentials.commands.homes;
|
||||
package com.zontreck.commands.homes;
|
||||
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import dev.zontreck.essentials.AriasEssentials;
|
||||
import dev.zontreck.essentials.Messages;
|
||||
import dev.zontreck.essentials.commands.teleport.TeleportActioner;
|
||||
import dev.zontreck.essentials.commands.teleport.TeleportContainer;
|
||||
import dev.zontreck.essentials.commands.teleport.TeleportDestination;
|
||||
import dev.zontreck.essentials.events.CommandExecutionEvent;
|
||||
import dev.zontreck.essentials.homes.Home;
|
||||
import dev.zontreck.essentials.exceptions.NoSuchHomeException;
|
||||
import dev.zontreck.essentials.homes.HomesSuggestionProvider;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import com.zontreck.Messages;
|
||||
import com.zontreck.events.CommandExecutionEvent;
|
||||
import com.zontreck.exceptions.NoSuchHomeException;
|
||||
import com.zontreck.homes.Home;
|
||||
import com.zontreck.libzontreck.profiles.Profile;
|
||||
import com.zontreck.libzontreck.util.ChatHelpers;
|
||||
import com.zontreck.util.TeleportActioner;
|
||||
import com.zontreck.util.TeleportContainer;
|
||||
import com.zontreck.util.TeleportDestination;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
@ -25,8 +24,8 @@ public class HomeCommand {
|
|||
dispatcher.register(Commands.literal("home").executes(c-> home(c.getSource(), "default")).then(Commands.argument("name", StringArgumentType.string()).executes(c->home(c.getSource(), StringArgumentType.getString(c, "name")))));
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
|
@ -44,7 +43,8 @@ public class HomeCommand {
|
|||
// if(homeName==null)return 0;
|
||||
try{
|
||||
ServerPlayer p = ctx.getPlayerOrException();
|
||||
Home home = AriasEssentials.player_homes.get(p.getUUID()).get(homeName);
|
||||
Profile prof = Profile.factory(p);
|
||||
Home home = prof.homes.get(homeName);
|
||||
|
||||
//Transaction tx = new Transaction(Bank.getAccount(p.getUUID()), Bank.SYSTEM, AEServerConfig.COST_TO_TP_HOME.get(), Instant.now().getEpochSecond());
|
||||
|
|
@ -1,33 +1,37 @@
|
|||
package dev.zontreck.essentials.commands.homes;
|
||||
package com.zontreck.commands.homes;
|
||||
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import dev.zontreck.essentials.AriasEssentials;
|
||||
import dev.zontreck.essentials.Messages;
|
||||
import dev.zontreck.essentials.commands.teleport.TeleportActioner;
|
||||
import dev.zontreck.essentials.commands.teleport.TeleportContainer;
|
||||
import dev.zontreck.essentials.commands.teleport.TeleportDestination;
|
||||
import dev.zontreck.essentials.homes.Home;
|
||||
import dev.zontreck.essentials.homes.Homes;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.chat.Clickable;
|
||||
import dev.zontreck.libzontreck.chat.HoverTip;
|
||||
import dev.zontreck.libzontreck.chestgui.ChestGUI;
|
||||
import dev.zontreck.libzontreck.chestgui.ChestGUIButton;
|
||||
import dev.zontreck.libzontreck.chestgui.ChestGUIIdentifier;
|
||||
import dev.zontreck.libzontreck.lore.LoreEntry;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.vectors.Vector2i;
|
||||
import com.zontreck.Messages;
|
||||
import com.zontreck.events.CommandExecutionEvent;
|
||||
import com.zontreck.exceptions.NoSuchHomeException;
|
||||
import com.zontreck.homes.Home;
|
||||
import com.zontreck.homes.Homes;
|
||||
import com.zontreck.libzontreck.chat.ChatColor;
|
||||
import com.zontreck.libzontreck.chat.Clickable;
|
||||
import com.zontreck.libzontreck.chat.HoverTip;
|
||||
import com.zontreck.libzontreck.chestgui.ChestGUI;
|
||||
import com.zontreck.libzontreck.chestgui.ChestGUIButton;
|
||||
import com.zontreck.libzontreck.chestgui.ChestGUIIdentifier;
|
||||
import com.zontreck.libzontreck.lore.LoreEntry;
|
||||
import com.zontreck.libzontreck.profiles.Profile;
|
||||
import com.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import com.zontreck.libzontreck.util.ChatHelpers;
|
||||
import com.zontreck.libzontreck.vectors.Vector2i;
|
||||
import com.zontreck.util.TeleportActioner;
|
||||
import com.zontreck.util.TeleportContainer;
|
||||
import com.zontreck.util.TeleportDestination;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
public class HomesCommand {
|
||||
private static final ChestGUIIdentifier HOMES_GUI_ID = new ChestGUIIdentifier("homes-gui");
|
||||
|
@ -43,7 +47,8 @@ public class HomesCommand {
|
|||
try{
|
||||
ServerPlayer player = ctx.getSource().getPlayerOrException();
|
||||
|
||||
Homes homes = AriasEssentials.player_homes.get(player.getUUID());
|
||||
Profile prof = Profile.factory(player);
|
||||
Homes homes = prof.homes;
|
||||
|
||||
ChatHelpers.broadcastTo(player.getUUID(), ChatHelpers.macro(Messages.HOME_COUNT, String.valueOf(homes.count())), player.server);
|
||||
|
||||
|
@ -95,7 +100,6 @@ public class HomesCommand {
|
|||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,29 +1,23 @@
|
|||
package dev.zontreck.essentials.commands.homes;
|
||||
package com.zontreck.commands.homes;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
||||
import dev.zontreck.essentials.AriasEssentials;
|
||||
import dev.zontreck.essentials.Messages;
|
||||
import dev.zontreck.essentials.commands.teleport.TeleportActioner;
|
||||
import dev.zontreck.essentials.commands.teleport.TeleportDestination;
|
||||
import dev.zontreck.essentials.events.CommandExecutionEvent;
|
||||
import dev.zontreck.essentials.homes.Home;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.essentials.configs.server.AEServerConfig;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.vectors.Vector2f;
|
||||
import dev.zontreck.libzontreck.vectors.Vector2i;
|
||||
import dev.zontreck.libzontreck.vectors.Vector3d;
|
||||
import com.zontreck.Messages;
|
||||
import com.zontreck.configs.server.AEServerConfig;
|
||||
import com.zontreck.events.CommandExecutionEvent;
|
||||
import com.zontreck.homes.Home;
|
||||
import com.zontreck.libzontreck.profiles.Profile;
|
||||
import com.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import com.zontreck.libzontreck.util.ChatHelpers;
|
||||
import com.zontreck.libzontreck.vectors.Vector2f;
|
||||
import com.zontreck.libzontreck.vectors.Vector3d;
|
||||
import com.zontreck.util.TeleportActioner;
|
||||
import com.zontreck.util.TeleportDestination;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
|
@ -33,11 +27,18 @@ import net.minecraftforge.common.MinecraftForge;
|
|||
public class SetHomeCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("sethome").executes(c->setHome(c.getSource(), "default")).then(Commands.argument("nickname", StringArgumentType.string()).executes(c -> setHome(c.getSource(), StringArgumentType.getString(c, "nickname")))));
|
||||
dispatcher.register(
|
||||
Commands.literal("sethome")
|
||||
.executes(c->setHome(c.getSource(), "default"))
|
||||
.then(Commands.argument("nickname", StringArgumentType.string())
|
||||
.executes(c -> setHome(c.getSource(), StringArgumentType.getString(c, "nickname")))
|
||||
)
|
||||
|
||||
);
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
|
@ -74,7 +75,10 @@ public class SetHomeCommand {
|
|||
BlockState bs = p.getLevel().getBlockState(dest.Position.moveDown().asBlockPos());
|
||||
|
||||
Home newhome = new Home(p, homeName, dest, new ItemStack(p.getBlockStateOn().getBlock().asItem()));
|
||||
AriasEssentials.player_homes.get(p.getUUID()).add(newhome);
|
||||
|
||||
Profile prof = Profile.factory(p);
|
||||
prof.homes.add(newhome);
|
||||
prof.commit();
|
||||
|
||||
|
||||
ChatHelpers.broadcastTo(p.getUUID(), ChatHelpers.macro(Messages.HOME_CREATE_SUCCESS), ctx.getServer());
|
|
@ -0,0 +1,60 @@
|
|||
package com.zontreck.commands.items;
|
||||
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.zontreck.Messages;
|
||||
import com.zontreck.libzontreck.chat.HoverTip;
|
||||
import com.zontreck.libzontreck.profiles.Profile;
|
||||
import com.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import com.zontreck.libzontreck.util.ChatHelpers;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.AirItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.server.ServerLifecycleHooks;
|
||||
|
||||
public class ShareItemInChatCommand {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("shareitem").executes(c->share_item(c.getSource())));
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
private static int share_item(CommandSourceStack source) {
|
||||
|
||||
if(source.getEntity() instanceof Player)
|
||||
{
|
||||
ServerPlayer play = (ServerPlayer)source.getEntity();
|
||||
ItemStack is = play.getItemInHand(InteractionHand.MAIN_HAND);
|
||||
if(is.getItem() instanceof AirItem)
|
||||
{
|
||||
play.displayClientMessage(ChatHelpers.macro(Messages.ESSENTIALS_PREFIX +" !Dark_Red!You cannot share air in the chat."), false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Profile prof = Profile.factory(play);
|
||||
|
||||
|
||||
MutableComponent component = ChatHelpers.macro(Messages.ESSENTIALS_PREFIX).append(is.getDisplayName()).append(ChatHelpers.macro(" !White!-!Dark_Purple! Hover here to see the item that "+prof.name_color+prof.nickname+"!Dark_Purple! shared"));
|
||||
Style style = Style.EMPTY.withFont(Style.DEFAULT_FONT);
|
||||
component = component.withStyle(style.withHoverEvent(HoverTip.getItem(is)));
|
||||
|
||||
ChatHelpers.broadcast(component, ServerLifecycleHooks.getCurrentServer());
|
||||
|
||||
}else {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
54
src/main/java/com/zontreck/commands/items/TIABDebug.java
Normal file
54
src/main/java/com/zontreck/commands/items/TIABDebug.java
Normal file
|
@ -0,0 +1,54 @@
|
|||
package com.zontreck.commands.items;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.zontreck.configs.server.AEServerConfig;
|
||||
import com.zontreck.items.abstracts.AbstractTIAB;
|
||||
import com.zontreck.items.impl.TimeBottle;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class TIABDebug {
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("tiab_set_expire").executes(c->setBottleExpired(c.getSource())));
|
||||
|
||||
dispatcher.register(Commands.literal("tiab_shift_uses").executes(c->shiftBottleUses(c.getSource())));
|
||||
|
||||
dispatcher.register(Commands.literal("tiab_reset").executes(c->resetBottle(c.getSource())));
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
private static int setBottleExpired(CommandSourceStack stack) {
|
||||
ItemStack item = stack.getPlayer().getMainHandItem();
|
||||
TimeBottle TIAB = (TimeBottle) item.getItem();
|
||||
|
||||
TIAB.setTotalAccumulatedTime(item, Integer.MAX_VALUE);
|
||||
TIAB.setExpired(item);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int shiftBottleUses(CommandSourceStack stack) {
|
||||
|
||||
ItemStack item = stack.getPlayer().getMainHandItem();
|
||||
TimeBottle TIAB = (TimeBottle) item.getItem();
|
||||
|
||||
TIAB.setStoredEnergy(item, 20 * AEServerConfig.getInstance().bottles.eachUseDuration * 20);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int resetBottle(CommandSourceStack stack) {
|
||||
|
||||
ItemStack item = stack.getPlayer().getMainHandItem();
|
||||
item.setTag(new CompoundTag());
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,36 +1,34 @@
|
|||
package dev.zontreck.essentials.commands.teleport;
|
||||
package com.zontreck.commands.teleport;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
|
||||
import dev.zontreck.ariaslib.terminal.Task;
|
||||
import dev.zontreck.essentials.Messages;
|
||||
import dev.zontreck.essentials.events.CommandExecutionEvent;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.chat.Clickable;
|
||||
import dev.zontreck.libzontreck.chat.HoverTip;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import com.zontreck.Messages;
|
||||
import com.zontreck.events.CommandExecutionEvent;
|
||||
import com.zontreck.libzontreck.chat.ChatColor;
|
||||
import com.zontreck.libzontreck.chat.Clickable;
|
||||
import com.zontreck.libzontreck.chat.HoverTip;
|
||||
import com.zontreck.libzontreck.profiles.Profile;
|
||||
import com.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import com.zontreck.libzontreck.util.ChatHelpers;
|
||||
import com.zontreck.util.TeleportContainer;
|
||||
import com.zontreck.util.TeleportRegistry;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
public class TPACommand {
|
||||
|
||||
public class TPACommand
|
||||
{
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("tpa").executes(c->usage(c.getSource())).then(Commands.argument("player", EntityArgument.player()).executes(c -> tpa(c.getSource(), EntityArgument.getPlayer(c, "player")))));
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
|
@ -97,11 +95,11 @@ public class TPACommand {
|
|||
}
|
||||
serverPlayer.playSound(Messages.TPA_SOUND, 1, serverPlayer.getRandom().nextFloat());
|
||||
ChatHelpers.broadcastTo(cont.ToPlayer, ChatHelpers.macro(Messages.TPA, p.name_color+p.nickname).
|
||||
append(ChatHelpers.macro(Messages.TELEPORT_ACCEPT+" ").setStyle(s)).
|
||||
append(ChatHelpers.macro(Messages.TELEPORT_DENY).setStyle(s2)), serverPlayer.server);
|
||||
append(ChatHelpers.macro(Messages.TELEPORT_ACCEPT+" ").setStyle(s)).
|
||||
append(ChatHelpers.macro(Messages.TELEPORT_DENY).setStyle(s2)), serverPlayer.server);
|
||||
|
||||
TeleportRegistry.get().add(cont);
|
||||
Thread tx = new Thread(new Task("tpa_expire",true){
|
||||
Thread tx = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
|
@ -123,7 +121,7 @@ public class TPACommand {
|
|||
|
||||
private static int usage(CommandSourceStack source) {
|
||||
|
||||
source.sendSystemMessage(ChatHelpers.macro("/tpa USAGE\n\n "+ChatColor.BOLD + ChatColor.DARK_GRAY+"/tpa "+ChatColor.DARK_RED+"target_player\n"));
|
||||
source.sendSystemMessage(ChatHelpers.macro("/tpa USAGE\n\n "+ ChatColor.BOLD + ChatColor.DARK_GRAY+"/tpa "+ChatColor.DARK_RED+"target_player\n"));
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,32 +1,35 @@
|
|||
package dev.zontreck.essentials.commands.teleport;
|
||||
package com.zontreck.commands.teleport;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
|
||||
import dev.zontreck.ariaslib.terminal.Task;
|
||||
import dev.zontreck.essentials.Messages;
|
||||
import dev.zontreck.essentials.events.CommandExecutionEvent;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.chat.Clickable;
|
||||
import dev.zontreck.libzontreck.chat.HoverTip;
|
||||
import dev.zontreck.libzontreck.profiles.Profile;
|
||||
import dev.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import com.zontreck.Messages;
|
||||
import com.zontreck.events.CommandExecutionEvent;
|
||||
import com.zontreck.libzontreck.chat.ChatColor;
|
||||
import com.zontreck.libzontreck.chat.Clickable;
|
||||
import com.zontreck.libzontreck.chat.HoverTip;
|
||||
import com.zontreck.libzontreck.profiles.Profile;
|
||||
import com.zontreck.libzontreck.profiles.UserProfileNotYetExistsException;
|
||||
import com.zontreck.libzontreck.util.ChatHelpers;
|
||||
import com.zontreck.util.TeleportContainer;
|
||||
import com.zontreck.util.TeleportRegistry;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.network.chat.*;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
public class TPAHereCommand {
|
||||
|
||||
public class TPAHereCommand
|
||||
{
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("tpahere").executes(c->usage(c.getSource())).then(Commands.argument("player", EntityArgument.player()).executes(c -> tpa(c.getSource(), EntityArgument.getPlayer(c, "player")))));
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
||||
|
@ -93,12 +96,12 @@ public class TPAHereCommand {
|
|||
}
|
||||
serverPlayer.playSound(Messages.TPA_SOUND, 1, serverPlayer.getRandom().nextFloat());
|
||||
ChatHelpers.broadcastTo(cont.FromPlayer, ChatHelpers.macro(Messages.TPA_HERE, p.name_color+p.nickname).
|
||||
append(ChatHelpers.macro(Messages.TELEPORT_ACCEPT+" ").setStyle(s)).
|
||||
append(ChatHelpers.macro(Messages.TELEPORT_DENY).setStyle(s2)), serverPlayer.server);
|
||||
append(ChatHelpers.macro(Messages.TELEPORT_ACCEPT+" ").setStyle(s)).
|
||||
append(ChatHelpers.macro(Messages.TELEPORT_DENY).setStyle(s2)), serverPlayer.server);
|
||||
|
||||
TeleportRegistry.get().add(cont);
|
||||
|
||||
Thread tx = new Thread(new Task("tpahere_expire",true){
|
||||
Thread tx = new Thread(new Runnable(){
|
||||
@Override
|
||||
public void run()
|
||||
{
|
|
@ -1,23 +1,23 @@
|
|||
package dev.zontreck.essentials.commands.teleport;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
package com.zontreck.commands.teleport;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
|
||||
import dev.zontreck.essentials.Messages;
|
||||
import dev.zontreck.essentials.events.CommandExecutionEvent;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import com.zontreck.Messages;
|
||||
import com.zontreck.events.CommandExecutionEvent;
|
||||
import com.zontreck.libzontreck.util.ChatHelpers;
|
||||
import com.zontreck.util.TeleportActioner;
|
||||
import com.zontreck.util.TeleportContainer;
|
||||
import com.zontreck.util.TeleportRegistry;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
public class TPAcceptCommand {
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TPAcceptCommand {
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("tpaccept").then(Commands.argument("TeleportUUID", StringArgumentType.string()).executes(c->doAccept(c.getSource(), StringArgumentType.getString(c, "TeleportUUID")))));
|
|
@ -1,21 +1,21 @@
|
|||
package dev.zontreck.essentials.commands.teleport;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
package com.zontreck.commands.teleport;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
|
||||
import dev.zontreck.essentials.Messages;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import com.zontreck.Messages;
|
||||
import com.zontreck.libzontreck.util.ChatHelpers;
|
||||
import com.zontreck.util.TeleportContainer;
|
||||
import com.zontreck.util.TeleportRegistry;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class TPCancelCommand {
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TPCancelCommand
|
||||
{
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("tpcancel").then(Commands.argument("TeleportUUID", StringArgumentType.string()).executes(c->doCancel(c.getSource(), StringArgumentType.getString(c, "TeleportUUID")))));
|
||||
|
@ -23,8 +23,8 @@ public class TPCancelCommand {
|
|||
//executes(c -> doCancel(c.getSource())));
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
|
@ -1,21 +1,21 @@
|
|||
package dev.zontreck.essentials.commands.teleport;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
package com.zontreck.commands.teleport;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
|
||||
import dev.zontreck.essentials.Messages;
|
||||
import dev.zontreck.libzontreck.chat.ChatColor;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import com.zontreck.Messages;
|
||||
import com.zontreck.libzontreck.util.ChatHelpers;
|
||||
import com.zontreck.util.TeleportContainer;
|
||||
import com.zontreck.util.TeleportRegistry;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public class TPDenyCommand {
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TPDenyCommand
|
||||
{
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher)
|
||||
{
|
||||
dispatcher.register(Commands.literal("tpdeny").then(Commands.argument("TeleportUUID", StringArgumentType.string()).executes(c->doCancel(c.getSource(), StringArgumentType.getString(c, "TeleportUUID")))));
|
||||
|
@ -23,8 +23,8 @@ public class TPDenyCommand {
|
|||
//executes(c -> doCancel(c.getSource())));
|
||||
|
||||
//dispatcher.register(Commands.literal("sethome").then(Commands.argument("nickname", StringArgumentType.string())).executes(command -> {
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//String arg = StringArgumentType.getString(command, "nickname");
|
||||
//return setHome(command.getSource(), arg);
|
||||
//}));
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package dev.zontreck.essentials.configs.client;
|
||||
package com.zontreck.configs.client;
|
||||
|
||||
import dev.zontreck.essentials.util.EssentialsDatastore;
|
||||
import dev.zontreck.libzontreck.util.SNbtIo;
|
||||
import com.zontreck.libzontreck.util.SNbtIo;
|
||||
import com.zontreck.util.EssentialsDatastore;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
@ -20,12 +20,13 @@ public class AEClientConfig
|
|||
AEClientConfig config = new AEClientConfig();
|
||||
config.EnableHearts = tag.getBoolean(TAG_HEARTS);
|
||||
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
public static void loadFromFile()
|
||||
{
|
||||
Path serverConfig = EssentialsDatastore.of("client.snbt");
|
||||
Path serverConfig = EssentialsDatastore.of("client.snbt", false);
|
||||
if(serverConfig.toFile().exists())
|
||||
{
|
||||
|
||||
|
@ -47,8 +48,6 @@ public class AEClientConfig
|
|||
{
|
||||
EnableHearts = true;
|
||||
|
||||
|
||||
|
||||
save();
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package com.zontreck.configs.client.sections;
|
||||
|
||||
public class Messages
|
||||
{
|
||||
|
||||
}
|
148
src/main/java/com/zontreck/configs/server/AEServerConfig.java
Normal file
148
src/main/java/com/zontreck/configs/server/AEServerConfig.java
Normal file
|
@ -0,0 +1,148 @@
|
|||
package com.zontreck.configs.server;
|
||||
|
||||
import com.zontreck.AriasEssentials;
|
||||
import com.zontreck.ariaslib.util.Lists;
|
||||
import com.zontreck.configs.server.sections.Bottles;
|
||||
import com.zontreck.configs.server.sections.Drops;
|
||||
import com.zontreck.configs.server.sections.Messages;
|
||||
import com.zontreck.configs.server.sections.Teleportation;
|
||||
import com.zontreck.libzontreck.util.SNbtIo;
|
||||
import com.zontreck.util.EssentialsDatastore;
|
||||
import net.minecraft.nbt.*;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class AEServerConfig
|
||||
{
|
||||
private static AEServerConfig inst;
|
||||
public Bottles bottles;
|
||||
public Teleportation teleport;
|
||||
public Messages messages;
|
||||
public Drops drops;
|
||||
public boolean enable_debug = false;
|
||||
|
||||
|
||||
|
||||
public static AEServerConfig deserialize(CompoundTag tag)
|
||||
{
|
||||
AEServerConfig config = new AEServerConfig();
|
||||
try {
|
||||
AriasEssentials.LOGGER.info("Loading Aria's Essentials configuration for - Server");
|
||||
if(tag.contains(Bottles.TAG_NAME))
|
||||
{
|
||||
config.bottles = Bottles.deserialize(tag.getCompound(Bottles.TAG_NAME));
|
||||
} else config.resetBottles();
|
||||
|
||||
|
||||
if(tag.contains(Teleportation.TAG_NAME))
|
||||
config.teleport = Teleportation.deserialize(tag.getCompound(Teleportation.TAG_NAME));
|
||||
else {
|
||||
config.resetTeleport();
|
||||
}
|
||||
|
||||
if(tag.contains(Messages.TAG_NAME))
|
||||
config.messages = Messages.deserialize(tag.getCompound(Messages.TAG_NAME));
|
||||
else config.messages = new Messages();
|
||||
|
||||
if(tag.contains("use_debug"))
|
||||
config.enable_debug = tag.getBoolean("use_debug");
|
||||
else config.enable_debug=false;
|
||||
|
||||
if(tag.contains(Drops.TAG_NAME))
|
||||
config.drops = Drops.load(tag.getCompound(Drops.TAG_NAME));
|
||||
else {
|
||||
config.resetDrops();
|
||||
}
|
||||
|
||||
AriasEssentials.LOGGER.info("Aria's Essentials Server Configuration Loaded");
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
public static void loadFromFile()
|
||||
{
|
||||
Path serverConfig = EssentialsDatastore.of("server.snbt",false);
|
||||
if(serverConfig.toFile().exists())
|
||||
{
|
||||
inst = deserialize(SNbtIo.loadSnbt(serverConfig));
|
||||
|
||||
save(); // incase of updates
|
||||
}else {
|
||||
initNewConfig();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static void initNewConfig()
|
||||
{
|
||||
inst = new AEServerConfig();
|
||||
inst.resetBottles(); // also saves
|
||||
inst.resetTeleport();
|
||||
inst.resetDrops();
|
||||
inst.messages = new Messages();
|
||||
inst.enable_debug=false;
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
private void resetBottles()
|
||||
{
|
||||
bottles = new Bottles();
|
||||
}
|
||||
|
||||
private void resetTeleport() {
|
||||
|
||||
teleport = new Teleportation();
|
||||
teleport.Effects = Lists.of(
|
||||
"minecraft:darkness",
|
||||
"minecraft:levitation",
|
||||
"minecraft:slow_falling",
|
||||
"minecraft:hunger"
|
||||
);
|
||||
teleport.Blacklist = Lists.of(
|
||||
"dimdoors:dungeon_pockets",
|
||||
"dimdoors:limbo",
|
||||
"dimdoors:personal_pockets",
|
||||
"dimdoors:public_pockets",
|
||||
"witherstormmod:bowels"
|
||||
);
|
||||
}
|
||||
|
||||
private void resetDrops() {
|
||||
drops = new Drops();
|
||||
}
|
||||
|
||||
public static void save()
|
||||
{
|
||||
Path serverConfig = EssentialsDatastore.of("server.snbt", false);
|
||||
|
||||
CompoundTag tag = inst.serialize();
|
||||
SNbtIo.writeSnbt(serverConfig, tag);
|
||||
}
|
||||
|
||||
public CompoundTag serialize()
|
||||
{
|
||||
CompoundTag tag = new CompoundTag();
|
||||
tag.put(Bottles.TAG_NAME, bottles.serialize());
|
||||
tag.put(Teleportation.TAG_NAME, teleport.serialize());
|
||||
tag.put(Messages.TAG_NAME, messages.serialize());
|
||||
tag.putBoolean("use_debug", enable_debug);
|
||||
tag.put(Drops.TAG_NAME, drops.save());
|
||||
|
||||
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static AEServerConfig getInstance()
|
||||
{
|
||||
return inst;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package dev.zontreck.essentials.configs.server.sections;
|
||||
package com.zontreck.configs.server.sections;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
|
@ -10,6 +10,8 @@ public class Bottles {
|
|||
public static final String TAG_MAX_TIME_RATE = "maxTimeRate";
|
||||
public static final String TAG_STORED_TIME = "maxTime";
|
||||
|
||||
public static final String TAG_MESSAGE_EXPIRED_BOTTLE = "expireMsg";
|
||||
|
||||
public static final String TAG_MESSAGE_STORED_TIME = "msg_storedTime";
|
||||
public static final String TAG_MESSAGE_ACCUMULATED_TIME = "msg_accumulatedTime";
|
||||
public static final String TAG_TOTAL_USES = "msg_totalUses";
|
||||
|
@ -25,7 +27,7 @@ public class Bottles {
|
|||
public String storedTimeStr = "!Dark_Green!Stored Time: [0]";
|
||||
public String accumulatedTimeStr = "!Gray!Total Accumulated Time: [0]";
|
||||
public String totalUses = "!Dark_Red!Total available uses: [0]";
|
||||
|
||||
public String expiredBottle = "!Dark_Green!This bottle is [0][1]";
|
||||
|
||||
|
||||
public CompoundTag serialize()
|
||||
|
@ -39,6 +41,7 @@ public class Bottles {
|
|||
tag.putString(TAG_MESSAGE_ACCUMULATED_TIME, accumulatedTimeStr);
|
||||
tag.putString(TAG_TOTAL_USES, totalUses);
|
||||
tag.putInt(TAG_STORED_TIME, maxTime);
|
||||
tag.putString(TAG_MESSAGE_EXPIRED_BOTTLE, expiredBottle);
|
||||
|
||||
|
||||
return tag;
|
||||
|
@ -73,6 +76,9 @@ public class Bottles {
|
|||
if(tag.contains(TAG_TOTAL_USES))
|
||||
bottles.totalUses = tag.getString(TAG_TOTAL_USES);
|
||||
|
||||
if(tag.contains(TAG_MESSAGE_EXPIRED_BOTTLE))
|
||||
bottles.expiredBottle = tag.getString(TAG_MESSAGE_EXPIRED_BOTTLE);
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package com.zontreck.configs.server.sections;
|
||||
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
public class Drops
|
||||
{
|
||||
public static final String TAG_NAME = "drops";
|
||||
public static final String TAG_PLAYER_HEAD_DROPS = "enablePlayerHeadDrops";
|
||||
public static final String TAG_SPAWN_EGG_CHANCE = "mobEggingChance";
|
||||
public static final String TAG_PLAYER_HEAD_CHANCE = "playerHeadChance";
|
||||
|
||||
public boolean enablePlayerHeadChance = true;
|
||||
public int mobEggingChance = 5;
|
||||
public int playerHeadChance=10;
|
||||
|
||||
|
||||
public CompoundTag save()
|
||||
{
|
||||
CompoundTag tag = new CompoundTag();
|
||||
tag.putBoolean(TAG_PLAYER_HEAD_DROPS, enablePlayerHeadChance);
|
||||
tag.putFloat(TAG_SPAWN_EGG_CHANCE, mobEggingChance);
|
||||
tag.putFloat(TAG_PLAYER_HEAD_CHANCE, playerHeadChance);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static Drops load(CompoundTag tag)
|
||||
{
|
||||
Drops drops = new Drops();
|
||||
|
||||
if(tag.contains(TAG_PLAYER_HEAD_DROPS))
|
||||
drops.enablePlayerHeadChance = tag.getBoolean(TAG_PLAYER_HEAD_DROPS);
|
||||
|
||||
if(tag.contains(TAG_SPAWN_EGG_CHANCE))
|
||||
drops.mobEggingChance = tag.getInt(TAG_SPAWN_EGG_CHANCE);
|
||||
|
||||
if(tag.contains(TAG_PLAYER_HEAD_CHANCE))
|
||||
drops.playerHeadChance = tag.getInt(TAG_PLAYER_HEAD_CHANCE);
|
||||
|
||||
return drops;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
package dev.zontreck.essentials.configs.server.sections;
|
||||
package com.zontreck.configs.server.sections;
|
||||
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
|
@ -26,3 +27,4 @@ public class Messages
|
|||
return tag;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dev.zontreck.essentials.configs.server.sections;
|
||||
package com.zontreck.configs.server.sections;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
|
@ -8,8 +8,7 @@ import net.minecraft.nbt.Tag;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Teleportation
|
||||
{
|
||||
public class Teleportation {
|
||||
public static final String TAG_NAME = "teleport";
|
||||
public static final String TAG_EFFECTS = "effects";
|
||||
public static final String TAG_BLACKLIST = "blacklist";
|
84
src/main/java/com/zontreck/effects/FlightEffect.java
Normal file
84
src/main/java/com/zontreck/effects/FlightEffect.java
Normal file
|
@ -0,0 +1,84 @@
|
|||
package com.zontreck.effects;
|
||||
|
||||
|
||||
import com.zontreck.Messages;
|
||||
import com.zontreck.libzontreck.util.ChatHelpers;
|
||||
import com.zontreck.libzontreck.util.ServerUtilities;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffectCategory;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeMap;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
public class FlightEffect extends MobEffect {
|
||||
int lastDuration = -1;
|
||||
ServerPlayer myPlayer;
|
||||
protected FlightEffect(MobEffectCategory pCategory, int pColor) {
|
||||
super(pCategory, pColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDurationEffectTick(int pDuration, int pAmplifier) {
|
||||
lastDuration=pDuration;
|
||||
|
||||
if(myPlayer!=null) {
|
||||
if(myPlayer.getAbilities().mayfly == false) {
|
||||
myPlayer.getAbilities().mayfly=true;
|
||||
myPlayer.onUpdateAbilities();
|
||||
}
|
||||
}
|
||||
|
||||
//OTEMod.LOGGER.info("Effect duration: " + lastDuration);
|
||||
return pDuration > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBeneficial() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAttributeModifiers(LivingEntity entity, AttributeMap map, int i) {
|
||||
super.addAttributeModifiers(entity, map, i);
|
||||
|
||||
if(entity instanceof ServerPlayer player)
|
||||
{
|
||||
if(player.getAbilities().mayfly==false)
|
||||
{
|
||||
myPlayer=player;
|
||||
player.getAbilities().mayfly=true;
|
||||
player.onUpdateAbilities();
|
||||
|
||||
ChatHelpers.broadcastTo(player, ChatHelpers.macro(Messages.FLIGHT_GIVEN), player.server);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removeFlightModifier(LivingEntity entity)
|
||||
{
|
||||
if(lastDuration == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ( entity instanceof Player player )
|
||||
{
|
||||
if(ServerUtilities.isServer() && lastDuration < (5*20))
|
||||
{
|
||||
ServerPlayer serverPlayer = (ServerPlayer) player;
|
||||
serverPlayer.getAbilities().mayfly = false;
|
||||
serverPlayer.getAbilities().flying = false;
|
||||
|
||||
serverPlayer.onUpdateAbilities();
|
||||
|
||||
ChatHelpers.broadcastTo(serverPlayer, ChatHelpers.macro(Messages.FLIGHT_REMOVED), serverPlayer.server);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttributeModifiers(LivingEntity entity, AttributeMap p_19470_, int p_19471_) {
|
||||
super.removeAttributeModifiers(entity, p_19470_, p_19471_);
|
||||
removeFlightModifier(entity);
|
||||
}
|
||||
}
|
25
src/main/java/com/zontreck/effects/ModEffects.java
Normal file
25
src/main/java/com/zontreck/effects/ModEffects.java
Normal file
|
@ -0,0 +1,25 @@
|
|||
package com.zontreck.effects;
|
||||
|
||||
|
||||
import com.zontreck.AriasEssentials;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffectCategory;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class ModEffects
|
||||
{
|
||||
public static final DeferredRegister<MobEffect> REGISTRY = DeferredRegister.create(ForgeRegistries.MOB_EFFECTS, AriasEssentials.MOD_ID);
|
||||
|
||||
public static final RegistryObject<MobEffect> FLIGHT = REGISTRY.register("flight", ()->new FlightEffect(MobEffectCategory.BENEFICIAL, 0xFF0000FF));
|
||||
|
||||
|
||||
|
||||
public static void register(IEventBus bus)
|
||||
{
|
||||
REGISTRY.register(bus);
|
||||
}
|
||||
}
|
||||
|
28
src/main/java/com/zontreck/effects/ModPotions.java
Normal file
28
src/main/java/com/zontreck/effects/ModPotions.java
Normal file
|
@ -0,0 +1,28 @@
|
|||
package com.zontreck.effects;
|
||||
|
||||
|
||||
import com.zontreck.AriasEssentials;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.item.alchemy.Potion;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class ModPotions {
|
||||
public static final DeferredRegister<Potion> REGISTRY = DeferredRegister.create(ForgeRegistries.POTIONS, AriasEssentials.MOD_ID);
|
||||
|
||||
|
||||
public static final RegistryObject<Potion> AWKWARD_FLIGHT = REGISTRY.register("flight_awkward", ()->new Potion(new MobEffectInstance(ModEffects.FLIGHT.get(), 30*20, 1)));
|
||||
|
||||
public static final RegistryObject<Potion> MUNDANE_FLIGHT = REGISTRY.register("flight_basic", ()->new Potion(new MobEffectInstance(ModEffects.FLIGHT.get(), 60*20, 1)));
|
||||
|
||||
public static final RegistryObject<Potion> FLIGHT = REGISTRY.register("flight", ()->new Potion(new MobEffectInstance(ModEffects.FLIGHT.get(), 360*20, 1)));
|
||||
|
||||
|
||||
public static void register(IEventBus bus)
|
||||
{
|
||||
REGISTRY.register(bus);
|
||||
}
|
||||
}
|
||||
|
160
src/main/java/com/zontreck/enchantments/ConsumptionMending.java
Normal file
160
src/main/java/com/zontreck/enchantments/ConsumptionMending.java
Normal file
|
@ -0,0 +1,160 @@
|
|||
package com.zontreck.enchantments;
|
||||
|
||||
|
||||
import com.zontreck.libzontreck.util.ItemUtils;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ConsumptionMending extends Enchantment
|
||||
{
|
||||
protected ConsumptionMending(EquipmentSlot... slots) {
|
||||
super(Rarity.RARE, EnchantmentCategory.BREAKABLE, slots);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLevel() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTradeable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTreasureOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCurse() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinCost(int pLevel) {
|
||||
return 25 + (pLevel-1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxCost(int pLevel) {
|
||||
return pLevel * 23;
|
||||
}
|
||||
|
||||
private static List<ItemStack> append(ServerPlayer player, List<ItemStack> items)
|
||||
{
|
||||
List<ItemStack> enchanted = new ArrayList<>();
|
||||
|
||||
for(ItemStack stack : player.getInventory().items)
|
||||
{
|
||||
if(ItemUtils.getEnchantmentLevel(ModEnchantments.CONSUMPTION_MENDING.get(), stack) > 0)
|
||||
{
|
||||
enchanted.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
return enchanted;
|
||||
}
|
||||
|
||||
public static void onEntityTick(ServerPlayer player)
|
||||
{
|
||||
// Check what items have this enchantment
|
||||
// If any, check for like-items that lack the enchant.
|
||||
|
||||
List<ItemStack> enchanted = ItemUtils.getPlayerInventory(player);
|
||||
List<ItemStack> procList = new ArrayList<>(enchanted);
|
||||
|
||||
for(ItemStack stack : enchanted)
|
||||
{
|
||||
int dmgValue = stack.getDamageValue();
|
||||
if(ItemUtils.getEnchantmentLevel(ModEnchantments.CONSUMPTION_MENDING.get(), stack) == 0 || dmgValue == 0) continue; // Skip, because this is a ineligible item
|
||||
|
||||
for(ItemStack item : procList)
|
||||
{
|
||||
// Is this a like item, and does it have the enchant?
|
||||
boolean eligible = false;
|
||||
if(!(ItemUtils.getEnchantmentLevel(ModEnchantments.CONSUMPTION_MENDING.get(), item)>0))
|
||||
{
|
||||
eligible=true;
|
||||
if(!item.isDamageableItem())
|
||||
{
|
||||
eligible=false;
|
||||
}
|
||||
}
|
||||
|
||||
if(stack.getDamageValue()==0)
|
||||
{
|
||||
eligible=false;
|
||||
}
|
||||
|
||||
if(stack.sameItem(item)) {
|
||||
eligible = false;
|
||||
}
|
||||
|
||||
if(eligible)
|
||||
{
|
||||
// Let's eat
|
||||
int iDamage = stack.getDamageValue();
|
||||
int iMax = stack.getMaxDamage();
|
||||
|
||||
int iNeeds = iDamage * 2;
|
||||
|
||||
// The stack we are inspecting:
|
||||
int nDamage = item.getDamageValue();
|
||||
int nMax = item.getMaxDamage();
|
||||
|
||||
int iRemain = nMax - nDamage;
|
||||
|
||||
if(iRemain == iNeeds)
|
||||
{
|
||||
nDamage = nMax;
|
||||
iDamage=0;
|
||||
} else {
|
||||
if(iRemain > iNeeds)
|
||||
{
|
||||
iDamage -= iNeeds;
|
||||
nDamage += iNeeds;
|
||||
} else {
|
||||
iDamage -= iRemain;
|
||||
nDamage = nMax;
|
||||
}
|
||||
}
|
||||
|
||||
if(nDamage == nMax){
|
||||
// Check for curses on the item
|
||||
if(item.isEnchanted())
|
||||
{
|
||||
Map<Enchantment, Integer> enchantments = ItemUtils.getEnchantments(item);
|
||||
for(Map.Entry<Enchantment,Integer> entry : enchantments.entrySet())
|
||||
{
|
||||
Enchantment id = entry.getKey();
|
||||
int dice = player.getRandom().nextInt(0,20);
|
||||
|
||||
if(id.isCurse() && ((dice >= 13) && (dice <= 18)))
|
||||
{
|
||||
stack.enchant(id, entry.getValue());
|
||||
player.getLevel().playSound(null, player.getOnPos(), SoundEvents.ANVIL_USE, SoundSource.NEUTRAL,1, player.getRandom().nextFloat());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
item.shrink(1);
|
||||
player.getLevel().playSound(null, player.getOnPos(), SoundEvents.PLAYER_BURP, SoundSource.NEUTRAL,1, player.getRandom().nextFloat());
|
||||
}
|
||||
else item.setDamageValue(nDamage);
|
||||
|
||||
stack.setDamageValue(iDamage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.zontreck.enchantments;
|
||||
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.MobType;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
|
||||
public class DamageIncreaseEnchantment extends Enchantment
|
||||
{
|
||||
protected DamageIncreaseEnchantment(Rarity arg, EnchantmentCategory arg2, EquipmentSlot[] args) {
|
||||
super(arg, arg2, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCurse() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowedOnBooks() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTradeable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLevel() {
|
||||
return 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinLevel() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDiscoverable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTreasureOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDamageBonus(int level, MobType mobType, ItemStack enchantedItem) {
|
||||
return (float) Math.pow(0.5, level);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.zontreck.enchantments;
|
||||
|
||||
|
||||
import com.zontreck.AriasEssentials;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class EnchantmentEvents
|
||||
{
|
||||
static Map<String, Integer> ticks = new HashMap<>();
|
||||
|
||||
@SubscribeEvent
|
||||
public static void handleEnchantmentTicks(TickEvent.PlayerTickEvent event)
|
||||
{
|
||||
if(event.side == LogicalSide.CLIENT) return;
|
||||
|
||||
if(event.phase == TickEvent.Phase.END)
|
||||
{
|
||||
if(event.player instanceof ServerPlayer sp)
|
||||
{
|
||||
boolean cont = false;
|
||||
|
||||
if(ticks.containsKey(sp.getStringUUID())){
|
||||
if(ticks.get(sp.getStringUUID()) > 150) {
|
||||
ticks.put(sp.getStringUUID(), 0);
|
||||
cont=true;
|
||||
} else cont=false;
|
||||
} else {
|
||||
// Insert
|
||||
ticks.put(sp.getStringUUID(),0);
|
||||
cont=false;
|
||||
}
|
||||
|
||||
if(!cont) {
|
||||
ticks.put(sp.getStringUUID(), ticks.get(sp.getStringUUID())+1);
|
||||
return;
|
||||
}
|
||||
|
||||
//AriasEssentials.LOGGER.info("ENCHANT TICK - Server Player");
|
||||
|
||||
FlightEnchantment.runEntityTick(sp);
|
||||
ConsumptionMending.onEntityTick(sp);
|
||||
VampiricMending.onTick(sp);
|
||||
NightVisionEnchantment.runEntityTick(sp);
|
||||
WaterBreathingEnchantment.runEntityTick(sp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package com.zontreck.enchantments;
|
||||
|
||||
|
||||
import com.zontreck.AriasEssentials;
|
||||
import com.zontreck.configs.server.AEServerConfig;
|
||||
import com.zontreck.effects.ModEffects;
|
||||
import com.zontreck.libzontreck.util.ItemUtils;
|
||||
import com.zontreck.libzontreck.util.ServerUtilities;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||
|
||||
public class FlightEnchantment extends Enchantment
|
||||
{
|
||||
|
||||
public FlightEnchantment(EquipmentSlot... slots)
|
||||
{
|
||||
super(Rarity.VERY_RARE, EnchantmentCategory.ARMOR_FEET, slots);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinCost(int level)
|
||||
{
|
||||
return 28 + (level - 1) * 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxCost(int level)
|
||||
{
|
||||
return this.getMinCost(level) + 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTreasureOnly(){
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isTradeable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Not a bug. Flight is meant to be a permanent upgrade to a item. It is considered a curse due to unstable behavior. Flight will eat up durability and forge energy
|
||||
// Flight should NOT be able to be removed via the grindstone
|
||||
@Override
|
||||
public boolean isCurse()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static void runEntityTick(ServerPlayer sp)
|
||||
{
|
||||
if(ServerUtilities.isClient()) return;
|
||||
|
||||
|
||||
if(AEServerConfig.getInstance().enable_debug)
|
||||
{
|
||||
AriasEssentials.LOGGER.info("> Flight Enchantment Tick <");
|
||||
}
|
||||
|
||||
ItemStack feet = sp.getItemBySlot(EquipmentSlot.FEET);
|
||||
|
||||
boolean hasFlight = false;
|
||||
|
||||
if(ItemUtils.getEnchantmentLevel(ModEnchantments.FLIGHT_ENCHANTMENT.get(), feet)>0)hasFlight=true;
|
||||
|
||||
if(hasFlight)
|
||||
{
|
||||
MobEffectInstance inst = new MobEffectInstance(ModEffects.FLIGHT.get(), 60*20, 0, false, false, true);
|
||||
MobEffectInstance existing = sp.getEffect(ModEffects.FLIGHT.get());
|
||||
|
||||
if(existing != null)
|
||||
{
|
||||
if(existing.getDuration() <= (30 * 20))
|
||||
{
|
||||
sp.addEffect(inst);
|
||||
return;
|
||||
}else return;
|
||||
}
|
||||
|
||||
sp.addEffect(inst);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
package com.zontreck.enchantments;
|
||||
|
||||
|
||||
import com.zontreck.AriasEssentials;
|
||||
import com.zontreck.configs.server.AEServerConfig;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class MobEggEnchantment extends Enchantment
|
||||
{
|
||||
public static final String TAG_BIAS = "mob_egging_bias";
|
||||
|
||||
public MobEggEnchantment()
|
||||
{
|
||||
super(Rarity.VERY_RARE, EnchantmentCategory.WEAPON, new EquipmentSlot[] {EquipmentSlot.MAINHAND});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinCost(int level)
|
||||
{
|
||||
return 28 + (level - 1) * 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxCost(int level)
|
||||
{
|
||||
return this.getMinCost(level) + 15;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canApplyAtEnchantingTable(ItemStack stack)
|
||||
{
|
||||
return super.canApplyAtEnchantingTable(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTreasureOnly(){
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isTradeable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDiscoverable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean givesEgg(int level, int bias)
|
||||
{
|
||||
int CHANCE = AEServerConfig.getInstance().drops.mobEggingChance;
|
||||
|
||||
CHANCE += level;
|
||||
CHANCE += bias;
|
||||
|
||||
if(AEServerConfig.getInstance().enable_debug)
|
||||
{
|
||||
AriasEssentials.LOGGER.info("Spawn Egg Chance (" + CHANCE + ")");
|
||||
}
|
||||
return rollChance(CHANCE);
|
||||
}
|
||||
|
||||
public static boolean rollChance(int percent)
|
||||
{
|
||||
Random rng = new Random();
|
||||
int test = rng.nextInt(100) + 1 + (100 - percent);
|
||||
if(AEServerConfig.getInstance().enable_debug)
|
||||
{
|
||||
AriasEssentials.LOGGER.info("Spawn Egg Dice Roll (" + test + " / " + percent + ")");
|
||||
}
|
||||
|
||||
return test <= percent;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package com.zontreck.enchantments;
|
||||
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
|
||||
public class ModDamageSources
|
||||
{
|
||||
public static final DamageSource VAMPIRIC_MENDING = new DamageSource("vampiric_mend");
|
||||
}
|
38
src/main/java/com/zontreck/enchantments/ModEnchantments.java
Normal file
38
src/main/java/com/zontreck/enchantments/ModEnchantments.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
package com.zontreck.enchantments;
|
||||
|
||||
import com.zontreck.AriasEssentials;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class ModEnchantments {
|
||||
|
||||
protected static final EquipmentSlot[] ARMOR_SLOTS = new EquipmentSlot[]{EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET};
|
||||
public static final DeferredRegister<Enchantment> REGISTERS = DeferredRegister.create(ForgeRegistries.ENCHANTMENTS, AriasEssentials.MOD_ID);
|
||||
|
||||
public static final RegistryObject<Enchantment> MOB_EGGING_ENCHANTMENT = REGISTERS.register("mob_egging", ()->new MobEggEnchantment());
|
||||
|
||||
public static final RegistryObject<Enchantment> FLIGHT_ENCHANTMENT = REGISTERS.register("player_flight", ()->new FlightEnchantment(EquipmentSlot.FEET));
|
||||
|
||||
|
||||
public static final RegistryObject<Enchantment> CONSUMPTION_MENDING = REGISTERS.register("consumption_mending", ()->new ConsumptionMending(EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.FEET, EquipmentSlot.LEGS, EquipmentSlot.MAINHAND, EquipmentSlot.OFFHAND));
|
||||
|
||||
|
||||
public static final RegistryObject<Enchantment> NIGHT_VISION_ENCHANT = REGISTERS.register("night_vision", ()->new NightVisionEnchantment(EquipmentSlot.HEAD));
|
||||
|
||||
public static final RegistryObject<Enchantment> WATER_BREATHING_ENCHANT = REGISTERS.register("water_breathing", ()->new WaterBreathingEnchantment(EquipmentSlot.HEAD));
|
||||
|
||||
public static final RegistryObject<Enchantment> WIP_LEVEL_FIELD = REGISTERS.register("extra_strength", ()->new DamageIncreaseEnchantment(Enchantment.Rarity.UNCOMMON, EnchantmentCategory.WEAPON, new EquipmentSlot[] {EquipmentSlot.MAINHAND}));
|
||||
|
||||
public static final RegistryObject<Enchantment> VAMPIRIC_MENDING = REGISTERS.register("vampiric_mend", ()-> new VampiricMending(EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.FEET, EquipmentSlot.LEGS, EquipmentSlot.MAINHAND, EquipmentSlot.OFFHAND));
|
||||
|
||||
|
||||
|
||||
public static void register(IEventBus bus){
|
||||
REGISTERS.register(bus);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package com.zontreck.enchantments;
|
||||
|
||||
|
||||
import com.zontreck.AriasEssentials;
|
||||
import com.zontreck.configs.server.AEServerConfig;
|
||||
import com.zontreck.libzontreck.util.ItemUtils;
|
||||
import com.zontreck.libzontreck.util.ServerUtilities;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||
|
||||
public class NightVisionEnchantment extends Enchantment
|
||||
{
|
||||
|
||||
public NightVisionEnchantment(EquipmentSlot... slots)
|
||||
{
|
||||
super(Rarity.VERY_RARE, EnchantmentCategory.ARMOR_HEAD, slots);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTreasureOnly(){
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isTradeable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Not a bug. Flight is meant to be a permanent upgrade to a item. It is considered a curse due to unstable behavior. Flight will eat up durability and forge energy
|
||||
// Flight should NOT be able to be removed via the grindstone
|
||||
@Override
|
||||
public boolean isCurse()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void runEntityTick(ServerPlayer sp)
|
||||
{
|
||||
if(ServerUtilities.isClient()) return;
|
||||
|
||||
|
||||
if(AEServerConfig.getInstance().enable_debug)
|
||||
{
|
||||
AriasEssentials.LOGGER.info("> NVision Enchantment Tick <");
|
||||
}
|
||||
|
||||
|
||||
ItemStack feet = sp.getItemBySlot(EquipmentSlot.HEAD);
|
||||
|
||||
boolean hasNV = false;
|
||||
|
||||
if(ItemUtils.getEnchantmentLevel(ModEnchantments.NIGHT_VISION_ENCHANT.get(), feet)>0)hasNV=true;
|
||||
|
||||
if(hasNV)
|
||||
{
|
||||
MobEffectInstance inst = new MobEffectInstance(MobEffects.NIGHT_VISION, 60*20, 4, false, false, true);
|
||||
|
||||
MobEffectInstance existing = sp.getEffect(MobEffects.NIGHT_VISION);
|
||||
if(existing != null)
|
||||
{
|
||||
if(existing.getDuration() <= (30*20))
|
||||
{
|
||||
sp.addEffect(inst);
|
||||
return;
|
||||
}else return;
|
||||
}
|
||||
|
||||
sp.addEffect(inst);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
107
src/main/java/com/zontreck/enchantments/VampiricMending.java
Normal file
107
src/main/java/com/zontreck/enchantments/VampiricMending.java
Normal file
|
@ -0,0 +1,107 @@
|
|||
package com.zontreck.enchantments;
|
||||
|
||||
import com.zontreck.Messages;
|
||||
import com.zontreck.libzontreck.chat.HoverTip;
|
||||
import com.zontreck.libzontreck.util.ChatHelpers;
|
||||
import com.zontreck.libzontreck.util.ItemUtils;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||
import net.minecraftforge.server.ServerLifecycleHooks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class VampiricMending extends Enchantment
|
||||
{
|
||||
protected VampiricMending(EquipmentSlot... args) {
|
||||
super(Rarity.VERY_RARE, EnchantmentCategory.BREAKABLE, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLevel() {
|
||||
return 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTreasureOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTradeable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDiscoverable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCurse() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowedOnBooks() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void onTick(ServerPlayer player) {
|
||||
List<ItemStack> lst1 = ItemUtils.getPlayerInventory(player);
|
||||
|
||||
for(ItemStack stack : lst1) {
|
||||
if(!stack.isDamageableItem()) {
|
||||
continue; // Not damageable, no way it would have the enchant
|
||||
}
|
||||
|
||||
if(stack.getDamageValue() == 0) continue;
|
||||
|
||||
if(ItemUtils.getEnchantmentLevel(ModEnchantments.VAMPIRIC_MENDING.get(), stack) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// We can proceed
|
||||
int lvl = ItemUtils.getEnchantmentLevel(ModEnchantments.VAMPIRIC_MENDING.get(), stack);
|
||||
|
||||
// Get the multiplier for number of hearts to drink up
|
||||
float base = 1.0f; // player has 20 hearts / 2 = 10 full hearts
|
||||
float numOfHeartsToTake = base*lvl;
|
||||
float playerHealth = player.getHealth();
|
||||
|
||||
int cLvl = 1;
|
||||
// Calculate the amount needed up to max per enchant level
|
||||
while(cLvl <= lvl) {
|
||||
numOfHeartsToTake = base*cLvl;
|
||||
|
||||
if(lvl == cLvl) break;
|
||||
if(stack.getDamageValue() <= (50 * cLvl)) break;
|
||||
|
||||
cLvl++;
|
||||
}
|
||||
|
||||
// Get corrected number of hearts
|
||||
float numToTake = numOfHeartsToTake;
|
||||
if(playerHealth > numToTake) {
|
||||
// we can take that many hearts
|
||||
player.hurt(ModDamageSources.VAMPIRIC_MENDING, numToTake);
|
||||
} else {
|
||||
numToTake = player.getHealth();
|
||||
player.hurt(ModDamageSources.VAMPIRIC_MENDING, numToTake);
|
||||
|
||||
|
||||
ChatHelpers.broadcast(ChatHelpers.macro(Messages.ESSENTIALS_PREFIX + " !Dark_Red!Vampiric Item [Hover Here]").setStyle(Style.EMPTY.withFont(Style.DEFAULT_FONT).withHoverEvent(HoverTip.getItem(stack))), ServerLifecycleHooks.getCurrentServer());
|
||||
}
|
||||
|
||||
int newDmg = stack.getDamageValue() - (50 * lvl);
|
||||
if(newDmg <= 0) newDmg = 0;
|
||||
stack.setDamageValue(newDmg);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package com.zontreck.enchantments;
|
||||
|
||||
|
||||
import com.zontreck.AriasEssentials;
|
||||
import com.zontreck.configs.server.AEServerConfig;
|
||||
import com.zontreck.libzontreck.util.ItemUtils;
|
||||
import com.zontreck.libzontreck.util.ServerUtilities;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||
|
||||
public class WaterBreathingEnchantment extends Enchantment
|
||||
{
|
||||
|
||||
public WaterBreathingEnchantment(EquipmentSlot... slots)
|
||||
{
|
||||
super(Rarity.VERY_RARE, EnchantmentCategory.ARMOR_HEAD, slots);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLevel()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTreasureOnly(){
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isTradeable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Not a bug. Flight is meant to be a permanent upgrade to a item. It is considered a curse due to unstable behavior. Flight will eat up durability and forge energy
|
||||
// Flight should NOT be able to be removed via the grindstone
|
||||
@Override
|
||||
public boolean isCurse()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void runEntityTick(ServerPlayer sp)
|
||||
{
|
||||
if(ServerUtilities.isClient()) return;
|
||||
|
||||
|
||||
if(AEServerConfig.getInstance().enable_debug)
|
||||
{
|
||||
AriasEssentials.LOGGER.info("> WBreath Enchantment Tick <");
|
||||
}
|
||||
|
||||
|
||||
ItemStack feet = sp.getItemBySlot(EquipmentSlot.HEAD);
|
||||
|
||||
boolean hasEnchantment = false;
|
||||
|
||||
if(ItemUtils.getEnchantmentLevel(ModEnchantments.WATER_BREATHING_ENCHANT.get(), feet)>0)hasEnchantment=true;
|
||||
|
||||
if(hasEnchantment)
|
||||
{
|
||||
MobEffectInstance inst = new MobEffectInstance(MobEffects.WATER_BREATHING, 60*20, 4, false, false, true);
|
||||
|
||||
MobEffectInstance existing = sp.getEffect(MobEffects.WATER_BREATHING);
|
||||
if(existing != null)
|
||||
{
|
||||
if(existing.getDuration() <= (30*20))
|
||||
{
|
||||
sp.addEffect(inst);
|
||||
return;
|
||||
}else return;
|
||||
}
|
||||
|
||||
sp.addEffect(inst);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
package dev.zontreck.essentials.entities;
|
||||
package com.zontreck.entities;
|
||||
|
||||
import dev.zontreck.essentials.AriasEssentials;
|
||||
import com.zontreck.AriasEssentials;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
|
@ -10,13 +9,13 @@ import net.minecraftforge.registries.DeferredRegister;
|
|||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class ModEntities
|
||||
{
|
||||
public static final DeferredRegister<EntityType<?>> REGISTER = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, AriasEssentials.MODID);
|
||||
public class ModEntities {
|
||||
|
||||
public static final DeferredRegister<EntityType<?>> REGISTER = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, AriasEssentials.MOD_ID);
|
||||
|
||||
public static RegistryObject<EntityType<TimeBoostEntity>> TIAB_ENTITY = REGISTER.register("tiab_entity_type", ()->EntityType.Builder.<TimeBoostEntity>of(TimeBoostEntity::new, MobCategory.MISC)
|
||||
.sized(0.1f, 0.1f)
|
||||
.build(new ResourceLocation(AriasEssentials.MODID, "tiab_entity_type").toString())
|
||||
.build(new ResourceLocation(AriasEssentials.MOD_ID, "tiab_entity_type").toString())
|
||||
);
|
||||
|
||||
|
|
@ -1,12 +1,11 @@
|
|||
package dev.zontreck.essentials.entities;
|
||||
package com.zontreck.entities;
|
||||
|
||||
import dev.zontreck.essentials.configs.NBTKeys;
|
||||
import dev.zontreck.essentials.configs.server.AEServerConfig;
|
||||
import com.zontreck.configs.server.AEServerConfig;
|
||||
import com.zontreck.items.NBTKeys;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
|
@ -20,8 +19,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
|
|||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
public class TimeBoostEntity extends Entity
|
||||
{
|
||||
public class TimeBoostEntity extends Entity {
|
||||
private static final EntityDataAccessor<Integer> timeRate = SynchedEntityData.defineId(TimeBoostEntity.class, EntityDataSerializers.INT);
|
||||
|
||||
private int remainingTime;
|
|
@ -1,4 +1,4 @@
|
|||
package dev.zontreck.essentials.events;
|
||||
package com.zontreck.events;
|
||||
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
|
@ -6,9 +6,10 @@ import net.minecraftforge.eventbus.api.Event;
|
|||
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@Cancelable
|
||||
public class CommandExecutionEvent extends Event
|
||||
{
|
||||
public class CommandExecutionEvent extends Event {
|
||||
|
||||
public UUID playerID;
|
||||
public String command;
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package dev.zontreck.essentials.events;
|
||||
package com.zontreck.events;
|
||||
|
||||
import dev.zontreck.essentials.homes.Home;
|
||||
|
||||
import com.zontreck.homes.Home;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
|
@ -16,3 +17,4 @@ public class HomeCreatedEvent extends Event
|
|||
this.home=home;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package dev.zontreck.essentials.events;
|
||||
package com.zontreck.events;
|
||||
|
||||
import dev.zontreck.essentials.homes.Home;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
|
||||
import com.zontreck.homes.Home;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
/**
|
||||
|
@ -17,3 +17,4 @@ public class HomeDeletedEvent extends Event
|
|||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,12 +1,13 @@
|
|||
package dev.zontreck.essentials.events;
|
||||
package com.zontreck.events;
|
||||
|
||||
import dev.zontreck.essentials.commands.teleport.TeleportContainer;
|
||||
import com.zontreck.util.TeleportContainer;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
@Cancelable
|
||||
public class TeleportEvent extends Event
|
||||
{
|
||||
|
||||
private final TeleportContainer container;
|
||||
public TeleportEvent(TeleportContainer container)
|
||||
{
|
|
@ -0,0 +1,5 @@
|
|||
package com.zontreck.exceptions;
|
||||
|
||||
public class NoSuchHomeException extends Exception
|
||||
{
|
||||
}
|
|
@ -1,16 +1,16 @@
|
|||
package dev.zontreck.essentials.homes;
|
||||
package com.zontreck.homes;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import dev.zontreck.essentials.commands.teleport.TeleportDestination;
|
||||
import dev.zontreck.libzontreck.exceptions.InvalidDeserialization;
|
||||
import com.zontreck.libzontreck.exceptions.InvalidDeserialization;
|
||||
import com.zontreck.util.TeleportDestination;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class Home {
|
||||
|
||||
public UUID owner;
|
||||
public String homeName;
|
||||
public TeleportDestination destination;
|
|
@ -1,19 +1,20 @@
|
|||
package dev.zontreck.essentials.homes;
|
||||
package com.zontreck.homes;
|
||||
|
||||
import com.zontreck.events.HomeCreatedEvent;
|
||||
import com.zontreck.events.HomeDeletedEvent;
|
||||
import com.zontreck.exceptions.NoSuchHomeException;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import dev.zontreck.essentials.events.HomeCreatedEvent;
|
||||
import dev.zontreck.essentials.events.HomeDeletedEvent;
|
||||
import dev.zontreck.essentials.exceptions.NoSuchHomeException;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
public class Homes {
|
||||
public class Homes
|
||||
{
|
||||
private final Map<String, Home> homes = new HashMap<>();
|
||||
|
||||
public String playerID;
|
||||
|
@ -46,7 +47,6 @@ public class Homes {
|
|||
homes.remove(name);
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(e);
|
||||
HomesProvider.commitHomes(this);
|
||||
}
|
||||
|
||||
public void add(Home toAdd)
|
||||
|
@ -55,8 +55,6 @@ public class Homes {
|
|||
|
||||
if(!MinecraftForge.EVENT_BUS.post(hce))
|
||||
homes.put(toAdd.homeName, toAdd);
|
||||
|
||||
HomesProvider.commitHomes(this);
|
||||
}
|
||||
|
||||
public static Homes deserialize(CompoundTag tag)
|
||||
|
@ -81,5 +79,4 @@ public class Homes {
|
|||
tag.put("homes", lst);
|
||||
return tag;
|
||||
}
|
||||
|
||||
}
|
28
src/main/java/com/zontreck/items/CreativeModeTabs.java
Normal file
28
src/main/java/com/zontreck/items/CreativeModeTabs.java
Normal file
|
@ -0,0 +1,28 @@
|
|||
package com.zontreck.items;
|
||||
|
||||
|
||||
import com.zontreck.AriasEssentials;
|
||||
import com.zontreck.block.ModBlocks;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = AriasEssentials.MOD_ID, value = Dist.CLIENT)
|
||||
public class CreativeModeTabs {
|
||||
public static CreativeModeTab AETAB = new CreativeModeTab("ariasessentials") {
|
||||
@Override
|
||||
public ItemStack makeIcon() {
|
||||
return new ItemStack(ModBlocks.BLUE_POOL_TILE.get().asItem());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public static <T extends Item> RegistryObject<T> addToAETab(RegistryObject<T> item)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
42
src/main/java/com/zontreck/items/DeprecatedItem.java
Normal file
42
src/main/java/com/zontreck/items/DeprecatedItem.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
package com.zontreck.items;
|
||||
|
||||
|
||||
import com.zontreck.libzontreck.util.ChatHelpers;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DeprecatedItem extends Item
|
||||
{
|
||||
public DeprecatedItem()
|
||||
{
|
||||
super(new Properties().fireResistant().tab(CreativeModeTabs.AETAB));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFoil(ItemStack p_41453_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is to give a use to an otherwise useless item. The piglins will exchange the item and it gets removed in that way.
|
||||
* @param stack
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isPiglinCurrency(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack p_41421_, Level p_41422_, List<Component> p_41423_, TooltipFlag p_41424_) {
|
||||
p_41423_.add(ChatHelpers.macro("!Dark_Red!This item is deprecated"));
|
||||
p_41423_.add(ChatHelpers.macro("!Dark_Green!It would appear this item smells faintly of gold. Maybe piglins will accept it?"));
|
||||
p_41423_.add(ChatHelpers.macro("!Dark_Red!This item is scheduled for removal in a future version. You should use it before it is too late."));
|
||||
}
|
||||
}
|
||||
|
19
src/main/java/com/zontreck/items/DeprecatedModItems.java
Normal file
19
src/main/java/com/zontreck/items/DeprecatedModItems.java
Normal file
|
@ -0,0 +1,19 @@
|
|||
package com.zontreck.items;
|
||||
|
||||
|
||||
import com.zontreck.AriasEssentials;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class DeprecatedModItems
|
||||
{
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, AriasEssentials.MOD_ID);
|
||||
|
||||
public static void register(IEventBus bus){
|
||||
ITEMS.register(bus);
|
||||
}
|
||||
}
|
||||
|
104
src/main/java/com/zontreck/items/IhanCrystal.java
Normal file
104
src/main/java/com/zontreck/items/IhanCrystal.java
Normal file
|
@ -0,0 +1,104 @@
|
|||
package com.zontreck.items;
|
||||
|
||||
|
||||
import com.zontreck.libzontreck.util.ChatHelpers;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class IhanCrystal extends Item {
|
||||
|
||||
public static final String TAG_XP = "xp";
|
||||
|
||||
public IhanCrystal() {
|
||||
super(new Properties().stacksTo(1).tab(CreativeModeTabs.AETAB));
|
||||
}
|
||||
|
||||
private void assertTag(ItemStack stack)
|
||||
{
|
||||
if(!stack.hasTag() || stack.getTag()==null)
|
||||
{
|
||||
stack.setTag(new CompoundTag());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFoil(ItemStack stack) {
|
||||
assertTag(stack);
|
||||
|
||||
if(stack.getTag().contains(TAG_XP))
|
||||
{
|
||||
if(stack.getTag().getInt(TAG_XP) > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, Level p_41422_, List<Component> tooltip, TooltipFlag p_41424_) {
|
||||
assertTag(stack);
|
||||
|
||||
tooltip.add(ChatHelpers.macro("!Dark_Green!Stored XP: !Dark_Red!" + stack.getTag().getInt(TAG_XP) + "!Dark_Green! " + Pluralize(stack.getTag().getInt(TAG_XP), "level")));
|
||||
}
|
||||
|
||||
|
||||
private String Pluralize(int num, String str) {
|
||||
return (num > 1 ? str + "s" : str);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level serverWorld, Player player, InteractionHand hand) {
|
||||
ItemStack stack = player.getItemInHand(hand);
|
||||
|
||||
assertTag(stack);
|
||||
|
||||
serverWorld.playSound(player, player.getOnPos(), SoundEvents.EXPERIENCE_ORB_PICKUP, SoundSource.NEUTRAL, 1F, 1F);
|
||||
|
||||
if(!serverWorld.isClientSide)
|
||||
{
|
||||
|
||||
ServerPlayer serverPlayer = (ServerPlayer) player;
|
||||
if(player.isCrouching())
|
||||
{
|
||||
int lvls=0;
|
||||
// Unpack the experience levels - 10 at a time!!
|
||||
int xp = stack.getTag().getInt(TAG_XP);
|
||||
if(xp>10){
|
||||
lvls = 10;
|
||||
}else lvls= xp;
|
||||
xp-=lvls;
|
||||
|
||||
serverPlayer.setExperienceLevels(serverPlayer.experienceLevel + lvls);
|
||||
|
||||
stack.getTag().putInt(TAG_XP, xp);
|
||||
} else {
|
||||
// Store the xp
|
||||
int xp = stack.getTag().getInt(TAG_XP);
|
||||
xp += player.experienceLevel;
|
||||
|
||||
serverPlayer.setExperienceLevels(0);
|
||||
|
||||
stack.getTag().putInt(TAG_XP, xp);
|
||||
}
|
||||
}
|
||||
|
||||
player.awardStat(Stats.ITEM_USED.get(this));
|
||||
return InteractionResultHolder.sidedSuccess(stack, serverWorld.isClientSide);
|
||||
|
||||
}
|
||||
|
||||
}
|
69
src/main/java/com/zontreck/items/MagmaPowder.java
Normal file
69
src/main/java/com/zontreck/items/MagmaPowder.java
Normal file
|
@ -0,0 +1,69 @@
|
|||
package com.zontreck.items;
|
||||
|
||||
import com.zontreck.AriasEssentials;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class MagmaPowder extends Item
|
||||
{
|
||||
MagmaPowder(Item.Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public InteractionResult useOn(UseOnContext context) {
|
||||
BlockPos usedOn = context.getClickedPos();
|
||||
Player player = context.getPlayer();
|
||||
Level level = context.getLevel();
|
||||
|
||||
// Get the block state at the position where the item was used
|
||||
BlockState blockState = level.getBlockState(usedOn);
|
||||
Block block = blockState.getBlock();
|
||||
|
||||
// Check if the block is fractured bedrock, seeping bedrock, or regular bedrock
|
||||
try{
|
||||
if (block == ForgeRegistries.BLOCKS.getValue(new ResourceLocation("tetra:fractured_bedrock")) ||
|
||||
block == ForgeRegistries.BLOCKS.getValue(new ResourceLocation("tetra:seeping_bedrock"))) {
|
||||
|
||||
// Do something if the block is one of the specified types
|
||||
if (player != null && !level.isClientSide()) {
|
||||
// Replace with new Tetra Seeping Bedrock
|
||||
Block seepingBedrock = ForgeRegistries.BLOCKS.getValue(new ResourceLocation("tetra:seeping_bedrock"));
|
||||
if(seepingBedrock == null || seepingBedrock == Blocks.AIR)
|
||||
{
|
||||
return InteractionResult.FAIL;
|
||||
}
|
||||
level.setBlock(usedOn, seepingBedrock.defaultBlockState(), 0);
|
||||
}
|
||||
|
||||
if(!player.isCreative()) {
|
||||
context.getItemInHand().shrink(1);
|
||||
}
|
||||
|
||||
// Return success to indicate the interaction was successful
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
}catch(Exception E) {
|
||||
// We likely do not have Tetra
|
||||
AriasEssentials.LOGGER.info("Tetra is not installed?");
|
||||
|
||||
return InteractionResult.FAIL;
|
||||
|
||||
}
|
||||
// If the block is not one of the specified types, do nothing special
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
||||
}
|
58
src/main/java/com/zontreck/items/MobCaptureBallItem.java
Normal file
58
src/main/java/com/zontreck/items/MobCaptureBallItem.java
Normal file
|
@ -0,0 +1,58 @@
|
|||
package com.zontreck.items;
|
||||
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
public class MobCaptureBallItem extends Item
|
||||
{
|
||||
public MobCaptureBallItem() {
|
||||
super(new Properties().tab(CreativeModeTabs.AETAB));
|
||||
}
|
||||
@Override
|
||||
public boolean isFoil(ItemStack pStack) {
|
||||
if(!pStack.hasTag() || pStack.getTag()==null)
|
||||
{
|
||||
pStack.setTag(new CompoundTag());
|
||||
}
|
||||
if(pStack.getTag().contains("entity"))
|
||||
{
|
||||
return true;
|
||||
} else return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, InteractionHand pUsedHand) {
|
||||
ItemStack stack = pPlayer.getItemInHand(pUsedHand);
|
||||
pLevel.playSound((Player) null, pPlayer.getX(), pPlayer.getY(), pPlayer.getZ(), SoundEvents.EGG_THROW, SoundSource.PLAYERS, 0.5F, 0.4F / (pLevel.random.nextFloat() * 0.4f + 0.8f));
|
||||
if(!pLevel.isClientSide)
|
||||
{
|
||||
ItemStack single = stack.copy();
|
||||
single.setCount(1);
|
||||
|
||||
if(!pPlayer.getAbilities().instabuild)
|
||||
{
|
||||
stack.shrink(1);
|
||||
}else {
|
||||
|
||||
}
|
||||
|
||||
ThrownMobCaptureBall TPB = new ThrownMobCaptureBall(pLevel, pPlayer, single);
|
||||
|
||||
|
||||
TPB.shootFromRotation(pPlayer, pPlayer.getXRot(), pPlayer.getYRot(), 0.0F, 1.5F, 1.0F);
|
||||
pLevel.addFreshEntity(TPB);
|
||||
}
|
||||
|
||||
pPlayer.awardStat(Stats.ITEM_USED.get(this));
|
||||
return super.use(pLevel, pPlayer, pUsedHand);
|
||||
}
|
||||
}
|
56
src/main/java/com/zontreck/items/ModItems.java
Normal file
56
src/main/java/com/zontreck/items/ModItems.java
Normal file
|
@ -0,0 +1,56 @@
|
|||
package com.zontreck.items;
|
||||
|
||||
import com.zontreck.items.impl.TimeBottle;
|
||||
import net.minecraft.world.item.SimpleFoiledItem;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraft.world.item.Item;
|
||||
import com.zontreck.AriasEssentials;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class ModItems {
|
||||
public static DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, AriasEssentials.MOD_ID);
|
||||
|
||||
public static RegistryObject<Item> TIAB = ITEMS.register("tiab", ()->new TimeBottle());
|
||||
|
||||
|
||||
|
||||
public static final RegistryObject<Item> IHAN_CRYSTAL = CreativeModeTabs.addToAETab(ITEMS.register("ihan_crystal", () -> new IhanCrystal()));
|
||||
|
||||
public static final RegistryObject<Item> ETERNIUM_RAW_ORE = CreativeModeTabs.addToAETab(ITEMS.register("eternium_ore", () -> new Item(new Item.Properties().tab(CreativeModeTabs.AETAB))));
|
||||
|
||||
public static final RegistryObject<Item> ETERNIUM_INGOT = CreativeModeTabs.addToAETab(ITEMS.register("eternium_ingot", ()-> new SimpleFoiledItem(new Item.Properties().tab(CreativeModeTabs.AETAB))));
|
||||
|
||||
public static final RegistryObject<Item> ETERNIUM_ROD = CreativeModeTabs.addToAETab(ITEMS.register("eternium_rod", () -> new SimpleFoiledItem(new Item.Properties().stacksTo(64).tab(CreativeModeTabs.AETAB))));
|
||||
|
||||
|
||||
public static final RegistryObject<Item> MIAB = CreativeModeTabs.addToAETab(ITEMS.register("mob_capture_ball", ()->new MobCaptureBallItem()));
|
||||
|
||||
|
||||
public static final RegistryObject<Item> EMPTY_SPAWN_EGG = CreativeModeTabs.addToAETab(ITEMS.register("empty_spawn_egg", () -> new Item(new Item.Properties().tab(CreativeModeTabs.AETAB))));
|
||||
|
||||
public static final RegistryObject<Item> GENERIC_DEPRECATED_ITEM = CreativeModeTabs.addToAETab(ITEMS.register("deprecated", ()->new DeprecatedItem()));
|
||||
|
||||
public static final RegistryObject<Item> WHITE_BRICK = CreativeModeTabs.addToAETab(ITEMS.register("white_brick", ()->new Item(new Item.Properties().tab(CreativeModeTabs.AETAB))));
|
||||
|
||||
public static final RegistryObject<Item> BLUE_BRICK = CreativeModeTabs.addToAETab(ITEMS.register("blue_brick", ()->new Item(new Item.Properties().tab(CreativeModeTabs.AETAB))));
|
||||
|
||||
public static final RegistryObject<Item> LIGHT_BLUE_BRICK = CreativeModeTabs.addToAETab(ITEMS.register("light_blue_brick", ()->new Item(new Item.Properties().tab(CreativeModeTabs.AETAB))));
|
||||
|
||||
public static final RegistryObject<Item> CYAN_BRICK = CreativeModeTabs.addToAETab(ITEMS.register("cyan_brick", ()->new Item(new Item.Properties().tab(CreativeModeTabs.AETAB))));
|
||||
|
||||
public static final RegistryObject<Item> DARK_RED_DYE = CreativeModeTabs.addToAETab(ITEMS.register("dark_red_dye", ()->new Item(new Item.Properties().tab(CreativeModeTabs.AETAB))));
|
||||
|
||||
public static final RegistryObject<Item> RED_BRICK = CreativeModeTabs.addToAETab(ITEMS.register("red_brick", ()->new Item(new Item.Properties().tab(CreativeModeTabs.AETAB))));
|
||||
|
||||
public static final RegistryObject<Item> DARK_RED_BRICK = CreativeModeTabs.addToAETab(ITEMS.register("dark_red_brick", ()->new Item(new Item.Properties().tab(CreativeModeTabs.AETAB))));
|
||||
|
||||
public static final RegistryObject<Item> GREEN_BRICK = CreativeModeTabs.addToAETab(ITEMS.register("green_brick", ()->new Item(new Item.Properties().tab(CreativeModeTabs.AETAB))));
|
||||
|
||||
public static final RegistryObject<Item> LIME_BRICK = CreativeModeTabs.addToAETab(ITEMS.register("lime_brick", ()->new Item(new Item.Properties().tab(CreativeModeTabs.AETAB))));
|
||||
|
||||
public static final RegistryObject<Item> PARTIAL_ITEM = CreativeModeTabs.addToAETab(ITEMS.register("partial_item", PartialItem::new));
|
||||
|
||||
public static final RegistryObject<Item> MAGMA_POWDER = CreativeModeTabs.addToAETab(ITEMS.register("magma_powder", ()-> new MagmaPowder(new Item.Properties().tab(CreativeModeTabs.AETAB))));
|
||||
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
package dev.zontreck.essentials.configs;
|
||||
|
||||
package com.zontreck.items;
|
||||
|
||||
public class NBTKeys {
|
||||
// for time in a bottle item
|
116
src/main/java/com/zontreck/items/PartialItem.java
Normal file
116
src/main/java/com/zontreck/items/PartialItem.java
Normal file
|
@ -0,0 +1,116 @@
|
|||
package com.zontreck.items;
|
||||
|
||||
|
||||
import com.zontreck.libzontreck.util.ChatHelpers;
|
||||
import net.minecraft.core.UUIDUtil;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.StringTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PartialItem extends Item
|
||||
{
|
||||
private static final String TAG_UNCRAFT_REMAIN = "remaining";
|
||||
private static final String TAG_UNCRAFT_LIST = "Items";
|
||||
|
||||
@Override
|
||||
public boolean isEnchantable(ItemStack p_41456_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBookEnchantable(ItemStack stack, ItemStack book) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public PartialItem() {
|
||||
super (new Properties().fireResistant().tab(CreativeModeTabs.AETAB));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, @Nullable Level p_41422_, List<Component> tooltip, TooltipFlag p_41424_) {
|
||||
tooltip.add(ChatHelpers.macro("!Yellow!This is a partially deconstructed item."));
|
||||
|
||||
if(stack.getTag()!= null)
|
||||
{
|
||||
if(stack.getTag().contains(TAG_UNCRAFT_REMAIN))
|
||||
{
|
||||
tooltip.add(ChatHelpers.macro("!Dark_Red!Number of uncraft steps remaining: [0]", "!Yellow!" + stack.getTag().getInt(TAG_UNCRAFT_REMAIN)));
|
||||
}
|
||||
if(stack.getTag().contains(ItemStack.TAG_ENCH))
|
||||
{
|
||||
tooltip.add(ChatHelpers.macro("!Dark_Red!Number of Enchantments remaining: [0]", "!Yellow!" + stack.getTag().getList(ItemStack.TAG_ENCH, Tag.TAG_COMPOUND).size()));
|
||||
}
|
||||
} else {
|
||||
tooltip.add(ChatHelpers.macro("!Dark_Red!This partial item appears to be invalid, and contains no fragments."));
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Item> getRemainingIngredients(ItemStack stack)
|
||||
{
|
||||
List<Item> itx = new ArrayList<>();
|
||||
if(stack.getTag()!=null)
|
||||
{
|
||||
if(stack.getTag().contains(TAG_UNCRAFT_LIST))
|
||||
{
|
||||
ListTag lst = stack.getTag().getList(TAG_UNCRAFT_LIST, ListTag.TAG_STRING);
|
||||
|
||||
for (Tag tag :
|
||||
lst) {
|
||||
StringTag st = (StringTag)tag;
|
||||
itx.add(deserializeItemType(st.getAsString()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return itx;
|
||||
}
|
||||
|
||||
private static Item deserializeItemType(String item)
|
||||
{
|
||||
return ForgeRegistries.ITEMS.getValue(new ResourceLocation(item));
|
||||
}
|
||||
|
||||
public static ItemStack makePartialItem(ItemStack original, boolean enchantMode, boolean uncraftMode)
|
||||
{
|
||||
if(enchantMode)
|
||||
{
|
||||
ItemStack partial = new ItemStack(ModItems.PARTIAL_ITEM.get(), 1);
|
||||
CompoundTag tag = new CompoundTag();
|
||||
Map<Enchantment, Integer> enchants = EnchantmentHelper.getEnchantments(original);
|
||||
partial.setTag(tag);
|
||||
for(Map.Entry<Enchantment, Integer> entry : enchants.entrySet())
|
||||
{
|
||||
//UUID id = UUIDUtil.createOfflinePlayerUUID()
|
||||
//UUID.nameUUIDFromBytes()
|
||||
partial.enchant(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
|
||||
return partial;
|
||||
} else return original;
|
||||
}
|
||||
}
|
||||
|
213
src/main/java/com/zontreck/items/ThrownMobCaptureBall.java
Normal file
213
src/main/java/com/zontreck/items/ThrownMobCaptureBall.java
Normal file
|
@ -0,0 +1,213 @@
|
|||
package com.zontreck.items;
|
||||
|
||||
|
||||
import com.zontreck.libzontreck.chat.ChatColor;
|
||||
import com.zontreck.libzontreck.lore.LoreContainer;
|
||||
import com.zontreck.libzontreck.lore.LoreEntry;
|
||||
import com.zontreck.libzontreck.util.ServerUtilities;
|
||||
import net.minecraft.core.particles.ItemParticleOption;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.projectile.ThrowableItemProjectile;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.EntityHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ThrownMobCaptureBall extends ThrowableItemProjectile
|
||||
{
|
||||
boolean captured = false;
|
||||
LivingEntity shooter;
|
||||
ItemStack self;
|
||||
|
||||
public ThrownMobCaptureBall(EntityType entity, Level level)
|
||||
{
|
||||
super(entity, level);
|
||||
}
|
||||
public ThrownMobCaptureBall(Level level, LivingEntity shooter, ItemStack item)
|
||||
{
|
||||
super(EntityType.EGG, shooter, level);
|
||||
|
||||
this.shooter = shooter;
|
||||
if(item.getTag() == null)
|
||||
{
|
||||
item.setTag(new CompoundTag());
|
||||
}
|
||||
self=item;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Item getDefaultItem()
|
||||
{
|
||||
return ModItems.MIAB.get();
|
||||
}
|
||||
|
||||
void returnBall()
|
||||
{
|
||||
|
||||
ItemEntity x;
|
||||
|
||||
if(shooter!=null)
|
||||
x = new ItemEntity(level, shooter.position().x, shooter.position().y, shooter.position().z, self, 0, 0, 0);
|
||||
else
|
||||
x = new ItemEntity(level, position().x, position().y, position().z, self, 0, 0, 0);
|
||||
level.addFreshEntity(x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleEntityEvent(byte pId) {
|
||||
if(pId == 3)
|
||||
{
|
||||
double size = 0.08;
|
||||
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
this.level.addParticle(new ItemParticleOption(ParticleTypes.ITEM, this.getItem()), this.getX(), this.getY(), this.getZ(), ((double)this.random.nextFloat() - 0.5) * 0.08, ((double)this.random.nextFloat() - 0.5) * 0.08, ((double)this.random.nextFloat() - 0.5) * 0.08);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onHitEntity(EntityHitResult pResult) {
|
||||
super.onHitEntity(pResult);
|
||||
if(ServerUtilities.isServer())
|
||||
{
|
||||
CompoundTag tag = self.getTag();
|
||||
if(tag == null)tag = new CompoundTag();
|
||||
if(tag.contains(ItemStack.TAG_DAMAGE))
|
||||
{
|
||||
tag.remove(ItemStack.TAG_DAMAGE);
|
||||
}
|
||||
|
||||
|
||||
if(self.getTag() == null || !self.getTag().contains("entity"))
|
||||
{
|
||||
/*
|
||||
|
||||
Ensure the tag is not null
|
||||
|
||||
*/
|
||||
|
||||
if(pResult.getEntity() instanceof LivingEntity le && !(le instanceof Player player))
|
||||
{
|
||||
// We don't want to capture players
|
||||
// Store the entity in the entity tag, then kill the entity
|
||||
|
||||
|
||||
CompoundTag store = new CompoundTag();
|
||||
String entityName = le.getName().getString();
|
||||
le.save(store);
|
||||
|
||||
self.getTag().put("entity", store);
|
||||
self.setCount(1);
|
||||
captured=true;
|
||||
|
||||
LoreContainer cont = new LoreContainer(self);
|
||||
cont.miscData.loreData.clear();
|
||||
LoreEntry entry = new LoreEntry.Builder().bold(true).text(ChatColor.doColors("!Dark_Green!Captured Mob: !Dark_Purple!" + entityName)).build();
|
||||
cont.miscData.loreData.add(entry);
|
||||
|
||||
cont.commitLore();
|
||||
|
||||
le.remove(RemovalReason.DISCARDED);
|
||||
}
|
||||
} else {
|
||||
|
||||
// Don't capture the entity
|
||||
|
||||
//pResult.getEntity().hurt(this.shooter.getLastDamageSource().thrown(this, this.getOwner()), 0.1F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onHit(HitResult pResult) {
|
||||
super.onHit(pResult);
|
||||
|
||||
if(ServerUtilities.isServer())
|
||||
{
|
||||
// We do two things here
|
||||
|
||||
// 1. If we contain an entity, spawn it
|
||||
// 2. If no entity, and none was captured, decrease the durability a little
|
||||
// 3. Drop the PossBall with entity, or without
|
||||
|
||||
ItemStack item = self;
|
||||
CompoundTag tag = item.getTag();
|
||||
|
||||
if(tag==null)tag=new CompoundTag();
|
||||
|
||||
if(tag.contains(ItemStack.TAG_DAMAGE))
|
||||
{
|
||||
tag.remove(ItemStack.TAG_DAMAGE); // Migrate existing poss balls to remove the obsolete damage tag
|
||||
}
|
||||
|
||||
if(tag.contains("entity"))
|
||||
{
|
||||
if(captured)
|
||||
{
|
||||
// Spawn poss ball item with the entity NBT
|
||||
returnBall();
|
||||
} else {
|
||||
// Spawn the real entity
|
||||
Optional<Entity> entity = EntityType.create(tag.getCompound("entity"), level);
|
||||
if(entity.isPresent())
|
||||
{
|
||||
Entity xEntity = entity.get();
|
||||
xEntity.setUUID(UUID.randomUUID());
|
||||
xEntity.setPos(position());
|
||||
level.addFreshEntity(xEntity);
|
||||
}
|
||||
|
||||
LoreContainer cont = new LoreContainer(item);
|
||||
cont.miscData.loreData.clear();
|
||||
cont.commitLore();
|
||||
|
||||
if(item.getDamageValue() == 0)
|
||||
{
|
||||
item.setTag(new CompoundTag());
|
||||
}else {
|
||||
tag.remove("entity");
|
||||
}
|
||||
|
||||
|
||||
returnBall();
|
||||
}
|
||||
} else {
|
||||
// No capture
|
||||
// Decrease the durability
|
||||
//int damage = item.getDamageValue();
|
||||
//damage++;
|
||||
//item.setDamageValue(damage);
|
||||
// Ensure no entity tag!
|
||||
tag.remove("entity");
|
||||
|
||||
if(tag.size()==0)
|
||||
{
|
||||
tag=null;
|
||||
item.setTag(new CompoundTag());
|
||||
}
|
||||
|
||||
|
||||
//if(item.getDamageValue() >= item.getMaxDamage())
|
||||
// return;
|
||||
|
||||
|
||||
returnBall();
|
||||
}
|
||||
|
||||
this.level.broadcastEntityEvent(this, (byte)3);
|
||||
this.discard();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +1,20 @@
|
|||
package dev.zontreck.essentials.items.abstraction;
|
||||
package com.zontreck.items.abstracts;
|
||||
|
||||
import dev.zontreck.essentials.configs.server.AEServerConfig;
|
||||
import dev.zontreck.essentials.entities.TimeBoostEntity;
|
||||
import dev.zontreck.essentials.util.SoundUtilities;
|
||||
import com.zontreck.configs.server.AEServerConfig;
|
||||
import com.zontreck.entities.TimeBoostEntity;
|
||||
import com.zontreck.items.CreativeModeTabs;
|
||||
import com.zontreck.util.SoundUtilities;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.PickaxeItem;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
@ -16,11 +23,41 @@ import net.minecraft.world.phys.AABB;
|
|||
|
||||
import java.util.Optional;
|
||||
|
||||
public abstract class AbstractBottle extends Item {
|
||||
public abstract class AbstractTIAB extends Item {
|
||||
private static final String[] NOTES = {"C", "D", "E", "F", "G2", "A2", "B2", "C2", "D2", "E2", "F2"};
|
||||
|
||||
public AbstractBottle() {
|
||||
super(new Properties().stacksTo(1));
|
||||
public AbstractTIAB() {
|
||||
super(new Properties().stacksTo(1).tab(CreativeModeTabs.AETAB));
|
||||
}
|
||||
|
||||
public abstract void setExpired(ItemStack stack);
|
||||
public abstract boolean getExpired(ItemStack stack);
|
||||
public abstract int getAvailableUses(ItemStack stack);
|
||||
|
||||
public abstract void enableDurability(ItemStack stack);
|
||||
public abstract void updateDurability(ItemStack stack);
|
||||
|
||||
@Override
|
||||
public int getMaxDamage(ItemStack stack) {
|
||||
if(getExpired(stack)){
|
||||
return stack.getOrCreateTag().getInt("max");
|
||||
}else return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDamageable(ItemStack stack) {
|
||||
return getExpired(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDamaged(ItemStack stack) {
|
||||
return getExpired(stack) ? (stack.getOrCreateTag().getInt("cur") > 0) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDamage(ItemStack stack) {
|
||||
if(getExpired(stack)) return stack.getOrCreateTag().getInt("cur");
|
||||
else return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,6 +110,8 @@ public abstract class AbstractBottle extends Item {
|
|||
TimeBoostEntity entityTA = new TimeBoostEntity(level, pos, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
|
||||
entityTA.setRemainingTime(getEachUseDuration());
|
||||
level.addFreshEntity(entityTA);
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!isCreativeMode) {
|
||||
|
@ -80,6 +119,12 @@ public abstract class AbstractBottle extends Item {
|
|||
}
|
||||
playSound(level, pos, nextRate);
|
||||
|
||||
if(getDamage(stack) >= getMaxDamage(stack) && getExpired(stack)) {
|
||||
level.playSound(null, pos, SoundEvents.GLASS_BREAK, SoundSource.PLAYERS, 0.5F, 0.5F);
|
||||
|
||||
player.getInventory().removeItem(stack);
|
||||
}
|
||||
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
|
|
@ -1,25 +1,22 @@
|
|||
package dev.zontreck.essentials.items.implementation;
|
||||
package com.zontreck.items.impl;
|
||||
|
||||
import dev.zontreck.ariaslib.util.TimeUtil;
|
||||
import dev.zontreck.essentials.configs.NBTKeys;
|
||||
import dev.zontreck.essentials.configs.server.AEServerConfig;
|
||||
import dev.zontreck.essentials.items.abstraction.AbstractBottle;
|
||||
import dev.zontreck.essentials.util.StylesUtil;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import com.zontreck.ariaslib.util.TimeUtil;
|
||||
import com.zontreck.configs.server.AEServerConfig;
|
||||
import com.zontreck.items.NBTKeys;
|
||||
import com.zontreck.items.abstracts.AbstractTIAB;
|
||||
import com.zontreck.libzontreck.util.ChatHelpers;
|
||||
import net.minecraft.nbt.ByteTag;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TimeBottle extends AbstractBottle
|
||||
public class TimeBottle extends AbstractTIAB
|
||||
{
|
||||
|
||||
public TimeBottle() {
|
||||
super();
|
||||
}
|
||||
|
@ -38,6 +35,18 @@ public class TimeBottle extends AbstractBottle
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDurability(ItemStack stack) {
|
||||
stack.getOrCreateTag().putInt("cur", getMaxDamage(stack) - getAvailableUses(stack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableDurability(ItemStack stack) {
|
||||
stack.getOrCreateTag().putInt("max", getAvailableUses(stack));
|
||||
updateDurability(stack);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack itemStack, Level world, List<Component> tooltip, TooltipFlag flag) {
|
||||
super.appendHoverText(itemStack, world, tooltip, flag);
|
||||
|
@ -50,7 +59,14 @@ public class TimeBottle extends AbstractBottle
|
|||
|
||||
tooltip.add(ChatHelpers.macro(AEServerConfig.getInstance().bottles.accumulatedTimeStr, TimeUtil.secondsToTimeNotation(TimeUtil.ticksToSeconds(totalAccumulatedTime, AEServerConfig.getInstance().bottles.ticks)).toString()));
|
||||
|
||||
tooltip.add(ChatHelpers.macro(AEServerConfig.getInstance().bottles.totalUses, "" + TimeUtil.ticksToSeconds(storedTime, AEServerConfig.getInstance().bottles.ticks) / AEServerConfig.getInstance().bottles.eachUseDuration));
|
||||
tooltip.add(ChatHelpers.macro(AEServerConfig.getInstance().bottles.totalUses, "" + getAvailableUses(itemStack)));
|
||||
|
||||
tooltip.add(ChatHelpers.macro(AEServerConfig.getInstance().bottles.expiredBottle, "" + (getExpired(itemStack) ? "!Dark_Red!Expired" : "!Dark_Green!still able to be used"), getExpired(itemStack) ? ", !Dark_Red!This item will break when it hits zero available uses." : ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailableUses(ItemStack stack) {
|
||||
return TimeUtil.ticksToSeconds(getStoredEnergy(stack), AEServerConfig.getInstance().bottles.ticks) / AEServerConfig.getInstance().bottles.eachUseDuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -67,6 +83,10 @@ public class TimeBottle extends AbstractBottle
|
|||
@Override
|
||||
public void applyDamage(ItemStack stack, int damage) {
|
||||
setStoredEnergy(stack, getStoredEnergy(stack) - damage);
|
||||
|
||||
if(getExpired(stack)) {
|
||||
updateDurability(stack);
|
||||
}
|
||||
}
|
||||
|
||||
public int getTotalAccumulatedTime(ItemStack stack) {
|
||||
|
@ -78,6 +98,19 @@ public class TimeBottle extends AbstractBottle
|
|||
stack.getOrCreateTag().putInt(NBTKeys.TOTAL_ACCUMULATED_TIME, newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExpired(ItemStack stack) {
|
||||
stack.getOrCreateTag().putBoolean("expired", true);
|
||||
|
||||
enableDurability(stack);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getExpired(ItemStack stack) {
|
||||
return stack.getOrCreateTag().getBoolean("expired");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack itemStack, Level level, Entity entity, int itemSlot, boolean isSelected) {
|
||||
|
@ -87,14 +120,25 @@ public class TimeBottle extends AbstractBottle
|
|||
}
|
||||
|
||||
if (level.getGameTime() % AEServerConfig.getInstance().bottles.ticks == 0) {
|
||||
if(getExpired(itemStack)) return;
|
||||
|
||||
int storedTime = this.getStoredEnergy(itemStack);
|
||||
if (storedTime < (AEServerConfig.getInstance().bottles.maxTime * 20)) {
|
||||
this.setStoredEnergy(itemStack, storedTime + AEServerConfig.getInstance().bottles.ticks);
|
||||
}
|
||||
|
||||
int totalAccumulatedTime = this.getTotalAccumulatedTime(itemStack);
|
||||
if(totalAccumulatedTime >= Integer.MAX_VALUE && !getExpired(itemStack)) {
|
||||
}
|
||||
if (totalAccumulatedTime < (AEServerConfig.getInstance().bottles.maxTime * 20)) {
|
||||
//this.setTotalAccumulatedTime(itemStack, Integer.MAX_VALUE);
|
||||
this.setTotalAccumulatedTime(itemStack, totalAccumulatedTime + AEServerConfig.getInstance().bottles.ticks);
|
||||
}else {
|
||||
if(!getExpired(itemStack))
|
||||
// The time bottle has now exceeded total possible uses.
|
||||
// Set a flag so that the bottle is deleted after it reaches zero total uses.
|
||||
this.setExpired(itemStack);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
37
src/main/java/com/zontreck/items/tags/ItemStatTag.java
Normal file
37
src/main/java/com/zontreck/items/tags/ItemStatTag.java
Normal file
|
@ -0,0 +1,37 @@
|
|||
package com.zontreck.items.tags;
|
||||
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
public class ItemStatTag {
|
||||
public static final String STATS_TAG = "stat";
|
||||
public ItemStatType type;
|
||||
public int tagPosition;
|
||||
public int value;
|
||||
|
||||
public ItemStatTag(ItemStatType t, int tagPos, int tag)
|
||||
{
|
||||
type = t;
|
||||
value = tag;
|
||||
tagPosition = tagPos;
|
||||
}
|
||||
|
||||
public void increment(){
|
||||
value++;
|
||||
}
|
||||
public void decrement()
|
||||
{
|
||||
value--;
|
||||
}
|
||||
|
||||
public void setValue(int value)
|
||||
{
|
||||
this.value=value;
|
||||
}
|
||||
|
||||
public void save(CompoundTag tag)
|
||||
{
|
||||
tag.putInt(STATS_TAG+"_"+type.name().toLowerCase(), value);
|
||||
}
|
||||
}
|
||||
|
16
src/main/java/com/zontreck/items/tags/ItemStatType.java
Normal file
16
src/main/java/com/zontreck/items/tags/ItemStatType.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
package com.zontreck.items.tags;
|
||||
|
||||
|
||||
public enum ItemStatType {
|
||||
SWORD,
|
||||
ARMOR,
|
||||
PICK,
|
||||
AXE,
|
||||
SHOVEL,
|
||||
SHOVELPATH,
|
||||
HOE,
|
||||
SHEARS,
|
||||
EGGING,
|
||||
EGG_CHANCE
|
||||
}
|
||||
|
54
src/main/java/com/zontreck/items/tags/ItemStatistics.java
Normal file
54
src/main/java/com/zontreck/items/tags/ItemStatistics.java
Normal file
|
@ -0,0 +1,54 @@
|
|||
package com.zontreck.items.tags;
|
||||
|
||||
|
||||
import com.zontreck.libzontreck.chat.ChatColor;
|
||||
|
||||
public class ItemStatistics {
|
||||
|
||||
public static String makeText(ItemStatTag tag)
|
||||
{
|
||||
return makeText(tag.type, tag.value);
|
||||
}
|
||||
public static String makeText(ItemStatType type, int val)
|
||||
{
|
||||
String lore = ChatColor.doColors("!White!");
|
||||
String sAppend = "";
|
||||
switch(type)
|
||||
{
|
||||
case SWORD -> {
|
||||
lore += "Mobs Killed: ";
|
||||
}
|
||||
case PICK -> {
|
||||
lore += "Blocks Mined: ";
|
||||
}
|
||||
case ARMOR -> {
|
||||
lore += "Damage Taken: ";
|
||||
}
|
||||
case SHOVEL -> {
|
||||
lore += "Blocks Dug Up: ";
|
||||
}
|
||||
case SHOVELPATH -> {
|
||||
lore += "Paths Made: ";
|
||||
}
|
||||
case AXE -> {
|
||||
lore += "Wood Chopped: ";
|
||||
}
|
||||
case HOE -> {
|
||||
lore += "Blocks Hoed: ";
|
||||
}
|
||||
case SHEARS -> {
|
||||
lore += "Sheep Shaved: ";
|
||||
}
|
||||
case EGGING -> {
|
||||
lore += "Spawn Eggs Dropped: ";
|
||||
}
|
||||
case EGG_CHANCE -> {
|
||||
lore += "Spawn Egg Chance: ";
|
||||
sAppend = "!White!%";
|
||||
}
|
||||
}
|
||||
lore += ChatColor.doColors("!Green!"+val + sAppend);
|
||||
return lore;
|
||||
}
|
||||
}
|
||||
|
24
src/main/java/com/zontreck/items/tags/ModIDs.java
Normal file
24
src/main/java/com/zontreck/items/tags/ModIDs.java
Normal file
|
@ -0,0 +1,24 @@
|
|||
package com.zontreck.items.tags;
|
||||
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public enum ModIDs {
|
||||
NULL(0,0),
|
||||
AC(0x9f, 0x9f),
|
||||
AE(5292022,1182023), // The date range of mod creation, then the day when this feature was added
|
||||
ITEM_STATS(154301182023L, 0x9f);
|
||||
|
||||
private UUID ID;
|
||||
|
||||
ModIDs(long A, long B)
|
||||
{
|
||||
ID=new UUID(A,B);
|
||||
}
|
||||
|
||||
public UUID get()
|
||||
{
|
||||
return ID;
|
||||
}
|
||||
}
|
||||
|
176
src/main/java/com/zontreck/libzontreck/LibZontreck.java
Normal file
176
src/main/java/com/zontreck/libzontreck/LibZontreck.java
Normal file
|
@ -0,0 +1,176 @@
|
|||
package com.zontreck.libzontreck;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import com.zontreck.libzontreck.chestgui.ChestGUIRegistry;
|
||||
import com.zontreck.libzontreck.config.ServerConfig;
|
||||
import com.zontreck.libzontreck.currency.Bank;
|
||||
import com.zontreck.libzontreck.currency.CurrencyHelper;
|
||||
import com.zontreck.libzontreck.events.BlockRestoreQueueRegistrationEvent;
|
||||
import com.zontreck.libzontreck.items.ModItems;
|
||||
import com.zontreck.libzontreck.memory.world.BlockRestoreQueueRegistry;
|
||||
import com.zontreck.libzontreck.memory.world.DatabaseMigrations;
|
||||
import com.zontreck.libzontreck.memory.world.DatabaseWrapper;
|
||||
import com.zontreck.libzontreck.menus.ChestGUIScreen;
|
||||
import com.zontreck.libzontreck.types.ModMenuTypes;
|
||||
import com.zontreck.libzontreck.networking.NetworkEvents;
|
||||
import net.minecraft.client.gui.screens.MenuScreens;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
|
||||
import com.zontreck.libzontreck.commands.Commands;
|
||||
import com.zontreck.libzontreck.events.ForgeEventHandlers;
|
||||
import com.zontreck.libzontreck.memory.player.VolatilePlayerStorage;
|
||||
import com.zontreck.libzontreck.networking.ModMessages;
|
||||
import com.zontreck.libzontreck.profiles.Profile;
|
||||
import com.zontreck.libzontreck.util.FileTreeDatastore;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.server.ServerStartedEvent;
|
||||
import net.minecraftforge.event.server.ServerStoppingEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
@Mod(LibZontreck.MOD_ID)
|
||||
public class LibZontreck {
|
||||
public static final Logger LOGGER = LogUtils.getLogger();
|
||||
public static final String MOD_ID = "libzontreck";
|
||||
public static final Map<String, Profile> PROFILES;
|
||||
public static VolatilePlayerStorage playerStorage;
|
||||
public static boolean ALIVE=true;
|
||||
public static final String FILESTORE = FileTreeDatastore.get();
|
||||
public static final Path BASE_CONFIG;
|
||||
public static final String PLAYER_INFO_URL = "https://api.mojang.com/users/profiles/minecraft/";
|
||||
public static final String PLAYER_SKIN_URL = "https://sessionserver.mojang.com/session/minecraft/profile/";
|
||||
public static final UUID NULL_ID;
|
||||
|
||||
public static boolean LIBZONTRECK_SERVER_AVAILABLE=false;
|
||||
public static ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
|
||||
|
||||
|
||||
public static LogicalSide CURRENT_SIDE;
|
||||
|
||||
|
||||
|
||||
static{
|
||||
NULL_ID = new UUID(0,0);
|
||||
PROFILES = new HashMap<>();
|
||||
BASE_CONFIG = FileTreeDatastore.of("libzontreck");
|
||||
|
||||
if(!BASE_CONFIG.toFile().exists())
|
||||
{
|
||||
try {
|
||||
Files.createDirectory(BASE_CONFIG);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public LibZontreck(){
|
||||
LibZontreck.playerStorage=new VolatilePlayerStorage();
|
||||
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
// Register the setup method for modloading
|
||||
bus.addListener(this::setup);
|
||||
|
||||
ServerConfig.init();
|
||||
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
MinecraftForge.EVENT_BUS.register(new ForgeEventHandlers());
|
||||
MinecraftForge.EVENT_BUS.register(new Commands());
|
||||
MinecraftForge.EVENT_BUS.register(new NetworkEvents());
|
||||
MinecraftForge.EVENT_BUS.register(ChestGUIRegistry.class);
|
||||
|
||||
|
||||
ModMenuTypes.REGISTRY.register(bus);
|
||||
//CreativeModeTabs.register(bus);
|
||||
ModItems.register(bus);
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(CurrencyHelper.class);
|
||||
MinecraftForge.EVENT_BUS.register(Bank.class);
|
||||
|
||||
}
|
||||
|
||||
private void setup(final FMLCommonSetupEvent event)
|
||||
{
|
||||
ModMessages.register();
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void onServerStarted(final ServerStartedEvent event)
|
||||
{
|
||||
ALIVE=true;
|
||||
|
||||
ServerConfig.init();
|
||||
try {
|
||||
DatabaseWrapper.start();
|
||||
}catch(RuntimeException e) {
|
||||
LOGGER.warn("Database not configured properly, it will not be available.");
|
||||
DatabaseWrapper.invalidate();
|
||||
}
|
||||
|
||||
CURRENT_SIDE = LogicalSide.SERVER;
|
||||
|
||||
/*MinecraftForge.EVENT_BUS.post(new BlockRestoreQueueRegistrationEvent());
|
||||
|
||||
for(ServerLevel level : event.getServer().getAllLevels())
|
||||
{
|
||||
// Queues have been registered, but we now need to initialize the queue's data from saveddata
|
||||
BlockRestoreQueueRegistry.init(level);
|
||||
}
|
||||
*/
|
||||
if(!DatabaseWrapper.hasDB)return;
|
||||
|
||||
try {
|
||||
DatabaseMigrations.initMigrations();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onServerStopping(final ServerStoppingEvent ev)
|
||||
{
|
||||
ALIVE=false;
|
||||
|
||||
Iterator<Profile> iProfile = PROFILES.values().iterator();
|
||||
while(iProfile.hasNext())
|
||||
{
|
||||
Profile prof = iProfile.next();
|
||||
prof.commit();
|
||||
iProfile.remove();
|
||||
prof=null;
|
||||
}
|
||||
}
|
||||
|
||||
@Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public static class ClientModEvents
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void onClientSetup(FMLClientSetupEvent ev) {
|
||||
LibZontreck.CURRENT_SIDE = LogicalSide.CLIENT;
|
||||
LibZontreck.ALIVE = false; // Prevents loops on the client that are meant for server tick processing
|
||||
|
||||
|
||||
MenuScreens.register(ModMenuTypes.CHEST_GUI_MENU.get(), ChestGUIScreen::new);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
138
src/main/java/com/zontreck/libzontreck/api/Vector2.java
Normal file
138
src/main/java/com/zontreck/libzontreck/api/Vector2.java
Normal file
|
@ -0,0 +1,138 @@
|
|||
package com.zontreck.libzontreck.api;
|
||||
|
||||
import com.zontreck.libzontreck.vectors.Vector2f;
|
||||
import com.zontreck.libzontreck.vectors.Vector2i;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
|
||||
public interface Vector2<T> extends Cloneable, Comparable<Vector2<T>>
|
||||
{
|
||||
/**
|
||||
* Converts the current Vector2 representation into a minecraft Vec2
|
||||
* @return Minecraft equivalent Vec2
|
||||
*/
|
||||
Vec2 asMinecraftVector();
|
||||
|
||||
/**
|
||||
* Parses a string in serialized format.
|
||||
* @param vector2 Expects it in the same format returned by Vector2#toString
|
||||
* @return New Vector2, or a null Vector2 initialized with zeros if invalid data
|
||||
*/
|
||||
static Vector2 parseString(String vector2){
|
||||
throw new UnsupportedOperationException("This method is not implemented by this implementation");
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the values to a new and detached instance
|
||||
* @return New Vector2
|
||||
*/
|
||||
Vector2 Clone();
|
||||
|
||||
/**
|
||||
* Saves the X and Y positions to a NBT tag
|
||||
* @return NBT compound tag
|
||||
*/
|
||||
CompoundTag serialize();
|
||||
|
||||
/**
|
||||
* Loads a Vector2 from a NBT tag
|
||||
* @param tag The NBT tag to load
|
||||
*/
|
||||
static Vector2 deserialize(CompoundTag tag)
|
||||
{
|
||||
throw new UnsupportedOperationException("This method is not implemented by this implementation");
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares the two vector2 instances
|
||||
* @param other The position to check
|
||||
* @return True if same position
|
||||
*/
|
||||
boolean Same(Vector2 other);
|
||||
|
||||
/**
|
||||
* True if the current position is inside the two points
|
||||
* @param point1 Lowest point
|
||||
* @param point2 Hightest Point
|
||||
* @return True if inside
|
||||
*/
|
||||
boolean Inside(Vector2 point1, Vector2 point2);
|
||||
|
||||
/**
|
||||
* Converts, if necessary, to Vector2d
|
||||
* @return A vector2d instance
|
||||
*/
|
||||
Vector2f asVector2f();
|
||||
|
||||
/**
|
||||
* Converts, if necessary, to Vector2i
|
||||
* @return A vector2i instance
|
||||
*/
|
||||
Vector2i asVector2i();
|
||||
|
||||
/**
|
||||
* Checks if the current vector is greater than the provided one
|
||||
* @param other The other vector to check
|
||||
* @return True if greater
|
||||
*/
|
||||
boolean greater(Vector2 other);
|
||||
|
||||
/**
|
||||
* Checks if the current vector is less than the provided one
|
||||
* @param other The vector to check
|
||||
* @return True if less than other
|
||||
*/
|
||||
boolean less(Vector2 other);
|
||||
|
||||
/**
|
||||
* Alias for Vector2#same
|
||||
* @param other Vector to check
|
||||
* @return True if same position
|
||||
*/
|
||||
boolean equal(Vector2 other);
|
||||
|
||||
/**
|
||||
* Adds the two vectors together
|
||||
* @param other Vector to add
|
||||
* @return New instance after adding the other vector
|
||||
*/
|
||||
Vector2 add(Vector2 other);
|
||||
|
||||
/**
|
||||
* Subtracts the other vector from this one
|
||||
* @param other Vector to subtract
|
||||
* @return New instance after subtracting
|
||||
*/
|
||||
Vector2 subtract(Vector2 other);
|
||||
|
||||
/**
|
||||
* Calculates the distance between the two vectors
|
||||
* @param other
|
||||
* @return The distance
|
||||
*/
|
||||
double distance(Vector2 other);
|
||||
|
||||
/**
|
||||
* Increments the Y axis by 1
|
||||
* @return New instance
|
||||
*/
|
||||
Vector2 moveUp();
|
||||
|
||||
/**
|
||||
* Decrements the Y axis by 1
|
||||
* @return New instance
|
||||
*/
|
||||
Vector2 moveDown();
|
||||
|
||||
/**
|
||||
* Gets the X value
|
||||
* @return X
|
||||
*/
|
||||
T getX();
|
||||
|
||||
/**
|
||||
* Gets the Y value
|
||||
* @return Y
|
||||
*/
|
||||
T getY();
|
||||
}
|
158
src/main/java/com/zontreck/libzontreck/api/Vector3.java
Normal file
158
src/main/java/com/zontreck/libzontreck/api/Vector3.java
Normal file
|
@ -0,0 +1,158 @@
|
|||
package com.zontreck.libzontreck.api;
|
||||
|
||||
import com.zontreck.libzontreck.vectors.Vector3d;
|
||||
import com.zontreck.libzontreck.vectors.Vector3i;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public interface Vector3<T> extends Cloneable, Comparable<Vector3<T>>
|
||||
{
|
||||
/**
|
||||
* Converts the current Vector3 representation into a minecraft Vec3
|
||||
* @return Minecraft equivalent Vec3
|
||||
*/
|
||||
Vec3 asMinecraftVector();
|
||||
|
||||
/**
|
||||
* Converts to a vec3i position
|
||||
* @return Equivalent vec3i
|
||||
*/
|
||||
Vec3i asVec3i();
|
||||
|
||||
/**
|
||||
* Converts to a block position
|
||||
* @return Equivalent block position
|
||||
*/
|
||||
BlockPos asBlockPos();
|
||||
|
||||
/**
|
||||
* Parses a string in serialized format.
|
||||
* @param vector3 Expects it in the same format returned by Vector3#toString
|
||||
* @return New Vector3, or a null Vector3 initialized with zeros if invalid data
|
||||
*/
|
||||
static Vector3 parseString(String vector3){
|
||||
throw new UnsupportedOperationException("This method is not implemented by this implementation");
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the values to a new and detached instance
|
||||
* @return New Vector3
|
||||
*/
|
||||
Vector3 Clone();
|
||||
|
||||
/**
|
||||
* Saves the X, Y, and Z positions to a NBT tag
|
||||
* @return NBT compound tag
|
||||
*/
|
||||
CompoundTag serialize();
|
||||
|
||||
/**
|
||||
* Loads a Vector3 from a NBT tag
|
||||
* @param tag The NBT tag to load
|
||||
*/
|
||||
static Vector3 deserialize(CompoundTag tag)
|
||||
{
|
||||
throw new UnsupportedOperationException("This method is not implemented by this implementation");
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares the two vector3 instances
|
||||
* @param other The position to check
|
||||
* @return True if same position
|
||||
*/
|
||||
boolean Same(Vector3 other);
|
||||
|
||||
/**
|
||||
* True if the current position is inside the two points
|
||||
* @param point1 Lowest point
|
||||
* @param point2 Hightest Point
|
||||
* @return True if inside
|
||||
*/
|
||||
boolean Inside(Vector3 point1, Vector3 point2);
|
||||
|
||||
/**
|
||||
* Converts, if necessary, to Vector3d
|
||||
* @return A vector2d instance
|
||||
*/
|
||||
Vector3d asVector3d();
|
||||
|
||||
/**
|
||||
* Converts, if necessary, to Vector3i
|
||||
* @return A vector3i instance
|
||||
*/
|
||||
Vector3i asVector3i();
|
||||
|
||||
/**
|
||||
* Checks if the current vector is greater than the provided one
|
||||
* @param other The other vector to check
|
||||
* @return True if greater
|
||||
*/
|
||||
boolean greater(Vector3 other);
|
||||
|
||||
/**
|
||||
* Checks if the current vector is less than the provided one
|
||||
* @param other The vector to check
|
||||
* @return True if less than other
|
||||
*/
|
||||
boolean less(Vector3 other);
|
||||
|
||||
/**
|
||||
* Alias for Vector3#same
|
||||
* @param other Vector to check
|
||||
* @return True if same position
|
||||
*/
|
||||
boolean equal(Vector3 other);
|
||||
|
||||
/**
|
||||
* Adds the two vectors together
|
||||
* @param other Vector to add
|
||||
* @return New instance after adding the other vector
|
||||
*/
|
||||
Vector3 add(Vector3 other);
|
||||
|
||||
/**
|
||||
* Subtracts the other vector from this one
|
||||
* @param other Vector to subtract
|
||||
* @return New instance after subtracting
|
||||
*/
|
||||
Vector3 subtract(Vector3 other);
|
||||
|
||||
/**
|
||||
* Calculates the distance between the two vectors
|
||||
* @param other
|
||||
* @return The distance
|
||||
*/
|
||||
double distance(Vector3 other);
|
||||
|
||||
/**
|
||||
* Increments the Y axis by 1
|
||||
* @return New instance
|
||||
*/
|
||||
Vector3 moveUp();
|
||||
|
||||
/**
|
||||
* Decrements the Y axis by 1
|
||||
* @return New instance
|
||||
*/
|
||||
Vector3 moveDown();
|
||||
|
||||
/**
|
||||
* Gets the X value
|
||||
* @return X
|
||||
*/
|
||||
T getX();
|
||||
|
||||
/**
|
||||
* Gets the Y value
|
||||
* @return Y
|
||||
*/
|
||||
T getY();
|
||||
|
||||
/**
|
||||
* Gets the Z value
|
||||
* @return Z
|
||||
*/
|
||||
T getZ();
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.zontreck.libzontreck.blocks;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
public class BlockCustomVoxels extends PartialTransparentBlock
|
||||
{
|
||||
private VoxelShape superShape;
|
||||
public BlockCustomVoxels(Properties p_54120_, VoxelShape shape) {
|
||||
super(p_54120_);
|
||||
this.superShape = shape;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState p_60555_, BlockGetter p_60556_, BlockPos p_60557_, CollisionContext p_60558_) {
|
||||
return superShape;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
package com.zontreck.libzontreck.blocks;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
/**
|
||||
* Code partially taken from HT's TreeChop
|
||||
* <p>
|
||||
* <a href="https://github.com/hammertater/treechop/blob/main/shared/src/main/java/ht/treechop/common/block/BlockImitator.java">Source Material</a>
|
||||
*/
|
||||
public abstract class BlockImitation extends Block
|
||||
{
|
||||
public BlockImitation(Properties pProperties) {
|
||||
super(pProperties);
|
||||
}
|
||||
|
||||
|
||||
public abstract BlockState getImitatedBlockState(BlockGetter level, BlockPos pos);
|
||||
|
||||
public abstract void updateImitation(BlockState newState, BlockGetter level, BlockPos pos);
|
||||
|
||||
@Override
|
||||
public void animateTick(BlockState blockState, Level level, BlockPos pos, RandomSource random) {
|
||||
BlockState imitatedBlockState = getImitatedBlockState(level, pos);
|
||||
imitatedBlockState.getBlock().animateTick(imitatedBlockState, level, pos, random);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stepOn(Level level, BlockPos pos, BlockState blockState, Entity entity) {
|
||||
BlockState imitatedBlockState = getImitatedBlockState(level, pos);
|
||||
imitatedBlockState.getBlock().stepOn(level, pos, imitatedBlockState, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fallOn(Level level, BlockState blockState, BlockPos pos, Entity entity, float speed) {
|
||||
BlockState imitatedBlockState = getImitatedBlockState(level, pos);
|
||||
imitatedBlockState.getBlock().fallOn(level, imitatedBlockState, pos, entity, speed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCloneItemStack(BlockGetter level, BlockPos pos, BlockState blockState) {
|
||||
BlockState imitatedBlockState = getImitatedBlockState(level, pos);
|
||||
return imitatedBlockState.getBlock().getCloneItemStack(level, pos, imitatedBlockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePrecipitation(BlockState blockState, Level level, BlockPos pos, Biome.Precipitation precipitation) {
|
||||
BlockState imitatedBlockState = getImitatedBlockState(level, pos);
|
||||
imitatedBlockState.getBlock().handlePrecipitation(imitatedBlockState, level, pos, precipitation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightBlock(BlockState blockState, BlockGetter level, BlockPos pos) {
|
||||
return super.getLightBlock(blockState, level, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getShadeBrightness(BlockState blockState, BlockGetter level, BlockPos pos) {
|
||||
return super.getShadeBrightness(blockState, level, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAnalogOutputSignal(BlockState blockState, Level level, BlockPos pos) {
|
||||
return getImitatedBlockState(level, pos).getAnalogOutputSignal(level, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomTick(BlockState blockState, ServerLevel level, BlockPos pos, RandomSource random) {
|
||||
getImitatedBlockState(level, pos).randomTick(level, pos, random);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(BlockState blockState, ServerLevel level, BlockPos pos, RandomSource random) {
|
||||
getImitatedBlockState(level, pos).tick(level, pos, random);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSignal(BlockState blockState, BlockGetter level, BlockPos pos, Direction direction) {
|
||||
return getImitatedBlockState(level, pos).getSignal(level, pos, direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDirectSignal(BlockState blockState, BlockGetter level, BlockPos pos, Direction direction) {
|
||||
return getImitatedBlockState(level, pos).getDirectSignal(level, pos, direction);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.zontreck.libzontreck.blocks;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.AbstractGlassBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class PartialTransparentBlock extends AbstractGlassBlock
|
||||
{
|
||||
public PartialTransparentBlock(Properties p_48729_) {
|
||||
super(p_48729_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState p_48740_, BlockGetter p_48741_, BlockPos p_48742_) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.zontreck.libzontreck.blocks;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.AbstractGlassBlock;
|
||||
import net.minecraft.world.level.block.SlabBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
public class PartialTransparentSlabBlock extends SlabBlock
|
||||
{
|
||||
public PartialTransparentSlabBlock(Properties p_48729_) {
|
||||
super(p_48729_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean propagatesSkylightDown(BlockState p_48740_, BlockGetter p_48741_, BlockPos p_48742_) {
|
||||
return true;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue