Compare commits

...

No commits in common. "1.20.4" and "master" have entirely different histories.

134 changed files with 3363 additions and 4880 deletions

5
.gitattributes vendored
View File

@ -1,5 +0,0 @@
# Disable autocrlf on generated files, they always generate with LF
# Add any extra files or paths here to make git stop saying they
# are changed when only line endings change.
src/generated/**/.cache/cache text eol=lf
src/generated/**/*.json text eol=lf

2
.gitignore vendored
View File

@ -16,6 +16,7 @@ out
# gradle
build
.gradle
gradle*
# other
eclipse
@ -23,3 +24,4 @@ run
# Files from Forge MDK
forge*changelog.txt

View File

@ -1,65 +0,0 @@
Minecraft Forge: Credits/Thank You
Forge is a set of tools and modifications to the Minecraft base game code to assist
mod developers in creating new and exciting content. It has been in development for
several years now, but I would like to take this time thank a few people who have
helped it along it's way.
First, the people who originally created the Forge projects way back in Minecraft
alpha. Eloraam of RedPower, and SpaceToad of Buildcraft, without their acceptiance
of me taking over the project, who knows what Minecraft modding would be today.
Secondly, someone who has worked with me, and developed some of the core features
that allow modding to be as functional, and as simple as it is, cpw. For developing
FML, which stabelized the client and server modding ecosystem. As well as the base
loading system that allows us to modify Minecraft's code as elegently as possible.
Mezz, who has stepped up as the issue and pull request manager. Helping to keep me
sane as well as guiding the community into creating better additions to Forge.
Searge, Bspks, Fesh0r, ProfMobious, and all the rest over on the MCP team {of which
I am a part}. For creating some of the core tools needed to make Minecraft modding
both possible, and as stable as can be.
On that note, here is some specific information of the MCP data we use:
* Minecraft Coder Pack (MCP) *
Forge Mod Loader and Minecraft Forge have permission to distribute and automatically
download components of MCP and distribute MCP data files. This permission is not
transitive and others wishing to redistribute the Minecraft Forge source independently
should seek permission of MCP or remove the MCP data files and request their users
to download MCP separately.
And lastly, the countless community members who have spent time submitting bug reports,
pull requests, and just helping out the community in general. Thank you.
--LexManos
=========================================================================
This is Forge Mod Loader.
You can find the source code at all times at https://github.com/MinecraftForge/MinecraftForge/tree/1.12.x/src/main/java/net/minecraftforge/fml
This minecraft mod is a clean open source implementation of a mod loader for minecraft servers
and minecraft clients.
The code is authored by cpw.
It began by partially implementing an API defined by the client side ModLoader, authored by Risugami.
http://www.minecraftforum.net/topic/75440-
This support has been dropped as of Minecraft release 1.7, as Risugami no longer maintains ModLoader.
It also contains suggestions and hints and generous helpings of code from LexManos, author of MinecraftForge.
http://www.minecraftforge.net/
Additionally, it contains an implementation of topological sort based on that
published at http://keithschwarz.com/interesting/code/?dir=topological-sort
It also contains code from the Maven project for performing versioned dependency
resolution. http://maven.apache.org/
It also contains a partial repackaging of the javaxdelta library from http://sourceforge.net/projects/javaxdelta/
with credit to it's authors.
Forge Mod Loader downloads components from the Minecraft Coder Pack
(http://mcp.ocean-labs.de/index.php/Main_Page) with kind permission from the MCP team.

View File

@ -1,523 +0,0 @@
Unless noted below, Minecraft Forge, Forge Mod Loader, and all
parts herein are licensed under the terms of the LGPL 2.1 found
here http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt and
copied below.
Homepage: http://minecraftforge.net/
https://github.com/MinecraftForge/MinecraftForge
A note on authorship:
All source artifacts are property of their original author, with
the exclusion of the contents of the patches directory and others
copied from it from time to time. Authorship of the contents of
the patches directory is retained by the Minecraft Forge project.
This is because the patches are partially machine generated
artifacts, and are changed heavily due to the way forge works.
Individual attribution within them is impossible.
Consent:
All contributions to Forge must consent to the release of any
patch content to the Forge project.
A note on infectivity:
The LGPL is chosen specifically so that projects may depend on Forge
features without being infected with its license. That is the
purpose of the LGPL. Mods and others using this code via ordinary
Java mechanics for referencing libraries are specifically not bound
by Forge's license for the Mod code.
=== MCP Data ===
This software includes data from the Minecraft Coder Pack (MCP), with kind permission
from them. The license to MCP data is not transitive - distribution of this data by
third parties requires independent licensing from the MCP team. This data is not
redistributable without permission from the MCP team.
=== Sharing ===
I grant permission for some parts of FML to be redistributed outside the terms of the LGPL, for the benefit of
the minecraft modding community. All contributions to these parts should be licensed under the same additional grant.
-- Runtime patcher --
License is granted to redistribute the runtime patcher code (src/main/java/net/minecraftforge/fml/common/patcher
and subdirectories) under any alternative open source license as classified by the OSI (http://opensource.org/licenses)
-- ASM transformers --
License is granted to redistribute the ASM transformer code (src/main/java/net/minecraftforge/common/asm/ and subdirectories)
under any alternative open source license as classified by the OSI (http://opensource.org/licenses)
=========================================================================
This software includes portions from the Apache Maven project at
http://maven.apache.org/ specifically the ComparableVersion.java code. It is
included based on guidelines at
http://www.softwarefreedom.org/resources/2007/gpl-non-gpl-collaboration.html
with notices intact. The only change is a non-functional change of package name.
This software contains a partial repackaging of javaxdelta, a BSD licensed program for generating
binary differences and applying them, sourced from the subversion at http://sourceforge.net/projects/javaxdelta/
authored by genman, heikok, pivot.
The only changes are to replace some Trove collection types with standard Java collections, and repackaged.
This software includes the Monocraft font from https://github.com/IdreesInc/Monocraft/ for use in the early loading
display.
=========================================================================
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS

View File

@ -1,46 +0,0 @@
Source installation information for modders
-------------------------------------------
This code follows the Minecraft Forge installation methodology. It will apply
some small patches to the vanilla MCP source code, giving you and it access
to some of the data and functions you need to build a successful mod.
Note also that the patches are built against "un-renamed" MCP source code (aka
SRG Names) - this means that you will not be able to read them directly against
normal code.
Setup Process:
==============================
Step 1: Open your command-line and browse to the folder where you extracted the zip file.
Step 2: You're left with a choice.
If you prefer to use Eclipse:
1. Run the following command: `gradlew genEclipseRuns` (`./gradlew genEclipseRuns` if you are on Mac/Linux)
2. Open Eclipse, Import > Existing Gradle Project > Select Folder
or run `gradlew eclipse` to generate the project.
If you prefer to use IntelliJ:
1. Open IDEA, and import project.
2. Select your build.gradle file and have it import.
3. Run the following command: `gradlew genIntellijRuns` (`./gradlew genIntellijRuns` if you are on Mac/Linux)
4. Refresh the Gradle Project in IDEA if required.
If at any point you are missing libraries in your IDE, or you've run into problems you can
run `gradlew --refresh-dependencies` to refresh the local cache. `gradlew clean` to reset everything
{this does not affect your code} and then start the process again.
Mapping Names:
=============================
By default, the MDK is configured to use the official mapping names from Mojang for methods and fields
in the Minecraft codebase. These names are covered by a specific license. All modders should be aware of this
license, if you do not agree with it you can change your mapping names to other crowdsourced names in your
build.gradle. For the latest license text, refer to the mapping file itself, or the reference copy here:
https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
Additional Resources:
=========================
Community Documentation: https://mcforge.readthedocs.io/en/latest/gettingstarted/
LexManos' Install Video: https://www.youtube.com/watch?v=8VEdtQLuLO0
Forge Forum: https://forums.minecraftforge.net/
Forge Discord: https://discord.gg/UvedJ9m

View File

@ -1,114 +1,175 @@
plugins {
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.neoforged.gradle.userdev' version '7.0.72'
}
version = mod_version
group = mod_group_id
base {
archivesName = mod_id
}
// Include resources generated by data generators.
sourceSets {
data
main.resources { srcDirs += data.resources.srcDirs }
}
// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
//minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg')
//minecraft.accessTransformers.entry public net.minecraft.client.Minecraft textureManager # textureManager
runs {
// applies to all the run configs below
configureEach {
systemProperty 'forge.logging.markers', 'REGISTRIES'
systemProperty 'forge.logging.console.level', 'debug'
modSource project.sourceSets.main
buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
jcenter()
mavenCentral()
}
client {
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
}
server {
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
programArgument '--nogui'
}
gameTestServer {
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
}
data {
// example of overriding the workingDirectory set in configureEach above
workingDirectory project.file('run-data')
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
programArguments '--mod', 'engage', '--all'
programArguments '--output', sourceSets.data.resources.srcDirs[0].toString()
programArguments '--existing', sourceSets.main.resources.srcDirs[0].toString()
modSources = [sourceSets.main, sourceSets.data]
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
}
}
apply plugin: 'net.minecraftforge.gradle'
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
configurations {
dataImplementation.extendsFrom implementation
version = '1.15.2-0.1'
group = 'uk.gemwire.engage' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'engage'
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
minecraft {
// The mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD Snapshot are built nightly.
// stable_# Stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: 'snapshot', version: '20200229-1.15.1'
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
client {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
mods {
examplemod {
source sourceSets.main
}
}
}
server {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
mods {
examplemod {
source sourceSets.main
}
}
}
data {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
args '--mod', 'engage', '--all', '--output', file('src/generated/resources/')
mods {
examplemod {Q
source sourceSets.main
}
}
}
}
}
dependencies {
// Specify the version of Minecraft to use.
// Depending on the plugin applied there are several options. We will assume you applied the userdev plugin as shown above.
// The group for userdev is net.neoforged, the module name is neoforge, and the version is the same as the neoforge version.
// You can however also use the vanilla plugin (net.neoforged.gradle.vanilla) to use a version of Minecraft without the neoforge loader.
// And its provides the option to then use net.minecraft as the group, and one of; client, server or joined as the module name, plus the game version as version.
// For all intends and purposes: You can treat this dependency as if it is a normal library you would use.
implementation "net.neoforged:neoforge:${neo_version}"
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft 'net.minecraftforge:forge:1.15.2-31.1.12'
dataImplementation sourceSets.main.output
// You may put jars on which you depend on in ./libs or you may define them like so..
// compile "some.group:artifact:version:classifier"
// compile "some.group:artifact:version"
// Real examples
// compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
// compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
// The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
// provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
// These dependencies get remapped to your current MCP mappings
// deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev'
// For more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
}
tasks.withType(ProcessResources).configureEach {
var replaceProperties = [
minecraft_version : minecraft_version, minecraft_version_range: minecraft_version_range,
neo_version : neo_version, neo_version_range: neo_version_range,
loader_version_range: loader_version_range,
mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
mod_authors : mod_authors, mod_description: mod_description, pack_format_number: pack_format_number,
]
inputs.properties replaceProperties
filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
expand replaceProperties + [project: project]
// Example for how to get properties into the manifest for reading by the runtime..
jar {
manifest {
attributes([
"Specification-Title": "examplemod",
"Specification-Vendor": "examplemodsareus",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor" :"examplemodsareus",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
// Example configuration to allow publishing using the maven-publish plugin
// Example configuration to allow publishing using the maven-publish task
// This is the preferred method to reobfuscate your jar file
jar.finalizedBy('reobfJar')
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
//publish.dependsOn('reobfJar')
publishing {
publications {
register('mavenJava', MavenPublication) {
from components.java
mavenJava(MavenPublication) {
artifact jar
}
}
repositories {
maven {
url "file://${project.projectDir}/repo"
url "file:///${project.projectDir}/mcmodsrepo"
}
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
build.dependsOn sourcesJar
artifacts {
archives sourcesJar
}
final var actualDateTime = OffsetDateTime.now(ZoneOffset.UTC).withNano(0)
// Process resources on build
processResources {
// This will ensure that this task is redone when the versions change.
inputs.property 'version', project.version
// Replace stuff in mods.toml, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'META-INF/mods.toml'
// Replace version
expand 'version':project.version
}
// Copy everything else except the mods.toml
from(sourceSets.main.resources.srcDirs) {
exclude 'META-INF/mods.toml'
}
}

View File

@ -1,839 +0,0 @@
1.20.x Changelog
47.0
====
- 47.0.34 [HotFix]: Somehow not caught by CI, but there was an issue in the SpawnUtils to handle.
- 47.0.33 Remove amount from FluidStack hashCode to fix the equal/hashCode java contract (#9602)
- 47.0.32 Add example usage for configs to the MDK (#9596)
Demonstrates proper usage of different config value types, validation, transformation/parsing, load/reload handling and direct field access.
- 47.0.31 Demonstrate configureEach in run configs (#9594)
- 47.0.30 Reduce verbosity of prepareRuns doc in MDK (#9593)
- 47.0.29 Lazily configure MDK tasks, improve IDE support (#9592)
- 47.0.28 Fix not dropping xp for player sourced explosions and various other cases when xp should drop (#9588)
- 47.0.27 add item handler capability to chiseled bookshelf (#9587)
- 47.0.26 Fix ignoring maxUpStep method overrides on entities (#9583)
- 47.0.25 Add missing damage type tag provider modid, existing file helper constructor overload (#9581)
- 47.0.24 Expose holder lookup registry provider as a helper in RegistriesDatapackGenerator (#9580)
- 47.0.23 Fix gametest collection causing secondary crash in loading error state (#9568)
- 47.0.22 Fix SpriteCoordinateExpander not working with chained methods (MC-263524) (#9564)
- 47.0.21 Expose EntityRendererProvider.Context to AddLayers event (#9562)
- 47.0.20 [1.20] Add events for checking spawn conditions (SpawnPlacementCheck and PositionCheck) (#9469)
- 47.0.19 Another tweak to the early display. We start a timer process while we create the window, in case it hangs. Also add a skip version config, to try and help in cases where the driver is stupid. (#9595)
- 47.0.18 Auto generate names for modded loot pools. Fixes #9589 (#9591)
- 47.0.17 More tweaks to the mod loading callbacks to make loading bars work better (#9585)
- 47.0.16 Reimplement LootPool name patches and hooks (#9573)
- 47.0.15 Fix experimental lighting pipeline breaking vanilla's emissive rendering. Closes #9552 (#9582)
- 47.0.14 Update early loading default configs to match standard expectations. (#9577)
Also allow a global override env variable for darkmode always. "FML_EARLY_WINDOW_DARK"
- 47.0.13 Add proper duplicate mod error message that includes the mod id(s) and mod files. (#9474)
- 47.0.12 Add missing stack tooltip rendering hooks (#9533)
Fix automatic tooltip wrapping discarding empty lines used as spacers
- 47.0.11 Add piston push reaction overrides to Block class (#9538)
- 47.0.10 Fix missing calls to level-sensitive block SoundType getter (#9553)
- 47.0.9 Fix forge registries that have wrappers/support tags not being in the HolderLookup Provider that is provided to the GatherDataEvent (#9566)
- 47.0.8 Make IItemDecorator a functional interface again. Fixes #9563 (#9574)
- 47.0.7 Make 1.20.x the main TC branch.
- 47.0.6 Fix custom geometry in parent models not being resolved (#9572)
- 47.0.5 Make the scheduled thread factory setDaemon on it's threads. Should allow things to close properly if something deadly happens early on. (#9575)
- 47.0.4 This is an early display window system for forge. (#9558)
- 47.0.3 fix the JIJ break by bumping SJH. apologies.
- 47.0.2 update libs (#9565)
- 47.0.1 Update Armor Layer Implementation to Match Vanilla (#9547)
- 47.0.0 1.20.1 Update
46.0
====
- 46.0.14 Fix JAR compatibility checks for 1.20 (#9556)
- 46.0.13 [1.20] Add `AFTER_LEVEL` render level stage (#9555)
- 46.0.12 Reorder overlay layers to match vanilla (#9550)
- 46.0.11 Re-implement missing level-sensitive block light hook in ChunkAccess (#9536)
- 46.0.10 Fix issues in the deserialization of empty ingredients (#9537)
- 46.0.9 Fix wrong variable passed into EnchantmentClue lookup Fixes #9543 (#9544)
- 46.0.8 Fix incorrect depth test state in debug graph rendering Fixes #9534 (#9539)
- 46.0.7 Fix initCapabilities patch location in ServerLevel Fixes #9526 (#9531)
- 46.0.6 Use Spinning Effect Intensity instead of Partial Tick for Portal Overlay Fixes #9529 (#9530)
- 46.0.5 Fix getArmorModelHook patch, Fixex #9523 (#9528)
- 46.0.4 Fix duplicate Map writes in PlayerList patch. (#9521)
- 46.0.3 Fix Forge Version including MC version in MDK.
- 46.0.2 Fix patch in light propagation (#9532)
- 46.0.1 Attempt to fix jar signing
Gradle 8 is stupid and doesn't (easily) allow in-place tasks, so a temporary fix has been made in ForgeGradle 6
- 46.0.0 Forge 1.20
- Creative mode tabs are now a registry; the `BuildContents` event was renamed to `BuildCreativeModeTabContentsEvent` and moved it to its own class
- The pack format is now 15 for both resource packs and data packs
- `ScreenUtils` was deprecated in favor of a `GuiGraphics` extension
- Forge and the MDK were updated to Gradle 8 and FG6
- The Forge common config file was removed (it only contained the deprecated old fields for resource caching, which was removed in 1.19.3)
- Registry dummy entries were removed
- `RemappingVertexPipeline` was fixed to forward the `endVertex()` call
- Forge tool tags were removed in favor of vanilla ones
Co-authored-by: ChampionAsh5357 <ash@ashwork.net>
Co-authored-by: coehlrich <coehlrich@users.noreply.github.com>
Co-authored-by: Dennis C <11262040+XFactHD@users.noreply.github.com>
Co-authored-by: Matyrobbrt <matyrobbrt@gmail.com>
45.1
====
- 45.1.0 1.19.4 Recommended Build
45.0
====
- 45.0.66 Add method to GatherDataEvent to obtain collection of all input paths. (#9499)
- 45.0.65 Log error when Sheets is class-loaded before registration is completed (#9475)
- 45.0.64 [1.19.x] Re-implement RenderTooltipEvent.Color (#9497)
* Reimplement RenderTooltipEvent.Color
* Formatting, comments, EXC
* Deprecate instead of replacing
- 45.0.63 Add API for registering custom world preset editors (#9436)
- 45.0.62 Remove unneeded extra reload of datapacks on world creation screen (#9454)
- 45.0.61 Bump ASM to 9.5
- 45.0.60 Fix crash when running server from root directory
Fixes #9498
- 45.0.59 Fix root transform matrix format, allow using all four root transform formats (#9496)
- 45.0.58 Add missing AT lines to allow registering custom game rule boolean/integer types (#9489)
- 45.0.57 [1.19.x] Fix SaplingGrowTreeEvent#setFeature being ignored in FungusBlock (#9485)
Co-authored-by: Brennan Ward <3682588+Shadows-of-Fire@users.noreply.github.com>
- 45.0.56 Restore AccessibilityOnboardingScreen
Fixes #9488
- 45.0.55 Update documentation on FinalizeSpawn (#9467)
- 45.0.54 Fix fluids without sound event causing exception in tryFillContainer and tryEmptyContainer (#9445)
- 45.0.53 Make FakePlayerFactory respect the given ServerLevel (#9479)
- 45.0.52 Collect and log exceptions occurring in DeferredWorkQueue tasks (#9449)
- 45.0.51 Fix `NamespacedWrapper#wrapAsHolder` (#9450)
- 45.0.50 Fixes ChatScreen calling .setScreen (#9443)
Fix test compile failures also.
- 45.0.49 Determine the Forge version the PR was built against when running PR compat checks (#9374)
- 45.0.48 Add buildscript test to error on deprecated members that should of been removed. (#9460)
- 45.0.47 Remove erroneous brace patch in Inventory (#9462)
Fixes #9459
- 45.0.46 [1.19.4] Move root transform builder to ModelBuilder to allow use in ItemModelBuilder (#9456)
- 45.0.45 Fix forge grindstone hooks allowing stacks of non-stackable items (#9457)
- 45.0.44 [1.19.4] Fix FMLOnly (#9415)
- 45.0.43 Fix ItemLayerModel erroneously adding particle texture to layer texture list (#9441)
- 45.0.42 Temporary fix for Canceling ProjectileImpactEvents of Piercing ammo.
Event needs to be re-worked to have finer control. #9370
- 45.0.41 Fix dummy air blocks not being marked as air (#9440)
- 45.0.40 Add support for splitting the login packet (#9367)
It contains full copies of data registries and can easily surpass vanilla's limits
- 45.0.39 Remove Attack Range and Reach Distance and add Block Reach and Entity Reach (#9361)
- 45.0.38 Add default bucket sounds for milk (#9432)
- 45.0.37 Deprecate Item.onUsingTick, as vanilla provides the same function in Item.onUseTick now. Closes #9342
- 45.0.36 Fix ScreenEvent.Init.[Pre/Post] not working correctly (#9431)
- 45.0.35 Allow FenceGateBlock to be used without a WoodType. Closes #9392
- 45.0.34 Deprecate duplicate tool tags that vanilla added in 1.19.4
We will maintain a seperate 'tools' tag until Mojang adds all relevent tool tags.
Closes #9393
- 45.0.33 Fix BlockEvent.Break not using ItemStack enchantment hooks.
- 45.0.32 Move Block.onCatchFire to above block removal to allow usage of BlockEntity data. Closes #9400
- 45.0.31 Fix FinalizeSpawn not blocking spawns during worldgen (#9420)
- 45.0.30 Fixed issue with MutableHashedLinkedMap when removing multiple sequential entries in the middle of the map.
Added Unit tests for MutableHashLinkedMap
Added support for removing using the iterator
Added concurrent modification detection to the iterator
Added default constructor with basic hashing strategy.
Closes #9426
- 45.0.29 Loosen access for BucketItem's canBlockContainFluid (#9421)
- 45.0.28 Update and Regenerate Datapacks (#9419)
Add generation for pack.mcmeta
- 45.0.27 Restore ability to change message in ClientChatEvent (#9377)
- 45.0.26 Remove duplicate line in FoodData patch (#9424)
The line was accidentally duplicated in the 1.19.4 update and patching
process.
Fixes #9422
- 45.0.25 Rename RegisterParticleProviderEvent's register methods to describe what kind of particle providers they register (deprecating old methods to avoid breaking) and minor docs tweaks (#9388)
- 45.0.24 Update pack versions (#9414)
- 45.0.23 [1.19.4] Revamp and fix spawn events (#9133)
- 45.0.22 [1.19.4] Replace blitOffset parameter with PoseStack in IItemDecorator (#9409)
* Replace blitOffset with PoseStack in IItemDecorator
* Circumvent breaking changes
* Fix blitOffset type
- 45.0.21 Fix JSON model root transforms (#9410)
- 45.0.20 Fix tossed items not being able to be picked up by other players. Closes #9412 (#9404)
- 45.0.19 Fix infinite BE render bounds failing frustum intersection test. Closes #9321 (#9407)
- 45.0.18 Make ForgeSlider use the new vanilla texture (#9406)
- 45.0.17 Add BlockSetType#register to accesstransformer.cfg (#9386)
- 45.0.16 Add option to completely hide a crash-callable depending on a runtime value (#9372)
- 45.0.15 Add isNewChunk to ChunkEvent.Load (#9369)
- 45.0.14 Remove DistExecutor calls in PistonEventTest (#9348)
- 45.0.13 Fix hardcoded precipitation in ClimateSettingsBuilder (#9402)
This effectively caused all biomes to have precipitation, such as
minecraft:desert.
Fixes #9397
- 45.0.12 Fix incorrect variable used for swimming check (#9403)
Because of the incorrect variable, the check to stop sprinting (and stop
swimming) never fired correctly.
1.19.3's `flag5` variable was renamed to `flag7` in 1.19.4; however,
this was not caught during patching because of the fuzzy patcher.
Fixes #9399
- 45.0.11 Fix incorrect boolean used for glint effect (#9401)
The `flag1` variable is ultimately controlled by whether the armor slot
being rendered is for the leggings, which explains this bug where the
leggings always had the enchantment glint but not any other armor piece.
Fixes #9394
- 45.0.10 Fixed ModMismatchDisconnectedScreen displaying missing mods wrongly (#9398)
- 45.0.9 Fix misaligned text render type patch (#9391)
- 45.0.8 Remove thread filter from processing clientside custom payloads. Closes @9390
- 45.0.7 Fix LivingEntity patch which caused crash while entities got hurt. Closes #9389
- 45.0.6 Fix wrong parameters in `Screen#renderTooltipInternal` patch (#9387)
- 45.0.5 Fix misaligned patch in LevelRenderer. Closes #9385
- 45.0.4 Remove our fix for MC-121048 as it has been fixed by Vanilla (#9381)
- 45.0.3 Fix advancements not loading, bug seems to be fixed by vanilla now. Closes #9384
- 45.0.2 Fixed patch verifier for cases where patches lowered access levels. Closes #9383
- 45.0.1 Fix crouching while sprinting stopping the player when step height is modified. Closes #9376
- 45.0.0 Forge 1.19.4
Properly move `ServerStatusPing` to codec
Reimplement custom display contexts
Co-authored-by: Matyrobbrt <matyrobbrt@gmail.com>
Co-authored-by: coehlrich <coehlrich@users.noreply.github.com>
44.1
====
- 44.1.23 Fix experimental world warning screen appearing everytime (#9375)
- 44.1.22 Fix continuing to use items after dropping or when a shield breaks (MC-231097, MC-168573) (#9344)
- 44.1.21 Add onStopUsing hook to IForgeItem (#9343)
- 44.1.20 Document RegisterParticleProvidersEvent's APIs (#9346)
- 44.1.19 Fix incorrect ListTag.getLongArray result (MC-260378) (#9351)
- 44.1.18 Fix missing patch that left TagBuilder#replace unused (#9354)
- 44.1.17 Add 2 new RenderLevelStageEvent.Stage for After Entities and After Block Entities (#9259)
- 44.1.16 Cleanup StemBlock Patch (#9337)
- 44.1.15 Cleanup ItemProperties patch (#9332)
- 44.1.14 Make IForgeIntrinsicHolderTagAppender methods properly chainable (#9331)
- 44.1.13 Fix in custom fluids not respecting max height correctly. (#9319)
- 44.1.12 Fix inconsistent vaporization in BucketItem & FluidType (#9269)
- 44.1.11 Fix reloading event firing during server shutdown and add explicit unloading event instead (#9016)
- 44.1.10 Homogenize and/or holdersets when serializing to prevent serializing to NBT from crashing (#9048) Fixes #9043
- 44.1.9 [1.19.x] Fix `ForgeSlider` not respecting custom height (#9237)
- 44.1.8 Fix stepsound for blocks in the inside_step_sound_blocks tag. (#9318)
- 44.1.7 Fix missing hanging sign material for modded wood type (#9303)
- 44.1.6 Fire TickEvent.LevelTickEvent on ClientLevel tick (#9299)
- 44.1.5 Add ClientChatReceivedEvent for system messages (#9284)
- 44.1.4 PR Action update (#9274)
- 44.1.3 fix HangingSignEditScreen crash when using custom wood types using modid (#9294)
- 44.1.2 Bump SecureJarHandler version, to help identify invalid mods.
- 44.1.1 [1.19.3] Hotfix missing null check in createUnbakedItemElements (#9285)
- 44.1.0 Mark 1.19.3 Recommended Build
44.0
====
- 44.0.49 [1.19.3] Allow Item and Elements models to specify static color, sky light, and block light values. (#9106)
- 44.0.48 Fix StemBlock not checking canSustainPlant for the correct block, it now checks for Melons/Pumpkins instead of the stem itself. (#9270)
- 44.0.47 Add github shared actions for automation purposes. (#9251)
- 44.0.46 Add translate key for Forge pack.mcmeta description (#9260)
- 44.0.45 Fix broken link for update checker docs in mdk (#9271)
- 44.0.44 Remove duplicate updateNeighbourForOutputSignal call Fixes #9169 (#9234)
- 44.0.43 Add helper methods to access the set of loaded sprite locations (#9223)
- 44.0.42 Disable guiLight3d for generated item models (#9230)
- 44.0.41 Remove resource caching (#9254)
- 44.0.40 Add TradeWithVillagerEvent (#9244)
- 44.0.39 Update link for Parchment "Getting Started" (#9243)
- 44.0.38 Allows DatapackBuiltinEntriesProvider to datagen LevelStems (#9247)
- 44.0.37 Add a method to LootContext.Builder that allows changing the queried loot table id (#9084)
- 44.0.36 [1.19.3] Fix Datagen Tests and Providers (#9212)
- 44.0.35 Fix concrete powder not being hydrated by singular water sources (#9236)
- 44.0.34 [1.19.3] Fix LootTableLoadEvent not getting fired (#9239)
- 44.0.33 Allow using custom factories in button builders (#9238)
- 44.0.32 Fix logspam when a root resource is requested from DelegatingPackResources, fixes #9197 (#9227)
- 44.0.31 [1.19.3] Fix `retrieveRegistryLookup` attempting to get the registry lookup from a `HolderGetter` (#9225)
- 44.0.30 [1.19.3] Add ability to datagen forge specific values in pack.mcmeta (#9221)
Co-authored-by: sciwhiz12 <sciwhiz12@gmail.com>
- 44.0.29 Add block atlas config to register forge:white texture (#9187)
- 44.0.28 Fix ExtendedButton not being highlighted when focused (#9144)
- 44.0.27 Separate checkAndFix from the check* tasks. (#9213)
- 44.0.26 Fix forge resources overriding vanilla ones (#9222)
- 44.0.25 Fix tooltip customization not working for creative inventory (#9218)
- 44.0.24 Fix glowing item frame entity's texture (#9126)
Fixes #9123
- 44.0.23 Fix datapack registries not being synced to clients (#9219)
- 44.0.22 Fix creatives tabs rendering overlapping tabs if the selected tab isn't on the current page. (#9214)
- 44.0.21 Fix `SidedInvWrapper` not accounting for vanilla stacking special cases in brewing stands and furnaces (#9189)
- 44.0.20 Update to the latest JarJar. (#9217)
- 44.0.19 Specify NetworkHooks#getEntitySpawningPacket Generic Return Type (#9220)
- 44.0.18 Fix using a DeferredRegister on a non-forge wrapped registry. Closes #9199
- 44.0.17 Add support for custom CreativeModeTab implementations (#9210)
- 44.0.16 Simplify tree grower patches (#9209)
- 44.0.15 Replace AdvancementProvider patch with Forge helper (#9188)
- 44.0.14 Allow using `PackOutput`s in Forge-added datagen classes (#9182)
- 44.0.13 Add simpleBlockWithItem for data gens (#9170)
- 44.0.12 Fix running test mods (#9211)
- 44.0.11 [1.19.3] Fix models nested in custom geometries not resolving parents (#9200)
- 44.0.10 Fix OBJ Loader caches not being thread-safe. (#9204)
- 44.0.9 [1.19.3] Add event before baked models are cached by the BlockModelShaper (#9190)
- 44.0.8 Fix compatibility checker task configuration (#9202)
- 44.0.7 Fix chat offset (#9184)
- 44.0.6 Redesign CreativeTab collection event to be a lot more straight forward. (#9198)
- 44.0.5 Move ICondition patch placement to before MC throws an error.
Disable the explicitly erroring test biome modifier.
- 44.0.4 Fix BlockStateProvider not waiting for models before finishing. (#9196) Fixes #9195:
- 44.0.3 Fix tooltips not rendering on screens. Closes #9191
- 44.0.2 Fix merged mod resource pack not returning all resources with the same name when asked. Closes #9194
- 44.0.1 Fix searching using the wrong prefix for items or tags. Fixes #9176 Fixes #9179 (#9177)
- 44.0.0 Forge 1.19.3
Created a CreativeModeTabEvent to register creative mode tabs and populate entries per tab
Moved datapack registries to DataPackRegistryEvent.NewRegistry event instead of tying them to ForgeRegistry
Made it easier for mods to datagen datapack builtin entries with DatapackBuiltinEntriesProvider
Provided access to lookupProvider for datagen
Updated dependencies to match versions used by vanilla and update JarJar to 0.3.18
Added a test mod for the new CreativeModeTabEvent
Throws better error message for Forge registries in tag datagen
Deleted ForgeRegistryTagsProvider
Updated ClientChatReceivedEvent and ServerChatEvent for Mojang changes
Added patches for both sign related methods in ModelLayers
Changed RegisterShadersEvent to use ResourceProvider
Migrated old Mojang math types to JOML
Co-authored-by: Marc Hermans <marc.hermans@ldtteam.com>
Co-authored-by: LexManos <LexManos@gmail.com>
Co-authored-by: sciwhiz12 <arnoldnunag12@gmail.com>
Co-authored-by: coehlrich <coehlrich@users.noreply.github.com>
43.2
====
- 43.2.0 43.2 Recommended Build.
43.1
====
- 43.1.65 Allow discovering services from the mods folder that use java's modular definition. (#9143)
- 43.1.64 Make Datapack Registries support ICondition(s) (#9113)
- 43.1.63 Enable additional build types to handle pull request validation. (#9159)
- 43.1.62 Check source permission level before selector permission (#9147)
In some situations, such as execution of a function by an advancement as
part of its reward, a command source stack may have a backing source of
a ServerPlayer which may lack the entity selector permission and have an
explicit permission level that should allow the use of entity selectors,
through CommandSourceStack#withPermission.
We now check if the permission level of the command source stack is
sufficient for entity selectors _before_ checking if the source is a
player and if they have the requisite permission.
This means that an operator permission level of 2 will always override
the Forge entity selector permission.
Fixes #9137
- 43.1.61 Fix fires spreading too/igniting custom portal frames. (#9142)
- 43.1.60 Add supplier to FlowerBlock so it works with custom MobEffects (#9139)
- 43.1.59 Fix some logical bugs related to the Grindstone Event (#9089)
- 43.1.58 Call baked model's `getModelData` before `getRenderTypes` (#9163)
- 43.1.57 Make Util.memoize thread-safe (#9155)
- 43.1.56 Rendering tweaks and fixes: Part 4 (#9065)
- 43.1.55 Fix `Transformation` loading `PoseStack` (#9083)
- 43.1.54 Add simple block appearance API (#9066)
- 43.1.53 Fix invalidated modded packets when on LAN (#9157)
- 43.1.52 Improve extensibility of DetectorRailBlock and PoweredRailBlock (#9130)
- 43.1.51 Fix launch handler minecraft classpath locator (#9120)
- 43.1.50 Add HitResult to `EntityTeleportEvent$EnderPearl` (#9135)
- 43.1.49 Throw aggregate exception for erroneous registry event dispatch (#9111)
This means that exceptions occurring during the dispatch of the registry
events, such as those from the suppliers of RegistryObjects, properly
cause a crash rather than merely being logged and allowing the game to
reach the main menu.
Fixes #8720
- 43.1.48 Add missing semi-colon near the Dist import statement in example mod.
- 43.1.47 Fix ClientModEvents example not subscribing to client-sided events (#9097)
- 43.1.46 Use GitHub action to lock issues with the `spam` label (#9087)
- 43.1.45 Remove structures slave map to Feature registry (#9091)
- 43.1.44 Improve logging of missing or unsupported dependencies (#9104)
- 43.1.43 [1.19.x] Fix ValueSpec caching the return value incorrectly (#9046)
- 43.1.42 [1.19.x] Add event for registering spawn placements, and modifying existing (#9024)
- 43.1.41 [1.19.x] Add event for items being stacked or swapped in a GUI. (#9050)
- 43.1.40 [1.19.x] Fix PlayerInteractEvent.EntityInteractSpecific not cancelling on a server (#9079)
- 43.1.39 Fix canceling phantom spawns preventing any further attempts that tick. (#9041)
- 43.1.38 Rename fluid type milk translation keys (#9077)
- 43.1.37 Fix minecart speed with water (#9076)
- 43.1.36 Add a cancellable event that gets fired when a Totem of Undying is used (#9069)
- 43.1.35 Fix performance issue and logging when resource caching is enabled (#9029)
- 43.1.34 Fix NPE when feeding wolves and cats (#9074)
- 43.1.33 Fix logically breaking change to ForgeConfigSpec.Builder#comment where modders could not add a empty line to the start of comments. (#9061)
- 43.1.32 Fix ServiceLoader bug
- 43.1.31 Fix ClientChatReceivedEvent for system messages
- 43.1.30 Make ForgeConfigSpec$Builder.comment able to be called multiple times for the same entry. (#9056)
- 43.1.29 Fix control modifier for mac with `KeyMapping`s using Alt instead of Super (#9057)
- 43.1.28 Fix is_desert tag not being applied correctly. (#9051)
- 43.1.27 Fix mob griefing event for SmallFireballs not using owner entity. (#9038)
- 43.1.26 Fix minecarts on rails not properly slowing down in water (#9033)
- 43.1.25 Change codestyle for BookShelves tag. Closes #9027
Add IS_CAVE tag Closes #8885
Add IS_DESERT tag Closes #8979
Simplify Mangrove Swamp tags Closes #8980
- 43.1.24 Allow faces of an "elements" model to have disabled ambient occlusion (#9019)
- 43.1.23 [1.19.x] Recipe ID-based grouping between modded and vanilla recipes. (#8876)
- 43.1.22 Update fence_gates/wooden (#8936)
- 43.1.21 [1.19.x] Added event for growing fungus (#8981)
- 43.1.20 Added Bookshelves block tag (#8991)
- 43.1.19 Create a Forge EntityType Tag for Bosses (#9017)
- 43.1.18 Allow mods to specify shader import namespace (#9021)
- 43.1.17 Grindstone Events (#8934)
One to modify the output, and one to modify the input.
- 43.1.16 Fix the serialized names of the enum (#9014)
- 43.1.15 Fix `tryEmptyContainerAndStow` duping fluids with stackable containers (#9004)
- 43.1.14 Add mod mismatch event (#8989)
- 43.1.13 [1.19.x] add methods with more context to tree growers (#8956)
- 43.1.12 [1.19.X] Adding more precise events for Advancements (#8360)
- 43.1.11 Default IItemHandler capability for shulker box itemstacks (#8827)
Co-authored-by: LexManos <LexManos@gmail.com>
- 43.1.10 [1.19] Add hook for items to remain in the hotbar when picking blocks/entities (#8872)
- 43.1.9 [1.19.x] Block Model Builder Root Transform Support (#8860)
Co-authored-by: sciwhiz12 <sciwhiz12@gmail.com>
- 43.1.8 [1.19.x] Make LivingSetAttackTargetEvent compatible with the Brain/Behavior system. (Port of PR #8918) (#8954)
- 43.1.7 [1.19.x] Add IForgeBlock#onTreeGrow to replace IForgeBlock#onPlantGrow from 1.16 (#8999)
- 43.1.6 [1.19.x] Moved Player.resetAttackStrengthTicker() to the end of Player.attack() (#9000)
- 43.1.5 fix misplaced patch in sapling block (#9005)
- 43.1.4 Fix failed entity interactions consuming the click. (#9007)
- 43.1.3 Fix entity selector permission check to check original source (#8995)
Permission checks should be against the command source and not the
target entity, as is done in vanilla.
Fixes #8994
- 43.1.2 Hotfix for 1.19.2 item animation bug (#8987)
* [HOT FIX]: Fixes #8985 by no-oping for vanilla models instead of throwing error
- 43.1.1 Add ability to Auto register capabilities via annotation (#8972)
- 43.1.0 1.19.2 RB
43.0
====
- 43.0.22 Added ItemDecorator API (#8794)
- 43.0.21 [1.19.x] Custom usage animations for items (#8932)
- 43.0.20 Allow registering custom `ColorResolver`s (#8880)
- 43.0.19 [1.19] Allow custom outline rendering on EntityRenderers and BlockEntityRenderers (#8938)
- 43.0.18 Redirect checks for entity selector use to a permission (#8947)
This allows greater flexibility for configuring servers with
operator-like permissions to user groups through the permissions API and
their permissions handler of choice without needing to grant the
vanilla operator permission to any player.
The new permission is "forge:use_entity_selectors", which is granted by
default to players with permission level 2 (GAMEMASTERS) and above.
The hook falls back to checking the permission level if the source of
the command is not a ServerPlayer, such as for command blocks and
functions.
- 43.0.17 Allow FakePlayer to report its position (#8963)
- 43.0.16 Add alternate version of renderEntityInInventory to allow for directly specifying the angles (#8961)
- 43.0.15 Add cancellable ToastAddEvent (#8952)
- 43.0.14 Modify ScreenEvent.RenderInventoryMobEffects to allow moving the effect stack left or right (#8951)
- 43.0.13 Fix Enchantment#doPostHurt and Enchantment#doPostAttack being called twice for players. Fixes MC-248272 (#8948)
- 43.0.12 Remove reflective implementation of ICustomPacket. (#8973)
Make vanilla custom packets able to be sent multiple times. Closes #8969
- 43.0.11 Filter name spaces to directories only. Closes #8413
- 43.0.10 Fix a corner case where the UMLB can not extract a version from a library. (#8967)
- 43.0.9 Fix worlds with removed dimension types unable to load. (#8959) Closes #8800
- 43.0.8 Fix issue where unknown chunk generators would cause DFU to fail. (#8957)
- 43.0.7 Fix comments and documentation that were missed during the review of #8712 (#8945)
- 43.0.6 Make AnvilUpdateEvent fire even if the second input is empty, which means it fires even if only changing the item name. (#8905)
- 43.0.5 Fix `LivingEntity#isBlocking` to use `ToolActions#SHIELD_BLOCK` instead of `UseAnim#BLOCK` (#8933)
- 43.0.4 Add Custom HolderSet Types allowing for logical combining of sets. (#8928)
- 43.0.3 Add values to VersionSupportMatrix to support loading mods that restrict versions to 1.19.1 on 1.19.2 (#8946)
- 43.0.2 Fix certain particles not updating their bounding box when their position changes (#8925)
- 43.0.1 Update EventBus to address concurrency issue in ModLauncher Factory. Closes #8924
- 43.0.0 1.19.2
42.0
====
- 42.0.9 Remove calls to getStepHeight in Player#maybeBackOffFromEdge (#8927)
- 42.0.8 Add forge tags for tools and armors, these DO NOT replace ToolActions, and are designed just for Recipes. (#8914)
- 42.0.7 Add Biomes.BEACH to Tags (#8892)
- 42.0.6 Let NetworkInstance.isRemotePresent check minecraft:register for channel IDs. (#8921)
- 42.0.5 Add an event for when the chunk ticket level is updated (#8909)
- 42.0.4 Re-add PotentialSpawns event (#8712)
- 42.0.3 Fix misplaced patch in ItemEntityRenderer breaking ItemEntityRenderer#shouldBob() (#8919)
- 42.0.2 [1.19] [HotFix] Fix the dedicated server not having access to the JiJ filesystems. (#8931)
- 42.0.1 Match Mojang's action bar fix for MC-72687 (#8917)
- 42.0.0 Forge 1.19.1
Load natives from classpath
Make command argument types a forge registry
Add `EntityMobGriefingEvent` to `Allay#wantsToPickUp`
Overhaul `ServerChatEvent` to use `ChatDecorator` system
Remove `ClientChatEvent#setMessage` for now
Gradle 7.5
41.1
====
- 41.1.0 Mark 1.19 RB
41.0
====
- 41.0.113 Allow faces of an "elements" model to be made emissive (#8890)
- 41.0.112 Fix invalid channel names sent from the server causing the network thread to error. (#8902)
- 41.0.111 Fix PlayerEvent.BreakSpeed using magic block position to signify invalid position. Closes #8906
- 41.0.110 Fix cases where URIs would not work properly with JarInJar (#8900)
- 41.0.109 Add new hook to allow modification of lightmap via Dimension special effects (#8863)
- 41.0.108 Fix Forge's packet handling on play messages. (#8875)
- 41.0.107 Add API for tab list header/footer (#8803)
- 41.0.106 Allow modded blocks overriding canStickTo prevent sticking to vanilla blocks/other modded blocks (#8837)
- 41.0.105 Multiple tweaks and fixes to the recent changes in the client refactor PR: Part 3 (#8864)
Fix weighted baked models not respecting children render types
Allow fluid container model to use base texture as particle
Fix inverted behavior in composite model building. Fixes #8871
- 41.0.104 Fix crossbows not firing ArrowLooseEvent (#8887)
- 41.0.103 Add User-Agent header to requests made by the update checker (#8881)
Format: Java-http-client/<Java version> MinecraftForge/<ForgeVer> <ModId>/<ModVersion>
- 41.0.102 Output the full path in a crash report so it is easier to find the outer mod when a crash in Jar-In-Jar occurs. (#8856)
- 41.0.101 Clean up the pick item ("middle mouse click") patches (#8870)
- 41.0.100 [1.19.x] Hotfix for test mods while the refactor is ongoing
- 41.0.99 add event to SugarCaneBlock (#8877)
- 41.0.98 Fix Global Loot Modifiers not using Dispatch Codec (#8859)
- 41.0.97 Allow block render types to be set in datagen (#8852)
- 41.0.96 Fix renderBreakingTexture not using the target's model data (#8849)
- 41.0.95 Multiple tweaks and fixes to the recent changes in the client refactor PR: Part 2 (#8854)
* Add getter for the component names in an unbaked geometry
* Fix render type hint not being copied in BlockGeometryBakingContext
* Ensure BlockRenderDispatches's renderSingleBlock uses the correct buffer
- 41.0.94 [1.19.x] Apply general renames, A SRG is provided for modders. (#8840)
See https://gist.github.com/SizableShrimp/882a671ff74256d150776da08c89ef72
- 41.0.93 Fix mob block breaking AI not working correctly when chunk 0,0 is unloaded. Closes #8853
- 41.0.92 Fix crash when breaking blocks with multipart models and remove caching. Closes #8850
- 41.0.91 Fixed `CompositeModel.Baked.Builder.build()` passing arguments in the wrong order (#8846)
- 41.0.90 Make cutout mipmaps explicitly opt-in for item/entity rendering (#8845)
* Make cutout mipmaps explicitly opt-in for item/entity rendering
* Default render type domain to "minecraft" in model datagens
- 41.0.89 Fixed multipart block models not using the new model driven render type system. (#8844)
- 41.0.88 Update to the latest JarJar to fix a collision issue where multiple jars could provide an exact match. (#8847)
- 41.0.87 Add FML config to disable DFU optimizations client-side. (#8842)
* Add client-side command line argument to disable DFU optimizations.
* Switch to using FMLConfig value instead.
- 41.0.86 [1.19] Fixed broken BufferBuilder.putBulkData(ByteBuffer) added by Forge (#8819)
* Fixes BufferBuilder.putBulkData(ByteBuffer)
* use nextElementByte
* Fixed merge conflict
- 41.0.85 [1.19.x] Fix shulker boxes allowing input of items, that return false for Item#canFitInsideContainerItems, through hoppers. (#8823)
* Make ShulkerBoxBlockEntity#canPlaceItemThroughFace delegate to Item#canFitInsideContainerItems.
* Switch to using Or and add comment.
* Switch Or to And.
- 41.0.84 [1.19.x] Added RenderLevelStageEvent to replace RenderLevelLastEvent (#8820)
* Ported RenderLevelStageEvent from 1.18.2
* Updated to fix merge conflicts
- 41.0.83 [1.19.x] Fix door datagenerator (#8821)
* Fix door datagenerator
Fix datagenerator for door blocks. Successor to #8687, addresses comments made there about statement complexity.
* Fix extra space around parameter
Fix extra space before comma around a parameter.
- 41.0.82 Create PieceBeardifierModifier to re-enable piecewise beardifier definitions (#8798)
- 41.0.81 Allow blocks to provide a dynamic MaterialColor for display on maps (#8812)
- 41.0.80 [1.19.x] BiomeTags Fixes/Improvements (#8711)
* dimension specific tag fix
* remove forge:is_beach cause vanilla has it already
* remove forge tags for new 1.19 vanilla tags (savanna, beach, overworld, end)
Co-authored-by: Flemmli97 <Flemmli97@users.noreply.github.com>
- 41.0.79 1.19 - Remove GlobalLootModifierSerializer and move to Codecs (#8721)
* convert GLM serializer class to codec
* cleanup
* GLM list needs to be sorted
* datagen
* simplify serialization
* fix test mods (oops)
* properly use suppliers for codec as they are registry obj
- 41.0.78 Implement item hooks for potions and enchantments (#8718)
* Implement item hooks for potions and enchantments
* code style fixes
- 41.0.77 Re-apply missing patch to ServerLevel.EntityCallbacks#onTrackingEnd() (#8828)
- 41.0.76 Double Bar Rendering fixed (#8806) (#8807)
* Double Bar Rendering fixed (#8806)
* Added requested changes by sciwhiz12
- 41.0.75 Multiple tweaks and fixes to the recent changes in the client refactor PR (#8836)
* Add an easy way to get the NamedGuiOverlay from a vanilla overlay
* Fix static member ordering crash in UnitTextureAtlasSprite
* Allow boss bar rendering to be cancelled
* Make fluid container datagen use the new name
- 41.0.74 Add FogMode to ViewportEvent.RenderFog (#8825)
- 41.0.73 Provide additional context to the getFieldOfView event (#8830)
- 41.0.72 Pass renderType to IForgeBakedModel.useAmbientOcclusion (#8834)
- 41.0.71 Load custom ITransformationServices from the classpath in dev (#8818)
* Add a classpath transformer discoverer to load custom transformation services from the classpath
* Update ClasspathTransformerDiscoverer to 1.18
* Update license year
* Update license header
* Fix the other license headers
* Update ClasspathTransformerDiscoverer to 1.19
- 41.0.70 Handle modded packets on the network thread (#8703)
* Handle modded packets on the network thread
- On the server we simply need to remove the call to
ensureRunningOnSameThread.
- On the client side, we now handle the packet at the very start of the
call. We make sure we're running from a network thread to prevent
calling the handling code twice.
While this does mean we no longer call .release(), in practice this
doesn't cause any leaks as ClientboundCustomPayloadPacket releases
for us.
* Clarify behaviour a little in the documentation
* Javadoc formatting
* Add a helper method for handling packets on the main thread
Also rename the network thread one. Should make it clearer the expected
behaviour of the two, and make it clearer there's a potentially breaking
change.
* Add back consumer() methods
Also document EventNetworkChannel, to clarify the thread behaviour
there.
* Add since = "1.19" to deprecated annotations
- 41.0.69 Cache resource listing calls in resource packs (#8829)
* Make the resource lookups cached.
* Include configurability and handle patch cleanup.
* Document and comment the cache manager.
* Make thread selection configurable.
* Implement a configurable loading mechanic that falls back to default behaviour when the config is not bound yet.
* Use boolean supplier and fix wildcard import.
* Clean up the VPR since this is more elegant.
* Clean up the VPR since this is more elegant.
* Address review comments.
* Address more review comments.
* Fix formatting on `getSource`
* Address comments by ichtt
* Adapt to pups requests.
* Stupid idea.
* Attempt this again with a copy on write list.
* Fix a concurrency and loading issue.
* Fix #8813
Checks if the paths are valid resource paths.
* Move the new methods on vanilla Patch.
- 41.0.68 Update SJH and JIJ
- 41.0.67 Fix #8833 (#8835)
- 41.0.66 Fix backwards fabulous check in SimpleBakedModel (#8832)
Yet another blunder we missed during the review of #8786.
- 41.0.65 Make texture atlas in StandaloneGeometryBakingContext configurable (#8831)
- 41.0.64 [1.19.X] Client code cleanup, updates, and other refactors (#8786)
* Revert "Allow safely registering RenderType predicates at any time (#8685)"
This reverts commit be7275443fd939db9c58bcad47079c3767789ac1.
* Renderable API refactors
- Rename "render values" to "context"
- Rename SimpleRenderable to CompositeRenderable to better reflect its use
- Remove IMultipartRenderValues since it doesn't have any real use
- Add extensive customization options to BakedModelRenderable
* ClientRegistry and MinecraftForgeClient refactors
- Add sprite loader manager and registration event
- Add spectator shader manager and registration event
- Add client tooltip factory manager and registration event
- Add recipe book manager and registration event
- Add key mapping registration event
- Remove ClientRegistry, as everything has been moved out of it
- Remove registration methods from MinecraftForgeClient, as they have dedicated events now
* Dimension special effects refactors
- Fold handlers into an extension class and remove public mutable fields
- Add dimension special effects manager and registration event
* HUD overlay refactors
- Rename to IGuiOverlay match vanilla (instead of Ingame)
- Add overlay manager and registration event
- Move vanilla overlays to a standalone enum
* Model loader refactors
- Rename IModelLoader to IGeometryLoader
- Add loader manager and registration event
- Fold all model events into one
- Move registration of additionally loaded models to an event
- Remove ForgeModelBakery and related classes as they served no purpose anymore
* Render properties refactors
- Rename all render properties to client extensions and relocate accordingly
- Move lookups to the respective interfaces
* Model data refactors
- Convert model data to a final class backed by an immutable map and document mutability requirements. This addresses several thread-safety issues in the current implementation which could result in race conditions
- Transfer ownership of the data manager to the client level. This addresses several issues that arise when multiple levels are used at once
* GUI and widget refactors
- Move all widgets to the correct package
- Rename GuiUtils and children to match vanilla naming
* New vertex pipeline API
- Move to vanilla's VertexConsumer
- Roll back recent PR making VertexConsumer format-aware. This is the opposite of what vanilla does, and should not be relevant with the updated lighting pipeline
* Lighting pipeline refactors
- Move to dedicated lighting package
- Separate flat and smooth lighters
- Convert from a vertex pipeline transformer to a pure vertex source (input is baked quads)
* Model geometry API refactors
- Rename IModelGeometry to IUnbakedGeometry
- Rename IModelConfiguration to IGeometryBakingContext
- Rename other elements to match vanilla naming
- Remove current changes to ModelState, as they do not belong there. Transforms should be specified through vanilla's system. ModelState is intended to transfer state from the blockstate JSON
- Remove multipart geometries and geometry parts. After some discussion, these should not be exposed. Instead, geometries should be baked with only the necessary parts enabled
* Make render types a first-class citizen in baked models
- Add named render types (block + entity + fabulous entity)
- Add named render type manager + registration event
- Make BakedModel aware of render types and transfer control over which ones are used to it instead of ItemBlockRenderTypes (fallback)
- (additional) Add concatenated list view. A wrapper for multiple lists that iterates through them in order without the cost of merging them. Useful for merging lists of baked quads
* General event refactors
- Several renames to either match vanilla or improve clarity
- Relocate client chat event dispatching out of common code
* Forge model type refactors
- Rename SeparatePerspectiveModel to SeparateTransformsModel
- Rename ItemModelMesherForge to ForgeItemModelShaper
- Rename DynamicBucketModel to DynamicFluidContainerModel
- Prefix all OBJ-related classes with "Obj" and decouple parsing from construction
- Extract ElementsModel from model loader registry
- Add EmptyModel (baked, unbaked and loader)
- Refactor CompositeModel to take over ItemMultiLayerBakedModel
- Remove FluidModel as it's not used and isn't compatible with the new fluid rendering in modern versions
- Move model loader registration to a proper event handler
- Update names of several JSON fields (backwards-compatible)
- Update datagens to match
* Miscellaneous changes and overlapping patches
- Dispatch all new registration events
- Convert ExtendedServerListData to a record
- Add/remove hooks from ForgeHooksClient as necessary
* Update test mods
* Fix VertexConsumerWrapper returning parent instead of itself
* Additional event cleanup pass
As discussed on Discord:
- Remove "@hidden" and "@see <callsite>" javadoc annotations from all client events and replace them with @ApiStatus.Internal annotation
- Make all events that shouldn't be fired directly into abstract classes with protected constructors
- Another styling pass, just in case (caught some missed classes)
* Add proper deprecation javadocs and de-dupe some vertex consumer code
* Replace sets of chunk render types with a faster BitSet-backed collection
This largely addresses potential performance concerns that using a plain HashSet might involve by making lookups and iteration as linear as they can likely be (aside from using a plain byte/int/long for bit storage). Further performance concerns related to the implementation may be addressed separately, as all the implementation details are hidden from the end user
* Requested changes
- Remove MinecraftForgeClient and move members to Minecraft, IForgeMinecraft and StencilManager
- Allow non-default elements to be passed into VertexConsumer and add support to derived classes
- Move array instantiation out of quad processing in lighting pipeline
- Fix flipped fluid container model
- Set default UV1 to the correct values in the remapping pipeline
- Minor documentation changes
* Add/update EXC entries and fix AT comment
* Add test mod as per Orion's request
* Additional requested changes
* Allow custom model types to request the particle texture to be loaded
* Even more requested changes
* Improve generics in ConcatenatedListView and add missing fallbacks
* Fix fluid render types being bound to the fluid and not its holder
* Remove non-contractual nullability in ChunkRenderTypeSet and add isEmpty
Additionally, introduce chunk render type checks in ItemBlockRenderTypes
Co-authored-by: Dennis C <xfacthd@gmx.de>
- 41.0.63 Implement full support for IPv6 (#8742)
- 41.0.62 Fix certain user-configured options being overwritten incorrectly due to validators. (#8780)
- 41.0.61 Allow safely registering RenderType predicates at any time (#8685)
- 41.0.60 Fix crash after loading error due to fluid texture gathering and config lookup (#8802)
- 41.0.59 Remove the configuration option for handling empty tags in ingredients. (#8799)
Now empty tags are considered broken in all states.
- 41.0.58 Fix MC-105317 Structure blocks do not rotate entities correctly when loading (#8792)
- 41.0.57 Fire ChunkWatchEvents after sending packets (#8747)
- 41.0.56 Add item handler capability to chest boats (#8787)
- 41.0.55 Add getter for correct BiomeSpecialEffectsBuilder to BiomeInfo$Builder (#8781)
- 41.0.54 Fix BlockToolModificationEvent missing cancelable annotation (#8778)
- 41.0.53 Fix ticking chunk tickets from forge's chunk manager not causing chunks to fully tick (#8775)
- 41.0.52 Fix default audio device config loading string comparison issue (#8767)
- 41.0.51 Fix missed vanilla method overrides in ForgeRegistry (#8766)
- 41.0.50 Add MinecraftServer reference to ServerTickEvent (#8765)
- 41.0.49 Fix TagsProviders for datapack registries not recognizing existing files (#8761)
- 41.0.48 Add callback after a BlockState was changed and the neighbors were updated (#8686)
- 41.0.47 Add biome tag entries for 1.19 biomes (#8684)
- 41.0.46 Make fishing rods use tool actions for relevant logic (#8681)
- 41.0.45 Update BootstrapLauncher to 1.1.1 and remove the forced
merge of text2speech since new BSL does it.
- 41.0.44 Merge text2speech libs together so the natives are part of the jar
- 41.0.43 Make Forge ConfigValues implement Supplier. (#8776)
- 41.0.42 Fix merge derp in AbstractModProvider and logic derp in ModDiscoverer
- 41.0.41 Add "send to mods in order" method to ModList and use it (#8759)
* Add "send to mods in order" method to ModList and use it in RegistryEvents and DataGen..
* Also preserve order in runAll
* Do better comparator thanks @pupnewfster
* postEvent as well.
- 41.0.40 Update SJH to 2.0.2.. (#8774)
* Update SJH to 2.0.3..
- 41.0.39 Sanity check the version specified in the mod file (#8749)
* Sanity check the version specified in the mod file to
make sure it's compatible with JPMS standards for
version strings.
Closes #8748
Requires SPI 6
- 41.0.38 Fix SP-Devtime world loading crash due to missing server configs (#8757)
- 41.0.37 Remove ForgeWorldPreset and related code (#8756)
Vanilla has a working replacement.
- 41.0.36 Change ConfigValue#get() to throw if called before config loaded (#8236)
This prevents silent issues where a mod gets the value of the setting
before configs are loaded, which means the default value is always
returned.
As there may be situations where the getting the config setting before
configs are loaded is needed, and it is not preferable to hardcode the
default value, the original behavior is made available through #getRaw.
Implements and closes #7716
* Remove getRaw() method
This is effectively replaced with the expression `spec.isLoaded() ?
configValue.get() : configValue.getDefault()`.
* Remove forceSystemNanoTime config setting
As implemented, it never had any effect as any place where the config
value would be queried happens before the configs are loaded.
- 41.0.35 Fix EnumArgument to use enum names for suggestions (#8728)
Previously, the suggestions used the string representation of the enum
through Enum#toString, which can differ from the name of the enum as
required by Enum#valueOf, causing invalid suggestions (both in gui and
through the error message).
- 41.0.34 Jar-In-Jar (#8715)
- 41.0.33 [1.19] Fix data-gen output path of custom data-pack registries (#8724)
- 41.0.32 Fix player dive and surface animations in custom fluids (#8738)
- 41.0.31 [1.19.x] Affect ItemEntity Motion in Custom Fluids (#8737)
- 41.0.30 [1.19] Add support for items to add enchantments without setting them in NBT (#8719)
- 41.0.29 [1.19.x] Add stock biome modifier types for adding features and spawns (#8697)
- 41.0.28 [1.19.x] Fluid API Overhaul (#8695)
- 41.0.27 Replace StructureSpawnListGatherEvent with StructureModifiers (#8717)
- 41.0.26 Use stack sensitive translation key by default for FluidAttributes. (#8707)
- 41.0.25 Delete LootItemRandomChanceCondition which added looting bonus enchantment incorrectly. (#8733)
- 41.0.24 Update EventBus to 6.0, ModLauncher to 10.0.1 and BootstrapLauncher to 1.1 (#8725)
- 41.0.23 Replace support bot with support action (#8700)
- 41.0.22 Fix Reach Distance / Attack Range being clamped at 6.0 (#8699)
- 41.0.21 [1.19.x] Fix mods' worldgen data not being loaded when creating new singleplayer worlds (#8693)
- 41.0.20 [1.19.x] Fix experimental confirmation screen (#8727)
- 41.0.19 Move is_mountain to forge's tag instead of vanilla's (#8726)
- 41.0.18 [1.19.x] Add CommandBuildContext to Register Command Events (#8716)
- 41.0.17 Only rewrite datagen cache when needed (#8709)
- 41.0.16 Implement a simple feature system for Forge (#8670)
* Implement a simple feature system for Forge. Allows mods to demand certain features are available in the loading system. An example for java_version is provided, but not expected to be used widely. This is more targeted to properties of the display, such as GL version and glsl profile.
Requires https://github.com/MinecraftForge/ForgeSPI/pull/13 to be merged first in ForgeSPI, and the SPI to be updated appropriately in build.gradle files.
* rebase onto 1.19 and add in SPI update
- 41.0.15 displayTest option in mods.toml (#8656)
* displayTest option in mods.toml
* "MATCH_VERSION" (or none) is existing match version string behaviour
* "IGNORE_SERVER_VERSION" accepts anything and sends special SERVERONLY string
* "IGNORE_ALL_VERSION" accepts anything and sends an empty string
* "NONE" allows the mod to supply their own displaytest using the IExtensionPoint mechanism.
* Update display test with feedback and added the mods.toml discussion in mdk.
- 41.0.14 Update forgeSPI to v5 (#8696)
- 41.0.13 Make IVertexConsumers such as the lighting pipeline, be aware of which format they are dealing with. (#8692)
Also fix Lighting pipeline ignoring the overlay coords from the block renderer.
- 41.0.12 Fixed misaligned patch to invalidateCaps in Entity (#8705)
- 41.0.11 Fix readAdditionalLevelSaveData (#8704)
- 41.0.10 Fixes setPos to syncPacketPositionCodec (#8702)
- 41.0.9 Fix wrong param passed to PlayLevelSoundEvent.AtEntity (#8688)
- 41.0.8 Override initialize in SlotItemHandler, so it uses the itemhandler instead of container (#8679)
- 41.0.7 Update MDK for 1.19 changes (#8675)
- 41.0.6 Add helper to RecipeType, and fix eclipse compiler error in test class.
- 41.0.5 Update modlauncher to latest (#8691)
- 41.0.4 Fix getting entity data serializer id crashing due to improper port to new registry system (#8678)
- 41.0.3 Fire registry events in the order vanilla registers to registries (#8677)
Custom registries are still fired in alphabetical order, after all vanilla registries.
Move forge's data_serializers registry to forge namespace.
- 41.0.2 Add method with pre/post wrap to allow setting/clearing mod context. (#8682)
Fixes ActiveContainer in ModContext not being present in registry events. Closes #8680
- 41.0.1 Fix the Curlie oopsie
- 41.0.0 Forge 1.19
* Bump pack.mcmeta formats
* 1.19 biome modifiers
* Mark ClientPlayerNetworkEvent.LoggedOutEvent's getters as nullable
* Add docs and package-info to client extension interfaces package
* Move RenderBlockOverlayEvent hooks to ForgeHooksClient
* Add package-infos to client events package
* Rename SoundLoadEvent to SoundEngineLoadEvent
This reduces confusion from consumers which may think the
name SoundLoadEvent refers to an individual sound being loaded rather
than the sound engine.
* Document and change SoundLoadEvent to fire on mod bus
Previously, it fired on both the mod bus and the Forge bus, which is
confusing for consumers.
* Delete SoundSetupEvent
Looking at its original implementation shows that there isn't an
appropriate place in the new sound code to reinsert the event, and the
place of 'sound engine/manager initialization event' is taken already by SoundLoadEvent.
* Perform some cleanup on client events
- Removed nullable annotations from ClientPlayerNetworkEvent
- Renamed #getPartialTicks methods to #getPartialTick, to be consistent
with vanilla's naming of the partial tick
- Cleanup documentation to remove line breaks, use the
spelling 'cancelled' over
'canceled', and improve docs on existing and
new methods.
* Remove EntityEvent.CanUpdate
Closes MinecraftForge/MinecraftForge#6394
* Switch to Jetbrains nullability annotations
* New PlayLevelSoundEvent; replaces old PlaySoundAtEntityEvent
* Remove ForgeWorldPresetScreens
* Remove IForgeRegistryEntry
* Remove use of List<Throwable> in FML's CompletableFutures
* Add docs to mod loading stages, stages, and phases
* Gradle 7.4.2
* Use SLF4J in FMLLoader and other subprojects
* Switch dynamic versions in subprojects to pinned ones
* Switch ForgeRoot and MDK to FG plugin markers
* Configure Forge javadoc task
The task now uses a custom stylesheet with MCForge elements, and
configured to combine the generation from the four FML subprojects
(fmlloader, fmlcore, javafmllanguage, mclanguage) and the Forge project
into the javadoc output.
* Update docs/md files, for 1.19 update and the move away from IRC to Discord.
* Make "Potentially dangerous alternative prefix" a debug warning, not info.
Co-authored-by: Curle <curle@gemwire.uk>
Co-authored-by: sciwhiz12 <arnoldnunag12@gmail.com>

View File

@ -1,60 +0,0 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
## Environment Properties
# The Minecraft version must agree with the Forge version to get a valid artifact
minecraft_version=1.20.4
# The Minecraft version range can use any release version of Minecraft as bounds.
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
# as they do not follow standard versioning conventions.
minecraft_version_range=[1.20.4,1.21)
# The Forge version must agree with the Minecraft version to get a valid artifact
neo_version=20.4.56-beta
# The Forge version range can use any version of Forge as bounds or match the loader version range
neo_version_range=[20.2,)
# The loader version range can only use the major version of Forge/FML as bounds
loader_version_range=[1,)
# The mapping channel to use for mappings.
# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"].
# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin.
#
# | Channel | Version | |
# |-----------|----------------------|--------------------------------------------------------------------------------|
# | official | MCVersion | Official field/method names from Mojang mapping files |
# | parchment | YYYY.MM.DD-MCVersion | Open community-sourced parameter names and javadocs layered on top of official |
#
# You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
# See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
#
# Parchment is an unofficial project maintained by ParchmentMC, separate from Minecraft Forge.
# Additional setup is needed to use their mappings, see https://parchmentmc.org/docs/getting-started
mapping_channel=official
# The mapping version to query from the mapping channel.
# This must match the format required by the mapping channel.
mapping_version=1.20.4
## Mod Properties
# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
# Must match the String constant located in the main mod class annotated with @Mod.
mod_id=engage
# The human-readable display name for the mod.
mod_name=Engage!
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=MIT
# The mod version. See https://semver.org/
mod_version=1.20.4-0.2.0
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
mod_group_id=uk.gemwire.engage
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
mod_authors=Curle
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
mod_description=Create Warp Plasma, and find an advanced tech tree to play with!
pack_format_number=18

Binary file not shown.

View File

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

244
gradlew vendored
View File

@ -1,244 +0,0 @@
#!/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##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# 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*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=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=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
# 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 \
"$@"
# 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
View File

@ -1,92 +0,0 @@
@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.
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% 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

View File

@ -1,13 +0,0 @@
pluginManagement {
repositories {
gradlePluginPortal()
maven {
name = 'NeoForged'
url = 'https://maven.neoforged.net/releases/'
}
}
}
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
}

View File

@ -1,44 +0,0 @@
package uk.gemwire.engage.data;
import net.minecraft.data.DataGenerator;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.data.event.GatherDataEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;
import org.jetbrains.annotations.NotNull;
import uk.gemwire.engage.data.blockstate.BlockStateProvider;
import uk.gemwire.engage.data.lang.EnglishProvider;
import uk.gemwire.engage.data.loot_tables.LootTableProvider;
import uk.gemwire.engage.data.model.block.BlockModelProvider;
import uk.gemwire.engage.data.model.item.ItemModelProvider;
import uk.gemwire.engage.data.sprites.SpriteSourceProvider;
import uk.gemwire.engage.data.tags.block.BlockTagProvider;
@Mod.EventBusSubscriber(modid = "engage", bus = Mod.EventBusSubscriber.Bus.MOD)
public class Datagen {
public static final Marker DATAGEN = MarkerManager.getMarker("DATAGEN");
public static final Logger LOGGER = LogManager.getLogger();
@SubscribeEvent
public static void onGatherData(@NotNull GatherDataEvent event) {
LOGGER.info(DATAGEN, "Gathering data providers");
DataGenerator generator = event.getGenerator();
LOGGER.info(DATAGEN, "Adding data providers for server data");
//generator.addProvider(event.includeServer(), new RecipeProviders(generator));
//generator.addProvider(event.includeServer(), new AdvancementsProvider(generator));
//generator.addProvider(event.includeServer(), new GLMProvider(generator));
generator.addProvider(event.includeServer(), new LootTableProvider(event.getGenerator().getPackOutput()));
generator.addProvider(event.includeServer(), new BlockTagProvider(event.getGenerator().getPackOutput(), event.getLookupProvider(), event.getExistingFileHelper()));
LOGGER.info(DATAGEN, "Adding data providers for client assets");
generator.addProvider(event.includeClient(), new EnglishProvider(event.getGenerator().getPackOutput()));
generator.addProvider(event.includeClient(), new SpriteSourceProvider(event.getGenerator().getPackOutput(), event.getLookupProvider(), event.getExistingFileHelper()));
generator.addProvider(event.includeClient(), new ItemModelProvider(event.getGenerator().getPackOutput(), event.getExistingFileHelper()));
generator.addProvider(event.includeClient(), new BlockModelProvider(event.getGenerator().getPackOutput(), event.getExistingFileHelper()));
generator.addProvider(event.includeClient(), new BlockStateProvider(event.getGenerator().getPackOutput(), event.getExistingFileHelper()));
}
}

View File

@ -1,66 +0,0 @@
package uk.gemwire.engage.data.blockstate;
import net.minecraft.core.Direction;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.PackOutput;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.Property;
import net.neoforged.neoforge.client.model.generators.BlockStateProvider;
import net.neoforged.neoforge.client.model.generators.ConfiguredModel;
import net.neoforged.neoforge.client.model.generators.ModelFile;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import org.jetbrains.annotations.NotNull;
import uk.gemwire.engage.data.model.block.BaseBlockModelProvider;
import uk.gemwire.engage.registries.fluid.FluidDeferredRegister;
import uk.gemwire.engage.registries.fluid.FluidRegistryObject;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Function;
public abstract class BaseBlockStateProvider<PROVIDER extends BaseBlockModelProvider> extends BlockStateProvider {
private final String modid;
private final PROVIDER modelProvider;
public BaseBlockStateProvider(PackOutput output, String modid, ExistingFileHelper existingFileHelper,
BiFunction<PackOutput, ExistingFileHelper, PROVIDER> providerCreator) {
super(output, modid, existingFileHelper);
this.modid = modid;
modelProvider = providerCreator.apply(output, existingFileHelper);
}
@NotNull
@Override
public String getName() {
return "Block state provider: " + modid;
}
@Override
public PROVIDER models() {
return modelProvider;
}
protected void registerFluidBlockStates(List<FluidRegistryObject<? extends FluidDeferredRegister.MekanismFluidType, ?, ?, ?, ?>> fluidROs) {
for (FluidRegistryObject<? extends FluidDeferredRegister.MekanismFluidType, ?, ?, ?, ?> fluidRO : fluidROs) {
simpleBlock(fluidRO.getBlock(), models().getBuilder(BuiltInRegistries.BLOCK.getKey(fluidRO.getBlock()).getPath()).texture("particle", fluidRO.getFluidType().stillTexture));
}
}
/**
* Like directionalBlock but allows us to skip specific properties
*/
protected void directionalBlock(Block block, Function<BlockState, ModelFile> modelFunc, int angleOffset, Property<?>... toSkip) {
getVariantBuilder(block).forAllStatesExcept(state -> {
Direction dir = state.getValue(BlockStateProperties.FACING);
return ConfiguredModel.builder()
.modelFile(modelFunc.apply(state))
.rotationX(dir == Direction.DOWN ? 180 : dir.getAxis().isHorizontal() ? 90 : 0)
.rotationY(dir.getAxis().isVertical() ? 0 : (((int) dir.toYRot()) + angleOffset) % 360)
.build();
}, toSkip);
}
}

View File

@ -1,38 +0,0 @@
package uk.gemwire.engage.data.blockstate;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import uk.gemwire.engage.data.model.block.BlockModelProvider;
import uk.gemwire.engage.registries.Blocks;
import uk.gemwire.engage.registries.Fluids;
import java.util.List;
public class BlockStateProvider extends BaseBlockStateProvider<BlockModelProvider> {
public BlockStateProvider(PackOutput output, ExistingFileHelper existingFileHelper) {
super(output, "engage", existingFileHelper, BlockModelProvider::new);
}
private ResourceLocation key(Block block) {
return BuiltInRegistries.BLOCK.getKey(block);
}
private String name(Block block) {
return key(block).getPath();
}
@Override
protected void registerStatesAndModels() {
registerFluidBlockStates(List.of(Fluids.HEAVY_WATER_FLUID, Fluids.DEUTERIUM_FLUID, Fluids.DEUTERIUM_SLUSH_FLUID, Fluids.ANTIDEUTERIUM_FLUID, Fluids.WARP_PLASMA_FLUID, Fluids.PROPANE_FLUID));
simpleBlockWithItem(Blocks.BERYLLITE_ORE_BLOCK.block().get(), models().cubeAll(name(Blocks.BERYLLITE_ORE_BLOCK.block().get()), new ResourceLocation("engage:block/beryllite_ore")));
simpleBlockWithItem(Blocks.COMPRESSOR_BLOCK.block().get(), models().cubeAll(name(Blocks.COMPRESSOR_BLOCK.block().get()), new ResourceLocation("minecraft:block/black_wool")));
simpleBlockWithItem(Blocks.COPPER_TUBE_BLOCK.block().get(), models().cubeAll(name(Blocks.COPPER_TUBE_BLOCK.block().get()), new ResourceLocation("minecraft:block/white_wool")));
simpleBlockWithItem(Blocks.COOLANT_METERING_BLOCK.block().get(), models().cubeAll(name(Blocks.COOLANT_METERING_BLOCK.block().get()), new ResourceLocation("minecraft:block/yellow_wool")));
simpleBlockWithItem(Blocks.COOLANT_HEAT_SPREADER_BLOCK.block().get(), models().cubeAll(name(Blocks.COOLANT_HEAT_SPREADER_BLOCK.block().get()), new ResourceLocation("minecraft:block/blue_wool")));
}
}

View File

@ -1,37 +0,0 @@
package uk.gemwire.engage.data.lang;
import net.minecraft.data.PackOutput;
import net.neoforged.neoforge.common.data.LanguageProvider;
import uk.gemwire.engage.registries.Blocks;
import uk.gemwire.engage.registries.Fluids;
import uk.gemwire.engage.registries.Items;
import uk.gemwire.engage.registries.fluid.FluidRegistryObject;
public class EnglishProvider extends LanguageProvider {
public EnglishProvider(PackOutput generatorIn) {
super(generatorIn, "engage", "en_us");
}
@Override
protected void addTranslations() {
add(Blocks.BERYLLITE_ORE_BLOCK.item().get(), "Beryllite Ore");
add(Items.RAW_BERYLLITE_ITEM.get(), "Beryllite");
add(Fluids.HEAVY_WATER_FLUID, "Heavy Water");
add(Fluids.PROPANE_FLUID, "Propane");
add(Fluids.DEUTERIUM_FLUID, "Deuterium");
add(Fluids.DEUTERIUM_SLUSH_FLUID, "Supercooled Deuterium");
add(Fluids.ANTIDEUTERIUM_FLUID, "Antideuterium");
add(Fluids.WARP_PLASMA_FLUID, "Warp Plasma");
add(Blocks.COMPRESSOR_BLOCK.item().get(), "Sterling Compressor");
add(Blocks.COPPER_TUBE_BLOCK.item().get(), "Copper Tube");
add(Blocks.COOLANT_HEAT_SPREADER_BLOCK.item().get(), "Heat Spreader");
add(Blocks.COOLANT_METERING_BLOCK.item().get(), "Capillary Tube");
}
void add(FluidRegistryObject<?, ?, ?, ?, ?> fluid, String name) {
add(fluid.getBlock(), name);
add(fluid.getBucket(), name + " Bucket");
}
}

View File

@ -1,21 +0,0 @@
package uk.gemwire.engage.data.loot_tables;
import net.minecraft.data.PackOutput;
import net.minecraft.data.loot.LootTableProvider;
import net.minecraft.resources.ResourceLocation;
import java.util.Collections;
import java.util.List;
import java.util.Set;
// Yoinked from Mekanism
public abstract class BaseLootProvider extends LootTableProvider {
protected BaseLootProvider(PackOutput output, List<SubProviderEntry> subProviders) {
this(output, Collections.emptySet(), subProviders);
}
protected BaseLootProvider(PackOutput output, Set<ResourceLocation> requiredTables, List<LootTableProvider.SubProviderEntry> subProviders) {
super(output, requiredTables, subProviders);
}
}

View File

@ -1,16 +0,0 @@
package uk.gemwire.engage.data.loot_tables;
import net.minecraft.data.PackOutput;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
import uk.gemwire.engage.data.loot_tables.block.BlockLootTables;
import java.util.List;
public class LootTableProvider extends BaseLootProvider {
public LootTableProvider(PackOutput pack) {
super(pack, List.of(
new SubProviderEntry(BlockLootTables::new, LootContextParamSets.BLOCK)
));
}
}

View File

@ -1,183 +0,0 @@
package uk.gemwire.engage.data.loot_tables.block;
import it.unimi.dsi.fastutil.objects.ReferenceArraySet;
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
import net.minecraft.advancements.critereon.EnchantmentPredicate;
import net.minecraft.advancements.critereon.ItemPredicate;
import net.minecraft.advancements.critereon.MinMaxBounds;
import net.minecraft.advancements.critereon.StatePropertiesPredicate;
import net.minecraft.data.loot.BlockLootSubProvider;
import net.minecraft.world.flag.FeatureFlags;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SlabBlock;
import net.minecraft.world.level.block.state.properties.SlabType;
import net.minecraft.world.level.storage.loot.LootPool;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.entries.LootItem;
import net.minecraft.world.level.storage.loot.entries.LootPoolEntryContainer;
import net.minecraft.world.level.storage.loot.functions.ApplyBonusCount;
import net.minecraft.world.level.storage.loot.functions.SetItemCountFunction;
import net.minecraft.world.level.storage.loot.predicates.*;
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
import net.minecraft.world.level.storage.loot.providers.number.NumberProvider;
import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
import static net.minecraft.world.level.storage.loot.LootTable.Builder;
public abstract class BaseBlockLootTables extends BlockLootSubProvider {
private static final LootItemCondition.Builder HAS_SILK_TOUCH = MatchTool.toolMatches(ItemPredicate.Builder.item()
.hasEnchantment(new EnchantmentPredicate(Enchantments.SILK_TOUCH, MinMaxBounds.Ints.atLeast(1))));
private final Set<Block> knownBlocks = new ReferenceOpenHashSet<>();
//Note: We use an array set as we never expect this to have more than a few elements (in reality it only ever has one)
private final Set<Block> toSkip = new ReferenceArraySet<>();
protected BaseBlockLootTables() {
//Note: We manually handle explosion resistance on a case by case basis dynamically
super(Collections.emptySet(), FeatureFlags.VANILLA_SET);
}
@Override
protected void add(@NotNull Block block, @NotNull LootTable.Builder table) {
//Overwrite the core register method to add to our list of known blocks
super.add(block, table);
knownBlocks.add(block);
}
@NotNull
@Override
protected Iterable<Block> getKnownBlocks() {
return knownBlocks;
}
protected boolean skipBlock(Block block) {
//Skip any blocks that we already registered a table for or have marked to skip
return knownBlocks.contains(block) || toSkip.contains(block);
}
protected LootTable.Builder createOreDrop(Block block, ItemLike item) {
return createSilkTouchDispatchTable(block, applyExplosionDecay(block, LootItem.lootTableItem(item.asItem())
.apply(ApplyBonusCount.addOreBonusCount(Enchantments.BLOCK_FORTUNE))
));
}
protected LootTable.Builder droppingWithFortuneOrRandomly(Block block, ItemLike item, UniformGenerator range) {
return createSilkTouchDispatchTable(block, applyExplosionDecay(block, LootItem.lootTableItem(item.asItem())
.apply(SetItemCountFunction.setCount(range))
.apply(ApplyBonusCount.addOreBonusCount(Enchantments.BLOCK_FORTUNE))
));
}
//IBlockProvider versions of BlockLootTable methods, modified to support varargs
protected void dropSelf(List<Block> blocks) {
for (Block block : blocks) {
if (!skipBlock(block)) {
dropSelf(block);
}
}
}
protected void add(Function<Block, LootTable.Builder> factory, Collection<? extends Block> blocks) {
for (Block block : blocks) {
add(block, factory);
}
}
protected void add(Function<Block, Builder> factory, Block... blocks) {
for (Block block : blocks) {
add(block, factory);
}
}
/**
* Like vanilla's {@link BlockLootSubProvider#applyExplosionCondition(ItemLike, ConditionUserBuilder)} except with a boolean for if it is explosion resistant.
*/
private static <T extends ConditionUserBuilder<T>> T applyExplosionCondition(boolean explosionResistant, ConditionUserBuilder<T> condition) {
return explosionResistant ? condition.unwrap() : condition.when(ExplosionCondition.survivesExplosion());
}
/**
* Like vanilla's {@link BlockLootSubProvider#createSlabItemTable(Block)} except with a named pool
*/
@NotNull
@Override
protected LootTable.Builder createSlabItemTable(@NotNull Block slab) {
return LootTable.lootTable().withPool(LootPool.lootPool()
.name("main")
.setRolls(ConstantValue.exactly(1))
.add(applyExplosionDecay(slab, LootItem.lootTableItem(slab)
.apply(SetItemCountFunction.setCount(ConstantValue.exactly(2))
.when(LootItemBlockStatePropertyCondition.hasBlockStateProperties(slab)
.setProperties(StatePropertiesPredicate.Builder.properties().hasProperty(SlabBlock.TYPE, SlabType.DOUBLE)))
)
)
)
);
}
/**
* Like vanilla's {@link BlockLootSubProvider#dropOther(Block, ItemLike)} except with a named pool
*/
@Override
public void dropOther(@NotNull Block block, @NotNull ItemLike drop) {
add(block, createSingleItemTable(drop));
}
/**
* Like vanilla's {@link BlockLootSubProvider#createSingleItemTable(ItemLike)} except with a named pool
*/
@NotNull
@Override
public LootTable.Builder createSingleItemTable(@NotNull ItemLike item) {
return LootTable.lootTable().withPool(applyExplosionCondition(item, LootPool.lootPool()
.name("main")
.setRolls(ConstantValue.exactly(1))
.add(LootItem.lootTableItem(item))
));
}
/**
* Like vanilla's {@link BlockLootSubProvider#createSingleItemTableWithSilkTouch(Block, ItemLike, NumberProvider)} except with a named pool
*/
@NotNull
@Override
protected LootTable.Builder createSingleItemTableWithSilkTouch(@NotNull Block block, @NotNull ItemLike item, @NotNull NumberProvider range) {
return createSilkTouchDispatchTable(block, applyExplosionDecay(block, LootItem.lootTableItem(item).apply(SetItemCountFunction.setCount(range))));
}
/**
* Like vanilla's {@link BlockLootSubProvider#createSilkTouchDispatchTable(Block, LootPoolEntryContainer.Builder)} except with a named pool
*/
@NotNull
protected static LootTable.Builder createSilkTouchDispatchTable(@NotNull Block block, @NotNull LootPoolEntryContainer.Builder<?> builder) {
return createSelfDropDispatchTable(block, HAS_SILK_TOUCH, builder);
}
/**
* Like vanilla's {@link BlockLootSubProvider#createSelfDropDispatchTable(Block, LootItemCondition.Builder, LootPoolEntryContainer.Builder)} except with a named pool
*/
@NotNull
protected static LootTable.Builder createSelfDropDispatchTable(@NotNull Block block, @NotNull LootItemCondition.Builder conditionBuilder,
@NotNull LootPoolEntryContainer.Builder<?> entry) {
return LootTable.lootTable().withPool(LootPool.lootPool()
.name("main")
.setRolls(ConstantValue.exactly(1))
.add(LootItem.lootTableItem(block)
.when(conditionBuilder)
.otherwise(entry)
)
);
}
}

View File

@ -1,12 +0,0 @@
package uk.gemwire.engage.data.loot_tables.block;
import uk.gemwire.engage.registries.Blocks;
import uk.gemwire.engage.registries.Items;
public class BlockLootTables extends BaseBlockLootTables {
@Override
protected void generate() {
add(block -> createOreDrop(block, Items.RAW_BERYLLITE_ITEM.get()), Blocks.BERYLLITE_ORE_BLOCK.block().get());
}
}

View File

@ -1,34 +0,0 @@
package uk.gemwire.engage.data.model.block;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.PackType;
import net.neoforged.neoforge.client.model.generators.BlockModelBuilder;
import net.neoforged.neoforge.client.model.generators.BlockModelProvider;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import org.jetbrains.annotations.NotNull;
public abstract class BaseBlockModelProvider extends BlockModelProvider {
public BaseBlockModelProvider(PackOutput output, String modid, ExistingFileHelper existingFileHelper) {
super(output, modid, existingFileHelper);
}
@NotNull
@Override
public String getName() {
return "Block model provider: " + modid;
}
public BlockModelBuilder sideBottomTop(String name, ResourceLocation parent, ResourceLocation texture) {
return withExistingParent(name, parent)
.texture("side", texture)
.texture("bottom", texture)
.texture("top", texture);
}
public boolean textureExists(ResourceLocation texture) {
return existingFileHelper.exists(texture, PackType.CLIENT_RESOURCES, ".png", "textures");
}
}

View File

@ -1,16 +0,0 @@
package uk.gemwire.engage.data.model.block;
import net.minecraft.data.PackOutput;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
public class BlockModelProvider extends BaseBlockModelProvider {
public BlockModelProvider(PackOutput output, ExistingFileHelper existingFileHelper) {
super(output, "engage", existingFileHelper);
}
@Override
protected void registerModels() {
}
}

View File

@ -1,100 +0,0 @@
package uk.gemwire.engage.data.model.item;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.PackType;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.block.Block;
import net.neoforged.neoforge.client.model.generators.ItemModelBuilder;
import net.neoforged.neoforge.client.model.generators.ItemModelProvider;
import net.neoforged.neoforge.client.model.generators.loaders.DynamicFluidContainerModelBuilder;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import org.jetbrains.annotations.NotNull;
import uk.gemwire.engage.registries.fluid.FluidDeferredRegister;
import uk.gemwire.engage.registries.fluid.FluidRegistryObject;
public abstract class BaseItemModelProvider extends ItemModelProvider {
protected BaseItemModelProvider(PackOutput output, String modid, ExistingFileHelper existingFileHelper) {
super(output, modid, existingFileHelper);
}
private String blockPath(Block block) {
return BuiltInRegistries.BLOCK.getKey(block).getPath();
}
private String itemPath(Item item) {
return BuiltInRegistries.ITEM.getKey(item).getPath();
}
@NotNull
@Override
public String getName() {
return "Item model provider: " + modid;
}
public boolean textureExists(ResourceLocation texture) {
return existingFileHelper.exists(texture, PackType.CLIENT_RESOURCES, ".png", "textures");
}
protected ResourceLocation itemTexture(ItemLike itemProvider) {
return modLoc("item/" + itemPath(itemProvider.asItem()));
}
protected void registerGenerated(ItemLike... itemProviders) {
for (ItemLike itemProvider : itemProviders) {
generated(itemProvider);
}
}
protected void registerBuckets(FluidDeferredRegister register) {
for (FluidRegistryObject<?, ?, ?, ?, ?> fluidRegistryObject : register.getAllFluids()) {
registerBucket(fluidRegistryObject);
}
}
protected ItemModelBuilder generated(ItemLike itemProvider) {
return generated(itemProvider, itemTexture(itemProvider));
}
protected ItemModelBuilder generated(ItemLike itemProvider, ResourceLocation texture) {
return withExistingParent(itemPath(itemProvider.asItem()), "item/generated").texture("layer0", texture);
}
protected ItemModelBuilder resource(ItemLike itemProvider, String type) {
//TODO: Try to come up with a better solution to this. Currently we have an empty texture for layer zero so that we can set
// the tint only on layer one so that we only end up having the tint show for this fallback texture
ItemModelBuilder modelBuilder = generated(itemProvider, modLoc("item/empty")).texture("layer1", modLoc("item/" + type));
ResourceLocation overlay = modLoc("item/" + type + "_overlay");
if (textureExists(overlay)) {
//If we have an overlay type for that resource type then add that as another layer
modelBuilder = modelBuilder.texture("layer2", overlay);
}
return modelBuilder;
}
protected void registerHandheld(ItemLike... itemProviders) {
for (ItemLike itemProvider : itemProviders) {
handheld(itemProvider);
}
}
protected ItemModelBuilder handheld(ItemLike itemProvider) {
return handheld(itemProvider, itemTexture(itemProvider));
}
protected ItemModelBuilder handheld(ItemLike itemProvider, ResourceLocation texture) {
return withExistingParent(itemPath(itemProvider.asItem()), "item/handheld").texture("layer0", texture);
}
//Note: This isn't the best way to do this in terms of model file validation, but it works
protected void registerBucket(FluidRegistryObject<?, ?, ?, ?, ?> fluidRO) {
withExistingParent(BuiltInRegistries.ITEM.getKey(fluidRO.getBucket()).getPath(), new ResourceLocation("item/bucket"))
.customLoader(DynamicFluidContainerModelBuilder::begin)
.fluid(fluidRO.getStillFluid());
}
}

View File

@ -1,44 +0,0 @@
package uk.gemwire.engage.data.model.item;
import net.minecraft.core.Holder;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import uk.gemwire.engage.registries.Fluids;
import uk.gemwire.engage.registries.Items;
public class ItemModelProvider extends BaseItemModelProvider {
public ItemModelProvider(PackOutput output, ExistingFileHelper existingFileHelper) {
super(output, "engage", existingFileHelper);
}
private ResourceLocation key(Block block) {
return BuiltInRegistries.BLOCK.getKey(block);
}
private String name(Block block) {
return key(block).getPath();
}
private ResourceLocation key(Item item) {
return BuiltInRegistries.ITEM.getKey(item);
}
private String name(Item item) {
return key(item).getPath();
}
@Override
protected void registerModels() {
registerBuckets(Fluids.FLUIDS_REGISTRY);
generated(Items.RAW_BERYLLITE_ITEM.get(), new ResourceLocation("engage:item/beryllite_raw"));
}
void blockParent(Holder<Item> item, Holder<Block> block) {
withExistingParent(name(item.value()), modLoc(BLOCK_FOLDER + name(block.value())));
}
}

View File

@ -1,50 +0,0 @@
package uk.gemwire.engage.data.sprites;
import net.minecraft.client.renderer.texture.atlas.sources.DirectoryLister;
import net.minecraft.client.renderer.texture.atlas.sources.SingleFile;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import net.neoforged.neoforge.common.data.SpriteSourceProvider;
import uk.gemwire.engage.registries.fluid.FluidDeferredRegister;
import uk.gemwire.engage.registries.fluid.FluidRegistryObject;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
public class BaseSpriteSourceProvider extends SpriteSourceProvider {
private final Set<ResourceLocation> trackedSingles = new HashSet<>();
protected BaseSpriteSourceProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, String modid, ExistingFileHelper fileHelper) {
super(output, lookupProvider, modid, fileHelper);
}
protected void addFiles(SourceList atlas, ResourceLocation... resourceLocations) {
for (ResourceLocation rl : resourceLocations) {
//Only add this source if we haven't already added it as a direct single file source
if (trackedSingles.add(rl)) {
atlas.addSource(new SingleFile(rl, Optional.empty()));
}
}
}
protected void addFluids(SourceList atlas, FluidDeferredRegister register) {
for (FluidRegistryObject<? extends FluidDeferredRegister.MekanismFluidType, ?, ?, ?, ?> fluidRO : register.getAllFluids()) {
FluidDeferredRegister.MekanismFluidType fluidType = fluidRO.getFluidType();
addFiles(atlas, fluidType.stillTexture, fluidType.flowingTexture, fluidType.overlayTexture, fluidType.renderOverlayTexture);
}
}
protected void addDirectory(SourceList atlas, String directory, String spritePrefix) {
atlas.addSource(new DirectoryLister(directory, spritePrefix));
}
@Override
protected void gather() {
}
}

View File

@ -1,22 +0,0 @@
package uk.gemwire.engage.data.sprites;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import uk.gemwire.engage.registries.Fluids;
import java.util.concurrent.CompletableFuture;
public class SpriteSourceProvider extends BaseSpriteSourceProvider {
public SpriteSourceProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, ExistingFileHelper fileHelper) {
super(output, lookupProvider, "engage", fileHelper);
}
@Override
protected void gather() {
SourceList atlas = atlas(BLOCKS_ATLAS);
addFluids(atlas, Fluids.FLUIDS_REGISTRY);
}
}

View File

@ -1,201 +0,0 @@
package uk.gemwire.engage.data.tags;
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.CachedOutput;
import net.minecraft.data.DataProvider;
import net.minecraft.data.PackOutput;
import net.minecraft.data.tags.TagsProvider;
import net.minecraft.resources.ResourceKey;
import net.minecraft.tags.TagBuilder;
import net.minecraft.tags.TagKey;
import net.minecraft.world.damagesource.DamageType;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.material.Fluid;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import org.jetbrains.annotations.NotNull;
import uk.gemwire.engage.registries.fluid.FluidRegistryObject;
import javax.annotation.Nullable;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
public abstract class BaseTagProvider implements DataProvider {
private final Map<ResourceKey<? extends Registry<?>>, Map<TagKey<?>, TagBuilder>> supportedTagTypes = new Object2ObjectLinkedOpenHashMap<>();
private final Set<Block> knownHarvestRequirements = new ReferenceOpenHashSet<>();
private final CompletableFuture<HolderLookup.Provider> lookupProvider;
private final ExistingFileHelper existingFileHelper;
private final PackOutput output;
private final String modid;
protected BaseTagProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, String modid, @Nullable ExistingFileHelper existingFileHelper) {
this.output = output;
this.modid = modid;
this.lookupProvider = lookupProvider;
this.existingFileHelper = existingFileHelper;
}
@NotNull
@Override
public String getName() {
return "Tags: " + modid;
}
protected abstract void registerTags(HolderLookup.Provider registries);
protected List<Block> getAllBlocks() {
return Collections.emptyList();
}
protected void hasHarvestData(Block block) {
knownHarvestRequirements.add(block);
}
@NotNull
@Override
public CompletableFuture<?> run(@NotNull CachedOutput cache) {
return this.lookupProvider.thenApply(registries -> {
supportedTagTypes.values().forEach(Map::clear);
registerTags(registries);
return registries;
}).thenCompose(registries -> {
for (Block block : getAllBlocks()) {
if (block.defaultBlockState().requiresCorrectToolForDrops() && !knownHarvestRequirements.contains(block)) {
throw new IllegalStateException("Missing harvest tool type for block '" + BuiltInRegistries.BLOCK.getKey(block) + "' that requires the correct tool for drops.");
}
}
List<CompletableFuture<?>> futures = new ArrayList<>();
supportedTagTypes.forEach((registry, tagTypeMap) -> {
if (!tagTypeMap.isEmpty()) {
//Create a dummy provider and pass all our collected data through to it
futures.add(new TagsProvider(output, registry, lookupProvider, modid, existingFileHelper) {
@Override
protected void addTags(@NotNull HolderLookup.Provider lookupProvider) {
//Add each tag builder to the wrapped provider's builder
tagTypeMap.forEach((tag, tagBuilder) -> builders.put(tag.location(), tagBuilder));
}
}.run(cache));
}
});
return CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new));
});
}
private <TYPE> Map<TagKey<?>, TagBuilder> getTagTypeMap(ResourceKey<? extends Registry<TYPE>> registry) {
return supportedTagTypes.computeIfAbsent(registry, type -> new Object2ObjectLinkedOpenHashMap<>());
}
private <TYPE> TagBuilder getTagBuilder(ResourceKey<? extends Registry<TYPE>> registry, TagKey<TYPE> tag) {
return getTagTypeMap(registry).computeIfAbsent(tag, ignored -> TagBuilder.create());
}
protected <TYPE> EngageTagBuilder<TYPE, ?> getBuilder(ResourceKey<? extends Registry<TYPE>> registry, TagKey<TYPE> tag) {
return new EngageTagBuilder<>(getTagBuilder(registry, tag), modid);
}
protected <TYPE> IntrinsicEngageTagBuilder<TYPE> getBuilder(ResourceKey<? extends Registry<TYPE>> registry, Function<TYPE, ResourceKey<TYPE>> keyExtractor, TagKey<TYPE> tag) {
return new IntrinsicEngageTagBuilder<>(keyExtractor, getTagBuilder(registry, tag), modid);
}
protected <TYPE> IntrinsicEngageTagBuilder<TYPE> getBuilder(Registry<TYPE> registry, TagKey<TYPE> tag) {
return new IntrinsicEngageTagBuilder<>(element -> registry.getResourceKey(element).orElseThrow(), getTagBuilder(registry.key(), tag), modid);
}
protected IntrinsicEngageTagBuilder<Item> getItemBuilder(TagKey<Item> tag) {
return getBuilder(BuiltInRegistries.ITEM, tag);
}
protected IntrinsicEngageTagBuilder<Block> getBlockBuilder(TagKey<Block> tag) {
return getBuilder(BuiltInRegistries.BLOCK, tag);
}
protected IntrinsicEngageTagBuilder<EntityType<?>> getEntityTypeBuilder(TagKey<EntityType<?>> tag) {
return getBuilder(BuiltInRegistries.ENTITY_TYPE, tag);
}
protected IntrinsicEngageTagBuilder<Fluid> getFluidBuilder(TagKey<Fluid> tag) {
return getBuilder(BuiltInRegistries.FLUID, tag);
}
protected IntrinsicEngageTagBuilder<BlockEntityType<?>> getTileEntityTypeBuilder(TagKey<BlockEntityType<?>> tag) {
return getBuilder(BuiltInRegistries.BLOCK_ENTITY_TYPE, tag);
}
protected IntrinsicEngageTagBuilder<GameEvent> getGameEventBuilder(TagKey<GameEvent> tag) {
return getBuilder(Registries.GAME_EVENT, gameEvent -> gameEvent.builtInRegistryHolder().key(), tag);
}
protected EngageTagBuilder<DamageType, ?> getDamageTypeBuilder(TagKey<DamageType> tag) {
return getBuilder(Registries.DAMAGE_TYPE, tag);
}
protected IntrinsicEngageTagBuilder<MobEffect> getMobEffectBuilder(TagKey<MobEffect> tag) {
return getBuilder(BuiltInRegistries.MOB_EFFECT, tag);
}
protected void addToTag(TagKey<Item> tag, ItemLike... itemProviders) {
getItemBuilder(tag).addTyped(ItemLike::asItem, itemProviders);
}
protected void addToTag(TagKey<Block> tag, Block... blocks) {
getBlockBuilder(tag).addTyped(b -> b, blocks);
}
@SafeVarargs
protected final void addToTag(TagKey<Block> blockTag, Map<?, ? extends Block>... blocks) {
IntrinsicEngageTagBuilder<Block> tagBuilder = getBlockBuilder(blockTag);
for (Map<?, ? extends Block> entry : blocks) {
for (Block value : entry.values()) {
tagBuilder.add(value);
}
}
}
protected void addToHarvestTag(TagKey<Block> tag, Block... blockProviders) {
IntrinsicEngageTagBuilder<Block> tagBuilder = getBlockBuilder(tag);
for (Block block : blockProviders) {
tagBuilder.add(block);
hasHarvestData(block);
}
}
@SafeVarargs
protected final void addToHarvestTag(TagKey<Block> blockTag, Map<?, ? extends Block>... blockProviders) {
IntrinsicEngageTagBuilder<Block> tagBuilder = getBlockBuilder(blockTag);
for (Map<?, ? extends Block> blockProvider : blockProviders) {
for (Block block : blockProvider.values()) {
tagBuilder.add(block);
hasHarvestData(block);
}
}
}
protected void addToTags(TagKey<Item> itemTag, TagKey<Block> blockTag, Block... blockProviders) {
IntrinsicEngageTagBuilder<Item> itemTagBuilder = getItemBuilder(itemTag);
IntrinsicEngageTagBuilder<Block> blockTagBuilder = getBlockBuilder(blockTag);
for (Block blockProvider : blockProviders) {
itemTagBuilder.add(blockProvider.asItem());
blockTagBuilder.add(blockProvider);
}
}
protected void addToTag(TagKey<Fluid> tag, FluidRegistryObject<?, ?, ?, ?, ?>... fluidRegistryObjects) {
IntrinsicEngageTagBuilder<Fluid> tagBuilder = getFluidBuilder(tag);
for (FluidRegistryObject<?, ?, ?, ?, ?> fluidRO : fluidRegistryObjects) {
tagBuilder.add(fluidRO.getStillFluid(), fluidRO.getFlowingFluid());
}
}
}

View File

@ -1,108 +0,0 @@
package uk.gemwire.engage.data.tags;
import java.util.function.Consumer;
import java.util.function.Function;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagBuilder;
import net.minecraft.tags.TagEntry;
import net.minecraft.tags.TagKey;
// Stolen from Mekanism
public class EngageTagBuilder<TYPE, BUILDER extends EngageTagBuilder<TYPE, BUILDER>> {
protected final TagBuilder builder;
protected final String modID;
public EngageTagBuilder(TagBuilder builder, String modID) {
this.builder = builder;
this.modID = modID;
}
@SuppressWarnings("unchecked")
private BUILDER getThis() {
return (BUILDER) this;
}
@SafeVarargs
public final BUILDER add(TagKey<TYPE>... tags) {
return apply(builder::addTag, TagKey::location, tags);
}
public BUILDER add(TagEntry tag) {
builder.add(tag);
return getThis();
}
@SafeVarargs
public final BUILDER add(ResourceKey<TYPE>... keys) {
return add(ResourceKey::location, keys);
}
@SafeVarargs
public final <T> BUILDER add(Function<T, ResourceLocation> locationGetter, T... elements) {
return apply(builder::addElement, locationGetter, elements);
}
public BUILDER replace() {
return replace(true);
}
public BUILDER replace(boolean value) {
builder.replace(value);
return getThis();
}
public BUILDER addOptional(ResourceLocation... locations) {
return addOptional(Function.identity(), locations);
}
@SafeVarargs
public final <T> BUILDER addOptional(Function<T, ResourceLocation> locationGetter, T... elements) {
return add(TagEntry::optionalElement, locationGetter, elements);
}
@SafeVarargs
public final BUILDER addOptionalTag(TagKey<TYPE>... tags) {
return addOptionalTag(TagKey::location, tags);
}
public BUILDER addOptionalTag(ResourceLocation... locations) {
return addOptionalTag(Function.identity(), locations);
}
@SafeVarargs
public final <T> BUILDER addOptionalTag(Function<T, ResourceLocation> locationGetter, T... elements) {
return add(TagEntry::optionalTag, locationGetter, elements);
}
@SafeVarargs
private <T> BUILDER add(Function<ResourceLocation, TagEntry> entryCreator, Function<T, ResourceLocation> locationGetter, T... elements) {
return apply(rl -> add(entryCreator.apply(rl)), locationGetter, elements);
}
public BUILDER remove(ResourceLocation... locations) {
return remove(Function.identity(), locations);
}
@SafeVarargs
public final <T> BUILDER remove(Function<T, ResourceLocation> locationGetter, T... elements) {
return apply(rl -> builder.removeElement(rl, modID), locationGetter, elements);
}
@SafeVarargs
public final BUILDER remove(TagKey<TYPE>... tags) {
for (TagKey<TYPE> tag : tags) {
builder.removeTag(tag.location(), modID);
}
return getThis();
}
@SafeVarargs
protected final <T> BUILDER apply(Consumer<ResourceLocation> consumer, Function<T, ResourceLocation> locationGetter, T... elements) {
for (T element : elements) {
consumer.accept(locationGetter.apply(element));
}
return getThis();
}
}

View File

@ -1,47 +0,0 @@
package uk.gemwire.engage.data.tags;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagBuilder;
import java.util.function.Function;
import java.util.function.Supplier;
public class IntrinsicEngageTagBuilder<TYPE> extends EngageTagBuilder<TYPE, IntrinsicEngageTagBuilder<TYPE>> {
private final Function<TYPE, ResourceKey<TYPE>> keyExtractor;
public IntrinsicEngageTagBuilder (Function<TYPE, ResourceKey<TYPE>> keyExtractor, TagBuilder builder, String modID) {
super(builder, modID);
this.keyExtractor = keyExtractor;
}
@SafeVarargs
public final IntrinsicEngageTagBuilder<TYPE> add(Supplier<TYPE>... elements) {
return addTyped(Supplier::get, elements);
}
public ResourceLocation getKey(TYPE element) {
return keyExtractor.apply(element).location();
}
@SafeVarargs
public final IntrinsicEngageTagBuilder<TYPE> add(TYPE... elements) {
return add(this::getKey, elements);
}
@SafeVarargs
public final <T> IntrinsicEngageTagBuilder<TYPE> addTyped(Function<T, TYPE> converter, T... elements) {
return add(converter.andThen(this::getKey), elements);
}
@SafeVarargs
public final IntrinsicEngageTagBuilder<TYPE> addOptional(TYPE... elements) {
return addOptional(this::getKey, elements);
}
@SafeVarargs
public final IntrinsicEngageTagBuilder<TYPE> remove(TYPE... elements) {
return remove(this::getKey, elements);
}
}

View File

@ -1,68 +0,0 @@
package uk.gemwire.engage.data.tags.block;
import net.minecraft.core.Holder;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.neoforged.neoforge.common.Tags;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import uk.gemwire.engage.data.tags.BaseTagProvider;
import uk.gemwire.engage.registries.Blocks;
import javax.annotation.Nullable;
import java.util.List;
import java.util.concurrent.CompletableFuture;
public class BlockTagProvider extends BaseTagProvider {
public BlockTagProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, @Nullable ExistingFileHelper existingFileHelper) {
super(output, lookupProvider, "engage", existingFileHelper);
}
@Override
protected List<Block> getAllBlocks() {
return Blocks.BLOCKS_REGISTRY.getEntries().stream().map(Holder::value).toList();
}
@Override
protected void registerTags(HolderLookup.Provider registries) {
addOres();
addHarvests();
}
private void addOres() {
List<Block> ores = List.of(Blocks.BERYLLITE_ORE_BLOCK.block().get());
for (Block ore : ores) {
TagKey<Item> itemTag = ItemTags.create(new ResourceLocation("forge:ores/" + BuiltInRegistries.ITEM.getKey(ore.asItem()).getPath()));
TagKey<Block> blockTag = BlockTags.create(new ResourceLocation("forge:ores/" + BuiltInRegistries.BLOCK.getKey(ore).getPath()));
addToTags(itemTag, blockTag, ore);
getItemBuilder(Tags.Items.ORES).add(itemTag);
getBlockBuilder(Tags.Blocks.ORES).add(blockTag);
addToTags(Tags.Items.ORE_RATES_SINGULAR, Tags.Blocks.ORE_RATES_SINGULAR, ore);
//addToTags(Tags.Items.ORES_IN_GROUND_DEEPSLATE, Tags.Blocks.ORES_IN_GROUND_DEEPSLATE, oreBlockType.deepslate());
addToTags(Tags.Items.ORES_IN_GROUND_STONE, Tags.Blocks.ORES_IN_GROUND_STONE, ore);
addToTag(BlockTags.OVERWORLD_CARVER_REPLACEABLES, ore);
addToTag(BlockTags.SNAPS_GOAT_HORN, ore);
}
}
private void addHarvests() {
addIronToolBlock(Blocks.BERYLLITE_ORE_BLOCK.block().get());
}
private void addIronToolBlock(Block b) {
addToHarvestTag(BlockTags.MINEABLE_WITH_PICKAXE, b);
getBlockBuilder(BlockTags.NEEDS_IRON_TOOL).add(b);
hasHarvestData(b);
}
}

View File

@ -1,8 +0,0 @@
// 1.20.4 2023-12-25T00:16:17.3389358 Item model provider: engage
a4ad24b327f697af5ce768f763ba6b8f6229a05f assets/engage/models/item/antideuterium_bucket.json
8b05e6a927ff10a8e07dd1d0632435d42b705ab6 assets/engage/models/item/beryllite_raw.json
fd1a1dee42420fa9bd983568add5f7dd9cadd6cb assets/engage/models/item/deuterium_bucket.json
2d8378928b331d16d9343144bdfa5ff027c735d7 assets/engage/models/item/deuterium_slush_bucket.json
35f0abf2c94aaf072e9fde5f915602a22e724cb3 assets/engage/models/item/heavy_water_bucket.json
310b2b21379c57680d8e43427d2c9781697645ea assets/engage/models/item/propane_bucket.json
7690d775c03e917a6782457cf9b9eb066e85754a assets/engage/models/item/warp_plasma_bucket.json

View File

@ -1,2 +0,0 @@
// 1.20.4 2023-12-25T00:16:17.3537196 Loot Tables
22933ac7663f965e6fe3c560231b4bcb76c43bfa data/engage/loot_tables/blocks/beryllite_ore.json

View File

@ -1,2 +0,0 @@
// 1.20.4 2023-12-25T00:16:17.3527194 atlases generator for engage
11e6e1f83c37071af466a42d29a662f54c2253c8 assets/minecraft/atlases/blocks.json

View File

@ -1 +0,0 @@
// 1.20.4 2023-12-25T00:16:17.3507174 Block model provider: engage

View File

@ -1,28 +0,0 @@
// 1.20.4 2023-12-25T00:16:17.3507174 Block state provider: engage
4af9c861d7727e9ee266ca6e10d9c78c9e4104ba assets/engage/blockstates/antideuterium.json
163e87835e33814e2cad190c2265142f42e18ba9 assets/engage/blockstates/beryllite_ore.json
1bb5f9aee9050675d6749ef05c6308e655a6e4ff assets/engage/blockstates/compressor.json
05bff6a9b886ec537edd7ec3be8dab1b76aedd3a assets/engage/blockstates/coolant_meter.json
e8c835ceab42e3cc09b67e242199e682ab37b47d assets/engage/blockstates/copper_tube.json
38881f2039561be97bb6ea53d31ab9db54875fe5 assets/engage/blockstates/deuterium.json
620e8e678622f335115b86475f40e518de4f9cba assets/engage/blockstates/deuterium_slush.json
84d1165d093a917bb6ff2fed0ae7fc5b6b1e850d assets/engage/blockstates/heat_spreader.json
8c9558de31b0459d70da1d07b499138e6248e38c assets/engage/blockstates/heavy_water.json
b58e421acd852f85bc9fee8f837609c8471b90b7 assets/engage/blockstates/propane.json
9b31876df3da1b32ac5639c48cab2ce60cc876ad assets/engage/blockstates/warp_plasma.json
f077c95c66d98f808227df298031ba934827bbfc assets/engage/models/block/antideuterium.json
e595ddd851a695d6bcf3047a05e291ac76427f4b assets/engage/models/block/beryllite_ore.json
cd4466ca9aff6e3cd44febc0ab2d2a5c4a3a45ed assets/engage/models/block/compressor.json
6164628d5c2a9ff67da9c172ffbffb82095851c0 assets/engage/models/block/coolant_meter.json
0021ec0a6a012353fc3294979a59e61e7c5c8f27 assets/engage/models/block/copper_tube.json
f077c95c66d98f808227df298031ba934827bbfc assets/engage/models/block/deuterium.json
f077c95c66d98f808227df298031ba934827bbfc assets/engage/models/block/deuterium_slush.json
d28b133024940edbbfa7aefa2c2f9e10df6bd271 assets/engage/models/block/heat_spreader.json
f077c95c66d98f808227df298031ba934827bbfc assets/engage/models/block/heavy_water.json
f077c95c66d98f808227df298031ba934827bbfc assets/engage/models/block/propane.json
f077c95c66d98f808227df298031ba934827bbfc assets/engage/models/block/warp_plasma.json
45314b766210255f87067ff2a93913e89b07f7ec assets/engage/models/item/beryllite_ore.json
604b3927d83cf0ec2f6df6426b2bc96de529aaa0 assets/engage/models/item/compressor.json
79d38cdc1bf52fa76e83ed1d3e1ba0143b139ba4 assets/engage/models/item/coolant_meter.json
2c86683db4b01a43068ed18c441d144e3f0e7ee1 assets/engage/models/item/copper_tube.json
f4c63d444041821c753f4a476c91a420d658131d assets/engage/models/item/heat_spreader.json

View File

@ -1,13 +0,0 @@
// 1.20.4 2023-12-25T00:16:17.3547194 Tags: engage
36ddf7e815c8651764d9b434226769617f395c02 data/forge/tags/blocks/ores.json
af866d91e488f4393cdfb764b61ac425837ec4a6 data/forge/tags/blocks/ores/beryllite_ore.json
af866d91e488f4393cdfb764b61ac425837ec4a6 data/forge/tags/blocks/ores_in_ground/stone.json
af866d91e488f4393cdfb764b61ac425837ec4a6 data/forge/tags/blocks/ore_rates/singular.json
36ddf7e815c8651764d9b434226769617f395c02 data/forge/tags/items/ores.json
af866d91e488f4393cdfb764b61ac425837ec4a6 data/forge/tags/items/ores/beryllite_ore.json
af866d91e488f4393cdfb764b61ac425837ec4a6 data/forge/tags/items/ores_in_ground/stone.json
af866d91e488f4393cdfb764b61ac425837ec4a6 data/forge/tags/items/ore_rates/singular.json
af866d91e488f4393cdfb764b61ac425837ec4a6 data/minecraft/tags/blocks/mineable/pickaxe.json
af866d91e488f4393cdfb764b61ac425837ec4a6 data/minecraft/tags/blocks/needs_iron_tool.json
af866d91e488f4393cdfb764b61ac425837ec4a6 data/minecraft/tags/blocks/overworld_carver_replaceables.json
af866d91e488f4393cdfb764b61ac425837ec4a6 data/minecraft/tags/blocks/snaps_goat_horn.json

View File

@ -1,7 +0,0 @@
{
"variants": {
"": {
"model": "engage:block/antideuterium"
}
}
}

View File

@ -1,7 +0,0 @@
{
"variants": {
"": {
"model": "engage:block/beryllite_ore"
}
}
}

View File

@ -1,7 +0,0 @@
{
"variants": {
"": {
"model": "engage:block/deuterium"
}
}
}

View File

@ -1,7 +0,0 @@
{
"variants": {
"": {
"model": "engage:block/deuterium_slush"
}
}
}

View File

@ -1,7 +0,0 @@
{
"variants": {
"": {
"model": "engage:block/heavy_water"
}
}
}

View File

@ -1,7 +0,0 @@
{
"variants": {
"": {
"model": "engage:block/propane"
}
}
}

View File

@ -1,7 +0,0 @@
{
"variants": {
"": {
"model": "engage:block/warp_plasma"
}
}
}

View File

@ -1,20 +0,0 @@
{
"block.engage.antideuterium": "Antideuterium",
"block.engage.beryllite_ore": "Beryllite Ore",
"block.engage.compressor": "Sterling Compressor",
"block.engage.coolant_meter": "Capillary Tube",
"block.engage.copper_tube": "Copper Tube",
"block.engage.deuterium": "Deuterium",
"block.engage.deuterium_slush": "Supercooled Deuterium",
"block.engage.heat_spreader": "Heat Spreader",
"block.engage.heavy_water": "Heavy Water",
"block.engage.propane": "Propane",
"block.engage.warp_plasma": "Warp Plasma",
"item.engage.antideuterium_bucket": "Antideuterium Bucket",
"item.engage.beryllite_raw": "Beryllite",
"item.engage.deuterium_bucket": "Deuterium Bucket",
"item.engage.deuterium_slush_bucket": "Supercooled Deuterium Bucket",
"item.engage.heavy_water_bucket": "Heavy Water Bucket",
"item.engage.propane_bucket": "Propane Bucket",
"item.engage.warp_plasma_bucket": "Warp Plasma Bucket"
}

View File

@ -1,5 +0,0 @@
{
"textures": {
"particle": "engage:liquid/liquid"
}
}

View File

@ -1,6 +0,0 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "engage:block/beryllite_ore"
}
}

View File

@ -1,5 +0,0 @@
{
"textures": {
"particle": "engage:liquid/liquid"
}
}

View File

@ -1,5 +0,0 @@
{
"textures": {
"particle": "engage:liquid/liquid"
}
}

View File

@ -1,5 +0,0 @@
{
"textures": {
"particle": "engage:liquid/liquid"
}
}

View File

@ -1,5 +0,0 @@
{
"textures": {
"particle": "engage:liquid/liquid"
}
}

View File

@ -1,5 +0,0 @@
{
"textures": {
"particle": "engage:liquid/liquid"
}
}

View File

@ -1,5 +0,0 @@
{
"parent": "minecraft:item/bucket",
"fluid": "engage:antideuterium",
"loader": "neoforge:fluid_container"
}

View File

@ -1,3 +0,0 @@
{
"parent": "engage:block/beryllite_ore"
}

View File

@ -1,6 +0,0 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "engage:item/beryllite_raw"
}
}

View File

@ -1,5 +0,0 @@
{
"parent": "minecraft:item/bucket",
"fluid": "engage:deuterium",
"loader": "neoforge:fluid_container"
}

View File

@ -1,5 +0,0 @@
{
"parent": "minecraft:item/bucket",
"fluid": "engage:deuterium_slush",
"loader": "neoforge:fluid_container"
}

View File

@ -1,5 +0,0 @@
{
"parent": "minecraft:item/bucket",
"fluid": "engage:heavy_water",
"loader": "neoforge:fluid_container"
}

View File

@ -1,5 +0,0 @@
{
"parent": "minecraft:item/bucket",
"fluid": "engage:propane",
"loader": "neoforge:fluid_container"
}

View File

@ -1,5 +0,0 @@
{
"parent": "minecraft:item/bucket",
"fluid": "engage:warp_plasma",
"loader": "neoforge:fluid_container"
}

View File

@ -1,20 +0,0 @@
{
"sources": [
{
"type": "minecraft:single",
"resource": "engage:liquid/liquid"
},
{
"type": "minecraft:single",
"resource": "engage:liquid/liquid_flow"
},
{
"type": "minecraft:single",
"resource": "minecraft:block/water_overlay"
},
{
"type": "minecraft:single",
"resource": "minecraft:misc/underwater"
}
]
}

View File

@ -1,50 +0,0 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:alternatives",
"children": [
{
"type": "minecraft:item",
"conditions": [
{
"condition": "minecraft:match_tool",
"predicate": {
"enchantments": [
{
"enchantment": "minecraft:silk_touch",
"levels": {
"min": 1
}
}
]
}
}
],
"name": "engage:beryllite_ore"
},
{
"type": "minecraft:item",
"functions": [
{
"enchantment": "minecraft:fortune",
"formula": "minecraft:ore_drops",
"function": "minecraft:apply_bonus"
},
{
"function": "minecraft:explosion_decay"
}
],
"name": "engage:beryllite_raw"
}
]
}
],
"rolls": 1.0
}
],
"random_sequence": "engage:blocks/beryllite_ore"
}

View File

@ -1,5 +0,0 @@
{
"values": [
"engage:beryllite_ore"
]
}

View File

@ -1,5 +0,0 @@
{
"values": [
"#forge:ores/beryllite_ore"
]
}

View File

@ -1,5 +0,0 @@
{
"values": [
"engage:beryllite_ore"
]
}

View File

@ -1,5 +0,0 @@
{
"values": [
"engage:beryllite_ore"
]
}

View File

@ -1,5 +0,0 @@
{
"values": [
"engage:beryllite_ore"
]
}

View File

@ -1,5 +0,0 @@
{
"values": [
"#forge:ores/beryllite_ore"
]
}

View File

@ -1,5 +0,0 @@
{
"values": [
"engage:beryllite_ore"
]
}

View File

@ -1,5 +0,0 @@
{
"values": [
"engage:beryllite_ore"
]
}

View File

@ -1,5 +0,0 @@
{
"values": [
"engage:beryllite_ore"
]
}

View File

@ -1,5 +0,0 @@
{
"values": [
"engage:beryllite_ore"
]
}

View File

@ -1,5 +0,0 @@
{
"values": [
"engage:beryllite_ore"
]
}

View File

@ -1,5 +0,0 @@
{
"values": [
"engage:beryllite_ore"
]
}

View File

@ -1,85 +1,105 @@
package uk.gemwire.engage;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.CreativeModeTabs;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
import net.neoforged.neoforge.common.CreativeModeTabRegistry;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.server.ServerStartedEvent;
import uk.gemwire.engage.registries.Blocks;
import uk.gemwire.engage.registries.Fluids;
import uk.gemwire.engage.registries.Items;
import uk.gemwire.engage.registries.Worldgen;
import uk.gemwire.engage.systems.coolant.CoolantNetworksSavedData;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.world.chunk.IChunk;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.world.ChunkEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import uk.gemwire.engage.api.multiblocks.bts.MultiblockRegistry;
import uk.gemwire.engage.blocks.Blocks;
import uk.gemwire.engage.blocks.tileEntities.EngageTETypes;
import uk.gemwire.engage.blocks.util.WCoreStruct;
import uk.gemwire.engage.items.ItemProperties;
import uk.gemwire.engage.multiblock.warpcore.block.WarpCoreBlockPort;
import uk.gemwire.engage.multiblock.warpcore.block.WarpCoreBlockType;
import uk.gemwire.engage.multiblock.warpcore.block.WarpCoreBlockWall;
import uk.gemwire.engage.multiblock.warpcore.tile.WarpCorePowerTileEntity;
import uk.gemwire.engage.multiblock.warpcore.tile.WarpCoreTileEntity;
/**
* Engage adds four varieties of Warp Core for power generation, based on:
* - The Defiant
* - The Enterprise-D
* - Voyager
* - Kelvin-timeline Enterprise
*
* The Warp structure itself has 7 components:
* - Casing
* - Reaction Gel
* - Reaction Chamber
* - Beryllite Containment Unit
* - Input port
* - Output vent
* - Status Indicator / Control Unit
*
* To power the Warp Core, you need:
* - Supercooled Deuterium
* (obtained by putting deuterium gas through a coolant loop)
* (deuterium obtained by electrolysis of heavy water)
* (heavy water obtained from deep water)
* - Contained antideuterium
* (contained by magnetic containment unit)
* (obtained by ???)
*
* The reaction generates Warp Plasma, which must be vented through hollow tubes (EPS Conduit), towards a consumer.
* Large structures may be created that convert the plasma to usable power.
* Power Nacelles:
* - Casing
* - Warp Gel
* = Power port
*
* The coolant loop needed to created Supercooled Deuterium consists of:
* - Copper tubes
* - Sterling Compressor
* - Multiple Vents
* - Constriction Valve
*
* The direction of the constriction valve will dictate which side will generate heat, and which side will consume heat.
* The Compressor must be loaded with Propane refrigerant before running, or it will destroy itself.
*
*/
@Mod("engage")
public class Engage {
public Engage(IEventBus bus) {
// registry classes
Items.ITEMS_REGISTRY.register(bus);
Items.CREATIVE_TABS_REGISTRY.register(bus);
Blocks.BLOCKS_REGISTRY.register(bus);
Fluids.FLUIDS_REGISTRY.register(bus);
Worldgen.CARVER_REGISTRY.register(bus);
Worldgen.BIOME_MODIFIER_SERIALIZERS.register(bus);
public static final Logger LOGGER = LogManager.getLogger();
public static ModSetup SETUP = new ModSetup();
public Engage() {
bus.addListener(this::commonSetup);
NeoForge.EVENT_BUS.addListener(this::serverStarted);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
}
public void commonSetup(FMLCommonSetupEvent e) { }
private void setup(final FMLCommonSetupEvent e) {
public void serverStarted(ServerStartedEvent e) {
CoolantNetworksSavedData.NETWORKS = CoolantNetworksSavedData.getOrCreate(e.getServer().overworld());
}
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public static class RegistryEvents {
@SubscribeEvent
public static void onBlockRegistry(final RegistryEvent.Register<Block> e) {
e.getRegistry().register(new WCoreStruct());
e.getRegistry().register(new WarpCoreBlockWall().setRegistryName("warpcorewall"));
e.getRegistry().register(new WarpCoreBlockPort(WarpCoreBlockType.Power).setRegistryName("warpcorepower"));
e.getRegistry().register(new WarpCoreBlockPort(WarpCoreBlockType.Input).setRegistryName("warpcoreinput"));
e.getRegistry().register(new WarpCoreBlockPort(WarpCoreBlockType.Output).setRegistryName("warpcoreoutput"));
}
@SubscribeEvent
public static void onItemRegistry(final RegistryEvent.Register<Item> e) {
e.getRegistry().register(new BlockItem(Blocks.WCORESTRUCT, ItemProperties.BlockItemProperties).setRegistryName("wcoreextern"));
e.getRegistry().register(new BlockItem(Blocks.WCOREWALL, ItemProperties.BlockItemProperties).setRegistryName("warpcorewall"));
e.getRegistry().register(new BlockItem(Blocks.WCOREPOWER, ItemProperties.BlockItemProperties).setRegistryName("warpcorepower"));
e.getRegistry().register(new BlockItem(Blocks.WCOREINPUT, ItemProperties.BlockItemProperties).setRegistryName("warpcoreinput"));
e.getRegistry().register(new BlockItem(Blocks.WCOREOUTPUT, ItemProperties.BlockItemProperties).setRegistryName("warpcoreoutput"));
}
@SubscribeEvent
public static void onTileRegistry(final RegistryEvent.Register<TileEntityType<?>> e) {
e.getRegistry().registerAll(TileEntityType.Builder.create(() -> new WarpCoreTileEntity(EngageTETypes.WarpCoreBaseType), Blocks.WCOREWALL).build(null).setRegistryName("warpcorebase"),
TileEntityType.Builder.create(() -> new WarpCorePowerTileEntity(EngageTETypes.WarpCorePowerType), Blocks.WCOREPOWER).build(null).setRegistryName("warpcorepower"),
TileEntityType.Builder.create(() -> new WarpCoreTileEntity(EngageTETypes.WarpCorePortType), Blocks.WCOREINPUT, Blocks.WCOREOUTPUT).build(null).setRegistryName("warpcoreport"));
}
@SubscribeEvent
public void onChunkLoad(final ChunkEvent.Load e) {
IChunk chunk = e.getChunk();
MultiblockRegistry.INSTANCE.onChunkLoaded(e.getWorld().getWorld(), chunk.getPos().x, chunk.getPos().z);
}
@SubscribeEvent
public void onWorldUnload(final WorldEvent.Unload e) {
MultiblockRegistry.INSTANCE.onWorldUnloaded(e.getWorld().getWorld());
}
@SubscribeEvent
public void onWorldTick(final TickEvent.WorldTickEvent e) {
if(e.phase == TickEvent.Phase.START)
MultiblockRegistry.INSTANCE.tickStart(e.world);
}
@OnlyIn(Dist.CLIENT)
@SubscribeEvent
public void onClientTick(final TickEvent.ClientTickEvent e) {
if(e.phase == TickEvent.Phase.START)
MultiblockRegistry.INSTANCE.tickStart(Minecraft.getInstance().world);
}
}
}

View File

@ -0,0 +1,19 @@
package uk.gemwire.engage;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import uk.gemwire.engage.blocks.Blocks;
public class ModSetup {
public ItemGroup tab = new ItemGroup("engage") {
@Override
public ItemStack createIcon() {
return new ItemStack(Blocks.WCORESTRUCT);
}
};
public void init() {
}
}

View File

@ -0,0 +1,241 @@
package uk.gemwire.engage.api.multiblocks.bts;
import net.minecraft.block.BlockState;
import net.minecraft.state.BooleanProperty;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import java.util.HashMap;
public final class BlockFacing {
private byte value;
private static HashMap<Byte, BlockFacing> cache;
public static final BlockFacing NONE;
public static final BlockFacing ALL;
public static final BlockFacing DOWN;
public static final BlockFacing UP;
public static final BlockFacing NORTH;
public static final BlockFacing SOUTH;
public static final BlockFacing WEST;
public static final BlockFacing EAST;
public static final BooleanProperty FACING_DOWN = BooleanProperty.create("downFacing");
public static final BooleanProperty FACING_UP = BooleanProperty.create("upFacing");
public static final BooleanProperty FACING_WEST = BooleanProperty.create("westFacing");
public static final BooleanProperty FACING_EAST = BooleanProperty.create("eastFacing");
public static final BooleanProperty FACING_NORTH = BooleanProperty.create("northFacing");
public static final BooleanProperty FACING_SOUTH = BooleanProperty.create("southFacing");
static {
Byte hash;
cache = new HashMap<Byte, BlockFacing>(8);
hash = BlockFacing.computeHash(false, false, false, false, false, false);
cache.put(hash, NONE = new BlockFacing(hash.byteValue()));
hash = BlockFacing.computeHash(true, true, true, true, true, true);
cache.put(hash, ALL = new BlockFacing(hash.byteValue()));
hash = BlockFacing.computeHash(true, false, false, false, false, false);
cache.put(hash, DOWN = new BlockFacing(hash.byteValue()));
hash = BlockFacing.computeHash(false, true, false, false, false, false);
cache.put(hash, UP = new BlockFacing(hash.byteValue()));
hash = BlockFacing.computeHash(false, false, true, false, false, false);
cache.put(hash, NORTH = new BlockFacing(hash.byteValue()));
hash = BlockFacing.computeHash(false, false, false, true, false, false);
cache.put(hash, SOUTH = new BlockFacing(hash.byteValue()));
hash = BlockFacing.computeHash(false, false, false, false, true, false);
cache.put(hash, WEST = new BlockFacing(hash.byteValue()));
hash = BlockFacing.computeHash(false, false, false, false, false, true);
cache.put(hash, EAST = new BlockFacing(hash.byteValue()));
}
public boolean isSet(Direction dir) {
return (this.value & (1 << dir.getIndex())) != 0;
}
public boolean none() {
return this.value == 0;
}
public boolean all() {
return this.value == 0x3f;
}
public boolean down() {
return this.isSet(Direction.DOWN);
}
public boolean up() {
return this.isSet(Direction.UP);
}
public boolean north() {
return this.isSet(Direction.NORTH);
}
public boolean south() {
return this.isSet(Direction.SOUTH);
}
public boolean west() {
return this.isSet(Direction.WEST);
}
public boolean east() {
return this.isSet(Direction.EAST);
}
public BlockState toBlockState(BlockState state) {
return state.with(FACING_DOWN, this.isSet(Direction.DOWN))
.with(FACING_UP, this.isSet(Direction.UP))
.with(FACING_WEST, this.isSet(Direction.WEST))
.with(FACING_EAST, this.isSet(Direction.EAST))
.with(FACING_NORTH, this.isSet(Direction.NORTH))
.with(FACING_SOUTH, this.isSet(Direction.SOUTH));
}
public BlockFacing set(Direction dir, boolean value) {
byte newHash = this.value;
if(value)
newHash |= (1 << dir.getIndex());
else
newHash &= (~1 << dir.getIndex());
return BlockFacing.from(Byte.valueOf(newHash));
}
public int countFacesIf(boolean areSet) {
int checkFor = areSet ? 1 : 0;
int mask = this.value;
int faces = 0;
for(int i = 0; i < 6; ++i, mask = mask >>> 1) {
if((mask & 1) == checkFor)
++faces;
}
return faces;
}
public BlockFacingProperty toProperty() {
BlockFacingProperty[] values = BlockFacingProperty.values();
for(int i = 0; i < values.length; ++i) {
if (values[i].hash == this.value)
return values[i];
}
return BlockFacingProperty.None;
}
public BlockPos offsetBlockPos(BlockPos origPos) {
int x = 0, y = 0, z = 0;
for(Direction direction : Direction.values()) {
if(this.isSet(direction)) {
x += direction.getXOffset();
y += direction.getYOffset();
z += direction.getZOffset();
}
}
return origPos.add(x, y, z);
}
public Direction firstIf(boolean isSet) {
for(Direction dir : Direction.values()) {
if(this.isSet(dir) == isSet)
return dir;
}
return null;
}
public static BlockFacing from(boolean down, boolean up, boolean north, boolean south, boolean west, boolean east) {
return BlockFacing.from(BlockFacing.computeHash(down, up, north, south, west, east));
}
public static BlockFacing from(boolean[] facings) {
return BlockFacing.from(BlockFacing.computeHash(facings));
}
@Override
public String toString() {
return String.format("Facings: %s%s%s%s%s%s",
this.isSet(Direction.DOWN) ? "DOWN " : "",
this.isSet(Direction.UP) ? "UP " : "",
this.isSet(Direction.NORTH) ? "NORTH " : "",
this.isSet(Direction.SOUTH) ? "SOUTH " : "",
this.isSet(Direction.WEST) ? "WEST " : "",
this.isSet(Direction.EAST) ? "EAST " : "");
}
static BlockFacing from(Byte hash) {
BlockFacing facing = BlockFacing.cache.get(hash);
if(facing == null) {
facing = new BlockFacing(hash.byteValue());
BlockFacing.cache.put(hash, facing);
}
return facing;
}
private BlockFacing(byte value) {
this.value = value;
}
static Byte computeHash(boolean down, boolean up, boolean north, boolean south, boolean west, boolean east) {
byte hash = 0;
if (down)
hash |= (1 << Direction.DOWN.getIndex());
if (up)
hash |= (1 << Direction.UP.getIndex());
if (north)
hash |= (1 << Direction.NORTH.getIndex());
if (south)
hash |= (1 << Direction.SOUTH.getIndex());
if (west)
hash |= (1 << Direction.WEST.getIndex());
if (east)
hash |= (1 << Direction.EAST.getIndex());
return Byte.valueOf(hash);
}
static Byte computeHash(boolean[] facings) {
byte hash = 0;
int len = null == facings ? -1 : facings.length;
if (len < 0 || len > Direction.values().length)
throw new IllegalArgumentException("Invalid length of facings array");
for (int i = 0; i < len; ++i) {
if (facings[i])
hash |= (1 << Direction.values()[1].getIndex());
}
return Byte.valueOf(hash);
}
}

View File

@ -0,0 +1,120 @@
package uk.gemwire.engage.api.multiblocks.bts;
import net.minecraft.state.EnumProperty;
import net.minecraft.util.IStringSerializable;
import java.util.EnumSet;
public enum BlockFacingProperty implements IStringSerializable {
None(BlockFacing.computeHash(false, false, false, false, false, false)),
All(BlockFacing.computeHash(true, true, true, true, true, true)),
Face_D(BlockFacing.computeHash(true, false, false, false, false, false)),
Face_E(BlockFacing.computeHash(false, false, false, false, false, true)),
Face_N(BlockFacing.computeHash(false, false, true, false, false, false)),
Face_S(BlockFacing.computeHash(false, false, false, true, false, false)),
Face_U(BlockFacing.computeHash(false, true, false, false, false, false)),
Face_W(BlockFacing.computeHash(false, false, false, false, true, false)),
Angle_DE(BlockFacing.computeHash(true, false, false, false, false, true)),
Angle_DN(BlockFacing.computeHash(true, false, true, false, false, false)),
Angle_DS(BlockFacing.computeHash(true, false, false, true, false, false)),
Angle_DW(BlockFacing.computeHash(true, false, false, false, true, false)),
Angle_EN(BlockFacing.computeHash(false, false, true, false, false, true)),
Angle_ES(BlockFacing.computeHash(false, false, false, true, false, true)),
Angle_EU(BlockFacing.computeHash(false, true, false, false, false, true)),
Angle_NU(BlockFacing.computeHash(false, true, true, false, false, false)),
Angle_NW(BlockFacing.computeHash(false, false, true, false, true, false)),
Angle_SU(BlockFacing.computeHash(false, true, false, true, false, false)),
Angle_SW(BlockFacing.computeHash(false, false, false, true, true, false)),
Angle_UW(BlockFacing.computeHash(false, true, false, false, true, false)),
Opposite_DU(BlockFacing.computeHash(true, true, false, false, false, false)),
Opposite_EW(BlockFacing.computeHash(false, false, false, false, true, true)),
Opposite_NS(BlockFacing.computeHash(false, false, true, true, false, false)),
CShape_DEU(BlockFacing.computeHash(true, true, false, false, false, true)),
CShape_DEW(BlockFacing.computeHash(true, false, false, false, true, true)),
CShape_DNS(BlockFacing.computeHash(true, false, true, true, false, false)),
CShape_DNU(BlockFacing.computeHash(true, true, true, false, false, false)),
CShape_DSU(BlockFacing.computeHash(true, true, false, true, false, false)),
CShape_DUW(BlockFacing.computeHash(true, true, false, false, true, false)),
CShape_ENS(BlockFacing.computeHash(false, false, true, true, false, true)),
CShape_ENW(BlockFacing.computeHash(false, false, true, false, true, true)),
CShape_ESW(BlockFacing.computeHash(false, false, false, true, true, true)),
CShape_EUW(BlockFacing.computeHash(false, true, false, false, true, true)),
CShape_NSU(BlockFacing.computeHash(false, true, true, true, false, false)),
CShape_NSW(BlockFacing.computeHash(false, false, true, true, true, false)),
Corner_DEN(BlockFacing.computeHash(true, false, true, false, false, true)),
Corner_DES(BlockFacing.computeHash(true, false, false, true, false, true)),
Corner_DNW(BlockFacing.computeHash(true, false, true, false, true, false)),
Corner_DSW(BlockFacing.computeHash(true, false, false, true, true, false)),
Corner_ENU(BlockFacing.computeHash(false, true, true, false, false, true)),
Corner_ESU(BlockFacing.computeHash(false, true, false, true, false, true)),
Corner_NUW(BlockFacing.computeHash(false, true, true, false, true, false)),
Corner_SUW(BlockFacing.computeHash(false, true, false, true, true, false)),
Misc_DENS(BlockFacing.computeHash(true, false, true, true, false, true)),
Misc_DENU(BlockFacing.computeHash(true, true, true, false, false, true)),
Misc_DENW(BlockFacing.computeHash(true, false, true, false, true, true)),
Misc_DESU(BlockFacing.computeHash(true, true, false, true, false, true)),
Misc_DESW(BlockFacing.computeHash(true, false, false, true, true, true)),
Misc_DNSW(BlockFacing.computeHash(true, false, true, true, true, false)),
Misc_DNUW(BlockFacing.computeHash(true, true, true, false, true, false)),
Misc_DSUW(BlockFacing.computeHash(true, true, false, true, true, false)),
Misc_ENSU(BlockFacing.computeHash(false, true, true, true, false, true)),
Misc_ENUW(BlockFacing.computeHash(false, true, true, false, true, true)),
Misc_ESUW(BlockFacing.computeHash(false, true, false, true, true, true)),
Misc_NSUW(BlockFacing.computeHash(false, true, true, true, true, false)),
Pipe_DEUW(BlockFacing.computeHash(true, true, false, false, true, true)),
Pipe_DNSU(BlockFacing.computeHash(true, true, true, true, false, false)),
Pipe_ENSW(BlockFacing.computeHash(false, false, true, true, true, true)),
PipeEnd_DENSU(BlockFacing.computeHash(true, true, true, true, false, true)),
PipeEnd_DENSW(BlockFacing.computeHash(true, false, true, true, true, true)),
PipeEnd_DENUW(BlockFacing.computeHash(true, true, true, false, true, true)),
PipeEnd_DESUW(BlockFacing.computeHash(true, true, false, true, true, true)),
PipeEnd_DNSUW(BlockFacing.computeHash(true, true, true, true, true, false)),
PipeEnd_ENSUW(BlockFacing.computeHash(false, true, true, true, false, true));
public static final EnumProperty FACINGS = EnumProperty.create("facings", BlockFacingProperty.class);
public static final EnumSet<BlockFacingProperty> ALL_AND_NONE;
public static final EnumSet<BlockFacingProperty> FACES;
public static final EnumSet<BlockFacingProperty> ANGLES;
public static final EnumSet<BlockFacingProperty> OPPOSITES;
public static final EnumSet<BlockFacingProperty> CSHAPES;
public static final EnumSet<BlockFacingProperty> CORNERS;
public static final EnumSet<BlockFacingProperty> MISCELLANEA;
public static final EnumSet<BlockFacingProperty> PIPES;
public static final EnumSet<BlockFacingProperty> PIPEENDS;
@Override
public String getName() {
return this.name;
}
BlockFacingProperty(byte hash) {
this.hash = hash;
this.name = this.toString().toLowerCase();
}
static {
ALL_AND_NONE = EnumSet.of(All, None);
FACES = EnumSet.of(Face_D, Face_E, Face_N, Face_S, Face_U, Face_W);
ANGLES = EnumSet.of(Angle_DE, Angle_DN, Angle_DS, Angle_DW, Angle_EN, Angle_ES, Angle_EU, Angle_NU, Angle_NW, Angle_SU, Angle_SW, Angle_UW);
OPPOSITES = EnumSet.of(Opposite_DU, Opposite_EW, Opposite_NS);
CSHAPES = EnumSet.of(CShape_DEU, CShape_DEW, CShape_DNS, CShape_DNU, CShape_DSU, CShape_DUW, CShape_ENS, CShape_ENW, CShape_ESW, CShape_EUW, CShape_NSU, CShape_NSW);
CORNERS = EnumSet.of(Corner_DEN, Corner_DES, Corner_DNW, Corner_DSW, Corner_ENU, Corner_ESU, Corner_NUW, Corner_SUW);
MISCELLANEA = EnumSet.of(Misc_DENS, Misc_DENU, Misc_DENW, Misc_DESU, Misc_DESW, Misc_DNSW, Misc_DNUW, Misc_DSUW, Misc_ENSU, Misc_ENUW, Misc_ESUW, Misc_NSUW);
PIPES = EnumSet.of(Pipe_DEUW, Pipe_DNSU, Pipe_ENSW);
PIPEENDS = EnumSet.of(PipeEnd_DENSU, PipeEnd_DENSW, PipeEnd_DENUW, PipeEnd_DESUW, PipeEnd_DNSUW, PipeEnd_ENSUW);
}
final byte hash;
private final String name;
}

View File

@ -0,0 +1,79 @@
package uk.gemwire.engage.api.multiblocks.bts;
import net.minecraft.world.World;
import uk.gemwire.engage.Engage;
import uk.gemwire.engage.api.multiblocks.iface.IMultiblockPart;
import uk.gemwire.engage.api.multiblocks.iface.IMultiblockRegistry;
import uk.gemwire.engage.api.multiblocks.te.MultiblockControllerBase;
import java.util.HashMap;
public class MultiblockRegistry implements IMultiblockRegistry {
private HashMap<World, MultiblockWorldRegistry> registries;
public static final MultiblockRegistry INSTANCE = new MultiblockRegistry();
private MultiblockRegistry() {
this.registries = new HashMap<>(2);
}
@Override
public void onPartAdded(final World world, final IMultiblockPart part) {
MultiblockWorldRegistry reg;
if(this.registries.containsKey(world)) {
reg = this.registries.get(world);
} else {
reg = new MultiblockWorldRegistry(world);
this.registries.put(world, reg);
}
reg.onPartAdded(part);
}
@Override
public void onPartRemoved(final World world, final IMultiblockPart part) {
if(this.registries.containsKey(world))
this.registries.get(world).onPartRemoved(part);
}
@Override
public void addDeadController(final World world, final MultiblockControllerBase controller) {
if(this.registries.containsKey(world))
this.registries.get(world).addDeadController(controller);
else
Engage.LOGGER.warn("Multiblock controller %d in world %d exists in an untracked world - assuming a glitch.", controller.hashCode(), world);
}
@Override
public void addDirtyController(final World world, final MultiblockControllerBase controller) {
if(this.registries.containsKey(world))
this.registries.get(world).addDirtyController(controller);
else
throw new IllegalArgumentException("Tried to update a controller in a world we don't track");
}
public void tickStart(final World world) {
if(this.registries.containsKey(world)) {
final MultiblockWorldRegistry reg = this.registries.get(world);
reg.processMultiblockChanges();
reg.tickStart();
}
}
public void onChunkLoaded(final World world, final int chunkX, final int chunkZ) {
if(this.registries.containsKey(world))
this.registries.get(world).onChunkLoaded(chunkX, chunkZ);
}
public void onWorldUnloaded(final World world) {
if(this.registries.containsKey(world)) {
this.registries.get(world).onWorldUnloaded();
this.registries.remove(world);
}
}
}

View File

@ -0,0 +1,293 @@
package uk.gemwire.engage.api.multiblocks.bts;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.AbstractChunkProvider;
import uk.gemwire.engage.Engage;
import uk.gemwire.engage.api.multiblocks.iface.IMultiblockPart;
import uk.gemwire.engage.api.multiblocks.te.MultiblockControllerBase;
import uk.gemwire.engage.misc.Helper;
import java.util.*;
final class MultiblockWorldRegistry {
private World worldObj;
private final Set<MultiblockControllerBase> controllers;
private final Set<MultiblockControllerBase> dirtyControllers;
private final Set<MultiblockControllerBase> deadControllers;
private Set<IMultiblockPart> orphanedParts;
private final Set<IMultiblockPart> detachedParts;
private final HashMap<Long, Set<IMultiblockPart>> partsAwaitingChunkLoad;
private final Object partsACLMutex;
private final Object orphanedPartsMutex;
public MultiblockWorldRegistry(final World world) {
worldObj = world;
controllers = new HashSet<MultiblockControllerBase>();
dirtyControllers = new HashSet<MultiblockControllerBase>();
deadControllers = new HashSet<MultiblockControllerBase>();
detachedParts = new HashSet<IMultiblockPart>();
orphanedParts = new HashSet<IMultiblockPart>();
partsAwaitingChunkLoad = new HashMap<Long, Set<IMultiblockPart>>();
partsACLMutex = new Object();
orphanedPartsMutex = new Object();
}
public void tickStart() {
if(controllers.size() > 0) {
for(MultiblockControllerBase controller : controllers) {
if(controller.WORLD == worldObj && controller.WORLD.isRemote == worldObj.isRemote) {
if(controller.isEmpty())
deadControllers.add(controller);
else
controller.updateMultiblockEntity();
}
}
}
}
public void processMultiblockChanges() {
BlockPos coord;
List<Set<MultiblockControllerBase>> mergePools = null;
if(orphanedParts.size() > 0) {
Set<IMultiblockPart> orphansToProcess = null;
synchronized (orphanedPartsMutex) {
if(orphanedParts.size() > 0) {
orphansToProcess = orphanedParts;
orphanedParts = new HashSet<IMultiblockPart>();
}
}
if(orphansToProcess != null && orphansToProcess.size() > 0) {
AbstractChunkProvider chunkProvider = this.worldObj.getChunkProvider();
Set<MultiblockControllerBase> compatibleControllers;
for(IMultiblockPart orphan : orphansToProcess) {
coord = orphan.getWorldPosition();
if(!this.worldObj.isBlockLoaded(coord)) continue;
if(!orphan.isPartValid()) continue;
if(this.getMultiblockPartFromWorld(worldObj, coord) != orphan) continue;
compatibleControllers = orphan.attachToControllers();
if(compatibleControllers == null) {
MultiblockControllerBase newController = orphan.createNewMultiblock();
newController.attachBlock(orphan);
this.controllers.add(newController);
} else if(compatibleControllers.size() > 1) {
if(mergePools == null) mergePools = new ArrayList<Set<MultiblockControllerBase>>();
boolean addedToPool = false;
List<Set<MultiblockControllerBase>> candidatePools = new ArrayList<Set<MultiblockControllerBase>>();
for(Set<MultiblockControllerBase> pool : mergePools) {
if(!Collections.disjoint(pool, compatibleControllers))
candidatePools.add(pool);
}
if(candidatePools.size() <= 0)
mergePools.add(compatibleControllers);
else if(candidatePools.size() == 1)
candidatePools.get(0).addAll(compatibleControllers);
else {
Set<MultiblockControllerBase> masterPool = candidatePools.get(0);
Set<MultiblockControllerBase> consumedPool;
for(int i = 1; i < candidatePools.size(); i++) {
consumedPool = candidatePools.get(i);
masterPool.addAll(consumedPool);
mergePools.remove(consumedPool);
}
masterPool.addAll(compatibleControllers);
}
}
}
}
}
if(mergePools != null && mergePools.size() > 0) {
for(Set<MultiblockControllerBase> mergePool : mergePools) {
MultiblockControllerBase master = null;
for(MultiblockControllerBase controller : mergePool) {
if(master == null || controller.shouldConsume(master)) {
master = controller;
}
}
if(master == null)
Engage.LOGGER.error("Multiblock system checked a merge candidate with no controller - this is impossible.");
else {
addDirtyController(master);
for(MultiblockControllerBase controller : mergePool) {
if(controller != master) {
master.assimilate(controller);
addDeadController(controller);
addDirtyController(master);
}
}
}
}
}
if(dirtyControllers.size() > 0) {
Set<IMultiblockPart> newlyDetachedParts = null;
for(MultiblockControllerBase controller : dirtyControllers) {
newlyDetachedParts = controller.checkForDisconnections();
if(!controller.isEmpty()) {
controller.recalculateBoundingBox();
controller.checkAssembled();
} else
addDeadController(controller);
if(newlyDetachedParts != null && newlyDetachedParts.size() > 0)
detachedParts.addAll(newlyDetachedParts);
}
dirtyControllers.clear();
}
if(deadControllers.size() > 0) {
for(MultiblockControllerBase controller : deadControllers) {
if(!controller.isEmpty()) {
Engage.LOGGER.error("Multiblock system killed a controller that still has parts. Forcing it to eat shit and die, because that's impossible.");
detachedParts.addAll(controller.detachAllBlocks());
}
this.controllers.remove(controller);
}
deadControllers.clear();
}
for(IMultiblockPart part : detachedParts)
part.assertDetached();
addAllOrphanedParts(detachedParts);
detachedParts.clear();
}
public void onPartAdded(final IMultiblockPart part) {
BlockPos worldLocation = part.getWorldPosition();
if(!this.worldObj.isBlockLoaded(worldLocation)) {
Set<IMultiblockPart> parts;
long chunkHash = Helper.chunkPosHash(worldLocation);
synchronized(partsACLMutex) {
if(!partsAwaitingChunkLoad.containsKey(chunkHash)) {
parts = new HashSet<IMultiblockPart>();
partsAwaitingChunkLoad.put(chunkHash, parts);
} else
parts = partsAwaitingChunkLoad.get(chunkHash);
parts.add(part);
}
} else
addOrphanedPart(part);
}
public void onPartRemoved(final IMultiblockPart part) {
final BlockPos loc = part.getWorldPosition();
if(loc != null) {
long chunkHash = Helper.chunkPosHash(loc);
synchronized (partsACLMutex) {
if(partsAwaitingChunkLoad.containsKey(chunkHash)) {
partsAwaitingChunkLoad.get(chunkHash).remove(part);
if(partsAwaitingChunkLoad.get(chunkHash).size() <= 0)
partsAwaitingChunkLoad.remove(chunkHash);
}
}
}
detachedParts.remove(part);
synchronized (orphanedPartsMutex) {
orphanedParts.remove(part);
}
part.assertDetached();
}
public void onWorldUnloaded() {
controllers.clear();
deadControllers.clear();
dirtyControllers.clear();
detachedParts.clear();
synchronized (partsACLMutex) {
partsAwaitingChunkLoad.clear();
}
synchronized (orphanedPartsMutex) {
orphanedParts.clear();
}
worldObj = null;
}
public void onChunkLoaded(final int chunkX, final int chunkZ) {
final long chunkHash = ChunkPos.asLong(chunkX, chunkZ);
synchronized (partsACLMutex) {
if(partsAwaitingChunkLoad.containsKey(chunkHash)) {
addAllOrphanedParts(partsAwaitingChunkLoad.get(chunkHash));
partsAwaitingChunkLoad.remove(chunkHash);
}
}
}
public void addDeadController(MultiblockControllerBase controller) {
this.deadControllers.add(controller);
}
public void addDirtyController(MultiblockControllerBase controller) {
this.dirtyControllers.add(controller);
}
public Set<MultiblockControllerBase> getControllers() {
return Collections.unmodifiableSet(controllers);
}
private void addOrphanedPart(final IMultiblockPart part) {
synchronized (orphanedPartsMutex) {
orphanedParts.add(part);
}
}
private void addAllOrphanedParts(final Collection<? extends IMultiblockPart> parts) {
synchronized (orphanedPartsMutex) {
orphanedParts.addAll(parts);
}
}
protected IMultiblockPart getMultiblockPartFromWorld(final World world, final BlockPos pos) {
TileEntity te = world.getTileEntity(pos);
return te instanceof IMultiblockPart ? (IMultiblockPart) te : null;
}
}

View File

@ -0,0 +1,61 @@
package uk.gemwire.engage.api.multiblocks.bts;
import net.minecraft.state.EnumProperty;
import net.minecraft.util.Direction;
import net.minecraft.util.IStringSerializable;
public enum PartPosition implements IStringSerializable {
Unknown(null, Type.Unknown),
Interior(null, Type.Unknown),
FrameCorner(null, Type.Frame),
FrameEastWest(null, Type.Frame),
FrameSouthNorth(null, Type.Frame),
FrameUpDown(null, Type.Frame),
TopFace(Direction.UP, Type.Face),
BottomFace(Direction.DOWN, Type.Face),
NorthFace(Direction.NORTH, Type.Face),
SouthFace(Direction.SOUTH, Type.Face),
EastFace(Direction.EAST, Type.Face),
WestFace(Direction.WEST, Type.Face);
public enum Type {
Unknown,
Interior,
Frame,
Face
}
public boolean isFace() {
return this.type == Type.Face;
}
public boolean isFrame() {
return this.type == Type.Frame;
}
public Direction getDir() {
return this.dir;
}
public Type getType() {
return this.type;
}
public static EnumProperty createProperty(String name) {
return EnumProperty.create(name, PartPosition.class);
}
@Override
public String getName() {
return this.toString();
}
PartPosition(Direction dir, Type type) {
this.dir = dir;
this.type = type;
}
private Direction dir;
private Type type;
}

View File

@ -0,0 +1,62 @@
package uk.gemwire.engage.api.multiblocks.iface;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.math.BlockPos;
import uk.gemwire.engage.api.multiblocks.te.MultiblockControllerBase;
import java.util.Set;
public interface IMultiblockPart {
boolean isConnected();
MultiblockControllerBase getMultiblockController();
BlockPos getWorldPosition();
boolean isPartValid();
void onAttached(MultiblockControllerBase newController);
void onDetached(MultiblockControllerBase controller);
void onOrphaned(MultiblockControllerBase controller, int oldMultiblockSize, int newMultiblockSize);
MultiblockControllerBase createNewMultiblock();
Class<? extends MultiblockControllerBase> getMultiblockControllerType();
void onAssimilated(MultiblockControllerBase newController);
void setVisited();
void setUnvisited();
boolean isVisited();
void becomeMultiblockSaveDelegate();
void forfeitMultiblockSaveDelegate();
boolean isMultiblockSaveDelegate();
IMultiblockPart[] getNeighboringParts();
void onMachineAssembled(MultiblockControllerBase controller);
void onMachineBroken();
void onMachineActivated();
void onMachineDeactivated();
Set<MultiblockControllerBase> attachToControllers();
void assertDetached();
boolean hasMultiblockSaveData();
CompoundNBT getMultiblockSaveDate();
void onMultiblockDataAssimilated();
}

View File

@ -0,0 +1,15 @@
package uk.gemwire.engage.api.multiblocks.iface;
import net.minecraft.world.World;
import uk.gemwire.engage.api.multiblocks.te.MultiblockControllerBase;
public interface IMultiblockRegistry {
void onPartAdded(World world, IMultiblockPart part);
void onPartRemoved(World world, IMultiblockPart part);
void addDeadController(World world, MultiblockControllerBase controller);
void addDirtyController(World world, MultiblockControllerBase controller);
}

View File

@ -0,0 +1,683 @@
package uk.gemwire.engage.api.multiblocks.te;
import net.minecraft.client.Minecraft;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.AbstractChunkProvider;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import uk.gemwire.engage.Engage;
import uk.gemwire.engage.api.multiblocks.bts.MultiblockRegistry;
import uk.gemwire.engage.api.multiblocks.iface.IMultiblockPart;
import uk.gemwire.engage.api.multiblocks.iface.IMultiblockRegistry;
import uk.gemwire.engage.api.multiblocks.validation.IMultiblockValidator;
import uk.gemwire.engage.api.multiblocks.validation.ValidationError;
import uk.gemwire.engage.blocks.ModTileEntity;
import uk.gemwire.engage.misc.Helper;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
public abstract class MultiblockControllerBase implements IMultiblockValidator {
public final World WORLD;
private static final IMultiblockRegistry REGISTRY;
static {
REGISTRY = MultiblockRegistry.INSTANCE;
}
protected enum AssembledState {Disassembled, Assembled, Paused}
protected AssembledState assembledState;
// Every block that makes up this multiblock
protected HashSet<IMultiblockPart> connectedParts;
// UID of the multiblock
private BlockPos referenceCoord;
// Rectangular bounding box
private BlockPos minCoord;
private BlockPos maxCoord;
// A flag to keep track of changes
private boolean needsChecked;
private ValidationError lastValidationError;
private boolean debugMode;
protected MultiblockControllerBase(World world) {
WORLD = world;
connectedParts = new HashSet<IMultiblockPart>();
referenceCoord = null;
assembledState = AssembledState.Disassembled;
minCoord = null;
maxCoord = null;
needsChecked = true;
lastValidationError = null;
debugMode = false;
}
public void setDebugMode(boolean debugMode) {
this.debugMode = debugMode;
}
public boolean isDebugMode() {
return debugMode;
}
public abstract void onAttachedPartWithMultiblockData(IMultiblockPart part, CompoundNBT data);
public boolean hasBlock(BlockPos block) {
return connectedParts.contains(block);
}
public void attachBlock(IMultiblockPart part) {
IMultiblockPart candidate;
BlockPos coord = part.getWorldPosition();
Engage.LOGGER.warn("[%s] Multiblock Controller %s is double-adding part %d @ %s. If issues arise, try breaking and re-placing the block.",
(WORLD.isRemote ? "CLIENT" : "SERVER"), hashCode(), part.hashCode(), coord);
part.onAttached(this);
this.onBlockAdded(part);
if(part.hasMultiblockSaveData()) {
CompoundNBT savedData = part.getMultiblockSaveDate();
onAttachedPartWithMultiblockData(part, savedData);
part.onMultiblockDataAssimilated();
}
if(this.referenceCoord == null) {
referenceCoord = coord;
part.becomeMultiblockSaveDelegate();
} else if(coord.compareTo(referenceCoord) < 0) {
TileEntity te = this.WORLD.getTileEntity(referenceCoord);
((IMultiblockPart)te).forfeitMultiblockSaveDelegate();
referenceCoord = coord;
part.becomeMultiblockSaveDelegate();
} else {
part.forfeitMultiblockSaveDelegate();
}
BlockPos partPos = part.getWorldPosition();
int curX, curY, curZ;
int newX, newY, newZ;
int partCoord;
if(this.minCoord != null) {
curX = this.minCoord.getX();
curY = this.minCoord.getY();
curZ = this.minCoord.getZ();
partCoord = partPos.getX();
newX = partCoord < curX ? partCoord : curX;
partCoord = partPos.getY();
newY = partCoord < curY ? partCoord : curY;
partCoord = partPos.getZ();
newZ = partCoord < curZ ? partCoord : curZ;
if((newX != curX) || (newY != curY) || newZ != curZ)
this.minCoord = new BlockPos(newX, newY, newZ);
}
if(this.maxCoord != null) {
curX = this.maxCoord.getX();
curY = this.maxCoord.getY();
curZ = this.maxCoord.getZ();
partCoord = partPos.getX();
newX = partCoord < curX ? partCoord : curX;
partCoord = partPos.getY();
newY = partCoord < curY ? partCoord : curY;
partCoord = partPos.getZ();
newZ = partCoord < curZ ? partCoord : curZ;
if((newX != curX) || (newY != curY) || newZ != curZ)
this.maxCoord = new BlockPos(newX, newY, newZ);
}
REGISTRY.addDirtyController(WORLD, this);
}
protected abstract void onBlockAdded(IMultiblockPart part);
protected abstract void onBlockRemoved(IMultiblockPart part);
protected abstract void onMachineAssembled();
protected abstract void onMachineRestored();
protected abstract void onMachinePaused();
protected abstract void onMachineDisassembled();
private void onDetachBlock(IMultiblockPart part) {
part.onDetached(this);
this.onBlockRemoved(part);
part.forfeitMultiblockSaveDelegate();
minCoord = maxCoord = null;
if(referenceCoord != null && referenceCoord.equals(part.getWorldPosition())) {
referenceCoord = null;
}
needsChecked = true;
}
public void detachBlock(IMultiblockPart part, boolean causedByChunkLoading) {
if(causedByChunkLoading && assembledState == AssembledState.Assembled) {
this.assembledState = AssembledState.Paused;
this.onMachinePaused();
}
onDetachBlock(part);
if(!connectedParts.remove(part)) {
BlockPos position = part.getWorldPosition();
Engage.LOGGER.warn("[%s] Block (%d) at %d, %d, %d is anomalous - if it causes issues, break it and replace it.",
(WORLD.isRemote ? "CLIENT" : "SERVER"), part.hashCode(), position.getX(), position.getY(), position.getZ());
}
if(connectedParts.isEmpty()) {
REGISTRY.addDeadController(this.WORLD, this);
return;
}
REGISTRY.addDirtyController(this.WORLD, this);
if(referenceCoord == null) {
selectNewReferenceCoord();
}
}
protected abstract int getMinBlocksInFullMachine();
protected abstract int getMaxXSize();
protected abstract int getMaxZSize();
protected abstract int getMaxYSize();
protected int getMinXSize() {return 1;}
protected int getMinZSize() {return 1;}
protected int getMinYSize() {return 1;}
@Override
public ValidationError getLastError() {
return this.lastValidationError;
}
@Override
public void setLastError(ValidationError error) {
if(error == null)
throw new IllegalArgumentException("Multiblock Controller was given an empty error");
this.lastValidationError = error;
}
@Override
public void setLastError(String format, Object... params) {
this.lastValidationError = new ValidationError(format, params);
}
protected abstract boolean isMachineWhole(IMultiblockValidator validatorCallback);
public void checkAssembled() {
AssembledState oldState = this.assembledState;
this.lastValidationError = null;
if(this.isMachineWhole(this)) {
assembleMachine(oldState);
} else if(oldState == AssembledState.Assembled) {
disassembleMachine();
}
}
private void assembleMachine(AssembledState oldState) {
for(IMultiblockPart part : connectedParts) {
part.onMachineAssembled(this);
}
this.assembledState = AssembledState.Assembled;
if(oldState == AssembledState.Paused) {
onMachineRestored();
} else {
onMachineAssembled();
}
}
private void disassembleMachine() {
for(IMultiblockPart part : connectedParts) {
part.onMachineBroken();
}
this.assembledState = AssembledState.Disassembled;
onMachineDisassembled();
}
public void assimilate(MultiblockControllerBase oldController) {
BlockPos oldControllerRefPos = oldController.getReferenceCoord();
if(oldControllerRefPos != null && getReferenceCoord().compareTo(oldControllerRefPos) >= 0)
throw new IllegalArgumentException("Controller with higher reference tried to assimilate a controller with a lower reference.");
TileEntity te;
Set<IMultiblockPart> partsToAcquire = new HashSet<IMultiblockPart>(oldController.connectedParts);
oldController._onAssimilated(this);
for(IMultiblockPart part : partsToAcquire) {
if(!part.isPartValid()) continue;
connectedParts.add(part);
part.onAssimilated(this);
this.onBlockAdded(part);
}
this.onAssimilate(oldController);
oldController.onAssimilated(this);
}
private void _onAssimilated(MultiblockControllerBase otherController) {
if(referenceCoord != null) {
if(this.WORLD.isBlockLoaded(this.referenceCoord)) {
TileEntity te = this.WORLD.getTileEntity(this.referenceCoord);
if(te instanceof IMultiblockPart) {
((IMultiblockPart)te).forfeitMultiblockSaveDelegate();
}
}
this.referenceCoord = null;
}
connectedParts.clear();
}
protected abstract void onAssimilate(MultiblockControllerBase assimilatedController);
protected abstract void onAssimilated(MultiblockControllerBase asssimilatorController);
public final void updateMultiblockEntity() {
if(connectedParts.isEmpty()) {
REGISTRY.addDeadController(this.WORLD, this);
return;
}
if(this.assembledState != AssembledState.Assembled) {
return;
}
if(WORLD.isRemote) {
updateClient();
} else if(updateServer()) {
if(minCoord != null && maxCoord != null &&
this.WORLD.isAreaLoaded(this.minCoord, this.maxCoord)) {
int minChunkX = Helper.blockToChunkX(this.minCoord);
int minChunkZ = Helper.blockToChunkZ(this.minCoord);
int maxChunkX = Helper.blockToChunkX(this.maxCoord);
int maxChunkZ = Helper.blockToChunkZ(this.maxCoord);
for(int x = minChunkX; x <= maxChunkX; x++) {
for(int z = minChunkZ; z <= maxChunkZ; z++) {
Chunk dirtyChunk = this.WORLD.getChunk(x, z);
dirtyChunk.setModified(true);
}
}
}
}
}
protected abstract void updateClient();
protected abstract boolean updateServer();
protected abstract boolean isBlockGoodForFrame(World world, int x, int y, int z, IMultiblockValidator validatorCallback);
protected abstract boolean isBlockGoodForTop(World world, int x, int y, int z, IMultiblockValidator validatorCallback);
protected abstract boolean isBlockGoodForBottom(World world, int x, int y, int z, IMultiblockValidator validatorCallback);
protected abstract boolean isBlockGoodForSides(World world, int x, int y, int z, IMultiblockValidator validatorCallback);
protected abstract boolean isBlockGoodForInterior(World world, int x, int y, int z, IMultiblockValidator validatorCallback);
public BlockPos getReferenceCoord() {
if(referenceCoord == null) selectNewReferenceCoord();
return referenceCoord;
}
public int getNumConnectedBlocks() {
return connectedParts.size();
}
public abstract void syncDataFrom(CompoundNBT data, ModTileEntity.SyncReason syncReason);
public abstract void syncDataTo(CompoundNBT data, ModTileEntity.SyncReason syncReason);
public void recalculateBoundingBox() {
int minX, minY, minZ, maxX, maxY, maxZ;
int partCoord;
BlockPos partPos;
minX = minY = minZ = Integer.MAX_VALUE;
maxX = maxY = maxZ = Integer.MIN_VALUE;
for(IMultiblockPart part : this.connectedParts) {
partPos = part.getWorldPosition();
partCoord = partPos.getX();
if(partCoord < minX) minX = partCoord;
if(partCoord > maxX) maxX = partCoord;
partCoord = partPos.getY();
if(partCoord < minY) minY = partCoord;
if(partCoord > maxY) maxY = partCoord;
partCoord = partPos.getZ();
if(partCoord < minZ) minZ = partCoord;
if(partCoord > maxZ) maxZ = partCoord;
}
this.minCoord = new BlockPos(minX, minY, minZ);
this.maxCoord = new BlockPos(maxX, maxY, maxZ);
}
public BlockPos getMinCoord() {
if(minCoord == null) recalculateBoundingBox();
return minCoord;
}
public BlockPos getMaxCoord() {
if(maxCoord == null) recalculateBoundingBox();
return maxCoord;
}
public boolean isEmpty() {
return connectedParts.isEmpty();
}
public boolean shouldConsume(MultiblockControllerBase otherController) {
if (!otherController.getClass().equals(getClass())) {
throw new IllegalArgumentException("Attempted to merge two different multiblocks - what?");
}
if (otherController == this) {
return false;
}
int res = _shouldConsume(otherController);
if (res < 0) return true;
else if (res > 0) return false;
else {
Engage.LOGGER.warn("[%s] A multiblock controller tried to consume itself - assuming this means it wants to check for valid parts.", this.WORLD.isRemote ? "CLIENT" : "SERVER");
auditParts();
otherController.auditParts();
res = _shouldConsume(otherController);
if (res < 0) return true;
else if (res > 0) return false;
else {
Engage.LOGGER.error("Controller (%d): size (%d), parts (%d)", hashCode(), connectedParts.size(), this.getPartsListString());
Engage.LOGGER.error("Other Controller (%d): size (%d), parts (%d)", otherController.hashCode(), otherController.connectedParts.size(), otherController.getPartsListString());
throw new IllegalArgumentException("[" + (this.WORLD.isRemote ? "CLIENT" : "SERVER") + "] Two valid Multiblock controllers at the same location tried to assimilate each other - Something is wrong!");
}
}
}
private int _shouldConsume(MultiblockControllerBase otherController) {
BlockPos myCoord = getReferenceCoord();
BlockPos theirCoord = otherController.getReferenceCoord();
if(theirCoord == null) return -1;
else return myCoord.compareTo(theirCoord);
}
private String getPartsListString() {
StringBuilder builder = new StringBuilder();
boolean first = true;
BlockPos partPos;
for(IMultiblockPart part : connectedParts) {
if(!first) {
builder.append(", ");
}
partPos = part.getWorldPosition();
builder.append(String.format("(%d: %d, %d, %d)", part.hashCode(), partPos.getX(), partPos.getY(), partPos.getZ()));
first = false;
}
return builder.toString();
}
private void auditParts() {
HashSet<IMultiblockPart> deadParts = new HashSet<IMultiblockPart>();
for(IMultiblockPart part : connectedParts) {
if(!part.isPartValid() || WORLD.getTileEntity(part.getWorldPosition()) != part) {
onDetachBlock(part);
deadParts.add(part);
}
}
connectedParts.removeAll(deadParts);
Engage.LOGGER.warn("[%s] Multiblock controller found %d dead parts during an audit, leaving %d parts.", (WORLD.isRemote ? "CLIENT" : "SERVER"), deadParts.size(), connectedParts.size());
}
public Set<IMultiblockPart> checkForDisconnections() {
if(!needsChecked) return null;
if(this.isEmpty()) {
REGISTRY.addDeadController(WORLD, this);
return null;
}
TileEntity te;
AbstractChunkProvider chunkProvider = WORLD.getChunkProvider();
referenceCoord = null;
Set<IMultiblockPart> deadParts = new HashSet<IMultiblockPart>();
BlockPos position;
IMultiblockPart refPart = null;
int originalSize = connectedParts.size();
for(IMultiblockPart part : connectedParts) {
position = part.getWorldPosition();
if ((!this.WORLD.isBlockLoaded(position)) || (!part.isPartValid()) || (WORLD.getTileEntity(position) != part)) {
deadParts.add(part);
onDetachBlock(part);
continue;
}
part.setUnvisited();
part.forfeitMultiblockSaveDelegate();
if(referenceCoord == null) {
referenceCoord = position;
refPart = part;
} else if(position.compareTo(referenceCoord) < 0) {
referenceCoord = position;
refPart = part;
}
}
connectedParts.removeAll(deadParts);
deadParts.clear();
if(refPart == null || isEmpty()) {
needsChecked = false;
REGISTRY.addDeadController(WORLD, this);
return null;
} else {
refPart.becomeMultiblockSaveDelegate();
}
IMultiblockPart part;
LinkedList<IMultiblockPart> partsToCheck = new LinkedList<IMultiblockPart>();
IMultiblockPart[] nearbyParts = null;
int visitedParts = 0;
partsToCheck.add(refPart);
while(!partsToCheck.isEmpty()) {
part = partsToCheck.removeFirst();
part.setVisited();
visitedParts++;
nearbyParts = part.getNeighboringParts();
for (IMultiblockPart nearbyPart: nearbyParts) {
if(nearbyPart.getMultiblockController() != this) {
continue;
}
if(!nearbyPart.isVisited()) {
nearbyPart.setVisited();
partsToCheck.add(nearbyPart);
}
}
}
Set<IMultiblockPart> removedParts = new HashSet<IMultiblockPart>();
for(IMultiblockPart orphanCandidate : connectedParts) {
if(!orphanCandidate.isVisited()) {
deadParts.add(orphanCandidate);
orphanCandidate.onOrphaned(this, originalSize, visitedParts);
onDetachBlock(orphanCandidate);
removedParts.add(orphanCandidate);
}
}
connectedParts.removeAll(deadParts);
deadParts.clear();
if(referenceCoord == null) {
selectNewReferenceCoord();
}
needsChecked = false;
return removedParts;
}
public Set<IMultiblockPart> detachAllBlocks() {
if(WORLD == null) return new HashSet<IMultiblockPart>();
for(IMultiblockPart part : connectedParts) {
if(this.WORLD.isBlockLoaded(part.getWorldPosition()))
onDetachBlock(part);
}
Set<IMultiblockPart> detachedParts = connectedParts;
connectedParts = new HashSet<IMultiblockPart>();
return detachedParts;
}
public boolean isAssembled() {
return this.assembledState == AssembledState.Assembled;
}
private void selectNewReferenceCoord() {
IMultiblockPart pickedPart = null;
BlockPos pos;
referenceCoord = null;
for(IMultiblockPart part : connectedParts) {
pos = part.getWorldPosition();
if(!part.isPartValid() || !this.WORLD.isBlockLoaded(pos))
continue;
if(referenceCoord == null || referenceCoord.compareTo(pos) > 0) {
referenceCoord = pos;
pickedPart = part;
}
}
if(pickedPart != null) {
pickedPart.becomeMultiblockSaveDelegate();
}
}
protected void markReferenceCoordForUpdate() {
BlockPos pos = this.getReferenceCoord();
if((this.WORLD != null) && (pos != null))
Helper.notifyBlockUpdate(this.WORLD, pos, null, null);
}
protected void markReferenceCoordDirty() {
if(WORLD == null || WORLD.isRemote) return;
BlockPos referenceCoord = this.getReferenceCoord();
if(referenceCoord == null) return;
TileEntity te = WORLD.getTileEntity(referenceCoord);
WORLD.markChunkDirty(referenceCoord, te);
}
@OnlyIn(Dist.CLIENT)
protected void markMultiblockForRenderUpdate() {
Minecraft.getInstance().worldRenderer.markBlockRangeForRenderUpdate(this.minCoord.getX(), this.minCoord.getY(), this.minCoord.getZ(), this.maxCoord.getX(), this.maxCoord.getY(), this.maxCoord.getZ());
}
}

View File

@ -0,0 +1,255 @@
package uk.gemwire.engage.api.multiblocks.te;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import uk.gemwire.engage.Engage;
import uk.gemwire.engage.api.multiblocks.bts.MultiblockRegistry;
import uk.gemwire.engage.api.multiblocks.iface.IMultiblockPart;
import uk.gemwire.engage.blocks.ModTileEntity;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public abstract class MultiblockTileEntityBase extends ModTileEntity implements IMultiblockPart {
private MultiblockControllerBase controller;
private boolean visited;
private boolean saveMultiblockData;
private CompoundNBT cachedData;
private boolean paused;
public MultiblockTileEntityBase(TileEntityType<?> type) {
super(type);
controller = null;
visited = false;
saveMultiblockData = false;
paused = false;
cachedData = null;
}
@Override
protected void syncDataFrom(CompoundNBT data, SyncReason reason) {
if(reason == SyncReason.FullSync) {
if(data.contains("multiblockData"))
this.cachedData = data.getCompound("multiblockData");
} else {
if(data.contains("multiblockData")) {
CompoundNBT tag = data.getCompound("mutliblockData");
if(isConnected())
getMultiblockController().syncDataFrom(tag, reason);
else
this.cachedData = tag;
}
}
}
@Override
protected void syncDataTo(CompoundNBT data, SyncReason reason) {
if(reason == SyncReason.FullSync) {
if(isMultiblockSaveDelegate() && isConnected()) {
CompoundNBT multiblockData = new CompoundNBT();
this.controller.syncDataTo(multiblockData, reason);
data.put("multiblockData", multiblockData);
}
} else {
if(isMultiblockSaveDelegate() && isConnected()) {
CompoundNBT tag = new CompoundNBT();
getMultiblockController().syncDataTo(tag, reason);
data.put("multiblockData", tag);
}
}
}
@Override
public Set<MultiblockControllerBase> attachToControllers() {
Set<MultiblockControllerBase> controllers = null;
MultiblockControllerBase bestController = null;
IMultiblockPart[] partsToCheck = getNeighboringParts();
for(IMultiblockPart neighborPart : partsToCheck) {
if(neighborPart.isConnected()) {
MultiblockControllerBase candidate = neighborPart.getMultiblockController();
if(!candidate.getClass().equals(this.getMultiblockControllerType()))
continue;
if(controllers == null) {
controllers = new HashSet<MultiblockControllerBase>();
bestController = candidate;
} else if(!controllers.contains(candidate) && candidate.shouldConsume(bestController))
bestController = candidate;
}
}
if(bestController != null) {
this.controller = bestController;
bestController.attachBlock(this);
}
return controllers;
}
@Override
public void assertDetached() {
if(this.controller != null) {
BlockPos coord = this.getWorldPosition();
Engage.LOGGER.info("[assert] Multiblock part at (%d %d %d) thinks it should have detached from the main structure at (%d %d %d), but it hasn't. This will be corrected with the ESAD method.", coord.getX(), coord.getY(), coord.getZ(), controller.getReferenceCoord().getX(), controller.getReferenceCoord().getY(), controller.getReferenceCoord().getZ());
this.controller = null;
}
}
@Override
public void onChunkUnloaded() {
super.onChunkUnloaded();
detachSelf(true);
}
@Override
public void validate() {
super.validate();
MultiblockRegistry.INSTANCE.onPartAdded(this.world, this);
}
@Override
public boolean hasMultiblockSaveData() {
return this.cachedData != null;
}
@Override
public CompoundNBT getMultiblockSaveDate() {
return cachedData;
}
@Override
public void onMultiblockDataAssimilated() {
this.cachedData = null;
}
@Override
public abstract void onMachineAssembled(MultiblockControllerBase controller);
@Override
public abstract void onMachineBroken();
@Override
public abstract void onMachineActivated();
@Override
public abstract void onMachineDeactivated();
@Override
public boolean isConnected() {
return (controller != null);
}
@Override
public MultiblockControllerBase getMultiblockController() {
return controller;
}
@Override
public void becomeMultiblockSaveDelegate() {
this.saveMultiblockData = true;
}
@Override
public void forfeitMultiblockSaveDelegate() {
this.saveMultiblockData = false;
}
@Override
public boolean isMultiblockSaveDelegate() {
return this.saveMultiblockData;
}
@Override
public void setUnvisited() {
this.visited = false;
}
@Override
public void setVisited() {
this.visited = true;
}
@Override
public boolean isVisited() {
return visited;
}
@Override
public void onAssimilated(MultiblockControllerBase newController) {
assert (this.controller != newController);
this.controller = newController;
}
@Override
public void onAttached(MultiblockControllerBase newController) {
this.controller = newController;
}
@Override
public void onDetached(MultiblockControllerBase controller) {
this.controller = null;
}
@Override
public abstract MultiblockControllerBase createNewMultiblock();
@Override
public IMultiblockPart[] getNeighboringParts() {
TileEntity te;
List<IMultiblockPart> parts = new ArrayList<IMultiblockPart>();
BlockPos neighborPos, partPos = this.getWorldPosition();
for(Direction dir : Direction.values()) {
neighborPos = partPos.offset(dir);
te = this.world.getTileEntity(neighborPos);
if(te instanceof IMultiblockPart)
parts.add((IMultiblockPart)te);
}
return parts.toArray(new IMultiblockPart[parts.size()]);
}
@Override
public void onOrphaned(MultiblockControllerBase controller, int oldMultiblockSize, int newMultiblockSize) {
this.markDirty();
world.markChunkDirty(this.getWorldPosition(), this);
}
@Override
public BlockPos getWorldPosition() {
return this.pos;
}
@Override
public boolean isPartValid() {
return !this.isRemoved();
}
public void notifyNeighborsOfBlockChange() {
world.notifyNeighborsOfStateChange(this.getWorldPosition(), this.getBlockState().getBlock());
}
protected void detachSelf(boolean chunkUnloading) {
if(this.controller != null) {
this.controller.detachBlock(this, chunkUnloading);
this.controller = null;
}
MultiblockRegistry.INSTANCE.onPartRemoved(world, this);
}
}

View File

@ -0,0 +1,148 @@
package uk.gemwire.engage.api.multiblocks.te.rectangular;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import uk.gemwire.engage.api.multiblocks.te.MultiblockControllerBase;
import uk.gemwire.engage.api.multiblocks.validation.IMultiblockValidator;
import uk.gemwire.engage.api.multiblocks.validation.ValidationError;
public abstract class RectangularMultiblockControllerBase extends MultiblockControllerBase {
protected RectangularMultiblockControllerBase(World world) {
super(world);
}
@Override
protected boolean isMachineWhole(IMultiblockValidator validatorCallback) {
if(connectedParts.size() < getMinBlocksInFullMachine()) {
validatorCallback.setLastError(ValidationError.MULTIBLOCK_INCOMPLETE);
return false;
}
BlockPos maxCoord = this.getMaxCoord();
BlockPos minCoord = this.getMinCoord();
int minX = minCoord.getX();
int minY = minCoord.getY();
int minZ = minCoord.getZ();
int maxX = maxCoord.getX();
int maxY = maxCoord.getY();
int maxZ = maxCoord.getZ();
int deltaX = maxX - minX + 1;
int deltaY = maxY - minY + 1;
int deltaZ = maxZ - minZ + 1;
int maxXSize = this.getMaxXSize();
int maxYSize = this.getMaxYSize();
int maxZSize = this.getMaxZSize();
int minXSize = this.getMinXSize();
int minYSize = this.getMinYSize();
int minZSize = this.getMinZSize();
if(maxXSize > 0 && deltaX > maxXSize) { validatorCallback.setLastError("engage:mblock.error.too_big", maxXSize, "x"); return false; }
if(maxYSize > 0 && deltaY > maxYSize) { validatorCallback.setLastError("engage:mblock.error.too_big", maxYSize, "y"); return false; }
if(maxZSize > 0 && deltaZ > maxZSize) { validatorCallback.setLastError("engage:mblock.error.too_big", maxZSize, "z"); return false; }
if(deltaX < minXSize) { validatorCallback.setLastError("engage:mblock.error.too_small", minXSize, "x"); return false; }
if(deltaY < minYSize) { validatorCallback.setLastError("engage:mblock.error.too_small", minYSize, "y"); return false; }
if(deltaZ < minZSize) { validatorCallback.setLastError("engage:mblock.error.too_small", minZSize, "z"); return false; }
TileEntity te;
RectangularMultiblockTileEntityBase part;
Class<? extends RectangularMultiblockControllerBase> controllerClass = this.getClass();
int extremes;
boolean partValid;
for(int x = minX; x <= maxX; x++) {
for(int y = minY; y <= maxY; y++) {
for(int z = minZ; z <= maxZ; z++){
te = this.WORLD.getTileEntity(new BlockPos(x, y, z));
if(te instanceof RectangularMultiblockTileEntityBase) {
part = (RectangularMultiblockTileEntityBase) te;
if(!controllerClass.equals(part.getMultiblockControllerType())) {
validatorCallback.setLastError("engage:mblock.error.invalid_part", x, y, z);
return false;
}
} else
part = null;
extremes = 0;
if(x == minX)
extremes++;
if(y == minY)
extremes++;
if(z == minZ)
extremes++;
if(x == maxX)
extremes++;
if(y == maxY)
extremes++;
if(z == maxZ)
extremes++;
if(extremes >= 2) {
partValid = part != null ? part.isGoodForFrame(validatorCallback) : this.isBlockGoodForFrame(this.WORLD, x, y, z, validatorCallback);
if(!partValid) {
if(validatorCallback.getLastError() == null)
validatorCallback.setLastError("engage:mblock.error.invalid_frame_part", x, y, z);
return false;
}
} else if(extremes == 1) {
if(y == maxY) {
partValid = part != null ? part.isGoodForTop(validatorCallback) : this.isBlockGoodForTop(this.WORLD, x, y, z, validatorCallback);
if(!partValid) {
if(validatorCallback.getLastError() == null)
validatorCallback.setLastError("engage:mblock.error.invalid_top_part", x, y, z);
return false;
}
} else if(y == minY) {
partValid = part != null ? part.isGoodForBottom(validatorCallback) : this.isBlockGoodForBottom(this.WORLD, x, y, z, validatorCallback);
if(!partValid) {
if(validatorCallback.getLastError() == null)
validatorCallback.setLastError("engage:mblock.error.invalid_bottom_part", x, y, z);
return false;
}
} else {
partValid = part != null ? part.isGoodForSides(validatorCallback) : this.isBlockGoodForSides(this.WORLD, x, y, z, validatorCallback);
if(!partValid) {
if(validatorCallback.getLastError() == null)
validatorCallback.setLastError("engage:mblock.error.invalid_side_part", x, y, z);
return false;
}
}
} else {
partValid = part != null ? part.isGoodForInterior(validatorCallback) : this.isBlockGoodForInterior(this.WORLD, x, y, z, validatorCallback);
if(!partValid) {
if(validatorCallback.getLastError() == null)
validatorCallback.setLastError("engage:mblock.error.invalid_interior_part", x, y, z);
return false;
}
}
}
}
}
return true;
}
}

View File

@ -0,0 +1,149 @@
package uk.gemwire.engage.api.multiblocks.te.rectangular;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import uk.gemwire.engage.api.multiblocks.bts.BlockFacing;
import uk.gemwire.engage.api.multiblocks.bts.PartPosition;
import uk.gemwire.engage.api.multiblocks.te.MultiblockControllerBase;
import uk.gemwire.engage.api.multiblocks.te.MultiblockTileEntityBase;
import uk.gemwire.engage.api.multiblocks.validation.IMultiblockValidator;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public abstract class RectangularMultiblockTileEntityBase extends MultiblockTileEntityBase {
private PartPosition pos;
private BlockFacing facing;
public RectangularMultiblockTileEntityBase(TileEntityType<?> type) {
super(type);
// pos = PartPosition.Unknown;
// facing = BlockFacing.NONE;
}
@Nonnull
public BlockFacing getOutDir() {
return facing;
}
@Nonnull
public PartPosition getPartPosition() {
return pos;
}
@Nullable
public Direction getOutwardDirection() {
Direction dir = this.pos != null ? this.pos.getDir() : null;
if(dir == null) {
BlockFacing out = this.getOutDir();
if(!out.none() && out.countFacesIf(true) == 1)
dir = out.firstIf(true);
}
return dir;
}
@Nullable
public Direction getOutwardDirectionFromWorldPosition() {
BlockFacing facing = null;
MultiblockControllerBase controller = this.getMultiblockController();
if(controller != null) {
BlockPos position = this.getWorldPosition();
BlockPos min = controller.getMinCoord();
BlockPos max = controller.getMaxCoord();
int x = position.getX(), y = position.getY(), z = position.getZ();
facing = BlockFacing.from(min.getY() == y, max.getY() == y, min.getZ() == z, max.getZ() == z, min.getX() == x, max.getX() == x);
}
return null != facing && !facing.none() && facing.countFacesIf(true) == 1 ? facing.firstIf(true) : null;
}
@Override
public void onAttached(MultiblockControllerBase newController) {
super.onAttached(newController);
recalculateOutwardsDirection(newController.getMinCoord(), newController.getMaxCoord());
}
@Override
public void onMachineAssembled(MultiblockControllerBase controller) {
recalculateOutwardsDirection(controller.getMinCoord(), controller.getMaxCoord());
}
@Override
public void onMachineBroken() {
pos = PartPosition.Unknown;
facing = BlockFacing.NONE;
}
public void recalculateOutwardsDirection(BlockPos minCoord, BlockPos maxCoord) {
BlockPos myPos = this.getPos();
int myX = myPos.getX();
int myY = myPos.getY();
int myZ = myPos.getZ();
int facesMatching = 0;
boolean downFacing = myY == minCoord.getY();
boolean upFacing = myY == maxCoord.getY();
boolean northFacing = myZ == minCoord.getZ();
boolean southFacing = myZ == maxCoord.getZ();
boolean westFacing = myX == minCoord.getX();
boolean eastFacing = myX == maxCoord.getX();
this.facing = BlockFacing.from(downFacing, upFacing, northFacing, southFacing, westFacing, eastFacing);
if(eastFacing || westFacing)
++facesMatching;
if(upFacing || westFacing)
++facesMatching;
if(southFacing || northFacing)
++facesMatching;
if(facesMatching < 1) // <= 0
this.pos = PartPosition.Interior;
else if(facesMatching < 2) { //== 1
if (eastFacing)
this.pos = PartPosition.EastFace;
else if (westFacing)
this.pos = PartPosition.WestFace;
else if (southFacing)
this.pos = PartPosition.SouthFace;
else if (northFacing)
this.pos = PartPosition.NorthFace;
else if (upFacing)
this.pos = PartPosition.TopFace;
else
this.pos = PartPosition.BottomFace;
} else if(facesMatching < 3) { // == 2
if (!eastFacing && !westFacing)
this.pos = PartPosition.FrameEastWest;
else if (!southFacing && !northFacing)
this.pos = PartPosition.FrameSouthNorth;
else
this.pos = PartPosition.FrameUpDown;
} else
this.pos = PartPosition.FrameCorner;
}
public abstract boolean isGoodForFrame(IMultiblockValidator validatorCallback);
public abstract boolean isGoodForSides(IMultiblockValidator validatorCallback);
public abstract boolean isGoodForTop(IMultiblockValidator validatorCallback);
public abstract boolean isGoodForBottom(IMultiblockValidator validatorCallback);
public abstract boolean isGoodForInterior(IMultiblockValidator validatorCallback);
}

View File

@ -0,0 +1,11 @@
package uk.gemwire.engage.api.multiblocks.validation;
public interface IMultiblockValidator {
ValidationError getLastError();
void setLastError(ValidationError error);
void setLastError(String format, Object... params);
}

View File

@ -0,0 +1,21 @@
package uk.gemwire.engage.api.multiblocks.validation;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
public class ValidationError {
protected final String _resourceKey;
protected final Object[] _parameters;
public static final ValidationError MULTIBLOCK_INCOMPLETE = new ValidationError("engage:multiblock.validation.incomplete");
public ValidationError(String format, Object... params) {
this._resourceKey = format;
this._parameters = params;
}
public ITextComponent getChatMessage() {
return new TranslationTextComponent(this._resourceKey, _parameters);
}
}

View File

@ -1,35 +0,0 @@
package uk.gemwire.engage.block.coolant;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* Contains a set of methods that allows all Coolant System blocks to check for a completed network on placement.
*/
public class CoolantBaseBlock extends Block {
static Logger LOGGER = LogManager.getLogger();
public CoolantBaseBlock(Properties p_49795_) {
super(p_49795_);
}
@Override
public void onPlace(BlockState prior, Level level, BlockPos pos, BlockState newState, boolean p_60570_) {
if (level.isClientSide) return;
// TODO
// CoolantNetworksSavedData.NETWORKS
// Find networks adjacent to our block
// Add to the networks
// If more than one:
// Figure out if we placed a connection between two Nodes of the same type
// if so: merge them into one Node, copy the Positions and Transitions of one into the other
// if not: simply copy all the Nodes of one Graph into the other
}
}

View File

@ -1,32 +0,0 @@
package uk.gemwire.engage.block.coolant;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
/**
* A single block used in the Coolant multiblock.
* Is directional, meaning that its facing determines the behaviour of the multiblock.
* Both the front and back must be touching valid tubes in a completed coolant loop.
*/
public class CoolantMeteringBlock extends CoolantBaseBlock {
public static final DirectionProperty FACING = BlockStateProperties.FACING;
public CoolantMeteringBlock(Properties p_49795_) {
super(p_49795_);
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> p_49915_) {
super.createBlockStateDefinition(p_49915_);
p_49915_.add(FACING);
}
public BlockState getStateForPlacement(BlockPlaceContext p_55928_) {
return this.defaultBlockState().setValue(FACING, p_55928_.getClickedFace());
}
}

View File

@ -0,0 +1,27 @@
package uk.gemwire.engage.blocks;
import net.minecraftforge.registries.ObjectHolder;
import uk.gemwire.engage.blocks.util.WCoreStruct;
import uk.gemwire.engage.multiblock.warpcore.block.WarpCoreBlockPort;
import uk.gemwire.engage.multiblock.warpcore.block.WarpCoreBlockWall;
public class Blocks {
@ObjectHolder("engage:wcoreextern")
public static WCoreStruct WCORESTRUCT;
@ObjectHolder("engage:warpcorewall")
public static WarpCoreBlockWall WCOREWALL;
@ObjectHolder("engage:warpcorepower")
public static WarpCoreBlockPort WCOREPOWER;
@ObjectHolder("engage:warpcoreinput")
public static WarpCoreBlockPort WCOREINPUT;
@ObjectHolder("engage:warpcoreoutput")
public static WarpCoreBlockPort WCOREOUTPUT;
}

View File

@ -0,0 +1,115 @@
package uk.gemwire.engage.blocks;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import uk.gemwire.engage.misc.Helper;
import javax.annotation.Nullable;
public abstract class ModTileEntity extends TileEntity {
public ModTileEntity(TileEntityType<?> type) {
super(type);
}
public boolean isUsableByPlayer(PlayerEntity player) {
BlockPos position = this.getPos();
if(world.getTileEntity(pos) != this)
return false;
return player.getDistanceSq((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D) <= 64D;
}
public boolean canOpenGui(World world, BlockPos pos, BlockState state) {
return false;
}
@OnlyIn(Dist.CLIENT)
public boolean showScreen(Screen screen) {
Minecraft.getInstance().displayGuiScreen(screen);
return true;
}
public enum SyncReason {
FullSync,
NetworkUpdate
}
@Override
public void read(CompoundNBT data) {
super.read(data);
this.syncDataFrom(data, SyncReason.FullSync);
}
@Override
public CompoundNBT write(CompoundNBT data) {
this.syncDataTo(super.write(data), SyncReason.FullSync);
return data;
}
@Override
public void handleUpdateTag(CompoundNBT tag) {
super.read(tag);
this.syncDataFrom(tag, SyncReason.NetworkUpdate);
}
@Override
public CompoundNBT getUpdateTag() {
CompoundNBT data = super.getUpdateTag();
this.syncDataTo(data, SyncReason.NetworkUpdate);
return data;
}
@Override
public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) {
this.syncDataFrom(getUpdatePacket().getNbtCompound(), SyncReason.NetworkUpdate);
}
@Nullable
@Override
public SUpdateTileEntityPacket getUpdatePacket() {
CompoundNBT data = new CompoundNBT();
this.syncDataTo(data, SyncReason.NetworkUpdate);
return new SUpdateTileEntityPacket(this.getPos(), 0, data);
}
protected abstract void syncDataFrom(CompoundNBT data, SyncReason reason);
protected abstract void syncDataTo(CompoundNBT data, SyncReason reason);
public void markChunkDirty() {
this.world.markChunkDirty(this.getPos(), this);
}
public void callNeighborBlockChange() {
this.world.notifyNeighborsOfStateChange(this.getPos(), this.getBlockState().getBlock());
}
public void notifyBlockUpdate() {
Helper.notifyBlockUpdate(this.world, this.getPos(), null, null);
}
public void notifyBlockUpdate(BlockState oldState, BlockState newState) {
Helper.notifyBlockUpdate(this.world, this.getPos(), oldState, newState);
}
public void notifyTileEntityUpdate() {
this.markDirty();
Helper.notifyBlockUpdate(this.world, this.getPos(), null, null);
}
}

View File

@ -0,0 +1,19 @@
package uk.gemwire.engage.blocks.tileEntities;
import net.minecraft.tileentity.TileEntityType;
import net.minecraftforge.registries.ObjectHolder;
import uk.gemwire.engage.multiblock.warpcore.tile.WarpCoreIOPortTileEntity;
import uk.gemwire.engage.multiblock.warpcore.tile.WarpCorePowerTileEntity;
import uk.gemwire.engage.multiblock.warpcore.tile.WarpCoreTileEntity;
public class EngageTETypes {
@ObjectHolder("engage:warpcorebase")
public static TileEntityType<WarpCoreTileEntity> WarpCoreBaseType;
@ObjectHolder("engage:warpcorepower")
public static TileEntityType<WarpCorePowerTileEntity> WarpCorePowerType;
@ObjectHolder("engage:warpcoreport")
public static TileEntityType<WarpCoreIOPortTileEntity> WarpCorePortType;
}

View File

@ -0,0 +1,20 @@
package uk.gemwire.engage.blocks.util;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
public class WCoreStruct extends Block {
public WCoreStruct() {
super(Properties
.create(Material.IRON)
.sound(SoundType.STONE)
.hardnessAndResistance(2.0f)
.lightValue(0)
);
setRegistryName("wcoreextern");
}
}

View File

@ -1,45 +0,0 @@
package uk.gemwire.engage.client;
import net.minecraft.client.color.item.ItemColor;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.RenderType;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent;
import net.neoforged.neoforge.client.model.DynamicFluidContainerModel;
import uk.gemwire.engage.registries.Fluids;
import uk.gemwire.engage.registries.fluid.FluidDeferredRegister;
import uk.gemwire.engage.registries.fluid.FluidRegistryObject;
import java.util.List;
@Mod.EventBusSubscriber(value= Dist.CLIENT, modid="engage", bus= Mod.EventBusSubscriber.Bus.MOD)
public class ClientStuff {
private static final ItemColor BUCKET_ITEM_COLOR = new DynamicFluidContainerModel.Colors();
@SubscribeEvent
public static void registerBucketColorHandler(RegisterColorHandlersEvent.Item event) {
for (FluidRegistryObject<? extends FluidDeferredRegister.MekanismFluidType, ?, ?, ?, ?> fluidRO : Fluids.FLUIDS_REGISTRY.getAllFluids()) {
event.register(BUCKET_ITEM_COLOR, fluidRO.getBucket());
}
}
@SubscribeEvent
public static void clientSetup(FMLClientSetupEvent e) {
e.enqueueWork(() -> {
//Set fluids to a translucent render layer
for (FluidRegistryObject<?, ?, ?, ?, ?> fluidRO : List.of(Fluids.HEAVY_WATER_FLUID, Fluids.DEUTERIUM_FLUID, Fluids.DEUTERIUM_SLUSH_FLUID, Fluids.ANTIDEUTERIUM_FLUID, Fluids.WARP_PLASMA_FLUID, Fluids.PROPANE_FLUID)) {
setRenderLayer(RenderType.translucent(), fluidRO);
}
});
}
public static void setRenderLayer(RenderType type, FluidRegistryObject<?, ?, ?, ?, ?>... fluidROs) {
for (FluidRegistryObject<?, ?, ?, ?, ?> fluidRO : fluidROs) {
ItemBlockRenderTypes.setRenderLayer(fluidRO.getStillFluid(), type);
ItemBlockRenderTypes.setRenderLayer(fluidRO.getFlowingFluid(), type);
}
}
}

View File

@ -0,0 +1,10 @@
package uk.gemwire.engage.items;
import net.minecraft.item.Item;
import uk.gemwire.engage.Engage;
public class ItemProperties {
public static Item.Properties BlockItemProperties = new Item.Properties()
.group(Engage.SETUP.tab);
}

View File

@ -0,0 +1,38 @@
package uk.gemwire.engage.misc;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.World;
public class Helper {
public static int blockToChunkX(int blockX) {
return blockX >> 4;
}
public static int blockToChunkX(BlockPos pos) {
return pos.getX() >> 4;
}
public static int blockToChunkZ(int blockZ) {
return blockZ >> 4;
}
public static int blockToChunkZ(BlockPos pos) {
return pos.getZ() >> 4;
}
public static void notifyBlockUpdate(World world, BlockPos position, BlockState oldState, BlockState newState) {
if(oldState == null)
oldState = world.getBlockState(position);
if(newState == null)
newState = oldState;
world.notifyBlockUpdate(position, oldState, newState, 3);
}
public static long chunkPosHash(BlockPos pos) {
return ChunkPos.asLong(pos.getX() >> 4, pos.getZ() >> 4);
}
}

View File

@ -0,0 +1,289 @@
package uk.gemwire.engage.multiblock.warpcore;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.world.World;
import uk.gemwire.engage.api.multiblocks.iface.IMultiblockPart;
import uk.gemwire.engage.api.multiblocks.te.MultiblockControllerBase;
import uk.gemwire.engage.api.multiblocks.te.rectangular.RectangularMultiblockControllerBase;
import uk.gemwire.engage.api.multiblocks.validation.IMultiblockValidator;
import uk.gemwire.engage.blocks.ModTileEntity;
import uk.gemwire.engage.multiblock.warpcore.tile.WarpCoreIOPortTileEntity;
import uk.gemwire.engage.multiblock.warpcore.tile.WarpCorePowerTileEntity;
import uk.gemwire.engage.multiblock.warpcore.tile.WarpCoreTileEntity;
public class WarpCoreController extends RectangularMultiblockControllerBase {
private static final int MACHINE_SIZE = 3;
private WarpCoreIOPortTileEntity inputPort;
private WarpCoreIOPortTileEntity outputPort;
private WarpCorePowerTileEntity powerPort;
private boolean active;
public WarpCoreController(World world) {
super(world);
this.inputPort = this.outputPort = null;
this.powerPort = null;
this.active = false;
}
public boolean isActive() {
return active;
}
public void toggleActive() {
this.setActive(!this.active);
}
public void setActive(boolean active) {
if (this.active == active)
return;
this.active = active;
if (!this.WORLD.isRemote) {
this.markReferenceCoordForUpdate();
this.markReferenceCoordDirty();
} else
this.markMultiblockForRenderUpdate();
}
@Override
protected boolean isBlockGoodForFrame(World world, int x, int y, int z, IMultiblockValidator validatorCallback) {
validatorCallback.setLastError("engage:multiblock.error.invalid_block", x, y, z);
return false;
}
@Override
protected boolean isBlockGoodForBottom(World world, int x, int y, int z, IMultiblockValidator validatorCallback) {
validatorCallback.setLastError("engage:multiblock.error.invalid_block", x, y, z);
return false;
}
@Override
protected boolean isBlockGoodForInterior(World world, int x, int y, int z, IMultiblockValidator validatorCallback) {
validatorCallback.setLastError("engage:multiblock.error.invalid_block", x, y, z);
return false;
}
@Override
protected boolean isBlockGoodForSides(World world, int x, int y, int z, IMultiblockValidator validatorCallback) {
validatorCallback.setLastError("engage:multiblock.error.invalid_block", x, y, z);
return false;
}
@Override
protected boolean isBlockGoodForTop(World world, int x, int y, int z, IMultiblockValidator validatorCallback) {
validatorCallback.setLastError("engage:multiblock.error.invalid_block", x, y, z);
return false;
}
@Override
protected void onBlockAdded(IMultiblockPart part) {
}
@Override
protected void onBlockRemoved(IMultiblockPart part) {
if (part instanceof WarpCoreTileEntity) {
WarpCoreTileEntity tile = (WarpCoreTileEntity) part;
if (tile == this.powerPort)
this.powerPort = null;
} else if (part instanceof WarpCoreIOPortTileEntity) {
WarpCoreIOPortTileEntity tile = (WarpCoreIOPortTileEntity) part;
if (tile == this.outputPort) {
this.outputPort = null;
} else if (tile == this.inputPort) {
this.inputPort = null;
}
}
}
@Override
protected boolean isMachineWhole(IMultiblockValidator validatorCallback) {
WarpCorePowerTileEntity powerPort = null;
WarpCoreIOPortTileEntity inputPort = null;
WarpCoreIOPortTileEntity outputPort = null;
if (!super.isMachineWhole(validatorCallback))
return false;
for (IMultiblockPart part : this.connectedParts) {
if (part instanceof WarpCorePowerTileEntity) {
if (powerPort != null) {
validatorCallback.setLastError("engage:multiblock.error.powerport_already_present");
return false;
}
powerPort = (WarpCorePowerTileEntity) part;
} else if (part instanceof WarpCoreIOPortTileEntity) {
WarpCoreIOPortTileEntity io = (WarpCoreIOPortTileEntity) part;
boolean isInput = io.isInput();
if (isInput) {
if (inputPort != null) {
validatorCallback.setLastError("engage:multiblock.error.inputport_already_present");
return false;
}
inputPort = io;
} else {
if (outputPort != null) {
validatorCallback.setLastError("engage:multiblock.error.outputport_already_present");
return false;
}
outputPort = io;
}
}
}
if (powerPort == null) {
validatorCallback.setLastError("engage:multiblock.error.powerport_missing");
return false;
}
if (inputPort == null) {
validatorCallback.setLastError("engage:multiblock.error.inputport_missing");
return false;
}
if (outputPort == null) {
validatorCallback.setLastError("engage:multiblock.error.outputport_missing");
return false;
}
return true;
}
@Override
protected void onMachineAssembled() {
this.lookupPorts();
if (this.WORLD.isRemote)
this.markMultiblockForRenderUpdate();
}
@Override
protected void onMachineRestored() {
this.onMachineAssembled();
}
@Override
protected void onMachinePaused() {
if (this.WORLD.isRemote)
this.markMultiblockForRenderUpdate();
}
@Override
protected void onMachineDisassembled() {
if (this.WORLD.isRemote)
this.markMultiblockForRenderUpdate();
}
@Override
public void onAttachedPartWithMultiblockData(IMultiblockPart part, CompoundNBT data) {
}
@Override
protected void onAssimilate(MultiblockControllerBase assimilatedController) {
}
@Override
protected void onAssimilated(MultiblockControllerBase asssimilatorController) {
}
@Override
protected int getMinBlocksInFullMachine() {
return 27;
}
@Override
protected int getMaxXSize() {
return MACHINE_SIZE;
}
@Override
protected int getMaxYSize() {
return MACHINE_SIZE;
}
@Override
protected int getMaxZSize() {
return MACHINE_SIZE;
}
@Override
protected int getMinXSize() {
return MACHINE_SIZE;
}
@Override
protected int getMinYSize() {
return MACHINE_SIZE;
}
@Override
protected int getMinZSize() {
return MACHINE_SIZE;
}
@Override
protected boolean updateServer() {
return false;
}
@Override
protected void updateClient() {
}
@Override
public void syncDataFrom(CompoundNBT data, ModTileEntity.SyncReason syncReason) {
if (data.contains("isActive"))
this.setActive(data.getBoolean("isActive"));
}
@Override
public void syncDataTo(CompoundNBT data, ModTileEntity.SyncReason syncReason) {
data.putBoolean("isActive", this.isActive());
}
private void lookupPorts() {
this.outputPort = null;
this.inputPort = null;
this.powerPort = null;
for (IMultiblockPart part : this.connectedParts) {
if (part instanceof WarpCorePowerTileEntity)
this.powerPort = (WarpCorePowerTileEntity) part;
if (part instanceof WarpCoreIOPortTileEntity) {
WarpCoreIOPortTileEntity io = (WarpCoreIOPortTileEntity) part;
if (io.isInput())
this.inputPort = io;
else
this.outputPort = io;
}
}
}
}

View File

@ -0,0 +1,92 @@
package uk.gemwire.engage.multiblock.warpcore.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import uk.gemwire.engage.api.multiblocks.iface.IMultiblockPart;
import uk.gemwire.engage.api.multiblocks.te.MultiblockControllerBase;
import uk.gemwire.engage.api.multiblocks.validation.ValidationError;
import uk.gemwire.engage.blocks.tileEntities.EngageTETypes;
import uk.gemwire.engage.multiblock.warpcore.WarpCoreController;
import uk.gemwire.engage.multiblock.warpcore.tile.WarpCoreIOPortTileEntity;
import uk.gemwire.engage.multiblock.warpcore.tile.WarpCorePowerTileEntity;
import uk.gemwire.engage.multiblock.warpcore.tile.WarpCoreTileEntity;
import javax.annotation.Nullable;
public class WarpCoreBlockBase extends Block {
private WarpCoreBlockType myType;
protected WarpCoreBlockBase(WarpCoreBlockType blockType) {
super(Properties.create(Material.IRON).hardnessAndResistance(1.5F, 10.0F).sound(SoundType.METAL));
this.myType = blockType;
}
@Override
public boolean hasTileEntity(BlockState state) {
return true;
}
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
switch(this.myType) {
default:
return new WarpCoreTileEntity(EngageTETypes.WarpCoreBaseType);
case Power:
return new WarpCorePowerTileEntity(EngageTETypes.WarpCorePowerType);
case Input:
return new WarpCoreIOPortTileEntity(EngageTETypes.WarpCorePortType, true);
case Output:
return new WarpCoreIOPortTileEntity(EngageTETypes.WarpCorePortType, false);
}
}
@Override
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult ray) {
if(world.isRemote || (hand != Hand.OFF_HAND || (player.getHeldItem(hand) == ItemStack.EMPTY)))
return ActionResultType.FAIL;
WarpCoreController controller = this.getWarpController(world, pos);
if(controller != null) {
if(player.isCrouching()) {
controller.toggleActive();
return ActionResultType.SUCCESS;
} else {
ValidationError status = controller.getLastError();
if(status != null) {
player.sendMessage(status.getChatMessage());
}
}
}
return ActionResultType.FAIL;
}
protected IMultiblockPart getMultiblockPartAt(World world, BlockPos pos) {
TileEntity te = world.getTileEntity(pos);
return te instanceof IMultiblockPart ? (IMultiblockPart) te : null;
}
protected WarpCoreController getWarpController(World world, BlockPos pos) {
MultiblockControllerBase controller = this.getMultiblockPartAt(world, pos).getMultiblockController();
return controller instanceof WarpCoreController ? (WarpCoreController) controller : null;
}
}

Some files were not shown because too many files have changed in this diff Show More