Init Commit

This commit is contained in:
neroduckale 2024-06-23 02:46:03 +05:00
commit cc6313dfc0
41 changed files with 1865 additions and 0 deletions

9
.gitattributes vendored Normal file
View file

@ -0,0 +1,9 @@
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf
# These are Windows script files and should use crlf
*.bat text eol=crlf

40
.gitignore vendored Normal file
View file

@ -0,0 +1,40 @@
# gradle
.gradle/
build/
out/
classes/
# eclipse
*.launch
# idea
.idea/
*.iml
*.ipr
*.iws
# vscode
.settings/
.vscode/
bin/
.classpath
.project
# macos
*.DS_Store
# fabric
run/
# java
hs_err_*.log
replay_*.log
*.hprof
*.jfr

121
LICENSE Normal file
View file

@ -0,0 +1,121 @@
Creative Commons Legal Code
CC0 1.0 Universal
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.
For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:
i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.

76
build.gradle Normal file
View file

@ -0,0 +1,76 @@
plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'maven-publish'
}
version = project.mod_version
group = project.maven_group
base {
archivesName = project.archives_base_name
}
repositories {
// 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.
}
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}"
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
tasks.withType(JavaCompile).configureEach {
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()
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
jar {
from("LICENSE") {
rename { "${it}_${project.base.archivesName.get()}" }
}
}
// configure the maven publication
publishing {
publications {
create("mavenJava", MavenPublication) {
artifactId = project.archives_base_name
from components.java
}
}
// 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.
}
}

14
gradle.properties Normal file
View file

@ -0,0 +1,14 @@
# 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.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.14.25
# Mod Properties
mod_version=1.0.0
maven_group=ru.neroduckale
archives_base_name=untitled
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.91.0+1.20.1

249
gradlew vendored Normal file
View file

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

92
gradlew.bat vendored Normal file
View file

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

11
settings.gradle Normal file
View file

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

View file

@ -0,0 +1,23 @@
package ru.neroduckale;
import net.fabricmc.api.ModInitializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.neroduckale.register.*;
public class NeroduckaleVapes implements ModInitializer {
public static final Logger LOGGER = LoggerFactory.getLogger("nerovapes");
public static final String MOD_ID = "nerovapes";
@Override
public void onInitialize() {
RegisterGUI.registerGUIs();
RegisterItems.registerModItems();
RegisterItemGroup.registerItemGroups();
RegisterSounds.registerSounds();
RegisterParticles.registerParticles();
LOGGER.info("Hello Fabric world!");
}
}

View file

@ -0,0 +1,121 @@
package ru.neroduckale;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.particle.*;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import java.util.List;
import java.util.Random;
@Environment(EnvType.CLIENT)
public class Particles extends SpriteBillboardParticle {
private final SpriteProvider spriteProvider;
private static final double MAX_SQUARED_COLLISION_CHECK_DISTANCE = MathHelper.square((double)100.0);
private boolean stopped;
float randomX = -0.03f + random.nextFloat() * (0.03f - -0.03f);
float randomZ = -0.03f + random.nextFloat() * (0.03f - -0.03f);
protected Particles(ClientWorld clientWorld, double x, double y, double z, double velX, double velY, double velZ, SpriteProvider spriteProvider) {
super(clientWorld, x, y, z);
this.spriteProvider = spriteProvider; //Sets the sprite provider from above to the sprite provider in the constructor parameters
this.maxAge = 50; //50 ticks = 2.5 seconds
this.scale = 0.5f;
this.velocityX = velX; //The velX from the constructor parameters
this.velocityY = velY;
this.velocityZ = velZ;
this.x = x; //The x from the constructor parameters
this.y = y;
this.z = z;
this.collidesWithWorld = true;
this.alpha = 1.0f; //Setting the alpha to 1.0f means there will be no opacity change until the alpha value is changed
this.setSpriteForAge(spriteProvider); //Required
}
@Override
public ParticleTextureSheet getType() {
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
}
public void tick() {
this.prevPosX = this.x;
this.prevPosY = this.y;
this.prevPosZ = this.z;
if (this.age++ >= this.maxAge || this.scale <= 0 || this.alpha <= 0) { //Despawns the particle if the age has reached the max age, or if the scale is 0, or if the alpha is 0
this.markDead();
return;
}
this.move(this.velocityX, this.velocityY, this.velocityZ);
if (this.age >= (this.maxAge / 3)) {
this.alpha -= 0.02f;
this.velocityX = randomX;
this.velocityZ = randomZ;
this.velocityY += 0.005f;
}
if (this.age >= (this.maxAge / 3) * 2) {
this.scale -= 0.02f;
}
if (this.onGround) {
this.velocityZ = 0;
this.velocityX = 0;
this.velocityY = 0.1f;
}
}
@Override
public void move(double dx, double dy, double dz) {
if (this.stopped) {
return;
}
double d = dx;
double e = dy;
double f = dz;
if (this.collidesWithWorld && (dx != 0.0 || dy != 0.0 || dz != 0.0) && dx * dx + dy * dy + dz * dz < MAX_SQUARED_COLLISION_CHECK_DISTANCE) {
Vec3d vec3d = Entity.adjustMovementForCollisions(null, new Vec3d(dx, dy, dz), this.getBoundingBox(), this.world, List.of());
dx = vec3d.x;
dy = vec3d.y;
dz = vec3d.z;
}
if (dx != 0.0 || dy != 0.0 || dz != 0.0) {
this.setBoundingBox(this.getBoundingBox().offset(dx, dy, dz));
this.repositionFromBoundingBox();
}
if (Math.abs(e) >= (double)1.0E-5f && Math.abs(dy) < (double)1.0E-5f) {
this.stopped = true;
}
boolean bl = this.onGround = e != dy && e < 0.0;
if (d != dx) {
this.velocityX = 0.0;
this.velocityY = 0.1f;
this.velocityZ = 0.0;
}
if (f != dz) {
this.velocityY = 0.1f;
this.velocityZ = 0.0;
this.velocityX = 0.0;
}
}
@Environment(EnvType.CLIENT)
public static class Factory implements ParticleFactory<DefaultParticleType> {
//The factory used in a particle's registry
private final SpriteProvider spriteProvider;
public Factory(SpriteProvider spriteProvider) {
this.spriteProvider = spriteProvider;
}
public Particle createParticle(DefaultParticleType defaultParticleType, ClientWorld clientWorld, double x, double y, double z, double velX, double velY, double velZ) {
return new Particles(clientWorld, x, y, z, velX, velY, velZ, this.spriteProvider);
}
}
}

