First working alpha

This commit is contained in:
Martin Prokoph
2022-08-15 23:41:45 +02:00
parent c66f9a680e
commit 5d62e8620c
42 changed files with 1039 additions and 0 deletions

25
.gitignore vendored Normal file
View File

@@ -0,0 +1,25 @@
# gradle
.gradle/
out/
classes/
build/
# idea
.idea/
*.iml
*.ipr
*.iws
# vscode
.settings/
.vscode/
bin/
.classpath
.project
# fabric
run/

27
Modfest_Singularity Normal file
View File

@@ -0,0 +1,27 @@
Modfest: Singularity
Mod name: Celestria
Feature: Celestrial Events (Shooting stars => Luck effect, Full moon => chance of insomnia potion effect)
Chat messages: (Configurable via MidnightConfig lists, translation strings, \n for line break)
- Shooting stars: (On occurance)
- Oh, look! A shooting star appeared and blessed you with good luck!
- Wow, make a wish, a shooting star appeared!
- ♪ Can we pretend that airplanes in the night sky are like shooting stars... ♫
Oh wait, there's a real one!
-
- Full moon: (When trying to sleep w/ insomnia effect)
- You're afraid of the full moon, so you just can't find no rest...
- Ouuwwwh... You hear strange noises from afar and can't close your eyes
-
Technical details:
- Shooting stars:
- randomly triggered serverside (only at night) and synced to all players
- can also be created using commands (for showcase - /celestria shooting_star %PLAYER% x z)
- server sends packet to client which then renders the shooting star (mixin into WorldRenderer)
- players get Minecraft's Luck effect
- Full moon:
- on start of night with full moon, players have an individual and configurable chance of receiving the 'Insomnia' effect
- effect prevents players from entering a bed, instead sending a chat message to inform them about the reason

82
build.gradle Executable file
View File

@@ -0,0 +1,82 @@
plugins {
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'maven-publish'
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
repositories {
maven { url "https://api.modrinth.com/maven" }
}
dependencies {
//to change the versions see the gradle.properties file
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}"
modImplementation "maven.modrinth:midnightlib:${midnightlib_version}"
include "maven.modrinth:midnightlib:${midnightlib_version}"
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"
// Minecraft 1.17 (21w19a) upwards uses Java 16.
it.options.release = 17
}
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()
}
jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
// add all the jars that should be included when publishing to maven
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// 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.
}
}

BIN
celestria.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

186
celestria.svg Normal file
View File

