Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 86f67529dc | |||
| 8df1c1244f | |||
| dcb81f8a0f | |||
| e19e164c69 | |||
| 4a8c1819a3 | |||
| 0e5a830912 | |||
| 799d7075ac | |||
| 1ed722c299 |
8
.gitignore
vendored
8
.gitignore
vendored
@@ -1,4 +1,4 @@
|
||||
/.gradle
|
||||
/.idea
|
||||
/build
|
||||
/run
|
||||
.gradle
|
||||
.idea
|
||||
build
|
||||
run
|
||||
21
LICENSE.txt
Normal file
21
LICENSE.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2025
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
64
build.gradle
64
build.gradle
@@ -1,55 +1,47 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id("xyz.jpenilla.run-paper") version "2.3.1"
|
||||
id 'fabric-loom' version "${loom_version}"
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
group = 'com.kasetoatz'
|
||||
version = '1.0'
|
||||
version = project.mod_version
|
||||
group = project.maven_group
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = "spigotmc-repo"
|
||||
url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
|
||||
}
|
||||
base {
|
||||
archivesName = project.archives_base_name
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("org.spigotmc:spigot-api:1.21.8-R0.1-SNAPSHOT")
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
}
|
||||
|
||||
tasks {
|
||||
runServer {
|
||||
// Configure the Minecraft version for our task.
|
||||
// This is the only required configuration besides applying the plugin.
|
||||
// Your plugin's jar (or shadowJar if present) will be used automatically.
|
||||
minecraftVersion("1.21.8")
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
inputs.property "minecraft_version", project.minecraft_version
|
||||
inputs.property "loader_version", project.loader_version
|
||||
filteringCharset "UTF-8"
|
||||
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": project.version,
|
||||
"minecraft_version": project.minecraft_version,
|
||||
"loader_version": project.loader_version
|
||||
}
|
||||
}
|
||||
|
||||
def targetJavaVersion = 21
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
|
||||
it.options.release.set(targetJavaVersion)
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
|
||||
sourceCompatibility = javaVersion
|
||||
targetCompatibility = javaVersion
|
||||
if (JavaVersion.current() < javaVersion) {
|
||||
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.encoding = 'UTF-8'
|
||||
|
||||
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
|
||||
options.release.set(targetJavaVersion)
|
||||
}
|
||||
}
|
||||
|
||||
processResources {
|
||||
def props = [version: version]
|
||||
inputs.properties props
|
||||
filteringCharset 'UTF-8'
|
||||
filesMatching('plugin.yml') {
|
||||
expand props
|
||||
}
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
# Done to increase the memory available to gradle.
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
# Fabric Properties
|
||||
# check these on https://modmuss50.me/fabric.html
|
||||
minecraft_version=1.21.11
|
||||
yarn_mappings=1.21.11+build.2
|
||||
loader_version=0.18.2
|
||||
loom_version=1.14-SNAPSHOT
|
||||
# Mod Properties
|
||||
mod_version=1.3
|
||||
maven_group=com.kasetoatz
|
||||
archives_base_name=fastghast
|
||||
# Dependencies
|
||||
# check this on https://modmuss50.me/fabric.html
|
||||
fabric_version=0.139.5+1.21.11
|
||||
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
10
gradlew
vendored
10
gradlew
vendored
@@ -15,6 +15,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@@ -84,7 +86,7 @@ done
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -112,7 +114,7 @@ case "$( uname )" in #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
CLASSPATH="\\\"\\\""
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
@@ -203,7 +205,7 @@ fi
|
||||
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,
|
||||
# * DEFAULT_JVM_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.
|
||||
@@ -211,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
|
||||
6
gradlew.bat
vendored
6
gradlew.bat
vendored
@@ -13,6 +13,8 @@
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@@ -68,11 +70,11 @@ goto fail
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
set CLASSPATH=
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
|
||||
@@ -1 +1,9 @@
|
||||
rootProject.name = 'FastGhast'
|
||||
pluginManagement {
|
||||
repositories {
|
||||
maven {
|
||||
name = 'Fabric'
|
||||
url = 'https://maven.fabricmc.net/'
|
||||
}
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,49 +1,26 @@
|
||||
package com.kasetoatz.fastGhast;
|
||||
package com.kasetoatz.fastghast;
|
||||
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeInstance;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.HappyGhast;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDismountEvent;
|
||||
import org.bukkit.event.entity.EntityMountEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||
import net.minecraft.entity.Leashable;
|
||||
import net.minecraft.entity.passive.HappyGhastEntity;
|
||||
import net.minecraft.network.packet.s2c.play.PositionFlag;
|
||||
|
||||
public final class FastGhast extends JavaPlugin implements Listener
|
||||
import java.util.EnumSet;
|
||||
|
||||
import static com.kasetoatz.fastghast.config.Config.load;
|
||||
|
||||
public class FastGhast implements ModInitializer
|
||||
{
|
||||
private static final double DEFAULT = 0.05;
|
||||
private double SPEED;
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
public void onInitialize()
|
||||
{
|
||||
saveDefaultConfig();
|
||||
SPEED = getConfig().getDouble("speed");
|
||||
getServer().getPluginManager().registerEvents(this, this);
|
||||
}
|
||||
|
||||
private void setSpeed(Entity entity, double speed)
|
||||
{
|
||||
if (entity instanceof HappyGhast ghast)
|
||||
{
|
||||
AttributeInstance attr = ghast.getAttribute(Attribute.FLYING_SPEED);
|
||||
if (attr != null)
|
||||
load();
|
||||
ServerTickEvents.END_SERVER_TICK.register((server) -> server.getWorlds().forEach(world -> world.iterateEntities().forEach(entity -> {
|
||||
if (entity instanceof Leashable leashed && leashed.isLeashed() && leashed.getLeashHolder() instanceof HappyGhastEntity ghast && leashed.getDistanceToCenter(ghast) > 8)
|
||||
{
|
||||
attr.setBaseValue(speed);
|
||||
entity.teleport(world, ghast.getX(), ghast.getY(), ghast.getZ(), EnumSet.noneOf(PositionFlag.class), entity.getYaw(), entity.getPitch(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityMount(EntityMountEvent event)
|
||||
{
|
||||
setSpeed(event.getMount(), SPEED);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDismount(EntityDismountEvent event)
|
||||
{
|
||||
setSpeed(event.getDismounted(), DEFAULT);
|
||||
})));
|
||||
}
|
||||
}
|
||||
|
||||
62
src/main/java/com/kasetoatz/fastGhast/config/Config.java
Normal file
62
src/main/java/com/kasetoatz/fastGhast/config/Config.java
Normal file
@@ -0,0 +1,62 @@
|
||||
package com.kasetoatz.fastghast.config;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.util.crash.CrashException;
|
||||
import net.minecraft.util.crash.CrashReport;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class Config
|
||||
{
|
||||
public static double UNMOUNTED_SPEED = 0.05;
|
||||
public static double MOUNTED_SPEED = 0.15;
|
||||
|
||||
private static final Path FILE = FabricLoader.getInstance().getConfigDir().resolve("fastghast.json");
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
public static void load() {
|
||||
if (!Files.exists(FILE))
|
||||
{
|
||||
save();
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
String json = Files.readString(FILE);
|
||||
JsonObject data = GSON.fromJson(json, JsonObject.class);
|
||||
if (data.has("unmounted-speed"))
|
||||
{
|
||||
UNMOUNTED_SPEED = data.get("unmounted-speed").getAsDouble();
|
||||
}
|
||||
if (data.has("mounted-speed"))
|
||||
{
|
||||
MOUNTED_SPEED = data.get("mounted-speed").getAsDouble();
|
||||
}
|
||||
save();
|
||||
}
|
||||
catch (IOException exc)
|
||||
{
|
||||
throw new CrashException(CrashReport.create(exc, "Loading config file."));
|
||||
}
|
||||
}
|
||||
|
||||
private static void save()
|
||||
{
|
||||
try
|
||||
{
|
||||
JsonObject data = new JsonObject();
|
||||
data.addProperty("unmounted-speed", UNMOUNTED_SPEED);
|
||||
data.addProperty("mounted-speed", MOUNTED_SPEED);
|
||||
Files.writeString(FILE, GSON.toJson(data));
|
||||
}
|
||||
catch (IOException exc)
|
||||
{
|
||||
throw new CrashException(CrashReport.create(exc, "Saving config file."));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.kasetoatz.fastghast.mixin;
|
||||
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.attribute.EntityAttribute;
|
||||
import net.minecraft.entity.passive.HappyGhastEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import static com.kasetoatz.fastghast.config.Config.MOUNTED_SPEED;
|
||||
import static com.kasetoatz.fastghast.config.Config.UNMOUNTED_SPEED;
|
||||
|
||||
@Mixin(HappyGhastEntity.class)
|
||||
public abstract class HappyGhastMixin
|
||||
{
|
||||
@Shadow @Nullable public abstract LivingEntity getControllingPassenger();
|
||||
|
||||
@Redirect(method="travel", at=@At(value="INVOKE", target="Lnet/minecraft/entity/passive/HappyGhastEntity;getAttributeValue(Lnet/minecraft/registry/entry/RegistryEntry;)D"))
|
||||
public double speed(HappyGhastEntity instance, RegistryEntry<EntityAttribute> registryEntry)
|
||||
{
|
||||
return getControllingPassenger() instanceof PlayerEntity ? MOUNTED_SPEED : UNMOUNTED_SPEED;
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
# Flying speed of mounted Happy Ghasts, default speed is 0.05 so 0.15 is 3 times as fast.
|
||||
speed: 0.15
|
||||
24
src/main/resources/fabric.mod.json
Normal file
24
src/main/resources/fabric.mod.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "fastghast",
|
||||
"version": "${version}",
|
||||
"name": "FastGhast",
|
||||
"description": "",
|
||||
"authors": [],
|
||||
"contact": {},
|
||||
"license": "MIT",
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"main": [
|
||||
"com.kasetoatz.fastghast.FastGhast"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"fastghast.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=${loader_version}",
|
||||
"fabric": "*",
|
||||
"minecraft": "${minecraft_version}"
|
||||
}
|
||||
}
|
||||
15
src/main/resources/fastghast.mixins.json
Normal file
15
src/main/resources/fastghast.mixins.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "com.kasetoatz.fastghast.mixin",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"mixins": [
|
||||
"HappyGhastMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"overwrites": {
|
||||
"requireAnnotations": true
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
name: FastGhast
|
||||
version: '1.0'
|
||||
main: com.kasetoatz.fastGhast.FastGhast
|
||||
api-version: '1.21'
|
||||
Reference in New Issue
Block a user