View file

@ -0,0 +1,122 @@
package ru.neroduckale;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.particle.*;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import java.util.List;
import java.util.Random;
@Environment(EnvType.CLIENT)
public class Particles2 extends SpriteBillboardParticle {
private final SpriteProvider spriteProvider;
private static final double MAX_SQUARED_COLLISION_CHECK_DISTANCE = MathHelper.square((double)100.0);
private boolean stopped;
float randomX = -0.03f + random.nextFloat() * (0.03f - -0.03f);
float randomZ = -0.03f + random.nextFloat() * (0.03f - -0.03f);
protected Particles2(ClientWorld clientWorld, double x, double y, double z, double velX, double velY, double velZ, SpriteProvider spriteProvider) {
super(clientWorld, x, y, z);
this.spriteProvider = spriteProvider; //Sets the sprite provider from above to the sprite provider in the constructor parameters
this.maxAge = 50; //50 ticks = 2.5 seconds
this.scale = 0.5f;
this.velocityX = velX; //The velX from the constructor parameters
this.velocityY = velY;
this.velocityZ = velZ;
this.x = x; //The x from the constructor parameters
this.y = y;
this.z = z;
this.collidesWithWorld = true;
this.alpha = 1f; //Setting the alpha to 1.0f means there will be no opacity change until the alpha value is changed
this.setSpriteForAge(spriteProvider); //Required
}
@Override
public ParticleTextureSheet getType() {
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
}
public void tick() {
this.prevPosX = this.x;
this.prevPosY = this.y;
this.prevPosZ = this.z;
if (this.age++ >= this.maxAge || this.scale <= 0 || this.alpha <= 0) { //Despawns the particle if the age has reached the max age, or if the scale is 0, or if the alpha is 0
this.markDead();
return;
}
this.move(this.velocityX, this.velocityY, this.velocityZ);
if (this.age >= (this.maxAge / 3)) {
this.alpha -= 0.02f;
this.velocityX = randomX;
this.velocityZ = randomZ;
this.velocityY += 0.005f;
}
if (this.age >= (this.maxAge / 3) * 2) {
this.scale -= 0.02f;
}
if (this.onGround) {
this.velocityZ = 0;
this.velocityX = 0;
this.velocityY = 0.1f;
}
}
@Override
public void move(double dx, double dy, double dz) {
if (this.stopped) {
return;
}
double d = dx;
double e = dy;
double f = dz;
if (this.collidesWithWorld && (dx != 0.0 || dy != 0.0 || dz != 0.0) && dx * dx + dy * dy + dz * dz < MAX_SQUARED_COLLISION_CHECK_DISTANCE) {
Vec3d vec3d = Entity.adjustMovementForCollisions(null, new Vec3d(dx, dy, dz), this.getBoundingBox(), this.world, List.of());
dx = vec3d.x;
dy = vec3d.y;
dz = vec3d.z;
}
if (dx != 0.0 || dy != 0.0 || dz != 0.0) {
this.setBoundingBox(this.getBoundingBox().offset(dx, dy, dz));
this.repositionFromBoundingBox();
}
if (Math.abs(e) >= (double)1.0E-5f && Math.abs(dy) < (double)1.0E-5f) {
this.stopped = true;
}
boolean bl = this.onGround = e != dy && e < 0.0;
if (d != dx) {
this.velocityX = 0.0;
this.velocityY = 0.1f;
this.velocityZ = 0.0;
}
if (f != dz) {
this.velocityY = 0.1f;
this.velocityZ = 0.0;
this.velocityX = 0.0;
}
}
@Environment(EnvType.CLIENT)
public static class Factory implements ParticleFactory<DefaultParticleType> {
//The factory used in a particle's registry
private final SpriteProvider spriteProvider;
public Factory(SpriteProvider spriteProvider) {
this.spriteProvider = spriteProvider;
}
public Particle createParticle(DefaultParticleType defaultParticleType, ClientWorld clientWorld, double x, double y, double z, double velX, double velY, double velZ) {
return new Particles2(clientWorld, x, y, z, velX, velY, velZ, this.spriteProvider);
}
}
}

View file