@@ -0,0 +1,186 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="512.0px"
height="512.0px"
viewBox="0 0 512.0 512.0"
version="1.1"
id="SVGRoot"
sodipodi:docname="celestria.svg"
inkscape:version="1.2.1 (9c6d41e410, 2022-07-14)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview14"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="px"
showgrid="true"
inkscape:zoom="0.65357086"
inkscape:cx="318.25164"
inkscape:cy="205.0275"
inkscape:window-width="1920"
inkscape:window-height="1011"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="layer1">
<inkscape:grid
type="xygrid"
id="grid20" />
</sodipodi:namedview>
<defs
id="defs9">
<linearGradient
inkscape:collect="always"
id="linearGradient215">
<stop
style="stop-color:#000044;stop-opacity:1"
offset="0"
id="stop211" />
<stop
style="stop-color:#0050dc;stop-opacity:1"
offset="1"
id="stop213" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient215"
id="linearGradient217"
x1="2.8844724"
y1="0.54643714"
x2="516.06079"
y2="516.8222"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient215"
id="linearGradient1423"
x1="1.0739838"
y1="-0.32054672"
x2="512.52893"
y2="512.30109"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(0,-2)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient215"
id="linearGradient1467"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(2.170239,6.5358396)"
x1="1.0739838"
y1="-0.32054672"
x2="512.52893"
y2="512.30109" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient215"
id="linearGradient1490"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(-0.091599,17.138808)"
x1="1.0739838"
y1="-0.32054672"
x2="512.52893"
y2="512.30109" />
</defs>
<g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="fill:url(#linearGradient217);fill-opacity:1;stroke-width:1"
id="rect129"
width="512"
height="512"
x="1.3048804"
y="1.3317544" />
<path
sodipodi:type="star"
style="fill:#ffffff"
id="path495"
inkscape:flatsided="false"
sodipodi:sides="5"
sodipodi:cx="205.73145"
sodipodi:cy="145.78644"
sodipodi:r1="65.212128"
sodipodi:r2="20.714731"
sodipodi:arg1="1.0224883"
sodipodi:arg2="1.6508068"
inkscape:rounded="0.05"
inkscape:randomized="0"
d="m 239.72288,201.43897 c -2.13181,1.30206 -33.15706,-34.80442 -35.64706,-35.00407 -2.49001,-0.19965 -38.87204,30.502 -40.76915,28.87689 -1.8971,-1.62511 22.85488,-42.28939 22.2753,-44.71922 -0.57957,-2.42983 -41.02124,-27.54387 -40.06191,-29.85031 0.95934,-2.30644 47.28214,8.66813 49.41395,7.36607 2.13182,-1.30207 13.51952,-47.52505 16.00953,-47.325397 2.49,0.199652 6.36709,47.646587 8.2642,49.271697 1.8971,1.62512 49.37676,-1.82822 49.95634,0.60161 0.57957,2.42984 -43.34706,20.77908 -44.3064,23.08552 -0.95933,2.30644 16.99701,46.39514 14.8652,47.69721 z"
inkscape:transform-center-x="-1.4367852"
inkscape:transform-center-y="-2.5647046"
transform="translate(71.06006,29.06306)" />
<path
sodipodi:type="star"
style="fill:#ffffff"
id="path497"
inkscape:flatsided="false"
sodipodi:sides="5"
sodipodi:cx="100.10706"
sodipodi:cy="186.06554"
sodipodi:r1="69.619064"
sodipodi:r2="22.114599"
sodipodi:arg1="0.7696116"
sodipodi:arg2="1.3979301"
inkscape:rounded="0.05"
inkscape:randomized="-4.8572257e-17"
d="m 150.10615,234.5104 c -1.85571,1.91526 -43.56817,-27.11857 -46.19523,-26.65986 -2.62706,0.4587 -32.032136,41.91029 -34.427096,40.73724 -2.39496,-1.17304 12.327995,-49.81589 11.07993,-52.17263 -1.248064,-2.35673 -49.757531,-17.51337 -49.381982,-20.15361 0.375549,-2.64023 51.18729,-3.66934 53.043006,-5.58459 1.855716,-1.91525 1.280289,-52.73415 3.907352,-53.19286 2.627062,-0.45871 19.30749,47.54812 21.70245,48.72116 2.39496,1.17305 50.54879,-15.07812 51.79686,-12.72139 1.24806,2.35674 -39.25461,33.0557 -39.63016,35.69593 -0.37554,2.64023 29.96059,43.41536 28.10487,45.33061 z"
inkscape:transform-center-x="3.700458"
inkscape:transform-center-y="-3.029601"
transform="translate(48.268882,98.308226)" />
<path
style="fill:#ffffff"
d="M 482.44522,379.16113 C 301.47922,222.81053 316.83234,210.40436 316.83234,210.40436"
id="path553" />
<path
style="fill:#ffffff"
d="M 496.4196,464.82486 C 200.91514,290.46663 197.03945,304.48652 197.03945,304.48652"
id="path555" />
<path
style="fill:#ffffff;stroke-width:1.377"
id="path609"
sodipodi:type="arc"
sodipodi:cx="-98.923004"
sodipodi:cy="-130.69897"
sodipodi:rx="70.545319"
sodipodi:ry="67.195251"
sodipodi:start="5.5480108"
sodipodi:end="4.094749"
sodipodi:arc-type="chord"
d="m -46.598573,-175.76795 a 70.545319,67.195251 0 0 1 10.497684,75.63887 70.545319,67.195251 0 0 1 -70.495701,36.226645 70.545319,67.195251 0 0 1 -60.60253,-49.890775 70.545319,67.195251 0 0 1 27.42242,-71.68652 z"
transform="matrix(-0.99393561,0.10996362,-0.1036226,-0.99461669,0,0)"
sodipodi:open="true" />
<rect
style="fill:url(#linearGradient1423);fill-opacity:1"
id="rect663"
width="137.74458"
height="2.9573181"
x="43.437553"
y="139.85849" />
<rect
style="fill:url(#linearGradient1467);fill-opacity:1"
id="rect663-7"
width="138.2057"
height="4.6834645"
x="45.607792"
y="148.39433" />
<rect
style="fill:url(#linearGradient1490);fill-opacity:1"
id="rect663-5"
width="137.65326"
height="7.1220856"
x="43.345947"
y="158.9973" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.7 KiB

BIN
celestria64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