@ -0,0 +1,117 @@
package ru.neroduckale;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.particle.*;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import java.util.List;
import java.util.Random;
@Environment(EnvType.CLIENT)
public class RingParticle extends SpriteBillboardParticle {
private final SpriteProvider spriteProvider;
private static final double MAX_SQUARED_COLLISION_CHECK_DISTANCE = MathHelper.square((double)100.0);
private boolean stopped;
protected RingParticle(ClientWorld clientWorld, double x, double y, double z, double velX, double velY, double velZ, SpriteProvider spriteProvider) {
super(clientWorld, x, y, z);
this.spriteProvider = spriteProvider; //Sets the sprite provider from above to the sprite provider in the constructor parameters
this.maxAge = 50; //50 ticks = 2.5 seconds
this.scale = 0.5f;
this.velocityX = velX; //The velX from the constructor parameters
this.velocityY = velY;
this.velocityZ = velZ;
this.x = x; //The x from the constructor parameters
this.y = y;
this.z = z;
this.collidesWithWorld = true;
this.alpha = 1.0f; //Setting the alpha to 1.0f means there will be no opacity change until the alpha value is changed
this.setSpriteForAge(spriteProvider); //Required
}
@Override
public ParticleTextureSheet getType() {
return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT;
}
public void tick() {
this.prevPosX = this.x;
this.prevPosY = this.y;
this.prevPosZ = this.z;
if (this.age++ >= this.maxAge || this.scale <= 0 || this.alpha <= 0) { //Despawns the particle if the age has reached the max age, or if the scale is 0, or if the alpha is 0
this.markDead();
return;
}
this.move(this.velocityX, this.velocityY, this.velocityZ);
if (this.age >= (this.maxAge / 3)) {
this.alpha -= 0.02f;
this.velocityY += 0.005f;
}
if (this.age >= (this.maxAge / 3) * 2) {
this.scale += 0.04f;
}
if (this.onGround) {
this.velocityZ = 0;
this.velocityX = 0;
this.velocityY = 0.1f;
}
}
@Override
public void move(double dx, double dy, double dz) {
if (this.stopped) {
return;
}
double d = dx;
double e = dy;
double f = dz;
if (this.collidesWithWorld && (dx != 0.0 || dy != 0.0 || dz != 0.0) && dx * dx + dy * dy + dz * dz < MAX_SQUARED_COLLISION_CHECK_DISTANCE) {
Vec3d vec3d = Entity.adjustMovementForCollisions(null, new Vec3d(dx, dy, dz), this.getBoundingBox(), this.world, List.of());
dx = vec3d.x;
dy = vec3d.y;
dz = vec3d.z;
}
if (dx != 0.0 || dy != 0.0 || dz != 0.0) {
this.setBoundingBox(this.getBoundingBox().offset(dx, dy, dz));
this.repositionFromBoundingBox();
}
if (Math.abs(e) >= (double)1.0E-5f && Math.abs(dy) < (double)1.0E-5f) {
this.stopped = true;
}
boolean bl = this.onGround = e != dy && e < 0.0;
if (d != dx) {
this.velocityX = 0.0;
this.velocityY = 0.1f;
this.velocityZ = 0.0;
}
if (f != dz) {
this.velocityY = 0.1f;
this.velocityZ = 0.0;
this.velocityX = 0.0;
}
}
@Environment(EnvType.CLIENT)
public static class Factory implements ParticleFactory<DefaultParticleType> {
//The factory used in a particle's registry
private final SpriteProvider spriteProvider;
public Factory(SpriteProvider spriteProvider) {
this.spriteProvider = spriteProvider;
}
public Particle createParticle(DefaultParticleType defaultParticleType, ClientWorld clientWorld, double x, double y, double z, double velX, double velY, double velZ) {
return new RingParticle(clientWorld, x, y, z, velX, velY, velZ, this.spriteProvider);
}
}
}

View file

@ -0,0 +1,45 @@
package ru.neroduckale.fluids;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.Text;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class ExampleFluid extends Item {
public String jija;
public ExampleFluid(Settings settings, String jija) {
super(settings.maxDamage(300));
this.jija = jija;
}
@Override
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
if (!stack.getNbt().contains("amountjija")) {
var nbt = new NbtCompound();
nbt.putInt("amountjija", 300);
stack.setNbt(nbt);
stack.setDamage(300);
}
stack.setDamage(stack.getMaxDamage() - stack.getNbt().getInt("amountjija"));
}
@Override
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) {
tooltip.add(Text.of(this.jija));
tooltip.add(Text.of("Жижи осталось: %s мл".formatted(((float) stack.getNbt().getInt("amountjija") / 10))));
}
}

View file

@ -0,0 +1,79 @@
package ru.neroduckale.gui;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import ru.neroduckale.util.MouseUtil;
public class prikolscreen extends HandledScreen<prikolscreenhandler> {
//A path to the gui texture. In this example we use the texture from the dispenser
private static final Identifier TEXTURE = new Identifier("nerovapes", "textures/gui/vapeui.png");
public prikolscreen(prikolscreenhandler handler, PlayerInventory inventory, Text title) {
super(handler, inventory, title);
}
@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
renderBackground(context);
super.render(context, mouseX, mouseY, delta);
drawMouseoverTooltip(context, mouseX, mouseY);
}
@Override
protected void init() {
super.init();
// Center the title
titleX = (backgroundWidth - textRenderer.getWidth(title)) / 2;
}
@Override
protected void drawBackground(DrawContext context, float delta, int mouseX, int mouseY) {
RenderSystem.setShader(GameRenderer::getPositionTexProgram);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderTexture(0, TEXTURE);
int x = (width - backgroundWidth) / 2;
int y = (height - backgroundHeight) / 2;
context.drawTexture(TEXTURE, x, y, 0, 0, backgroundWidth, backgroundHeight);
//in 1.20 or above,this method is in DrawContext class.
drawFluidAmount(context);
}
@Override
public void drawForeground(DrawContext context, int mouseX, int mouseY) {
int x = (width - backgroundWidth) / 2;
int y = (height - backgroundHeight) / 2;
renderEnergyAreaTooltips(context, mouseX, mouseY, x, y);
}
private void renderEnergyAreaTooltips(DrawContext context, int pMouseX, int pMouseY, int x, int y) {
if(isMouseAboveArea(pMouseX, pMouseY, x, y, 41, 7, 10, 63)) {
context.drawTooltip(textRenderer, getTooltips(), pMouseX - x, pMouseY - y);
}
}
private void drawFluidAmount(DrawContext context) {
int x1 = x + 41; //Начало строки на интерфейсе (Ширина)
int y1 = y + 7 + 63 - handler.getHeight(); //Начало строки на интерфейсе (Длина)
int u = 190; //Начало полоски жижи вне интерфейса
int v = 1 + 63 - handler.getHeight(); //Начало полоски жижи вне интерфейса
int width = 11;//Ширина полоски вне интерфейса и в интерфейсе
int height = handler.getHeight();//Длина полоски вне интерфейса и в интерфейсе, при половине 31
context.drawTexture(TEXTURE, x1, y1, u, v, width, height);
}
public Text getTooltips() {
String a = "Жижи осталось: %s мл".formatted(((float) handler.getAmount()) / 10);
return Text.of(a);
}
private boolean isMouseAboveArea(int pMouseX, int pMouseY, int x, int y, int offsetX, int offsetY, int width, int height) {
return MouseUtil.isMouseOver(pMouseX, pMouseY, x + offsetX, y + offsetY, width, height);
}
}

View file

@ -0,0 +1,84 @@
package ru.neroduckale.gui;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.SimpleInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.slot.Slot;
import net.minecraft.util.Hand;
import ru.neroduckale.NeroduckaleVapes;
import ru.neroduckale.register.RegisterGUI;
import ru.neroduckale.vapes.Vape;
public class prikolscreenhandler extends ScreenHandler {
private Inventory inventory;
public ItemStack vape;
public int amountjija;
//This constructor gets called from the BlockEntity on the server without calling the other constructor first, the server knows the inventory of the container
//and can therefore directly provide it as an argument. This inventory will then be synced to the client.
public prikolscreenhandler(int syncId, PlayerInventory playerInventory, Inventory inventory) {
super(RegisterGUI.PRIKOL_SCREEN_HANDLER, syncId);
checkSize(inventory, 2);
this.inventory = inventory;
this.vape = playerInventory.player.getStackInHand(Hand.MAIN_HAND);
this.amountjija = vape.getNbt().getInt("amountjija");
//some inventories do custom logic when a player opens it.
inventory.onOpen(playerInventory.player);
//This will place the slot in the correct locations for a 3x3 Grid. The slots exist on both server and client!
//This will not render the background of the slots however, this is the Screens job
int m;
int l;
//Our inventory
this.addSlot(new Slot(inventory, 0, 16, 32));
this.addSlot(new Slot(inventory, 1, 131, 11));
//The player inventory
for (m = 0; m < 3; ++m) {
for (l = 0; l < 9; ++l) {
this.addSlot(new Slot(playerInventory, l + m * 9 + 9, 8 + l * 18, 84 + m * 18));
}
}
//The player Hotbar
for (m = 0; m < 9; ++m) {
this.addSlot(new Slot(playerInventory, m, 8 + m * 18, 142));
}
}
public prikolscreenhandler(int i, PlayerInventory playerInventory) {
this(i, playerInventory, new SimpleInventory(2));
}
@Override
public ItemStack quickMove(PlayerEntity player, int slot) {
return player.getInventory().getStack(slot);
}
@Override
public boolean canUse(PlayerEntity player) {
return true;
}
public int getHeight() {
int progressArrowSize = 63; // This is the width in pixels of your arrow
if (amountjija != 0 && this.vape.getItem() instanceof Vape pasito) {
return amountjija * progressArrowSize / pasito.mlbak;
}
return 0;
}
public int getAmount() {
return this.amountjija;
}
@Override
public void onClosed(PlayerEntity player) {
super.onClosed(player);
this.dropInventory(player, this.inventory);
}
}

View file

@ -0,0 +1,18 @@
package ru.neroduckale;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.minecraft.client.gui.screen.ingame.HandledScreens;
import ru.neroduckale.register.RegisterGUI;
import ru.neroduckale.gui.prikolscreen;
import ru.neroduckale.register.RegisterParticles;
public class neroduckalevapesclient implements ClientModInitializer {
@Override
public void onInitializeClient() {
HandledScreens.register(RegisterGUI.PRIKOL_SCREEN_HANDLER, prikolscreen::new);
ParticleFactoryRegistry.getInstance().register(RegisterParticles.MY_CLOUD, Particles.Factory::new);
ParticleFactoryRegistry.getInstance().register(RegisterParticles.MY_CLOUD1, Particles2.Factory::new);
ParticleFactoryRegistry.getInstance().register(RegisterParticles.RING_PARTICLE, RingParticle.Factory::new);
}
}