18
gradle.properties Executable file
View File

@@ -0,0 +1,18 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.4
loader_version=0.14.9
# Mod Properties
mod_version = 1.0.0
maven_group = eu.midnightdust
archives_base_name = celestria
# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.59.0+1.19.2
midnightlib_version=0.5.2

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

Binary file not shown.

5
gradle/wrapper/gradle-wrapper.properties vendored Executable file
View File

@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

234
gradlew vendored Executable file
View File

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

89
gradlew.bat vendored Executable file
View File

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

10
settings.gradle Executable file
View File

@@ -0,0 +1,10 @@
pluginManagement {
repositories {
jcenter()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
gradlePluginPortal()
}
}

View File

@@ -0,0 +1,88 @@
package eu.midnightdust.celestria;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import eu.midnightdust.lib.util.MidnightColorUtil;
import eu.midnightdust.celestria.config.CelestriaConfig;
import eu.midnightdust.celestria.effect.InsomniaStatusEffect;
import io.netty.buffer.Unpooled;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.command.argument.EntityArgumentType;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectCategory;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.random.Random;
import net.minecraft.util.registry.Registry;
import java.util.Collection;
public class Celestria implements ModInitializer {
public static final String MOD_ID = "celestria";
public static final Identifier SHOOTING_STAR_PACKET = new Identifier(MOD_ID, "shooting_star");
public static final Identifier WELCOME_PACKET = new Identifier(MOD_ID, "welcome");
public static final StatusEffect INSOMNIA = new InsomniaStatusEffect(StatusEffectCategory.HARMFUL, MidnightColorUtil.hex2Rgb("88A9C8").getRGB());
public static int shootingStarCooldown = 0;
private int prevPlayerAmount = 0;
public void onInitialize() {
CelestriaConfig.init(MOD_ID, CelestriaConfig.class);
Registry.register(Registry.STATUS_EFFECT, new Identifier(MOD_ID, "insomnia"), INSOMNIA);
LiteralArgumentBuilder<ServerCommandSource> command = CommandManager.literal("shootingStar");
var commandPlayers = command.then(CommandManager.argument("players", EntityArgumentType.players()));
var commandX = commandPlayers.then(CommandManager.argument("x", IntegerArgumentType.integer(90, 180)));
var commandY = commandX.then(CommandManager.argument("y", IntegerArgumentType.integer(0, 360)));
var commandType = commandY.then(CommandManager.argument("type", IntegerArgumentType.integer(0, 3)));
LiteralArgumentBuilder<ServerCommandSource> finalized = CommandManager.literal("celestria").requires(source -> source.hasPermissionLevel(2)).then(commandType).executes(ctx ->
createShootingStar(EntityArgumentType.getPlayers(ctx, "players"),
IntegerArgumentType.getInteger(ctx, "x"), IntegerArgumentType.getInteger(ctx, "y"), IntegerArgumentType.getInteger(ctx, "type")));
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated, registrationEnvironment) -> dispatcher.register(finalized));
ServerTickEvents.END_WORLD_TICK.register(world -> {
if (shootingStarCooldown > 0) --shootingStarCooldown;
if (world.getPlayers().size() > prevPlayerAmount) {
world.getPlayers().forEach(player -> ServerPlayNetworking.send(player, WELCOME_PACKET, new PacketByteBuf(Unpooled.buffer())));
prevPlayerAmount = world.getPlayers().size();
}
if (world.isNight() && world.getMoonPhase() == 0) {
for (ServerPlayerEntity player : world.getPlayers()) {
if (world.random.nextInt(CelestriaConfig.insomniaChance) == 0) {
player.addStatusEffect(new StatusEffectInstance(INSOMNIA, CelestriaConfig.insomniaDuration, 0, true, false, true));
}
}
}
if (world.isNight() && Celestria.shootingStarCooldown <= 0 && world.random.nextInt(CelestriaConfig.shootingStarChance) == 0) {
int x = world.random.nextBetween(100, 150);
int y = world.random.nextInt(360);
int type = world.random.nextInt(3);
createShootingStar(world.getPlayers(), x, y, type);
Celestria.shootingStarCooldown = CelestriaConfig.shootingStarCooldownLength;
}
});
}
public int createShootingStar(Collection<ServerPlayerEntity> players, int x, int y, int type) {
int[] array = new int[3];
array[0] = x;
array[1] = y;
array[2] = type;
PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
passedData.writeIntArray(array);
int message = Random.create().nextInt(CelestriaConfig.shootingStarMessages.size());
players.forEach(player -> {
player.addStatusEffect(new StatusEffectInstance(StatusEffects.LUCK, CelestriaConfig.shootingStarLuckDuration, 0, true, false, true));
ServerPlayNetworking.send(player, SHOOTING_STAR_PACKET, passedData);
if (CelestriaConfig.sendChatMessages) player.sendMessageToClient(Text.literal("§f§l[§7§lC§8§le§7§ll§f§le§7§ls§8§lt§7§lr§f§li§7§la§8§l] ").append(Text.translatable(CelestriaConfig.shootingStarMessages.get(message))),false);
});
return 1;
}
}