View file

@ -0,0 +1,21 @@
package ru.neroduckale.register;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.resource.featuretoggle.FeatureFlags;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.util.Identifier;
import ru.neroduckale.NeroduckaleVapes;
import ru.neroduckale.gui.prikolscreenhandler;
public class RegisterGUI {
public static ScreenHandlerType<prikolscreenhandler> PRIKOL_SCREEN_HANDLER = new ScreenHandlerType<>(prikolscreenhandler::new, FeatureFlags.VANILLA_FEATURES);
public static void registerGUIs() {
NeroduckaleVapes.LOGGER.info("Registering GUI for mod %s".formatted(NeroduckaleVapes.MOD_ID));
PRIKOL_SCREEN_HANDLER = Registry.register(Registries.SCREEN_HANDLER, new Identifier(NeroduckaleVapes.MOD_ID), PRIKOL_SCREEN_HANDLER);
}
}

View file

@ -0,0 +1,27 @@
package ru.neroduckale.register;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import ru.neroduckale.NeroduckaleVapes;
public class RegisterItemGroup {
public static ItemGroup NeroVapeGroup = Registry.register(Registries.ITEM_GROUP, new Identifier(NeroduckaleVapes.MOD_ID, "nerovapesgroup"),
FabricItemGroup.builder()
.displayName(Text.of("VapeMod"))
.icon(() -> new ItemStack(RegisterItems.pasito2))
.entries((displayContext, entries) -> {
entries.add(RegisterItems.pasito2);
entries.add(RegisterItems.ExpampleFluid);
})
.build());
public static void registerItemGroups() {
NeroduckaleVapes.LOGGER.info("Registering Item Groups for %s".formatted(NeroduckaleVapes.MOD_ID));
}
}

View file

@ -0,0 +1,35 @@
package ru.neroduckale.register;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.minecraft.item.Item;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
import ru.neroduckale.NeroduckaleVapes;
import ru.neroduckale.fluids.ExampleFluid;
import ru.neroduckale.vapes.Vape;
import static ru.neroduckale.NeroduckaleVapes.MOD_ID;
public class RegisterItems {
public static final Item pasito2 = registerItem("pasito2", new Vape(new FabricItemSettings(), 60, 1));
public static final Item ExpampleFluid = registerItem("fluid", new ExampleFluid(new FabricItemSettings(), "SKALA - Кактус со льдом"));
/**
*
* НЕ ЗАБУДЬ ДОБАВИТЬ В ItemGroup.{@link RegisterItemGroup}
*/
private static Item registerItem(String name, Item item) {
return Registry.register(Registries.ITEM, new Identifier(MOD_ID, name), item);
}
public static void registerModItems() {
NeroduckaleVapes.LOGGER.info("Registering Mod Items for " + MOD_ID);
}
}

View file

@ -0,0 +1,24 @@
package ru.neroduckale.register;
import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;
import ru.neroduckale.NeroduckaleVapes;
import static ru.neroduckale.NeroduckaleVapes.MOD_ID;
public class RegisterParticles {
public static final DefaultParticleType MY_CLOUD = FabricParticleTypes.simple();
public static final DefaultParticleType MY_CLOUD1 = FabricParticleTypes.simple();
public static final DefaultParticleType RING_PARTICLE = FabricParticleTypes.simple();
public static void registerParticles() {
Registry.register(Registries.PARTICLE_TYPE, new Identifier(MOD_ID, "cloud"), MY_CLOUD);
Registry.register(Registries.PARTICLE_TYPE, new Identifier(MOD_ID, "cloud1"), MY_CLOUD1);
Registry.register(Registries.PARTICLE_TYPE, new Identifier(MOD_ID, "ringparticle"), RING_PARTICLE);
NeroduckaleVapes.LOGGER.info("Registering Particles for nerovapes");
}
}

View file

@ -0,0 +1,31 @@
package ru.neroduckale.register;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.sound.SoundEvent;
import net.minecraft.util.Identifier;
import ru.neroduckale.NeroduckaleVapes;
public class RegisterSounds {
private RegisterSounds() {
// private empty constructor to avoid accidental instantiation
}
// ITEM_METAL_WHISTLE is the name of the custom sound event
// and is called in the mod to use the custom sound
public static final SoundEvent VAPE = registerSound("vape");
// actual registration of all the custom SoundEvents
private static SoundEvent registerSound(String id) {
SoundEvent sound = SoundEvent.of(new Identifier(NeroduckaleVapes.MOD_ID, id));
return Registry.register(Registries.SOUND_EVENT, new Identifier(NeroduckaleVapes.MOD_ID, id), sound);
}
// This static method starts class initialization, which then initializes
// the static class variables (e.g. ITEM_METAL_WHISTLE).
public static void registerSounds() {
NeroduckaleVapes.LOGGER.info("Registering " + NeroduckaleVapes.MOD_ID + " Sounds");
// Technically this method can stay empty, but some developers like to notify
// the console, that certain parts of the mod have been successfully initialized
}
}

View file

@ -0,0 +1,132 @@
package ru.neroduckale.util;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventories;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.collection.DefaultedList;
/**
* A simple {@code Inventory} implementation with only default methods + an item list getter.
*
* Originally by Juuz
*/
public interface ImplementedInventory extends Inventory {
/**
* Retrieves the item list of this inventory.
* Must return the same instance every time it's called.
*/
DefaultedList<ItemStack> getItems();
/**
* Creates an inventory from the item list.
*/
static ImplementedInventory of(DefaultedList<ItemStack> items) {
return () -> items;
}
/**
* Creates a new inventory with the specified size.
*/
static ImplementedInventory ofSize(int size) {
return of(DefaultedList.ofSize(size, ItemStack.EMPTY));
}
/**
* Returns the inventory size.
*/
@Override
default int size() {
return getItems().size();
}
/**
* Checks if the inventory is empty.
* @return true if this inventory has only empty stacks, false otherwise.
*/
@Override
default boolean isEmpty() {
for (int i = 0; i < size(); i++) {
ItemStack stack = getStack(i);
if (!stack.isEmpty()) {
return false;
}
}
return true;
}
/**
* Retrieves the item in the slot.
*/
@Override
default ItemStack getStack(int slot) {
return getItems().get(slot);
}
/**
* Removes items from an inventory slot.
* @param slot The slot to remove from.
* @param count How many items to remove. If there are less items in the slot than what are requested,
* takes all items in that slot.
*/
@Override
default ItemStack removeStack(int slot, int count) {
ItemStack result = Inventories.splitStack(getItems(), slot, count);
if (!result.isEmpty()) {
markDirty();
}
return result;
}
/**
* Removes all items from an inventory slot.
* @param slot The slot to remove from.
*/
@Override
default ItemStack removeStack(int slot) {
return Inventories.removeStack(getItems(), slot);
}
/**
* Replaces the current stack in an inventory slot with the provided stack.
* @param slot The inventory slot of which to replace the itemstack.
* @param stack The replacing itemstack. If the stack is too big for
* this inventory ({@link Inventory#getMaxCountPerStack()}),
* it gets resized to this inventory's maximum amount.
*/
@Override
default void setStack(int slot, ItemStack stack) {
getItems().set(slot, stack);
if (stack.getCount() > stack.getMaxCount()) {
stack.setCount(stack.getMaxCount());
}
}
/**
* Clears the inventory.
*/
@Override
default void clear() {
getItems().clear();
}
/**
* Marks the state as dirty.
* Must be called after changes in the inventory, so that the game can properly save
* the inventory contents and notify neighboring blocks of inventory changes.
*/
@Override
default void markDirty() {
// Override if you want behavior.
}
/**
* @return true if the player can use the inventory, false otherwise.
*/
@Override
default boolean canPlayerUse(PlayerEntity player) {
return true;
}
}

View file

@ -0,0 +1,14 @@
package ru.neroduckale.util;
public class MouseUtil {
public static boolean isMouseOver(double mouseX, double mouseY, int x, int y) {
return isMouseOver(mouseX, mouseY, x, y, 16);
}
public static boolean isMouseOver(double mouseX, double mouseY, int x, int y, int size) {
return isMouseOver(mouseX, mouseY, x, y, size, size);
}
public static boolean isMouseOver(double mouseX, double mouseY, int x, int y, int sizeX, int sizeY) {
return (mouseX >= x && mouseX <= x + sizeX) && (mouseY >= y && mouseY <= y + sizeY);
}
}

View file