View File

@@ -0,0 +1,56 @@
package eu.midnightdust.celestria;
import eu.midnightdust.celestria.config.CelestriaConfig;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.fabricmc.fabric.api.resource.ResourcePackActivationType;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.util.Identifier;
public class CelestriaClient implements ClientModInitializer {
private static boolean clientOnlyMode = true;
public static int shootingStarProgress = 0;
public static int shootingStarType = 0;
public static int shootingStarX = 0;
public static int shootingStarY = 0;
@Override
public void onInitializeClient() {
FabricLoader.getInstance().getModContainer(Celestria.MOD_ID).ifPresent(modContainer -> {
ResourceManagerHelper.registerBuiltinResourcePack(new Identifier(Celestria.MOD_ID,"realistic"), modContainer, ResourcePackActivationType.NORMAL);
ResourceManagerHelper.registerBuiltinResourcePack(new Identifier(Celestria.MOD_ID,"pixelperfect"), modContainer, ResourcePackActivationType.NORMAL);
});
ClientPlayNetworking.registerGlobalReceiver(Celestria.SHOOTING_STAR_PACKET,
(client, handler, attachedData, packetSender) -> {
int[] array = attachedData.readIntArray(3);
client.execute(() -> {
if (client.world != null) {
CelestriaClient.clientOnlyMode = false; // If the welcome packet wasn't received correctly for some reason, disable clientOnlyMode on shooting star occurrence
CelestriaClient.shootingStarX = array[0];
CelestriaClient.shootingStarY = array[1];
CelestriaClient.shootingStarType = array[2];
CelestriaClient.shootingStarProgress = 100 + shootingStarType * 10;
}
});
});
ClientPlayNetworking.registerGlobalReceiver(Celestria.WELCOME_PACKET,
(client, handler, attachedData, packetSender) -> client.execute(() -> CelestriaClient.clientOnlyMode = false));
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (shootingStarProgress > 0) --shootingStarProgress;
if (CelestriaClient.clientOnlyMode && client.world != null) {
if (Celestria.shootingStarCooldown > 0) --Celestria.shootingStarCooldown;
if (client.world.isNight() && Celestria.shootingStarCooldown <= 0 && client.world.random.nextInt(CelestriaConfig.shootingStarChance) == 0) {
CelestriaClient.shootingStarX = client.world.random.nextBetween(100, 150);
CelestriaClient.shootingStarY = client.world.random.nextInt(360);
CelestriaClient.shootingStarType = client.world.random.nextInt(3);
CelestriaClient.shootingStarProgress = 100 + shootingStarType * 10;
Celestria.shootingStarCooldown = CelestriaConfig.shootingStarCooldownLength;
}
}
});
ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> CelestriaClient.clientOnlyMode = true);
}
}

View File

@@ -0,0 +1,17 @@
package eu.midnightdust.celestria.config;
import com.google.common.collect.Lists;
import eu.midnightdust.lib.config.MidnightConfig;
import java.util.List;
public class CelestriaConfig extends MidnightConfig {
@Entry public static boolean sendChatMessages = true;
@Entry public static int shootingStarChance = 10000;
@Entry public static int shootingStarCooldownLength = 1000;
@Entry public static int shootingStarLuckDuration = 1000;
@Entry public static int insomniaChance = 30000;
@Entry public static int insomniaDuration = 1000;
@Entry public static List<String> shootingStarMessages = Lists.newArrayList("celestria.shootingStar.1", "celestria.shootingStar.2", "celestria.shootingStar.3");
@Entry public static List<String> insomniaMessages = Lists.newArrayList("celestria.insomnia.1", "celestria.insomnia.2");
}

View File