@ -0,0 +1,158 @@
package ru.neroduckale.vapes;
import com.mojang.authlib.yggdrasil.response.User;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.screen.NamedScreenHandlerFactory;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Text;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.UseAction;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import ru.neroduckale.NeroduckaleVapes;
import ru.neroduckale.register.RegisterParticles;
import ru.neroduckale.util.ImplementedInventory;
import ru.neroduckale.fluids.ExampleFluid;
import ru.neroduckale.gui.prikolscreenhandler;
import ru.neroduckale.register.RegisterSounds;
public class Vape extends Item implements NamedScreenHandlerFactory, ImplementedInventory {
public int mlbak;
public int rasxod;
private final DefaultedList<ItemStack> inventory = DefaultedList.ofSize(2, ItemStack.EMPTY);
public Vape(Settings settings, int mlbak, int rasxod) {
super(settings.maxCount(1));
this.rasxod = rasxod;
this.mlbak = mlbak;
}
//
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
if (!world.isClient()) {
if (user.isInSneakingPose()) {
user.openHandledScreen(this);
return TypedActionResult.pass(user.getStackInHand(hand));
}
var stack = user.getStackInHand(hand);
if (stack.getNbt().getInt("amountjija") <= 0) {
user.sendMessage(Text.of("Жижи нет"), true);
return TypedActionResult.fail(user.getStackInHand(hand));
}
NbtCompound nbt = new NbtCompound();
nbt.putInt("amountjija", stack.getNbt().getInt("amountjija") - rasxod);
stack.setNbt(nbt);
user.setCurrentHand(hand);
} else {
var stack = user.getStackInHand(hand);
if (stack.getNbt().getInt("amountjija") <= 0) {
user.sendMessage(Text.of("Жижи нет"), true);
return TypedActionResult.fail(user.getStackInHand(hand));
}
if (user.isInSneakingPose()) {
return TypedActionResult.success(user.getStackInHand(hand));
}
user.setCurrentHand(hand);
}
user.playSound(RegisterSounds.VAPE, 2f, 1f);
return TypedActionResult.pass(user.getStackInHand(hand));
}
public static void spawnParticles(World world, PlayerEntity user, Vec3d vec3d, int count) {
var sw = (ServerWorld) world;
sw.spawnParticles(RegisterParticles.MY_CLOUD, user.getX(), user.getEyeY(), user.getZ(), 0, vec3d.getX(), vec3d.getY(), vec3d.getZ(), 0.1f);
sw.spawnParticles(RegisterParticles.RING_PARTICLE, user.getX(), user.getEyeY(), user.getZ(), 0, vec3d.getX(), vec3d.getY(), vec3d.getZ(), 0.1f);
for (int i = 0; i < count; i++) {
sw.spawnParticles(RegisterParticles.MY_CLOUD1, user.getX(), user.getEyeY(), user.getZ(), 0, vec3d.getX(), vec3d.getY(), vec3d.getZ(), 0.1f);
}
}
@Override
public Text getDisplayName() {
return Text.literal("VAPE UI");
}
@Nullable
@Override
public ScreenHandler createMenu(int syncId, PlayerInventory playerInventory, PlayerEntity player) {
return new prikolscreenhandler(syncId, playerInventory, this);
}
@Override
public DefaultedList<ItemStack> getItems() {
return inventory;
}
@Override
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
if (!world.isClient()) {
if (!stack.hasNbt()) {
NbtCompound nbtCompound = new NbtCompound();
nbtCompound.putInt("amountjija", mlbak);
stack.setNbt(nbtCompound);
}
if (inventory.get(0) != ItemStack.EMPTY && inventory.get(0).getItem() instanceof ExampleFluid && entity instanceof PlayerEntity user) {
if (stack.getNbt().getInt("amountjija") != mlbak) { //Если бак в вейпе не полный
var fluiditemamount = getAmount(inventory.get(0));
var vapefluidamount = getAmount(stack);
var amountskokzalit = mlbak - vapefluidamount;
if (fluiditemamount >= amountskokzalit) {
inventory.get(0).getNbt().putInt("amountjija", fluiditemamount - amountskokzalit);
stack.getNbt().putInt("amountjija", vapefluidamount + amountskokzalit);
inventory.get(0).setDamage(inventory.get(0).getMaxDamage() - getAmount(inventory.get(0)));
} else if (fluiditemamount < amountskokzalit && fluiditemamount != 0) {
stack.getNbt().putInt("amountjija", vapefluidamount + fluiditemamount);
inventory.get(0).getNbt().putInt("amountjija", 0);
inventory.get(0).setDamage(inventory.get(0).getMaxDamage() - getAmount(inventory.get(0)));
}
}
}
} else {
if (entity instanceof PlayerEntity user && user.currentScreenHandler instanceof prikolscreenhandler p) {
p.amountjija = getAmount(stack);
}
}
}
public int getAmount(ItemStack stack) {
return stack.getNbt().getInt("amountjija");
}
@Override
public void usageTick(World world, LivingEntity user, ItemStack stack, int remainingUseTicks) {
}
@Override
public int getMaxUseTime(ItemStack stack) {
return 72000;
}
@Override
public void onStoppedUsing(ItemStack stack, World world, LivingEntity entity, int remainingUseTicks) {
PlayerEntity user = (PlayerEntity) entity;
if (!world.isClient()) {
user.getItemCooldownManager().set(this, 20);
Vec3d vec3d = Vec3d.fromPolar(user.getPitch(), user.getYaw());
vec3d.multiply(0.05f);
float intp = getMaxUseTime(stack) - remainingUseTicks;
float pizdec = intp / 20;
spawnParticles(world, user, vec3d, Math.round(pizdec));
NeroduckaleVapes.LOGGER.error(String.valueOf(pizdec));
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View file

@ -0,0 +1,5 @@
{
"item.nerovapes.pasito2": "Пасито 2",
"item.nerovapes.fluid": "Жижка",
"sound.nerovapes.vape": "Кто то попарил."
}

View file

@ -0,0 +1,22 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "nerovapes:item/fluid"
},
"display": {
"firstperson_righthand": {
"rotation": [0, -32, 0],
"translation": [0, 6.25, 2],
"scale": [0.5, 0.5, 0.5]
},
"firstperson_lefthand": {
"rotation": [0, -54, 0],
"translation": [2.5, 5, 0],
"scale": [0.5, 0.5, 1]
},
"ground": {
"translation": [0, 4, 0],
"scale": [1, 1, 1]
}
}
}

View file