@@ -0,0 +1,10 @@
package eu.midnightdust.celestria.effect;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectCategory;
public class InsomniaStatusEffect extends StatusEffect {
public InsomniaStatusEffect(StatusEffectCategory statusEffectCategory, int color) {
super(statusEffectCategory, color);
}
}

View File

@@ -0,0 +1,29 @@
package eu.midnightdust.celestria.mixin;
import eu.midnightdust.celestria.Celestria;
import eu.midnightdust.celestria.config.CelestriaConfig;
import net.minecraft.block.BedBlock;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(BedBlock.class)
public abstract class MixinBedBlock {
@Inject(at = @At("HEAD"), method = "onUse", cancellable = true)
public void celestria$onBedUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit, CallbackInfoReturnable<ActionResult> cir) {
if (!world.isClient() && player instanceof ServerPlayerEntity serverPlayer && player.hasStatusEffect(Celestria.INSOMNIA)) {
if (CelestriaConfig.sendChatMessages) serverPlayer.sendMessageToClient(Text.literal("§f§l[§7§lC§8§le§7§ll§f§le§7§ls§8§lt§7§lr§f§li§7§la§8§l] ").append(Text.translatable(CelestriaConfig.insomniaMessages.get(world.random.nextInt(CelestriaConfig.insomniaMessages.size())))),false);
cir.setReturnValue(ActionResult.FAIL);
}
}
}

View File

@@ -0,0 +1,25 @@
package eu.midnightdust.celestria.mixin;
import eu.midnightdust.celestria.render.ShootingStarRenderer;
import net.minecraft.client.render.*;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.util.math.Matrix4f;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(WorldRenderer.class)
public abstract class MixinWorldRenderer {
@Unique private final ShootingStarRenderer shootingStarRenderer = new ShootingStarRenderer();
@Shadow @Nullable private ClientWorld world;
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", ordinal = 6, shift = At.Shift.BEFORE), method = "render")
public void celestria$renderShootingStars(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix, CallbackInfo ci) {
shootingStarRenderer.renderShootingStar(world, matrices);
}
}

View File

@@ -0,0 +1,42 @@
package eu.midnightdust.celestria.render;
import com.mojang.blaze3d.systems.RenderSystem;
import eu.midnightdust.celestria.Celestria;
import eu.midnightdust.celestria.CelestriaClient;
import eu.midnightdust.lib.util.MidnightMathUtil;
import net.minecraft.client.render.*;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Matrix4f;
import net.minecraft.util.math.Vec3f;
public class ShootingStarRenderer {
public void renderShootingStar(ClientWorld world, MatrixStack matrices) {
if (world != null && CelestriaClient.shootingStarProgress > 0) {
world.getProfiler().swap("shooting_star");
matrices.push();
matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(MidnightMathUtil.isEven(CelestriaClient.shootingStarType) ? CelestriaClient.shootingStarY + CelestriaClient.shootingStarProgress : CelestriaClient.shootingStarY - CelestriaClient.shootingStarProgress));
matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(CelestriaClient.shootingStarX));
Matrix4f matrix4f = matrices.peek().getPositionMatrix();
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
RenderSystem.enableTexture();
RenderSystem.defaultBlendFunc();
RenderSystem.enableDepthTest();
RenderSystem.enableBlend();
float alpha = (float) (Math.log(CelestriaClient.shootingStarProgress) / 5f);
RenderSystem.setShaderColor(1,1,1,alpha);
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderTexture(0, new Identifier(Celestria.MOD_ID, "textures/environment/shooting_star"+(CelestriaClient.shootingStarType+1)+".png"));
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE);
bufferBuilder.vertex(matrix4f, -20.0F, -100.0F, 20.0F).texture(0.0F, 0.0F).next();
bufferBuilder.vertex(matrix4f, 20.0F, -100.0F, 20.0F).texture(1.0F, 0.0F).next();
bufferBuilder.vertex(matrix4f, 20.0F, -100.0F, -20.0F).texture(1.0F, 1.0F).next();
bufferBuilder.vertex(matrix4f, -20.0F, -100.0F, -20.0F).texture(0.0F, 1.0F).next();
BufferRenderer.drawWithShader(bufferBuilder.end());
RenderSystem.disableTexture();
matrices.pop();
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@@ -0,0 +1,17 @@
{
"celestria.midnightconfig.title": "Celestria Konfiguration",
"celestria.midnightconfig.sendChatMessages": "Sende Chat Nachrichten bei Events",
"celestria.midnightconfig.shootingStarChance": "Sternschnuppen-Wahrscheinlichkeit",
"celestria.midnightconfig.shootingStarCooldownLength": "Sternschnuppen Cooldown Länge",
"celestria.midnightconfig.shootingStarLuckDuration": "Sternschnuppen Glück Effektlänge",
"celestria.midnightconfig.shootingStarMessages": "Sternschnuppen-Nachrichten",
"celestria.midnightconfig.insomniaChance": "Schlaflosigkeits-Wahrscheinlichkeit",
"celestria.midnightconfig.insomniaMessages": "Schlaflosigkeits-Nachrichten",
"celestria.midnightconfig.insomniaDuration": "Schlaflosigkeit Effektlänge",
"celestria.shootingStar.1": "§eOh, schau! Eine Sternschnuppe ist erschienen und hat dir Glück gebracht!",
"celestria.shootingStar.2": "§6Wow, eine Sternschnuppe ist erschienen, wünsch dir was!",
"celestria.shootingStar.3": "§2♪ Can we pretend that airplanes in the night sky are like shooting stars... ♫\n§3Oh warte, da ist ja eine echte Sternschnuppe!",
"celestria.insomnia.1": "§cDu hast Angst vor dem Vollmond, also kannst du einfach nicht einschlafen...",
"celestria.insomnia.2": "§3Ouuwwwh... Du hörst seltsame Geräusche und kannst deine Augen nicht schließen",
"celestria.mob_effect.insomnia": "Schlaflosigkeit"
}