@ -0,0 +1,100 @@
{
"credit": "Made with Blockbench",
"textures": {
"0": "nerovapes:item/pasito2",
"1": "nerovapes:item/texture",
"particle": "nerovapes:item/pasito2"
},
"elements": [
{
"from": [6, 0, 5],
"to": [10, 15, 12],
"faces": {
"north": {"uv": [6.69886, 0.07955, 9.15341, 16], "texture": "#0"},
"east": {"uv": [0, 2.31818, 4.58523, 16], "texture": "#0"},
"south": {"uv": [12.40341, 0.1875, 15.71023, 16], "texture": "#0"},
"west": {"uv": [0, 2.38068, 4.58523, 16], "texture": "#0"},
"up": {"uv": [4.25, 0.25, 4.75, 0.75], "rotation": 270, "texture": "#1"},
"down": {"uv": [3.25, 0.25, 3.75, 0.75], "rotation": 90, "texture": "#missing"}
}
},
{
"from": [7, 16, 7],
"to": [9, 19, 9],
"faces": {
"north": {"uv": [1.16477, 0.05682, 2.57386, 1.73864], "texture": "#0"},
"east": {"uv": [1.16477, 0.05682, 2.57386, 1.73864], "texture": "#0"},
"south": {"uv": [1.16477, 0.05682, 2.57386, 1.73864], "texture": "#0"},
"west": {"uv": [1.16477, 0.05682, 2.57386, 1.73864], "texture": "#0"},
"up": {"uv": [4.25, 0.25, 4.75, 0.75], "rotation": 270, "texture": "#1"},
"down": {"uv": [5.25, 0.25, 5.75, 0.75], "rotation": 90, "texture": "#1"}
}
},
{
"from": [6, 15, 6],
"to": [10, 16, 10],
"faces": {
"north": {"uv": [0.88068, 1.875, 2.78977, 2.26136], "texture": "#0"},
"east": {"uv": [0.88068, 1.875, 2.78977, 2.26136], "texture": "#0"},
"south": {"uv": [0.88068, 1.875, 2.78977, 2.26136], "texture": "#0"},
"west": {"uv": [0.88068, 1.875, 2.78977, 2.26136], "texture": "#0"},
"up": {"uv": [0, 0, 3, 0.75], "rotation": 270, "texture": "#1"},
"down": {"uv": [0, 0, 4, 4], "rotation": 90, "texture": "#missing"}
}
},
{
"from": [7, 9, 12],
"to": [9, 11, 12.3],
"faces": {
"north": {"uv": [3.5625, 2.625, 4.1875, 3], "texture": "#0"},
"east": {"uv": [3.5625, 2.625, 4.1875, 3], "texture": "#0"},
"south": {"uv": [13.125, 4.5, 15, 6.1875], "texture": "#0"},
"west": {"uv": [3.5625, 2.625, 4.1875, 3], "texture": "#0"},
"up": {"uv": [3.5625, 2.625, 4.1875, 3], "texture": "#0"},
"down": {"uv": [3.5625, 2.625, 4.1875, 3], "texture": "#0"}
}
},
{
"from": [6.5, 1.5, 12],
"to": [9.5, 2.5, 12.3],
"faces": {
"north": {"uv": [0, 0, 3, 1], "texture": "#1"},
"east": {"uv": [0, 0, 0.3, 1], "texture": "#1"},
"south": {"uv": [12.875, 13.25, 15.3125, 14.5625], "texture": "#0"},
"west": {"uv": [0, 0, 0.3, 1], "texture": "#1"},
"up": {"uv": [0, 0, 3, 0.3], "texture": "#1"},
"down": {"uv": [0, 0, 3, 0.3], "texture": "#1"}
}
}
],
"display": {
"thirdperson_righthand": {
"translation": [0, 2.75, 1.25],
"scale": [0.5, 0.5, 0.5]
},
"thirdperson_lefthand": {
"translation": [0, 2.75, 2.25],
"scale": [0.5, 0.5, 0.5]
},
"firstperson_righthand": {
"translation": [0.75, 5.25, 0],
"scale": [0.7, 0.7, 0.7]
},
"firstperson_lefthand": {
"translation": [0.25, 5.5, 0],
"scale": [0.7, 0.7, 0.7]
},
"ground": {
"translation": [0, 2.75, 0],
"scale": [0.7, 0.7, 0.7]
},
"gui": {
"rotation": [0, 32.75, 0],
"translation": [-1, -1.25, 0],
"scale": [0.9, 0.84, 3.05625]
},
"fixed": {
"rotation": [0, -90, 0]
}
}
}

View file

@ -0,0 +1,12 @@
{
"textures": [
"minecraft:generic_7",
"minecraft:generic_6",
"minecraft:generic_5",
"minecraft:generic_4",
"minecraft:generic_3",
"minecraft:generic_2",
"minecraft:generic_1",
"minecraft:generic_0"
]
}

View file

@ -0,0 +1,12 @@
{
"textures": [
"minecraft:generic_7",
"minecraft:generic_6",
"minecraft:generic_5",
"minecraft:generic_4",
"minecraft:generic_3",
"minecraft:generic_2",
"minecraft:generic_1",
"minecraft:generic_0"
]
}

View file

@ -0,0 +1,5 @@
{
"textures": [
"nerovapes:ringparticle"
]
}

View file

@ -0,0 +1,8 @@
{
"vape": {
"subtitle": "sound.nerovapes.vape",
"sounds": [
"nerovapes:vape"
]
}
}

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 362 B

View file

@ -0,0 +1,30 @@
{
"schemaVersion": 1,
"id": "nerovapes",
"version": "${version}",
"name": "neroduckale vapes",
"description": "Мод добавляет вейпы",
"authors": [
"neroduckale"
],
"contact": {
"homepage": "https://neroduck.ru/",
"sources": "https://github.com/neroduckale"
},
"license": "ARR",
"icon": "assets/nerovapes/icon.png",
"environment": "*",
"entrypoints": {
"main": [
"ru.neroduckale.NeroduckaleVapes"
],
"client": [
"ru.neroduckale.neroduckalevapesclient"
]
},
"depends": {
"fabricloader": ">=0.14.25",
"fabric": "*",
"minecraft": "1.20.1"
}
}

View file

@ -0,0 +1,8 @@
{
"required": true,
"package": "ru.neroduckale.mixin",
"compatibilityLevel": "JAVA_17",
"injectors": {
"defaultRequire": 1
}
}