View File

@@ -0,0 +1,17 @@
{
"celestria.midnightconfig.title": "Celestria Config",
"celestria.midnightconfig.sendChatMessages": "Send Chat Messages on Events",
"celestria.midnightconfig.shootingStarChance": "Shooting Star Chance",
"celestria.midnightconfig.shootingStarCooldownLength": "Shooting Star Cooldown Length",
"celestria.midnightconfig.shootingStarLuckDuration": "Shooting Star Luck Duration",
"celestria.midnightconfig.shootingStarMessages": "Shooting Star Messages",
"celestria.midnightconfig.insomniaChance": "Insomnia Chance",
"celestria.midnightconfig.insomniaMessages": "Insomnia Messages",
"celestria.midnightconfig.insomniaDuration": "Insomnia Effect Duration",
"celestria.shootingStar.1": "§eOh, look! A shooting star appeared and blessed you with good luck!",
"celestria.shootingStar.2": "§6Wow, a shooting star appeared, make a wish!",
"celestria.shootingStar.3": "§2♪ Can we pretend that airplanes in the night sky are like shooting stars... ♫\n§3Oh wait, there's a real one!",
"celestria.insomnia.1": "§cYou're afraid of the full moon, so you just can't find no rest...",
"celestria.insomnia.2": "§3Ouuwwwh... You hear strange noises from afar and can't close your eyes",
"celestria.mob_effect.insomnia": "Insomnia"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -0,0 +1,14 @@
{
"required": true,
"package": "eu.midnightdust.celestria.mixin",
"compatibilityLevel": "JAVA_17",
"client": [
"MixinWorldRenderer"
],
"mixins": [
"MixinBedBlock"
],
"injectors": {
"defaultRequire": 1
}
}

View File

@@ -0,0 +1,34 @@
{
"schemaVersion": 1,
"id": "celestria",
"version": "${version}",
"name": "Celestria",
"description": "Adds celestrial events, such as shooting stars and occasional insomnia from full moon.",
"authors": [
"Motschen",
"TeamMidnightDust"
],
"contact": {
"homepage": "https://www.midnightdust.eu/",
"sources": "https://github.com/TeamMidnightDust/Celestria",
"issues": "https://github.com/TeamMidnightDust/Celestria/issues"
},
"license": "MIT",
"icon": "assets/celestria/icon.png",
"environment": "*",
"entrypoints": {
"main": [
"eu.midnightdust.celestria.Celestria"
],
"client": [
"eu.midnightdust.celestria.CelestriaClient"
]
},
"mixins": [
"celestria.mixins.json"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@@ -0,0 +1,6 @@
{
"pack": {
"pack_format": 9,
"description": "Makes the shooting star texture consistent with vanilla stars"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

@@ -0,0 +1,2 @@
https://www.pngkey.com/maxpic/u2a9o0o0o0y3u2u2/
https://picsart.com/i/sticker-275568554020211

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@@ -0,0 +1,6 @@
{
"pack": {
"pack_format": 9,
"description": "Makes the shooting star textures appear realistic"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB