Prvni verze

This commit is contained in:
bv
2026-09-01 20:29:31 +02:00
commit cffd3e4a76
114 changed files with 5138 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
# 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
+25
View File
@@ -0,0 +1,25 @@
# eclipse
bin
*.launch
.settings
.metadata
.classpath
.project
# idea
out
*.ipr
*.iws
*.iml
.idea
# gradle
build
.gradle
# other
eclipse
run
# Files from Forge MDK
forge*changelog.txt
+65
View File
@@ -0,0 +1,65 @@
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.
+523
View File
@@ -0,0 +1,523 @@
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
+46
View File
@@ -0,0 +1,46 @@
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`
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`
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://docs.minecraftforge.net/en/1.20.1/gettingstarted/
LexManos' Install Video: https://youtu.be/8VEdtQLuLO0
Forge Forums: https://forums.minecraftforge.net/
Forge Discord: https://discord.minecraftforge.net/
+284
View File
@@ -0,0 +1,284 @@
plugins {
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
}
version = mod_version
group = mod_group_id
base {
archivesName = mod_id
}
// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
minecraft {
// The mappings can be changed at any time and must be in the following format.
// Channel: Version:
// official MCVersion Official field/method names from Mojang mapping files
// parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official
//
// You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
//
// Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
// Additional setup is needed to use their mappings: https://parchmentmc.org/docs/getting-started
//
// Use non-default mappings at your own risk. They may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: mapping_channel, version: mapping_version
// When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game.
// In most cases, it is not necessary to enable.
// enableEclipsePrepareRuns = true
// enableIdeaPrepareRuns = true
// This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
// It is REQUIRED to be set to true for this template to function.
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
copyIdeResources = true
// When true, this property will add the folder name of all declared run configurations to generated IDE run configurations.
// The folder name can be set on a run configuration using the "folderName" property.
// By default, the folder name of a run configuration is the name of the Gradle project containing it.
// generateRunFolders = true
// This property enables access transformers for use in development.
// They will be applied to the Minecraft artifact.
// The access transformer file can be anywhere in the project.
// However, it must be at "META-INF/accesstransformer.cfg" in the final mod jar to be loaded by Forge.
// This default location is a best practice to automatically put the file in the right place in the final jar.
// See https://docs.minecraftforge.net/en/latest/advanced/accesstransformers/ for more information.
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
// applies to all the run configs below
configureEach {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
// The markers can be added/remove as needed separated by commas.
// "SCAN": For mods scan.
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
property 'forge.logging.markers', 'REGISTRIES'
// Recommended logging level for the console
// You can set various levels here.
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
property 'forge.logging.console.level', 'debug'
mods {
"${mod_id}" {
source sourceSets.main
}
}
}
client {
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
property 'forge.enabledGameTestNamespaces', mod_id
}
server {
property 'forge.enabledGameTestNamespaces', mod_id
args '--nogui'
}
// This run config launches GameTestServer and runs all registered gametests, then exits.
// By default, the server will crash when no gametests are provided.
// The gametest system is also enabled by default for other run configs under the /test command.
gameTestServer {
property 'forge.enabledGameTestNamespaces', mod_id
}
data {
// example of overriding the workingDirectory set in configureEach above
workingDirectory project.file('run-data')
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
}
}
}
// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }
repositories {
// Put repositories for dependencies here
// ForgeGradle automatically adds the Forge maven and Maven Central for you
maven {
// Valkyrien Skies 2 - ship physics library used to make the raised/repaired Titanic actually sail
name = 'Valkyrien Skies'
url = 'https://maven.valkyrienskies.org'
content {
includeGroup 'org.valkyrienskies'
includeGroup 'org.valkyrienskies.core'
}
}
maven {
// Required at runtime by Valkyrien Skies (it is written in Kotlin)
name = 'Kotlin for Forge'
url = 'https://thedarkcolour.github.io/KotlinForForge/'
content {
includeGroup 'thedarkcolour'
}
}
maven {
// Only needed for one small transitive dependency of Valkyrien Skies core (jackson-kotlin-dsl)
name = 'JitPack'
url = 'https://jitpack.io'
content {
includeGroup 'com.github.Rubydesic'
}
}
// If you have mod jar dependencies in ./libs, you can declare them as a repository like so.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html#sub:flat_dir_resolver
// flatDir {
// dir 'libs'
// }
}
// fg.deobf() resolves its own internal probe configuration to locate the raw artifact before
// remapping it, and that probe does not honour excludes attached only to the outer
// `implementation(...) { exclude ... }` block. Applying the excludes globally makes sure
// Valkyrien Skies' optional Create/Flywheel/profiler compat dependencies (which require extra
// repositories we don't want to add) are never resolved anywhere in the build, since we don't
// use Create.
configurations.all {
exclude group: 'com.simibubi.create'
exclude group: 'net.createmod.ponder'
exclude group: 'dev.engine-room.flywheel'
exclude group: 'com.tterrag.registrate'
exclude group: 'curse.maven'
exclude group: 'maven.modrinth'
exclude group: 'com.jozufozu.resourcefullib'
}
dependencies {
// Specify the version of Minecraft to use.
// Any artifact can be supplied so long as it has a "userdev" classifier artifact and is a compatible patcher artifact.
// The "userdev" classifier will be requested and setup by ForgeGradle.
// If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"],
// then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
// Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}")
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}-forge-api:${jei_version}")
// runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}-forge:${jei_version}")
// Example mod dependency using a mod jar from ./libs with a flat dir repository
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
// The group id is ignored when searching -- in this case, it is "blank"
// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
// Kotlin runtime for Forge - required by Valkyrien Skies (written in Kotlin) at runtime.
implementation fg.deobf("thedarkcolour:kotlinforforge:${kotlinforforge_version}")
// Valkyrien Skies 2 - lets a group of blocks (the raised/repaired Titanic) become
// a physical, floating, steerable "ship" once assembled.
// We don't use Create, so all of VS2's optional Create/Flywheel/profiler compat
// dependencies (which otherwise require extra repos like Modrinth/CurseMaven) are excluded.
implementation(fg.deobf("org.valkyrienskies:valkyrienskies-120-forge:${vs2_version}")) {
exclude group: 'com.simibubi', module: ''
exclude group: 'com.simibubi.create', module: ''
exclude group: 'net.createmod.ponder', module: ''
exclude group: 'dev.engine-room', module: ''
exclude group: 'dev.engine-room.flywheel', module: ''
exclude group: 'com.jozufozu', module: ''
exclude group: 'com.tterrag.registrate', module: ''
exclude group: 'curse.maven', module: ''
exclude group: 'maven.modrinth', module: ''
}
implementation("org.valkyrienskies.core:api:${vscore_version}") {
exclude group: 'org.joml', module: ''
}
implementation("org.valkyrienskies.core:internal:${vscore_version}") {
exclude group: 'org.joml', module: ''
}
implementation("org.valkyrienskies.core:util:${vscore_version}") {
exclude group: 'org.joml', module: ''
}
// joml-primitives (AABBdc etc.) is excluded above along with the rest of the org.joml
// group to avoid duplicating the base joml classes Minecraft already provides - but
// joml-primitives itself isn't provided by Minecraft. VS2 already bundles it at runtime
// via its own Jar-in-Jar, so this only needs to be visible at compile time.
compileOnly 'org.joml:joml-primitives:1.10.0'
// For more info:
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
}
// This block of code expands all declared replace properties in the specified resource targets.
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
tasks.named('processResources', ProcessResources).configure {
var replaceProperties = [
minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
forge_version: forge_version, forge_version_range: forge_version_range,
loader_version_range: loader_version_range,
mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
mod_authors: mod_authors, mod_description: mod_description,
]
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 at runtime.
tasks.named('jar', Jar).configure {
manifest {
attributes([
'Specification-Title' : mod_id,
'Specification-Vendor' : mod_authors,
'Specification-Version' : '1', // We are version 1 of ourselves
'Implementation-Title' : project.name,
'Implementation-Version' : project.jar.archiveVersion,
'Implementation-Vendor' : mod_authors,
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
// This is the preferred method to reobfuscate your jar file
finalizedBy 'reobfJar'
}
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing:
// tasks.named('publish').configure {
// dependsOn 'reobfJar'
// }
// Example configuration to allow publishing using the maven-publish plugin
publishing {
publications {
register('mavenJava', MavenPublication) {
artifact jar
}
}
repositories {
maven {
url "file://${project.projectDir}/mcmodsrepo"
}
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}
+1056
View File
File diff suppressed because it is too large Load Diff
+54
View File
@@ -0,0 +1,54 @@
# 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.1
# 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.1,1.21)
# The Forge version must agree with the Minecraft version to get a valid artifact
forge_version=47.4.5
# The Forge version range can use any version of Forge as bounds or match the loader version range
forge_version_range=[47,)
# The loader version range can only use the major version of Forge/FML as bounds
loader_version_range=[47,)
# The mapping channel to use for mappings.
mapping_channel=official
# The mapping version to query from the mapping channel.
mapping_version=1.20.1
## 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=titanic
# The human-readable display name for the mod.
mod_name=Titanic
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=All Rights Reserved
# The mod version. See https://semver.org/
mod_version=0.1.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.
mod_group_id=com.titanicmc.titanic
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
mod_authors=TitanicMC
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
mod_description=Raise the wreck, repair her in dry dock and sail the Titanic.\nRequires Valkyrien Skies 2 for ship physics.
## Library versions
# Valkyrien Skies 2 (ship physics library) - Forge 1.20.1 build
vs2_version=2.4.13+a22354cf66
# Valkyrien Skies Core (must match the vs2 build's core version)
vscore_version=1.1.0+46c89d8af9
# Kotlin For Forge (required at runtime by Valkyrien Skies, which is written in Kotlin)
kotlinforforge_version=4.10.0
Binary file not shown.
+6
View File
@@ -0,0 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+245
View File
@@ -0,0 +1,245 @@
#!/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
# 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
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, 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" "$@"
Vendored
+92
View File
@@ -0,0 +1,92 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
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
+13
View File
@@ -0,0 +1,13 @@
pluginManagement {
repositories {
gradlePluginPortal()
maven {
name = 'MinecraftForge'
url = 'https://maven.minecraftforge.net/'
}
}
}
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
}
@@ -0,0 +1,71 @@
package com.titanicmc.titanic;
import net.minecraftforge.common.ForgeConfigSpec;
/**
* Common (server-authoritative) config for the Titanic mod.
*/
public class Config {
public static final ForgeConfigSpec SPEC;
public static final ForgeConfigSpec.IntValue WRECK_RARITY;
public static final ForgeConfigSpec.IntValue DRY_DOCK_IRON_REQUIRED;
public static final ForgeConfigSpec.IntValue DRY_DOCK_GLASS_REQUIRED;
public static final ForgeConfigSpec.IntValue DRY_DOCK_GLASS_PANES_REQUIRED;
public static final ForgeConfigSpec.IntValue DRY_DOCK_REPEATERS_REQUIRED;
public static final ForgeConfigSpec.IntValue DRY_DOCK_COMPARATORS_REQUIRED;
public static final ForgeConfigSpec.IntValue DRY_DOCK_CHESTS_REQUIRED;
public static final ForgeConfigSpec.IntValue DRY_DOCK_PLANKS_REQUIRED;
public static final ForgeConfigSpec.IntValue DRY_DOCK_REDSTONE_BLOCKS_REQUIRED;
public static final ForgeConfigSpec.IntValue MAX_SHIP_BLOCKS;
public static final ForgeConfigSpec.DoubleValue RAISE_SPEED;
public static final ForgeConfigSpec.DoubleValue BOILER_HEAT_PER_FUEL;
public static final ForgeConfigSpec.DoubleValue ENGINE_POWER_PER_HEAT;
static {
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
builder.push("world_generation");
WRECK_RARITY = builder
.comment("1 in N ocean chunks (approximately) will attempt to place a Titanic wreck.")
.defineInRange("wreckRarity", 800, 1, 100000);
builder.pop();
builder.push("ships");
MAX_SHIP_BLOCKS = builder
.comment("Safety limit on how many connected blocks may be assembled into one ship.")
.defineInRange("maxShipBlocks", 20000, 100, 200000);
RAISE_SPEED = builder
.comment("Upward speed (blocks/tick) applied while a wreck is being raised to the surface.")
.defineInRange("raiseSpeed", 0.08, 0.001, 1.0);
BOILER_HEAT_PER_FUEL = builder
.comment("Heat generated per fuel-tick burned in a Boiler.")
.defineInRange("boilerHeatPerFuel", 0.02, 0.0001, 10.0);
ENGINE_POWER_PER_HEAT = builder
.comment("Engine power applied to the ship per unit of accumulated heat, when a Crankshaft is adjacent.")
.defineInRange("enginePowerPerHeat", 4000.0, 1.0, 1000000.0);
builder.pop();
builder.push("dry_dock_repair");
DRY_DOCK_IRON_REQUIRED = builder.comment("Iron ingots required to repair the hull (3 * 64 per the design doc).")
.defineInRange("ironIngots", 192, 1, 100000);
DRY_DOCK_GLASS_REQUIRED = builder.comment("Glass blocks required for portholes/windows.")
.defineInRange("glassBlocks", 64, 1, 100000);
DRY_DOCK_GLASS_PANES_REQUIRED = builder.comment("Glass panes required.")
.defineInRange("glassPanes", 64, 1, 100000);
DRY_DOCK_REPEATERS_REQUIRED = builder.comment("Redstone repeaters required (engine control linkages).")
.defineInRange("repeaters", 16, 1, 100000);
DRY_DOCK_COMPARATORS_REQUIRED = builder.comment("Redstone comparators required (gauges/telegraph).")
.defineInRange("comparators", 20, 1, 100000);
DRY_DOCK_CHESTS_REQUIRED = builder.comment("Chests required (cargo holds / boiler feed bunkers).")
.defineInRange("chests", 64, 1, 100000);
DRY_DOCK_PLANKS_REQUIRED = builder.comment("Planks required (deck planking).")
.defineInRange("planks", 50, 1, 100000);
DRY_DOCK_REDSTONE_BLOCKS_REQUIRED = builder.comment("Redstone blocks required (power for the engine telegraph).")
.defineInRange("redstoneBlocks", 10, 1, 100000);
builder.pop();
SPEC = builder.build();
}
}
@@ -0,0 +1,61 @@
package com.titanicmc.titanic;
import com.mojang.logging.LogUtils;
import com.titanicmc.titanic.event.ForgeEventHandler;
import com.titanicmc.titanic.registry.ModBlockEntities;
import com.titanicmc.titanic.registry.ModBlocks;
import com.titanicmc.titanic.registry.ModCreativeTabs;
import com.titanicmc.titanic.registry.ModEntities;
import com.titanicmc.titanic.registry.ModFeatures;
import com.titanicmc.titanic.registry.ModItems;
import com.titanicmc.titanic.ship.TitanicShipControl;
import kotlin.Unit;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.slf4j.Logger;
import org.valkyrienskies.mod.common.VSGameUtilsKt;
/**
* Titanic - raise the wreck, repair her in dry dock, and sail her again.
* <p>
* Ship physics (buoyancy, steering, collisions) are provided by the Valkyrien Skies 2
* library mod. This mod never manually shuffles blocks around to fake movement; once a
* structure is "assembled" via {@code org.valkyrienskies.mod.common.assembly.ShipAssembler}
* it becomes a real physics object that VS2 simulates every tick.
*/
@Mod(TitanicMod.MODID)
public class TitanicMod {
public static final String MODID = "titanic";
public static final Logger LOGGER = LogUtils.getLogger();
public TitanicMod(FMLJavaModLoadingContext context) {
IEventBus modEventBus = context.getModEventBus();
ModItems.ITEMS.register(modEventBus);
ModBlocks.BLOCKS.register(modEventBus);
ModBlockEntities.BLOCK_ENTITIES.register(modEventBus);
ModEntities.ENTITIES.register(modEventBus);
ModFeatures.FEATURES.register(modEventBus);
ModCreativeTabs.TABS.register(modEventBus);
context.registerConfig(ModConfig.Type.COMMON, Config.SPEC);
MinecraftForge.EVENT_BUS.register(new ForgeEventHandler());
// Required by Valkyrien Skies 2: any class attached to a ship via
// LoadedServerShip#setAttachment must first be registered with its attachment
// registry, or setAttachment throws IllegalArgumentException. This mod's mods.toml
// declares an AFTER ordering dependency on valkyrienskies, so its core (and this
// registry) is guaranteed to already be initialized here. TitanicShipControl carries
// only in-memory runtime state (raise/engine state, a live ship reference) that should
// never be persisted, hence the transient serializer.
VSGameUtilsKt.getVsCore().registerAttachment(TitanicShipControl.class, builder -> {
builder.useTransientSerializer();
return Unit.INSTANCE;
});
}
}
@@ -0,0 +1,65 @@
package com.titanicmc.titanic.block;
import com.titanicmc.titanic.blockentity.BoilerBlockEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BaseEntityBlock;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import org.jetbrains.annotations.Nullable;
/** A huge coal-fired boiler. See {@link BoilerBlockEntity} for behaviour. */
public class BoilerBlock extends BaseEntityBlock {
public BoilerBlock(Properties properties) {
super(properties);
}
@Override
public RenderShape getRenderShape(BlockState state) {
return RenderShape.MODEL;
}
@Override
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand,
BlockHitResult hit) {
if (level.isClientSide) return InteractionResult.SUCCESS;
if (!(level.getBlockEntity(pos) instanceof BoilerBlockEntity boiler)) return InteractionResult.PASS;
ItemStack held = player.getItemInHand(hand);
if (!held.isEmpty() && boiler.tryFeed(held)) {
player.displayClientMessage(Component.translatable("message.titanic.boiler_fed"), true);
return InteractionResult.CONSUME;
}
player.displayClientMessage(Component.translatable(
boiler.isBurning() ? "message.titanic.boiler_burning" : "message.titanic.boiler_needs_fuel"), true);
return InteractionResult.CONSUME;
}
@Nullable
@Override
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return new BoilerBlockEntity(pos, state);
}
@Nullable
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
if (level.isClientSide) return null;
return (lvl, pos, st, be) -> {
if (be instanceof BoilerBlockEntity boiler) {
boiler.serverTick((ServerLevel) lvl);
}
};
}
}
@@ -0,0 +1,51 @@
package com.titanicmc.titanic.block;
import com.titanicmc.titanic.entity.SeatEntity;
import com.titanicmc.titanic.registry.ModEntities;
import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
import java.util.List;
/**
* A simple dining-room / cabin chair. Right-click to sit down; sneak to get back up.
* Works fine on an assembled ship since VS2 handles entities riding blocks-on-ships.
*/
public class ChairBlock extends Block {
public ChairBlock(Properties properties) {
super(properties);
}
@Override
public InteractionResult use(net.minecraft.world.level.block.state.BlockState state, Level level, BlockPos pos,
Player player, InteractionHand hand, BlockHitResult hit) {
if (level.isClientSide) {
return InteractionResult.SUCCESS;
}
if (player.isPassenger() || player.isShiftKeyDown()) {
return InteractionResult.PASS;
}
AABB searchBox = new AABB(pos).inflate(0.2);
List<SeatEntity> existing = level.getEntitiesOfClass(SeatEntity.class, searchBox);
SeatEntity seat = existing.isEmpty() ? null : existing.get(0);
if (seat == null) {
seat = ModEntities.SEAT.get().create(level);
if (seat == null) return InteractionResult.PASS;
seat.setPos(pos.getX() + 0.5, pos.getY() + 0.2, pos.getZ() + 0.5);
level.addFreshEntity(seat);
}
player.startRiding(seat, true);
return InteractionResult.CONSUME;
}
}
@@ -0,0 +1,14 @@
package com.titanicmc.titanic.block;
import net.minecraft.world.level.block.Block;
/**
* Purely a structural marker: a {@link BoilerBlock} only converts its heat into ship
* propulsion while at least one Crankshaft is directly adjacent to it. This forces the
* player to actually build out an "engine room" rather than dropping a single block.
*/
public class CrankshaftBlock extends Block {
public CrankshaftBlock(Properties properties) {
super(properties);
}
}
@@ -0,0 +1,78 @@
package com.titanicmc.titanic.block;
import com.titanicmc.titanic.blockentity.HelmBlockEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BaseEntityBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
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.phys.BlockHitResult;
import org.jetbrains.annotations.Nullable;
/** The real ship's wheel, installed automatically once dry dock repairs are finished. */
public class HelmBlock extends BaseEntityBlock {
public HelmBlock(Properties properties) {
super(properties);
registerDefaultState(this.stateDefinition.any().setValue(BlockStateProperties.HORIZONTAL_FACING, Direction.NORTH));
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(BlockStateProperties.HORIZONTAL_FACING);
}
@Nullable
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
return defaultBlockState().setValue(BlockStateProperties.HORIZONTAL_FACING, context.getHorizontalDirection().getOpposite());
}
@Override
public RenderShape getRenderShape(BlockState state) {
return RenderShape.MODEL;
}
@Override
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand,
BlockHitResult hit) {
if (level.isClientSide) return InteractionResult.SUCCESS;
if (!(level.getBlockEntity(pos) instanceof HelmBlockEntity helm)) return InteractionResult.PASS;
if (helm.sit(player)) {
return InteractionResult.CONSUME;
}
player.displayClientMessage(Component.translatable("message.titanic.helm_not_seaworthy"), true);
return InteractionResult.CONSUME;
}
@Nullable
@Override
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return new HelmBlockEntity(pos, state);
}
@Nullable
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
if (level.isClientSide) return null;
return (lvl, pos, st, be) -> {
if (be instanceof HelmBlockEntity helm) {
helm.serverTick();
}
};
}
}
@@ -0,0 +1,24 @@
package com.titanicmc.titanic.block;
import net.minecraft.core.Direction;
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;
/**
* Generated on the wreck's bridge during world generation, marking where the real helm will
* be installed once dry dock repairs are finished. Never placeable by the player.
*/
public class HelmSocketBlock extends Block {
public HelmSocketBlock(Properties properties) {
super(properties);
registerDefaultState(this.stateDefinition.any().setValue(BlockStateProperties.HORIZONTAL_FACING, Direction.NORTH));
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(BlockStateProperties.HORIZONTAL_FACING);
}
}
@@ -0,0 +1,106 @@
package com.titanicmc.titanic.block;
import com.titanicmc.titanic.blockentity.LiftingFrameBlockEntity;
import com.titanicmc.titanic.registry.ModBlockEntities;
import com.titanicmc.titanic.registry.ModItems;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BaseEntityBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
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.IntegerProperty;
import net.minecraft.world.phys.BlockHitResult;
import org.jetbrains.annotations.Nullable;
/**
* The recovery "box" a player builds and lowers over the sunken wreck. It has four eyes;
* right-clicking it with a Steel Cable threads one eye at a time. Once all four are threaded
* the frame is "rigged" and can be linked to a {@link WinchBlock} on a surface vessel to
* start the raise sequence.
*/
public class LiftingFrameBlock extends BaseEntityBlock {
public static final IntegerProperty CABLES = IntegerProperty.create("cables", 0, 4);
public LiftingFrameBlock(Properties properties) {
super(properties);
registerDefaultState(this.stateDefinition.any().setValue(CABLES, 0));
}
@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
builder.add(CABLES);
}
@Override
public RenderShape getRenderShape(BlockState state) {
return RenderShape.MODEL;
}
@Override
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand,
BlockHitResult hit) {
if (level.isClientSide) {
return InteractionResult.SUCCESS;
}
BlockEntity be = level.getBlockEntity(pos);
if (!(be instanceof LiftingFrameBlockEntity frame)) {
return InteractionResult.PASS;
}
ItemStack held = player.getItemInHand(hand);
int cables = state.getValue(CABLES);
if (cables < 4 && held.is(ModItems.STEEL_CABLE.get())) {
held.shrink(1);
level.setBlock(pos, state.setValue(CABLES, cables + 1), 3);
player.displayClientMessage(
Component.translatable("message.titanic.frame_threaded", cables + 1, 4), true);
if (cables + 1 == 4) {
player.displayClientMessage(Component.translatable("message.titanic.frame_rigged"), true);
}
return InteractionResult.CONSUME;
}
if (cables >= 4) {
player.displayClientMessage(
Component.translatable(frame.isLinkedToWinch()
? "message.titanic.frame_already_linked"
: "message.titanic.frame_needs_winch"), true);
} else {
player.displayClientMessage(
Component.translatable("message.titanic.frame_needs_cable", 4 - cables), true);
}
return InteractionResult.CONSUME;
}
@Nullable
@Override
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return new LiftingFrameBlockEntity(pos, state);
}
@Nullable
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> type) {
if (level.isClientSide) return null;
return (lvl, pos, st, blockEntity) -> {
if (blockEntity instanceof LiftingFrameBlockEntity frame) {
frame.serverTick((ServerLevel) lvl);
}
};
}
}
@@ -0,0 +1,50 @@
package com.titanicmc.titanic.block;
import com.titanicmc.titanic.blockentity.RepairPanelBlockEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BaseEntityBlock;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import org.jetbrains.annotations.Nullable;
/**
* Generated inside the wreck's bridge. Right-click while holding a repair material to hand
* it in. See {@link RepairPanelBlockEntity} for the full repair logic.
*/
public class RepairPanelBlock extends BaseEntityBlock {
public RepairPanelBlock(Properties properties) {
super(properties);
}
@Override
public RenderShape getRenderShape(BlockState state) {
return RenderShape.MODEL;
}
@Override
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand,
BlockHitResult hit) {
if (level.isClientSide) return InteractionResult.SUCCESS;
if (!(level.getBlockEntity(pos) instanceof RepairPanelBlockEntity panel)) return InteractionResult.PASS;
ItemStack held = player.getItemInHand(hand);
panel.handleDeliver((ServerLevel) level, player, held);
return InteractionResult.CONSUME;
}
@Nullable
@Override
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return new RepairPanelBlockEntity(pos, state);
}
}
@@ -0,0 +1,62 @@
package com.titanicmc.titanic.block;
import com.titanicmc.titanic.blockentity.LiftingFrameBlockEntity;
import com.titanicmc.titanic.registry.ModItems;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
/**
* Placed on the player's recovery vessel above the water. Right-clicking with a Steel Cable
* searches straight down for a fully rigged {@link LiftingFrameBlock} and, if found, links the
* two together, starting the automatic raise sequence.
*/
public class WinchBlock extends Block {
private static final int MAX_SEARCH_DEPTH = 256;
public WinchBlock(Properties properties) {
super(properties);
}
@Override
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand,
BlockHitResult hit) {
if (level.isClientSide) {
return InteractionResult.SUCCESS;
}
ItemStack held = player.getItemInHand(hand);
if (!held.is(ModItems.STEEL_CABLE.get())) {
player.displayClientMessage(Component.translatable("message.titanic.winch_needs_cable"), true);
return InteractionResult.CONSUME;
}
BlockPos.MutableBlockPos search = pos.mutable();
for (int i = 0; i < MAX_SEARCH_DEPTH; i++) {
search.move(0, -1, 0);
BlockEntity be = level.getBlockEntity(search);
if (be instanceof LiftingFrameBlockEntity frame) {
if (!frame.isRigged(level.getBlockState(search))) {
player.displayClientMessage(Component.translatable("message.titanic.frame_not_rigged"), true);
return InteractionResult.CONSUME;
}
held.shrink(1);
frame.linkToWinch(pos);
player.displayClientMessage(Component.translatable("message.titanic.raise_started"), true);
return InteractionResult.CONSUME;
}
}
player.displayClientMessage(Component.translatable("message.titanic.no_frame_found"), true);
return InteractionResult.CONSUME;
}
}
@@ -0,0 +1,122 @@
package com.titanicmc.titanic.blockentity;
import com.titanicmc.titanic.Config;
import com.titanicmc.titanic.block.CrankshaftBlock;
import com.titanicmc.titanic.registry.ModBlockEntities;
import com.titanicmc.titanic.ship.ShipUtil;
import com.titanicmc.titanic.ship.TitanicShipControl;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.Container;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.ForgeHooks;
import org.valkyrienskies.core.api.ships.LoadedServerShip;
/**
* Burns fuel to build up heat. Heat only turns into ship propulsion while a
* {@link CrankshaftBlock} is directly adjacent - this represents the engine room
* requiring both giant boilers and their crankshafts to actually drive the propellers.
* <p>
* Fuel can be fed directly by right-clicking with a burnable item, or the boiler will
* automatically pull one burnable item per cycle from any directly adjacent chest.
*/
public class BoilerBlockEntity extends BlockEntity {
private int burnTimeRemaining = 0;
public BoilerBlockEntity(BlockPos pos, BlockState state) {
super(ModBlockEntities.BOILER.get(), pos, state);
}
/** Attempts to feed the boiler with the given item. Returns true if it was consumed. */
public boolean tryFeed(ItemStack stack) {
int burnTime = ForgeHooks.getBurnTime(stack, null);
if (burnTime <= 0) {
return false;
}
stack.shrink(1);
burnTimeRemaining += burnTime;
setChanged();
return true;
}
public void serverTick(ServerLevel level) {
if (burnTimeRemaining <= 0) {
tryAutoFeedFromChest(level);
}
if (burnTimeRemaining <= 0) {
return;
}
burnTimeRemaining--;
if (!hasAdjacentCrankshaft(level)) {
return;
}
LoadedServerShip ship = ShipUtil.getLoadedShipManagingPos(level, getBlockPos());
if (ship == null) {
return;
}
TitanicShipControl control = ship.getAttachment(TitanicShipControl.class);
if (control == null || !control.isRepaired()) {
// Un-repaired hulls can't safely run their engines yet.
return;
}
double power = Config.BOILER_HEAT_PER_FUEL.get() * Config.ENGINE_POWER_PER_HEAT.get();
control.addEnginePower(power);
setChanged();
}
private boolean hasAdjacentCrankshaft(ServerLevel level) {
for (Direction direction : Direction.values()) {
if (level.getBlockState(getBlockPos().relative(direction)).getBlock() instanceof CrankshaftBlock) {
return true;
}
}
return false;
}
private void tryAutoFeedFromChest(ServerLevel level) {
for (Direction direction : Direction.values()) {
BlockEntity neighbor = level.getBlockEntity(getBlockPos().relative(direction));
if (!(neighbor instanceof Container container)) {
continue;
}
for (int slot = 0; slot < container.getContainerSize(); slot++) {
ItemStack stack = container.getItem(slot);
if (stack.isEmpty()) continue;
int burnTime = ForgeHooks.getBurnTime(stack, null);
if (burnTime > 0) {
container.removeItem(slot, 1);
burnTimeRemaining += burnTime;
setChanged();
return;
}
}
}
}
public boolean isBurning() {
return burnTimeRemaining > 0;
}
@Override
protected void saveAdditional(CompoundTag tag) {
super.saveAdditional(tag);
tag.putInt("BurnTime", burnTimeRemaining);
}
@Override
public void load(CompoundTag tag) {
super.load(tag);
burnTimeRemaining = tag.getInt("BurnTime");
}
}
@@ -0,0 +1,70 @@
package com.titanicmc.titanic.blockentity;
import com.titanicmc.titanic.registry.ModBlockEntities;
import com.titanicmc.titanic.ship.ShipUtil;
import com.titanicmc.titanic.ship.TitanicShipControl;
import net.minecraft.commands.arguments.EntityAnchorArgument;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.phys.Vec3;
import org.valkyrienskies.core.api.ships.LoadedServerShip;
import org.valkyrienskies.mod.common.ValkyrienSkiesMod;
import org.valkyrienskies.mod.common.entity.ShipMountingEntity;
/**
* The real, working ship's wheel. Right-click it to sit down and steer, just like the
* wheelhouse of the real Titanic: forward/back on the wheel throttles the engines, left/right
* turns the rudder.
*/
public class HelmBlockEntity extends BlockEntity {
private ShipMountingEntity seat;
public HelmBlockEntity(BlockPos pos, BlockState state) {
super(ModBlockEntities.HELM.get(), pos, state);
}
public void serverTick() {
LoadedServerShip ship = getShip();
if (ship == null) return;
TitanicShipControl control = ship.getAttachment(TitanicShipControl.class);
if (control == null) {
// Normally a Helm only exists after the Repair Panel finishes repairs (which
// already marks the control as repaired). This is just a safety net for ships
// that got a Helm some other way (e.g. placed directly in creative mode).
control = new TitanicShipControl();
control.markRepaired();
ship.setAttachment(TitanicShipControl.class, control);
}
control.ship = ship;
}
private LoadedServerShip getShip() {
return ShipUtil.getLoadedShipManagingPos((net.minecraft.server.level.ServerLevel) level, getBlockPos());
}
public boolean sit(Player player) {
LoadedServerShip ship = getShip();
if (ship == null) {
return false;
}
if (seat == null || !seat.isAlive()) {
seat = ValkyrienSkiesMod.SHIP_MOUNTING_ENTITY_TYPE.create(level);
if (seat == null) return false;
var facing = getBlockState().getValue(BlockStateProperties.HORIZONTAL_FACING);
Vec3 offset = Vec3.atLowerCornerOf(getBlockPos()).add(0.5, 1.1, 0.5).add(facing.getOpposite().getStepX() * 0.6, 0, facing.getOpposite().getStepZ() * 0.6);
seat.moveTo(offset.x, offset.y, offset.z);
seat.lookAt(EntityAnchorArgument.Anchor.EYES, offset.add(facing.getStepX(), 0, facing.getStepZ()));
seat.setController(true);
((net.minecraft.server.level.ServerLevel) level).addFreshEntityWithPassengers(seat);
}
return player.startRiding(seat, true);
}
}
@@ -0,0 +1,71 @@
package com.titanicmc.titanic.blockentity;
import com.titanicmc.titanic.registry.ModBlockEntities;
import com.titanicmc.titanic.ship.ShipUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
/**
* Tracks the rigging state of a {@link com.titanicmc.titanic.block.LiftingFrameBlock}.
* Once linked to a winch, {@link #serverTick(ServerLevel)} drives the raise sequence by
* asking {@link ShipUtil} to assemble the wreck into a Valkyrien Skies ship and apply a
* temporary lifting force until it breaches the surface.
*/
public class LiftingFrameBlockEntity extends BlockEntity {
private boolean linkedToWinch = false;
private BlockPos winchPos = null;
private boolean raiseStarted = false;
public LiftingFrameBlockEntity(BlockPos pos, BlockState state) {
super(ModBlockEntities.LIFTING_FRAME.get(), pos, state);
}
public boolean isRigged(BlockState state) {
return state.getValue(com.titanicmc.titanic.block.LiftingFrameBlock.CABLES) >= 4;
}
public boolean isLinkedToWinch() {
return linkedToWinch;
}
public void linkToWinch(BlockPos winch) {
this.linkedToWinch = true;
this.winchPos = winch.immutable();
setChanged();
}
public void serverTick(ServerLevel level) {
if (raiseStarted || !linkedToWinch || winchPos == null) {
return;
}
if (!isRigged(getBlockState())) {
return;
}
raiseStarted = true;
ShipUtil.beginWreckRaise(level, getBlockPos());
}
@Override
protected void saveAdditional(CompoundTag tag) {
super.saveAdditional(tag);
tag.putBoolean("LinkedToWinch", linkedToWinch);
tag.putBoolean("RaiseStarted", raiseStarted);
if (winchPos != null) {
tag.putLong("WinchPos", winchPos.asLong());
}
}
@Override
public void load(CompoundTag tag) {
super.load(tag);
linkedToWinch = tag.getBoolean("LinkedToWinch");
raiseStarted = tag.getBoolean("RaiseStarted");
if (tag.contains("WinchPos")) {
winchPos = BlockPos.of(tag.getLong("WinchPos"));
}
}
}
@@ -0,0 +1,211 @@
package com.titanicmc.titanic.blockentity;
import com.titanicmc.titanic.Config;
import com.titanicmc.titanic.registry.ModBlockEntities;
import com.titanicmc.titanic.registry.ModBlocks;
import com.titanicmc.titanic.registry.ModItems;
import com.titanicmc.titanic.ship.ShipUtil;
import com.titanicmc.titanic.ship.TitanicShipControl;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import org.valkyrienskies.core.api.ships.LoadedServerShip;
import java.util.List;
import java.util.Set;
/**
* Generated as part of the wreck's bridge structure, so it automatically becomes part of the
* ship at assembly time. Players hand in dry dock repair materials here; every delivery
* proportionally patches the hull's damaged blocks and broken portholes. The final part,
* the ship's wheel, finishes the job by installing a real, working {@link com.titanicmc.titanic.block.HelmBlock}.
*/
public class RepairPanelBlockEntity extends BlockEntity {
private enum Material {
IRON, GLASS, PANES, REPEATERS, COMPARATORS, CHESTS, PLANKS, REDSTONE_BLOCKS
}
private final int[] delivered = new int[Material.values().length];
private boolean wheelDelivered = false;
private int hullTotal = -1;
private int portholeTotal = -1;
public RepairPanelBlockEntity(BlockPos pos, BlockState state) {
super(ModBlockEntities.REPAIR_PANEL.get(), pos, state);
}
public void handleDeliver(ServerLevel level, Player player, ItemStack stack) {
if (stack.is(ModItems.SHIPS_WHEEL_PART.get())) {
deliverWheel(level, player);
return;
}
Material material = classify(stack);
if (material == null) {
player.displayClientMessage(Component.translatable("message.titanic.repair_wrong_item"), true);
return;
}
int required = requiredFor(material);
int have = delivered[material.ordinal()];
if (have >= required) {
player.displayClientMessage(Component.translatable("message.titanic.repair_material_done"), true);
return;
}
int amount = Math.min(stack.getCount(), required - have);
stack.shrink(amount);
delivered[material.ordinal()] += amount;
setChanged();
player.displayClientMessage(Component.translatable("message.titanic.repair_delivered",
delivered[material.ordinal()], required), true);
applyRepairProgress(level);
}
private void deliverWheel(ServerLevel level, Player player) {
if (!isMaterialsComplete()) {
player.displayClientMessage(Component.translatable("message.titanic.repair_needs_materials_first"), true);
return;
}
if (wheelDelivered) {
player.displayClientMessage(Component.translatable("message.titanic.repair_already_done"), true);
return;
}
wheelDelivered = true;
setChanged();
finishRepair(level, player);
}
private boolean isMaterialsComplete() {
for (Material material : Material.values()) {
if (delivered[material.ordinal()] < requiredFor(material)) {
return false;
}
}
return true;
}
private void applyRepairProgress(ServerLevel level) {
int totalRequired = 0;
int totalDelivered = 0;
for (Material material : Material.values()) {
totalRequired += requiredFor(material);
totalDelivered += delivered[material.ordinal()];
}
double progress = totalRequired == 0 ? 1.0 : (double) totalDelivered / (double) totalRequired;
Set<BlockPos> shipBlocks = ShipUtil.collectConnectedBlocks(level, getBlockPos(), Config.MAX_SHIP_BLOCKS.get());
if (hullTotal < 0) {
hullTotal = ShipUtil.findBlocksOfType(level, shipBlocks, ModBlocks.DAMAGED_HULL.get()).size();
}
if (portholeTotal < 0) {
portholeTotal = ShipUtil.findBlocksOfType(level, shipBlocks, ModBlocks.BROKEN_PORTHOLE.get()).size();
}
convertRemaining(level, shipBlocks, ModBlocks.DAMAGED_HULL.get(), ModBlocks.SHIP_HULL.get().defaultBlockState(),
hullTotal, progress);
convertRemaining(level, shipBlocks, ModBlocks.BROKEN_PORTHOLE.get(), Blocks.GLASS_PANE.defaultBlockState(),
portholeTotal, progress);
}
private void convertRemaining(ServerLevel level, Set<BlockPos> shipBlocks, net.minecraft.world.level.block.Block from,
BlockState toState, int total, double progress) {
if (total <= 0) return;
List<BlockPos> remaining = ShipUtil.findBlocksOfType(level, shipBlocks, from);
int alreadyConverted = total - remaining.size();
int shouldBeConverted = (int) Math.floor(progress * total);
int toConvertNow = Math.max(0, shouldBeConverted - alreadyConverted);
for (int i = 0; i < toConvertNow && i < remaining.size(); i++) {
level.setBlock(remaining.get(i), toState, 3);
}
}
private void finishRepair(ServerLevel level, Player player) {
Set<BlockPos> shipBlocks = ShipUtil.collectConnectedBlocks(level, getBlockPos(), Config.MAX_SHIP_BLOCKS.get());
List<BlockPos> sockets = ShipUtil.findBlocksOfType(level, shipBlocks, ModBlocks.HELM_SOCKET.get());
for (BlockPos socketPos : sockets) {
Direction facing = level.getBlockState(socketPos).hasProperty(BlockStateProperties.HORIZONTAL_FACING)
? level.getBlockState(socketPos).getValue(BlockStateProperties.HORIZONTAL_FACING)
: Direction.NORTH;
level.setBlock(socketPos, ModBlocks.HELM.get().defaultBlockState()
.setValue(BlockStateProperties.HORIZONTAL_FACING, facing), 3);
}
LoadedServerShip ship = ShipUtil.getLoadedShipManagingPos(level, getBlockPos());
if (ship != null) {
TitanicShipControl control = ship.getAttachment(TitanicShipControl.class);
if (control == null) {
control = new TitanicShipControl();
ship.setAttachment(TitanicShipControl.class, control);
}
control.markRepaired();
}
level.players().forEach(p -> p.displayClientMessage(Component.translatable("message.titanic.repair_complete"), false));
}
private static Material classify(ItemStack stack) {
if (stack.is(Items.IRON_INGOT)) return Material.IRON;
if (stack.is(Items.GLASS)) return Material.GLASS;
if (stack.is(Items.GLASS_PANE)) return Material.PANES;
if (stack.is(Items.REPEATER)) return Material.REPEATERS;
if (stack.is(Items.COMPARATOR)) return Material.COMPARATORS;
if (stack.getItem() instanceof net.minecraft.world.item.BlockItem blockItem
&& blockItem.getBlock() instanceof net.minecraft.world.level.block.ChestBlock) {
return Material.CHESTS;
}
if (stack.is(ItemTags.PLANKS)) return Material.PLANKS;
if (stack.is(Items.REDSTONE_BLOCK)) return Material.REDSTONE_BLOCKS;
return null;
}
private static int requiredFor(Material material) {
return switch (material) {
case IRON -> Config.DRY_DOCK_IRON_REQUIRED.get();
case GLASS -> Config.DRY_DOCK_GLASS_REQUIRED.get();
case PANES -> Config.DRY_DOCK_GLASS_PANES_REQUIRED.get();
case REPEATERS -> Config.DRY_DOCK_REPEATERS_REQUIRED.get();
case COMPARATORS -> Config.DRY_DOCK_COMPARATORS_REQUIRED.get();
case CHESTS -> Config.DRY_DOCK_CHESTS_REQUIRED.get();
case PLANKS -> Config.DRY_DOCK_PLANKS_REQUIRED.get();
case REDSTONE_BLOCKS -> Config.DRY_DOCK_REDSTONE_BLOCKS_REQUIRED.get();
};
}
@Override
protected void saveAdditional(CompoundTag tag) {
super.saveAdditional(tag);
tag.putIntArray("Delivered", delivered);
tag.putBoolean("WheelDelivered", wheelDelivered);
tag.putInt("HullTotal", hullTotal);
tag.putInt("PortholeTotal", portholeTotal);
}
@Override
public void load(CompoundTag tag) {
super.load(tag);
int[] loaded = tag.getIntArray("Delivered");
System.arraycopy(loaded, 0, delivered, 0, Math.min(loaded.length, delivered.length));
wheelDelivered = tag.getBoolean("WheelDelivered");
hullTotal = tag.contains("HullTotal") ? tag.getInt("HullTotal") : -1;
portholeTotal = tag.contains("PortholeTotal") ? tag.getInt("PortholeTotal") : -1;
}
}
@@ -0,0 +1,59 @@
package com.titanicmc.titanic.entity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.Level;
/**
* Invisible, non-solid mount used so a player can "sit" on a chair. Spawned on demand by
* {@link com.titanicmc.titanic.block.ChairBlock} and removed automatically once nobody is
* riding it.
*/
public class SeatEntity extends Entity {
public SeatEntity(EntityType<?> type, Level level) {
super(type, level);
this.noPhysics = true;
this.blocksBuilding = false;
}
@Override
public void tick() {
super.tick();
if (!level().isClientSide && this.getPassengers().isEmpty() && this.tickCount > 0) {
this.discard();
}
}
@Override
protected void defineSynchedData() {
// No synced data needed.
}
@Override
protected void readAdditionalSaveData(CompoundTag tag) {
// Nothing to persist.
}
@Override
protected void addAdditionalSaveData(CompoundTag tag) {
// Nothing to persist.
}
@Override
public boolean isPickable() {
return false;
}
@Override
public boolean isPushable() {
return false;
}
@Override
public boolean shouldBeSaved() {
return false;
}
}
@@ -0,0 +1,19 @@
package com.titanicmc.titanic.event;
import com.titanicmc.titanic.ship.ShipRaiseScheduler;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
/**
* Cross-cutting game event handling. Registered on the Forge event bus in
* {@link com.titanicmc.titanic.TitanicMod}.
*/
public class ForgeEventHandler {
@SubscribeEvent
public void onServerTick(TickEvent.ServerTickEvent event) {
if (event.phase == TickEvent.Phase.END) {
ShipRaiseScheduler.tick();
}
}
}
@@ -0,0 +1,33 @@
package com.titanicmc.titanic.registry;
import com.titanicmc.titanic.TitanicMod;
import com.titanicmc.titanic.blockentity.BoilerBlockEntity;
import com.titanicmc.titanic.blockentity.HelmBlockEntity;
import com.titanicmc.titanic.blockentity.LiftingFrameBlockEntity;
import com.titanicmc.titanic.blockentity.RepairPanelBlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class ModBlockEntities {
public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES =
DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, TitanicMod.MODID);
public static final RegistryObject<BlockEntityType<LiftingFrameBlockEntity>> LIFTING_FRAME =
BLOCK_ENTITIES.register("lifting_frame", () -> BlockEntityType.Builder.of(
LiftingFrameBlockEntity::new, ModBlocks.LIFTING_FRAME.get()).build(null));
public static final RegistryObject<BlockEntityType<RepairPanelBlockEntity>> REPAIR_PANEL =
BLOCK_ENTITIES.register("repair_panel", () -> BlockEntityType.Builder.of(
RepairPanelBlockEntity::new, ModBlocks.REPAIR_PANEL.get()).build(null));
public static final RegistryObject<BlockEntityType<HelmBlockEntity>> HELM =
BLOCK_ENTITIES.register("helm", () -> BlockEntityType.Builder.of(
HelmBlockEntity::new, ModBlocks.HELM.get()).build(null));
public static final RegistryObject<BlockEntityType<BoilerBlockEntity>> BOILER =
BLOCK_ENTITIES.register("boiler", () -> BlockEntityType.Builder.of(
BoilerBlockEntity::new, ModBlocks.BOILER.get()).build(null));
}
@@ -0,0 +1,23 @@
package com.titanicmc.titanic.registry;
import com.titanicmc.titanic.TitanicMod;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.block.Block;
public class ModBlockTags {
private ModBlockTags() {
}
/**
* Every block that can legitimately be part of a generated Titanic wreck/ship: the hull
* plating itself plus all the furniture/fixture blocks {@link com.titanicmc.titanic.worldgen.WreckFeature}
* places inside it. Used to bound {@link com.titanicmc.titanic.ship.ShipUtil#collectConnectedBlocks}
* so a flood fill starting on the wreck can never spill out into the surrounding seafloor
* terrain the wreck happens to be resting on/against.
*/
public static final TagKey<Block> SHIP_BLOCKS = TagKey.create(Registries.BLOCK,
new ResourceLocation(TitanicMod.MODID, "ship_blocks"));
}
@@ -0,0 +1,105 @@
package com.titanicmc.titanic.registry;
import com.titanicmc.titanic.TitanicMod;
import com.titanicmc.titanic.block.BoilerBlock;
import com.titanicmc.titanic.block.ChairBlock;
import com.titanicmc.titanic.block.CrankshaftBlock;
import com.titanicmc.titanic.block.HelmBlock;
import com.titanicmc.titanic.block.HelmSocketBlock;
import com.titanicmc.titanic.block.LiftingFrameBlock;
import com.titanicmc.titanic.block.RepairPanelBlock;
import com.titanicmc.titanic.block.WinchBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.material.MapColor;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class ModBlocks {
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, TitanicMod.MODID);
/** Rusted, holed hull plating - generated by the wreck, converted to {@link #SHIP_HULL} on repair. */
public static final RegistryObject<Block> DAMAGED_HULL = BLOCKS.register("damaged_hull",
() -> new Block(BlockBehaviour.Properties.of()
.mapColor(MapColor.COLOR_BROWN)
.strength(4.0f, 20.0f)
.sound(SoundType.NETHERITE_BLOCK)
.requiresCorrectToolForDrops()));
/** Freshly patched hull plating - what {@link #DAMAGED_HULL} becomes once repaired. */
public static final RegistryObject<Block> SHIP_HULL = BLOCKS.register("ship_hull",
() -> new Block(BlockBehaviour.Properties.of()
.mapColor(MapColor.METAL)
.strength(5.0f, 20.0f)
.sound(SoundType.METAL)
.requiresCorrectToolForDrops()));
/** A shattered porthole - generated by the wreck, converted to a glass pane on repair. */
public static final RegistryObject<Block> BROKEN_PORTHOLE = BLOCKS.register("broken_porthole",
() -> new Block(BlockBehaviour.Properties.of()
.mapColor(MapColor.COLOR_LIGHT_GRAY)
.strength(1.0f)
.sound(SoundType.GLASS)
.noOcclusion()));
/** Marks where the real helm will be installed once repairs finish. World-gen only. */
public static final RegistryObject<Block> HELM_SOCKET = BLOCKS.register("helm_socket",
() -> new HelmSocketBlock(BlockBehaviour.Properties.of()
.mapColor(MapColor.WOOD)
.strength(3.0f)
.sound(SoundType.WOOD)
.noOcclusion()));
/** The real, working ship's wheel. */
public static final RegistryObject<Block> HELM = BLOCKS.register("helm",
() -> new HelmBlock(BlockBehaviour.Properties.of()
.mapColor(MapColor.WOOD)
.strength(3.5f)
.sound(SoundType.WOOD)
.noOcclusion()));
public static final RegistryObject<Block> LIFTING_FRAME = BLOCKS.register("lifting_frame",
() -> new LiftingFrameBlock(BlockBehaviour.Properties.of()
.mapColor(MapColor.METAL)
.strength(5.0f)
.sound(SoundType.METAL)
.noOcclusion()));
public static final RegistryObject<Block> WINCH = BLOCKS.register("winch",
() -> new WinchBlock(BlockBehaviour.Properties.of()
.mapColor(MapColor.METAL)
.strength(5.0f)
.sound(SoundType.METAL)));
public static final RegistryObject<Block> REPAIR_PANEL = BLOCKS.register("repair_panel",
() -> new RepairPanelBlock(BlockBehaviour.Properties.of()
.mapColor(MapColor.COLOR_LIGHT_BLUE)
.strength(4.0f)
.sound(SoundType.METAL)
.lightLevel(state -> 6)));
public static final RegistryObject<Block> BOILER = BLOCKS.register("boiler",
() -> new BoilerBlock(BlockBehaviour.Properties.of()
.mapColor(MapColor.COLOR_BLACK)
.strength(6.0f, 20.0f)
.sound(SoundType.METAL)
.lightLevel(state -> 3)
.requiresCorrectToolForDrops()));
public static final RegistryObject<Block> CRANKSHAFT = BLOCKS.register("crankshaft",
() -> new CrankshaftBlock(BlockBehaviour.Properties.of()
.mapColor(MapColor.METAL)
.strength(6.0f, 20.0f)
.sound(SoundType.METAL)
.requiresCorrectToolForDrops()));
public static final RegistryObject<Block> CHAIR = BLOCKS.register("chair",
() -> new ChairBlock(BlockBehaviour.Properties.of()
.mapColor(MapColor.WOOD)
.strength(2.5f)
.sound(SoundType.WOOD)
.noOcclusion()));
}
@@ -0,0 +1,33 @@
package com.titanicmc.titanic.registry;
import com.titanicmc.titanic.TitanicMod;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.RegistryObject;
public class ModCreativeTabs {
public static final DeferredRegister<CreativeModeTab> TABS =
DeferredRegister.create(Registries.CREATIVE_MODE_TAB, TitanicMod.MODID);
public static final RegistryObject<CreativeModeTab> TITANIC_TAB = TABS.register("titanic",
() -> CreativeModeTab.builder()
.title(Component.translatable("itemGroup.titanic"))
.icon(() -> ModItems.HELM.get().getDefaultInstance())
.displayItems((parameters, output) -> {
output.accept(ModItems.STEEL_INGOT.get());
output.accept(ModItems.STEEL_CABLE.get());
output.accept(ModItems.SHIPS_WHEEL_PART.get());
output.accept(ModItems.SHIP_HULL.get());
output.accept(ModItems.LIFTING_FRAME.get());
output.accept(ModItems.WINCH.get());
output.accept(ModItems.REPAIR_PANEL.get());
output.accept(ModItems.BOILER.get());
output.accept(ModItems.CRANKSHAFT.get());
output.accept(ModItems.CHAIR.get());
output.accept(ModItems.HELM.get());
})
.build());
}
@@ -0,0 +1,23 @@
package com.titanicmc.titanic.registry;
import com.titanicmc.titanic.TitanicMod;
import com.titanicmc.titanic.entity.SeatEntity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class ModEntities {
public static final DeferredRegister<EntityType<?>> ENTITIES =
DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, TitanicMod.MODID);
public static final RegistryObject<EntityType<SeatEntity>> SEAT = ENTITIES.register("seat",
() -> EntityType.Builder.<SeatEntity>of(SeatEntity::new, MobCategory.MISC)
.sized(0.1f, 0.1f)
.noSummon()
.noSave()
.clientTrackingRange(6)
.build("seat"));
}
@@ -0,0 +1,19 @@
package com.titanicmc.titanic.registry;
import com.mojang.serialization.Codec;
import com.titanicmc.titanic.TitanicMod;
import com.titanicmc.titanic.worldgen.WreckFeature;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class ModFeatures {
public static final DeferredRegister<Feature<?>> FEATURES =
DeferredRegister.create(ForgeRegistries.FEATURES, TitanicMod.MODID);
public static final RegistryObject<Feature<NoneFeatureConfiguration>> WRECK =
FEATURES.register("wreck", () -> new WreckFeature(NoneFeatureConfiguration.CODEC));
}
@@ -0,0 +1,48 @@
package com.titanicmc.titanic.registry;
import com.titanicmc.titanic.TitanicMod;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class ModItems {
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, TitanicMod.MODID);
/** Smelted from iron; used to craft steel cables and hull-repair adjacent recipes. */
public static final RegistryObject<Item> STEEL_INGOT = ITEMS.register("steel_ingot",
() -> new Item(new Item.Properties()));
/**
* Threaded through a Lifting Frame's four eyes and then joined to a Winch to raise the wreck.
* Consumed on use.
*/
public static final RegistryObject<Item> STEEL_CABLE = ITEMS.register("steel_cable",
() -> new Item(new Item.Properties()));
/**
* The final part delivered to the Repair Panel. Consuming it slots a real,
* controllable helm into the wreck's bridge and finishes the repair.
*/
public static final RegistryObject<Item> SHIPS_WHEEL_PART = ITEMS.register("ships_wheel",
() -> new Item(new Item.Properties()));
public static final RegistryObject<Item> SHIP_HULL = ITEMS.register("ship_hull",
() -> new BlockItem(ModBlocks.SHIP_HULL.get(), new Item.Properties()));
public static final RegistryObject<Item> LIFTING_FRAME = ITEMS.register("lifting_frame",
() -> new BlockItem(ModBlocks.LIFTING_FRAME.get(), new Item.Properties()));
public static final RegistryObject<Item> WINCH = ITEMS.register("winch",
() -> new BlockItem(ModBlocks.WINCH.get(), new Item.Properties()));
public static final RegistryObject<Item> REPAIR_PANEL = ITEMS.register("repair_panel",
() -> new BlockItem(ModBlocks.REPAIR_PANEL.get(), new Item.Properties()));
public static final RegistryObject<Item> BOILER = ITEMS.register("boiler",
() -> new BlockItem(ModBlocks.BOILER.get(), new Item.Properties()));
public static final RegistryObject<Item> CRANKSHAFT = ITEMS.register("crankshaft",
() -> new BlockItem(ModBlocks.CRANKSHAFT.get(), new Item.Properties()));
public static final RegistryObject<Item> CHAIR = ITEMS.register("chair",
() -> new BlockItem(ModBlocks.CHAIR.get(), new Item.Properties()));
public static final RegistryObject<Item> HELM = ITEMS.register("helm",
() -> new BlockItem(ModBlocks.HELM.get(), new Item.Properties()));
}
@@ -0,0 +1,79 @@
package com.titanicmc.titanic.ship;
import com.titanicmc.titanic.TitanicMod;
import net.minecraft.server.level.ServerLevel;
import org.valkyrienskies.core.api.ships.LoadedServerShip;
import org.valkyrienskies.core.api.world.ServerShipWorld;
import org.valkyrienskies.mod.common.VSGameUtilsKt;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* Freshly {@link ShipUtil#assembleWreck assembled} ships are not always a
* {@link LoadedServerShip} on the very tick they're created - Valkyrien Skies relocates the
* collected blocks into a brand new ship storage area, and that area only becomes "loaded"
* once VS2 finishes registering it, which can take a tick or more.
* <p>
* Rather than giving up immediately when that happens, pending raises are tracked here by the
* ship's stable {@code long} id (not by {@link net.minecraft.core.BlockPos}, since the seed
* position's block may itself have just been physically relocated as part of assembly) and
* retried every server tick until the ship reports itself loaded, or a generous timeout is hit.
*/
public final class ShipRaiseScheduler {
/** ~30 seconds at 20 TPS. VS2 normally finishes loading within a tick or two. */
private static final int MAX_WAIT_TICKS = 600;
private static final List<Pending> PENDING = new ArrayList<>();
private ShipRaiseScheduler() {
}
/** Queues an already-assembled-but-not-yet-loaded ship to begin raising once it loads. */
public static void schedule(ServerLevel level, long shipId, double targetWorldY) {
PENDING.add(new Pending(level, shipId, targetWorldY));
}
/** Call once per server tick (see {@link com.titanicmc.titanic.event.ForgeEventHandler}). */
public static void tick() {
if (PENDING.isEmpty()) {
return;
}
Iterator<Pending> it = PENDING.iterator();
while (it.hasNext()) {
Pending pending = it.next();
ServerShipWorld shipWorld = VSGameUtilsKt.getShipObjectWorld(pending.level.getServer());
LoadedServerShip ship = shipWorld.getLoadedShips().getById(pending.shipId);
if (ship != null) {
TitanicMod.LOGGER.info(
"Ship {} finished loading after {} ticks - beginning raise to y={}",
pending.shipId, pending.ticksWaited, pending.targetWorldY);
ShipUtil.beginRaiseSafely(pending.level, ship, pending.targetWorldY);
it.remove();
continue;
}
pending.ticksWaited++;
if (pending.ticksWaited > MAX_WAIT_TICKS) {
TitanicMod.LOGGER.warn(
"Gave up waiting for assembled ship {} to finish loading for raising after {} ticks",
pending.shipId, pending.ticksWaited);
it.remove();
}
}
}
private static final class Pending {
final ServerLevel level;
final long shipId;
final double targetWorldY;
int ticksWaited = 0;
Pending(ServerLevel level, long shipId, double targetWorldY) {
this.level = level;
this.shipId = shipId;
this.targetWorldY = targetWorldY;
}
}
}
@@ -0,0 +1,211 @@
package com.titanicmc.titanic.ship;
import com.titanicmc.titanic.Config;
import com.titanicmc.titanic.TitanicMod;
import com.titanicmc.titanic.registry.ModBlockTags;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.joml.primitives.AABBdc;
import org.valkyrienskies.core.api.ships.LoadedServerShip;
import org.valkyrienskies.core.api.ships.ServerShip;
import org.valkyrienskies.mod.common.VSGameUtilsKt;
import org.valkyrienskies.mod.common.assembly.ShipAssembler;
/**
* All direct interop with the Valkyrien Skies 2 API lives here, so any future API changes
* only need to be fixed in one place.
* <p>
* Important VS2 quirk this class relies on: once a structure is assembled into a ship, every
* one of its blocks keeps living at its original ("storage") {@link BlockPos} for as long as
* the ship exists, even though the ship visually moves elsewhere in the world. Any BlockPos
* handed to us through normal block/interaction callbacks (place, use, block entity ticking)
* is always already in that stable storage space - Valkyrien Skies transparently remaps
* rendering, physics and click-raycasts for us. That means code elsewhere in this mod never
* needs to special-case "is this block on a ship" positions; it can use them exactly like any
* other {@link BlockPos}.
*/
public final class ShipUtil {
private ShipUtil() {
}
/**
* Returns the ship that manages storage of the block at {@code pos}, or {@code null} if
* that position isn't part of any assembled ship.
*/
public static ServerShip getShipManagingPos(ServerLevel level, BlockPos pos) {
return VSGameUtilsKt.getShipManagingPos(level, pos);
}
/**
* Same as {@link #getShipManagingPos}, but only returns a result if the ship is currently
* loaded (required to read/write ship attachments like {@link TitanicShipControl}).
*/
public static LoadedServerShip getLoadedShipManagingPos(ServerLevel level, BlockPos pos) {
ServerShip ship = getShipManagingPos(level, pos);
return ship instanceof LoadedServerShip loaded ? loaded : null;
}
/**
* Flood-fills every block tagged {@link ModBlockTags#SHIP_BLOCKS} connected to {@code seed}
* (up to the configured safety limit). Used both to gather the initial wreck for assembly
* and to re-scan an already assembled ship's blocks (e.g. to find remaining damaged blocks).
* <p>
* Only blocks that are actually part of a Titanic wreck/ship qualify - anything else (air,
* fluids, and, importantly, the natural seafloor terrain a wreck rests on/against) acts as a
* boundary the fill does not cross. Without this restriction a seed touching bare stone,
* sand, or gravel would keep flooding through the entire connected landmass until it hit
* {@code maxBlocks}, producing a huge, malformed "ship" instead of just the wreck.
* <p>
* {@code seed} itself is always accepted and expanded from regardless of that tag, even if
* it isn't a wreck block - callers seed this from player-placed attachment points like the
* {@link com.titanicmc.titanic.block.LiftingFrameBlock} lowered over the wreck, which need
* to bridge into the tagged wreck blocks touching them rather than being rejected outright.
*/
public static Set<BlockPos> collectConnectedBlocks(ServerLevel level, BlockPos seed, int maxBlocks) {
Set<BlockPos> collected = new HashSet<>();
Set<Long> visited = new HashSet<>();
ArrayDeque<BlockPos> queue = new ArrayDeque<>();
BlockPos immutableSeed = seed.immutable();
queue.add(immutableSeed);
visited.add(immutableSeed.asLong());
while (!queue.isEmpty() && collected.size() < maxBlocks) {
BlockPos pos = queue.poll();
BlockState state = level.getBlockState(pos);
boolean isSeed = pos.equals(immutableSeed);
if (!isSeed && !state.is(ModBlockTags.SHIP_BLOCKS)) {
continue;
}
if (state.isAir() || !state.getFluidState().isEmpty()) {
continue;
}
collected.add(pos);
for (int dx = -1; dx <= 1; dx++) {
for (int dy = -1; dy <= 1; dy++) {
for (int dz = -1; dz <= 1; dz++) {
if (dx == 0 && dy == 0 && dz == 0) continue;
BlockPos next = pos.offset(dx, dy, dz);
long key = next.asLong();
if (visited.add(key)) {
queue.add(next);
}
}
}
}
}
return collected;
}
/** Filters a previously collected block set down to positions currently holding {@code block}. */
public static List<BlockPos> findBlocksOfType(ServerLevel level, Set<BlockPos> allBlocks, Block block) {
List<BlockPos> found = new ArrayList<>();
for (BlockPos pos : allBlocks) {
if (level.getBlockState(pos).is(block)) {
found.add(pos);
}
}
return found;
}
/**
* Flood-fills every {@link ModBlockTags#SHIP_BLOCKS}-tagged block connected to {@code seed}
* and hands the collected region to Valkyrien Skies so it becomes one real, physically
* simulated ship.
*/
public static ServerShip assembleWreck(ServerLevel level, BlockPos seed) {
Set<BlockPos> collected = collectConnectedBlocks(level, seed, Config.MAX_SHIP_BLOCKS.get());
if (collected.isEmpty()) {
return null;
}
TitanicMod.LOGGER.info("Assembling Titanic hull with {} blocks", collected.size());
return ShipAssembler.assembleToShip(level, collected, 1.0);
}
/** Kicks off the raise sequence: assembles the wreck and applies lifting force until it surfaces. */
public static void beginWreckRaise(ServerLevel level, BlockPos seed) {
ServerShip assembled = getShipManagingPos(level, seed);
if (assembled == null) {
assembled = assembleWreck(level, seed);
}
if (assembled == null) {
TitanicMod.LOGGER.warn("Failed to assemble wreck at {} for raising", seed);
return;
}
double targetWorldY = level.getSeaLevel() + 1;
TitanicMod.LOGGER.info("Wreck assembled as ship id={} (already loaded={}), raise target y={}",
assembled.getId(), assembled instanceof LoadedServerShip, targetWorldY);
if (assembled instanceof LoadedServerShip ship) {
beginRaiseSafely(level, ship, targetWorldY);
} else {
// A freshly assembled ship isn't always immediately Loaded - VS2 relocates the
// collected blocks into a new ship storage area that can take a tick or more to
// finish registering. Retry by stable ship id until it comes online instead of
// failing outright (see ShipRaiseScheduler for why id, not BlockPos, is used).
ShipRaiseScheduler.schedule(level, assembled.getId(), targetWorldY);
}
}
/**
* Pushes any player standing on/near the ship safely clear before starting the raise, then
* begins it.
* <p>
* The raise repeatedly re-asserts the ship's position directly (see
* {@link TitanicShipControl}), which was observed to violently launch a player standing on
* the hull ~100 blocks away over the course of the raise - each of those position
* corrections appears to trigger Minecraft's own "entity is stuck inside a block" pushback
* against the player, and dozens of small pushes over a few seconds add up fast. Moving
* players safely above the ship first avoids that class of collision entirely.
*/
public static void beginRaiseSafely(ServerLevel level, LoadedServerShip ship, double targetWorldY) {
pushPlayersClear(level, ship);
getOrCreateControl(ship).beginRaise(targetWorldY);
}
/** Teleports any player inside/near the ship's world AABB to a safe spot directly above it. */
private static void pushPlayersClear(ServerLevel level, LoadedServerShip ship) {
AABBdc shipAabb = ship.getWorldAABB();
AABB searchArea = new AABB(
shipAabb.minX(), shipAabb.minY(), shipAabb.minZ(),
shipAabb.maxX(), shipAabb.maxY(), shipAabb.maxZ())
.inflate(4.0);
double safeY = shipAabb.maxY() + 10.0;
for (ServerPlayer player : level.getEntitiesOfClass(ServerPlayer.class, searchArea)) {
if (player.getY() < safeY) {
player.teleportTo(player.getX(), safeY, player.getZ());
player.setDeltaMovement(0.0, 0.0, 0.0);
player.fallDistance = 0.0f;
}
}
}
/** Gets or creates the {@link TitanicShipControl} attachment for a loaded ship. */
public static TitanicShipControl getOrCreateControl(LoadedServerShip ship) {
TitanicShipControl control = ship.getAttachment(TitanicShipControl.class);
if (control == null) {
control = new TitanicShipControl();
ship.setAttachment(TitanicShipControl.class, control);
}
// Keep this in sync unconditionally (cheap) so a valid LoadedServerShip reference is
// always available for direct transform manipulation (see TitanicShipControl.onServerTick),
// not just once a Helm block entity happens to refresh it.
control.ship = ship;
return control;
}
}
@@ -0,0 +1,230 @@
package com.titanicmc.titanic.ship;
import com.titanicmc.titanic.TitanicMod;
import org.joml.Vector3d;
import org.joml.Vector3dc;
import org.valkyrienskies.core.api.ships.LoadedServerShip;
import org.valkyrienskies.core.api.ships.PhysShip;
import org.valkyrienskies.core.api.ships.ServerTickListener;
import org.valkyrienskies.core.api.ships.ShipPhysicsListener;
import org.valkyrienskies.core.api.ships.properties.ShipTransform;
import org.valkyrienskies.core.api.world.PhysLevel;
import org.valkyrienskies.mod.api.SeatedControllingPlayer;
/**
* Per-ship "brain" attached to every assembled Titanic hull. Handles three responsibilities:
* <ul>
* <li>Raising: steps the hull's position directly upward each tick until it breaches the
* surface (see {@link #onServerTick}).</li>
* <li>Buoyancy assist: while not yet repaired, the wreck is full of holes and shouldn't
* realistically float - we cancel out net gravity so it doesn't sink while under tow.</li>
* <li>Propulsion: Boilers (with an adjacent Crankshaft) feed {@link #addEnginePower(double)}
* every tick; that power is turned into forward thrust in the direction the helm is
* facing, and steering torque from the helm's turn input.</li>
* </ul>
*/
public final class TitanicShipControl implements ShipPhysicsListener, ServerTickListener {
private static final double GRAVITY = 10.0;
/**
* Linear damping applied to vertical velocity every physics tick (see {@link #physTick}).
* Keeps any velocity the hull picks up (from collisions, residual momentum, etc.) from
* building up and coasting the hull upward/downward forever once gravity is cancelled below.
*/
private static final double VERTICAL_DAMPING = 2.0;
/**
* Blocks climbed per server tick while raising (20 ticks/sec, so ~3 blocks/sec).
* <p>
* Raising is driven by directly stepping the ship's transform via
* {@link org.valkyrienskies.core.api.ships.ServerShip#unsafeSetTransform} rather than by
* applying physics forces. Force-based raising (mass * constant acceleration, every physics
* tick) proved wildly unreliable for hulls this large: observed overshoot ranged from a few
* blocks to 600+ blocks past the target in under a second, wildly out of proportion to the
* force actually intended - almost certainly some multiplier/timestep mismatch specific to
* hulls with this many blocks/this much mass. Direct, small, per-tick position steps sidestep
* that whole class of problem entirely.
*/
private static final double RAISE_SPEED_PER_TICK = 0.15;
private volatile boolean raising = false;
private volatile double raiseTargetWorldY = 62.0;
private volatile boolean repaired = false;
private double pendingEnginePower = 0.0;
private double enginePower = 0.0;
private int raiseTickCounter = 0;
private boolean loggedInvalidMass = false;
/**
* Our own authoritative X/Y/Z for the ship while raising, forced onto it every tick via
* {@link org.valkyrienskies.core.api.ships.ServerShip#unsafeSetTransform} regardless of
* whatever position VS2's physics/collision engine may have produced in between our ticks.
* <p>
* The read-back position ({@code getTransform()}) was observed to become wildly corrupted
* mid-raise (Y jumping to values in the tens of thousands, even decreasing between ticks,
* which our own upward-only stepping could never do) - a bug in VS2 itself when a
* freshly-assembled hull's collision is resolved against the terrain/water it was just cut
* out of. Trusting that read-back to decide "where to step from next" let the corruption
* compound. Tracking our own value here and always re-asserting it sidesteps that entirely:
* whatever VS2 does to the ship between our ticks is simply overwritten back to where we
* expect it to be on the very next tick.
*/
private double raiseX = Double.NaN;
private double raiseY = Double.NaN;
private double raiseZ = Double.NaN;
/** Refreshed every game tick by the Helm block entity so physTick can find the seated player. */
public volatile LoadedServerShip ship;
public void beginRaise(double targetWorldY) {
this.raising = true;
this.raiseTargetWorldY = targetWorldY;
// NaN sentinel: onServerTick seeds these from the ship's real position on its first
// raising tick, then owns them exclusively from there on (see field javadoc above).
this.raiseX = Double.NaN;
this.raiseY = Double.NaN;
this.raiseZ = Double.NaN;
TitanicMod.LOGGER.info("TitanicShipControl.beginRaise: target y={}", targetWorldY);
}
public boolean isRaising() {
return raising;
}
public void markRepaired() {
this.repaired = true;
}
public boolean isRepaired() {
return repaired;
}
/** Called by a Boiler/Crankshaft pair every game tick to contribute propulsion power. */
public void addEnginePower(double power) {
pendingEnginePower += power;
}
@Override
public void onServerTick() {
enginePower = pendingEnginePower;
pendingEnginePower = 0.0;
if (!raising) {
return;
}
LoadedServerShip currentShip = this.ship;
if (currentShip == null) {
return;
}
ShipTransform transform = currentShip.getTransform();
if (Double.isNaN(raiseY)) {
// First tick of this raise - seed our own tracked position from the real one once.
Vector3dc startPos = transform.getPosition();
raiseX = startPos.x();
raiseY = startPos.y();
raiseZ = startPos.z();
}
if (raiseY >= raiseTargetWorldY) {
raising = false;
TitanicMod.LOGGER.info("Raising complete at y={}", raiseY);
return;
}
raiseY = Math.min(raiseY + RAISE_SPEED_PER_TICK, raiseTargetWorldY);
Vector3d newPos = new Vector3d(raiseX, raiseY, raiseZ);
ShipTransform newTransform =
transform.copy(newPos, transform.getPositionInModel(), transform.getRotation(), transform.getScaling());
currentShip.unsafeSetTransform(newTransform);
if (raiseTickCounter++ % 20 == 0) {
TitanicMod.LOGGER.info("Raising: y={} target={} (actual ship-reported y={})",
raiseY, raiseTargetWorldY, transform.getPosition().y());
}
}
@Override
public void physTick(PhysShip physShip, PhysLevel physLevel) {
double mass = physShip.getMass();
if (!(mass > 0.0) || !Double.isFinite(mass)) {
// A ship's inertia data can momentarily be unset/invalid right as it finishes
// loading. Applying forces computed from a bogus mass (0, NaN, Infinity) would
// inject garbage into the physics engine, which can corrupt or silently delete the
// ship - skip this tick entirely rather than risk that.
if (!loggedInvalidMass) {
TitanicMod.LOGGER.warn("TitanicShipControl.physTick: skipping tick(s), invalid mass={}", mass);
loggedInvalidMass = true;
}
return;
}
// Valkyrien Skies has its own built-in fluid buoyancy simulation, which was fighting
// our own hand-tuned gravity-cancel/raise force below - both were pushing the hull
// upward at once, and depending on how much of the hull happened to be submerged that
// combination produced wildly inconsistent, sometimes huge, overshoot (observed
// anywhere from a few blocks to 150+ blocks past the raise target). We want full manual
// control over vertical motion here, so disable VS2's automatic buoyancy/fluid drag
// entirely and let our own forces be the only thing acting on it.
physShip.setBuoyantFactor(0.0);
physShip.setDoFluidDrag(false);
// NOTE: marking the ship static while raising was tried here to stop VS2's own
// physics/collision engine from fighting our unsafeSetTransform calls. It backfired in a
// different way than expected: our position updates DID appear to take effect visually
// for the player (the hull was seen rising for a few seconds), but the physics engine's
// own internal position never actually moved (confirmed via logging - it stayed pinned
// at the pre-raise value for the entire raise) and un-staticing at the end snapped
// everything back to that stale position, which is what looked like the ship
// "disappearing" right after the visible rise. VS2's own reference usage of
// unsafeSetTransform (its ShipCreatorItem) never touches setStatic either, so we don't
// either - we stay dynamic and simply re-assert our own tracked position every tick in
// onServerTick (see the raiseX/Y/Z field javadoc), unconditionally overwriting whatever
// the physics engine did to it in between. Now that beginRaiseSafely moves nearby
// players out of the way first, the engine's own uncontrolled collision response during
// that tug-of-war can no longer launch anyone even if it still happens.
Vector3dc centerOfMass = physShip.getCenterOfMass();
// While actively raising, position is driven directly in onServerTick via
// unsafeSetTransform - don't also fight it with gravity-cancel force here.
if (!raising && !repaired) {
// Cancel gravity so the patched-up hull doesn't sink under tow.
physShip.applyWorldForce(new Vector3d(0.0, mass * GRAVITY, 0.0), centerOfMass);
}
// Always bleed off vertical velocity a little so any residual momentum (from
// collisions, buoyancy remnants, etc.) doesn't coast the hull upward/downward forever
// once other vertical forces are balanced out.
double verticalVelocity = physShip.getVelocity().y();
physShip.applyWorldForce(new Vector3d(0.0, -mass * verticalVelocity * VERTICAL_DAMPING, 0.0), centerOfMass);
LoadedServerShip currentShip = this.ship;
SeatedControllingPlayer controller =
currentShip != null ? currentShip.getAttachment(SeatedControllingPlayer.class) : null;
if (enginePower > 0.0001 && controller != null) {
Vector3d forwardDirection = new Vector3d(
controller.getSeatInDirection().getStepX(),
0.0,
controller.getSeatInDirection().getStepZ());
physShip.getTransform().getShipToWorldRotation().transform(forwardDirection);
forwardDirection.normalize();
Vector3d thrust = forwardDirection.mul(enginePower * controller.getForwardImpulse());
physShip.applyWorldForce(thrust, centerOfMass);
float turn = controller.getLeftImpulse();
if (Math.abs(turn) > 0.0001) {
double turnStrength = enginePower * 0.02 * turn;
physShip.applyWorldTorque(new Vector3d(0.0, turnStrength, 0.0));
}
}
// Always damp angular velocity a little so the hull doesn't spin forever.
Vector3dc omega = physShip.getAngularVelocity();
physShip.applyWorldTorque(new Vector3d(omega).mul(-mass * 0.02));
}
}
@@ -0,0 +1,173 @@
package com.titanicmc.titanic.worldgen;
import com.mojang.serialization.Codec;
import com.titanicmc.titanic.registry.ModBlocks;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.registries.ForgeRegistries;
/**
* Procedurally builds a stylised, single-piece Titanic wreck lying on the seafloor. This is
* deliberately a simplified silhouette (a tapered hull with a bow, a few interior rooms, and
* marked bridge/engine areas) rather than a 1:1 scale replica - it's generated entirely in
* code, with no schematic/NBT structure file and no player-visible "assembly" of separate
* pieces.
*/
public class WreckFeature extends Feature<NoneFeatureConfiguration> {
private static final int LENGTH = 48;
private static final int WIDTH = 9;
private static final int HEIGHT = 12;
private static final int BOW_TAPER = LENGTH / 4;
public WreckFeature(Codec<NoneFeatureConfiguration> codec) {
super(codec);
}
@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> context) {
WorldGenLevel level = context.level();
RandomSource random = context.random();
BlockPos origin = anchorToChunk(context.origin());
int centerZ = WIDTH / 2;
for (int x = 0; x < LENGTH; x++) {
int halfWidth = halfWidthAt(x);
boolean bowTip = x == 0;
boolean sternWall = x == LENGTH - 1;
for (int y = 0; y < HEIGHT; y++) {
boolean keel = y == 0;
boolean deck = y == HEIGHT - 1;
for (int z = centerZ - halfWidth; z <= centerZ + halfWidth; z++) {
boolean sideWall = z == centerZ - halfWidth || z == centerZ + halfWidth;
boolean shell = bowTip || sternWall || keel || deck || sideWall;
BlockPos pos = origin.offset(x, y, z - centerZ);
if (!shell) {
// Hollow interior.
level.setBlock(pos, Blocks.WATER.defaultBlockState(), 2);
continue;
}
if (deck && random.nextFloat() < 0.06f) {
// A few holes punched through the deck.
level.setBlock(pos, Blocks.WATER.defaultBlockState(), 2);
continue;
}
if (sideWall && !bowTip && !sternWall && y == HEIGHT / 2 && z % 3 == 0) {
level.setBlock(pos, ModBlocks.BROKEN_PORTHOLE.get().defaultBlockState(), 2);
continue;
}
if (shell && random.nextFloat() < 0.1f && !keel) {
// Damage: leave a gap in the hull plating.
continue;
}
level.setBlock(pos, ModBlocks.DAMAGED_HULL.get().defaultBlockState(), 2);
}
}
}
buildEngineRoom(level, origin, centerZ, random);
buildGalleyAndCabins(level, origin, centerZ, random);
buildBridge(level, origin, centerZ);
return true;
}
/**
* The placement modifiers ({@code in_square} + {@code heightmap}) hand us an origin whose
* X/Z can land anywhere within the chunk currently being decorated. Since the hull is
* {@link #LENGTH} (48) blocks long in X - three chunks' worth - building it forward from
* that arbitrary in-chunk X would routinely write into chunks more than one chunk away from
* the decorating chunk, which is exactly what trips vanilla's "Detected setBlock in a far
* chunk" sanity check (a plain {@link Feature}'s {@link WorldGenLevel} is only guaranteed
* safe for writes within one chunk of the one being decorated).
* <p>
* To stay inside that safe window regardless of where in its chunk the origin happens to
* fall, the hull is anchored to the decorating chunk's own boundary instead of to the
* origin's exact X: it always starts one full chunk before that chunk and runs for exactly
* three chunks (48 blocks), i.e. spanning the decorating chunk minus-one through plus-one -
* precisely the safe range - every time. Only X is adjusted; Y (from the heightmap sample)
* and Z (the hull is only {@link #WIDTH} blocks wide, well under one chunk) are left as-is.
*/
private static BlockPos anchorToChunk(BlockPos origin) {
int chunkStartX = origin.getX() - Math.floorMod(origin.getX(), 16);
return new BlockPos(chunkStartX - 16, origin.getY(), origin.getZ());
}
private static int halfWidthAt(int x) {
int half = WIDTH / 2;
if (x < BOW_TAPER) {
int taperedHalf = Math.round(half * ((x + 1f) / BOW_TAPER));
return Math.max(1, taperedHalf);
}
return half;
}
private void buildEngineRoom(WorldGenLevel level, BlockPos origin, int centerZ, RandomSource random) {
int startX = LENGTH / 4 + 2;
int floorY = 1;
for (int i = 0; i < 3; i++) {
int x = startX + i * 2;
BlockPos boilerPos = origin.offset(x, floorY, 0);
level.setBlock(boilerPos, ModBlocks.BOILER.get().defaultBlockState(), 2);
level.setBlock(boilerPos.relative(Direction.SOUTH), ModBlocks.CRANKSHAFT.get().defaultBlockState(), 2);
}
}
private void buildGalleyAndCabins(WorldGenLevel level, BlockPos origin, int centerZ, RandomSource random) {
int x = (int) (LENGTH * 0.62);
int floorY = 1;
BlockState cookingBlock = getFarmersDelightCookingBlock();
level.setBlock(origin.offset(x, floorY, -2), cookingBlock, 2);
level.setBlock(origin.offset(x, floorY, 2), ModBlocks.CHAIR.get().defaultBlockState(), 2);
level.setBlock(origin.offset(x + 1, floorY, 2), ModBlocks.CHAIR.get().defaultBlockState(), 2);
int cabinX = (int) (LENGTH * 0.72);
level.setBlock(origin.offset(cabinX, floorY, -1), Blocks.RED_BED.defaultBlockState()
.setValue(BlockStateProperties.HORIZONTAL_FACING, Direction.EAST)
.setValue(BlockStateProperties.BED_PART, net.minecraft.world.level.block.state.properties.BedPart.FOOT), 2);
level.setBlock(origin.offset(cabinX + 1, floorY, -1), Blocks.RED_BED.defaultBlockState()
.setValue(BlockStateProperties.HORIZONTAL_FACING, Direction.EAST)
.setValue(BlockStateProperties.BED_PART, net.minecraft.world.level.block.state.properties.BedPart.HEAD), 2);
}
private void buildBridge(WorldGenLevel level, BlockPos origin, int centerZ) {
int x = LENGTH - 6;
int floorY = HEIGHT - 3;
level.setBlock(origin.offset(x, floorY, 0), ModBlocks.HELM_SOCKET.get().defaultBlockState()
.setValue(BlockStateProperties.HORIZONTAL_FACING, Direction.WEST), 2);
level.setBlock(origin.offset(x - 1, floorY, 0), ModBlocks.REPAIR_PANEL.get().defaultBlockState(), 2);
}
private static BlockState getFarmersDelightCookingBlock() {
if (ModList.get().isLoaded("farmersdelight")) {
var block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation("farmersdelight", "cooking_pot"));
if (block != null) {
return block.defaultBlockState();
}
}
return Blocks.FURNACE.defaultBlockState();
}
}
+94
View File
@@ -0,0 +1,94 @@
# This is an example mods.toml file. It contains the data relating to the loading mods.
# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
# The overall format is standard TOML format, v0.5.0.
# Note that there are a couple of TOML lists in this file.
# Find more information on toml format here: https://github.com/toml-lang/toml
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
modLoader="javafml" #mandatory
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
loaderVersion="${loader_version_range}" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
license="${mod_license}"
# A URL to refer people to when problems occur with this mod
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
# If your mod is purely client-side and has no multiplayer functionality (be it dedicated servers or Open to LAN),
# set this to true, and Forge will set the correct displayTest for you and skip loading your mod on dedicated servers.
#clientSideOnly=true #optional - defaults to false if absent
# A list of mods - how many allowed here is determined by the individual mod loader
[[mods]] #mandatory
# The modid of the mod
modId="${mod_id}" #mandatory
# The version number of the mod
version="${mod_version}" #mandatory
# A display name for the mod
displayName="${mod_name}" #mandatory
# A URL to query for updates for this mod. See the JSON update specification https://docs.minecraftforge.net/en/latest/misc/updatechecker/
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional
# A URL for the "homepage" for this mod, displayed in the mod UI
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional
# A file name (in the root of the mod JAR) containing a logo for display
#logoFile="examplemod.png" #optional
# A text field displayed in the mod UI
#credits="" #optional
# A text field displayed in the mod UI
authors="${mod_authors}" #optional
# Display Test controls the display for your mod in the server connection screen
# MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod.
# IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod.
# IGNORE_ALL_VERSION means that your mod will not cause a red X if it's present on the client or the server. This is a special case and should only be used if your mod has no server component.
# NONE means that no display test is set on your mod. You need to do this yourself, see IExtensionPoint.DisplayTest for more information. You can define any scheme you wish with this value.
# IMPORTANT NOTE: this is NOT an instruction as to which environments (CLIENT or DEDICATED SERVER) your mod loads on. Your mod should load (and maybe do nothing!) whereever it finds itself.
#displayTest="MATCH_VERSION" # if nothing is specified, MATCH_VERSION is the default when clientSideOnly=false, otherwise IGNORE_ALL_VERSION when clientSideOnly=true (#optional)
# The description text for the mod (multi line!) (#mandatory)
description='''${mod_description}'''
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
[[dependencies.${mod_id}]] #optional
# the modid of the dependency
modId="forge" #mandatory
# Does this dependency have to exist - if not, ordering below must be specified
mandatory=true #mandatory
# The version range of the dependency
versionRange="${forge_version_range}" #mandatory
# An ordering relationship for the dependency - BEFORE or AFTER required if the dependency is not mandatory
# BEFORE - This mod is loaded BEFORE the dependency
# AFTER - This mod is loaded AFTER the dependency
ordering="NONE"
# Side this dependency is applied on - BOTH, CLIENT, or SERVER
side="BOTH"
# Here's another dependency
[[dependencies.${mod_id}]]
modId="minecraft"
mandatory=true
# This version range declares a minimum of the current minecraft version up to but not including the next major version
versionRange="${minecraft_version_range}"
ordering="NONE"
side="BOTH"
# Valkyrien Skies 2 provides the ship physics that make the repaired Titanic actually sail.
[[dependencies.${mod_id}]]
modId="valkyrienskies"
mandatory=true
versionRange="[2.0,)"
ordering="AFTER"
side="BOTH"
# Valkyrien Skies is written in Kotlin and needs the Kotlin runtime provided by this mod.
[[dependencies.${mod_id}]]
modId="kotlinforforge"
mandatory=true
versionRange="[4.10,)"
ordering="AFTER"
side="BOTH"
# Optional: if Farmer's Delight is installed, the Titanic's galley uses its cooking blocks/food.
[[dependencies.${mod_id}]]
modId="farmersdelight"
mandatory=false
versionRange="[1.20.1,)"
ordering="AFTER"
side="BOTH"
# Features are specific properties of the game environment, that you may want to declare you require. This example declares
# that your mod requires GL version 3.2 or higher. Other features will be added. They are side aware so declaring this won't
# stop your mod loading on the server for example.
#[features.${mod_id}]
#openGLVersion="[3.2,)"
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "titanic:block/boiler" }
}
}
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "titanic:block/broken_porthole" }
}
}
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "titanic:block/chair" }
}
}
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "titanic:block/crankshaft" }
}
}
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "titanic:block/damaged_hull" }
}
}
@@ -0,0 +1,8 @@
{
"variants": {
"facing=north": { "model": "titanic:block/helm" },
"facing=south": { "model": "titanic:block/helm", "y": 180 },
"facing=west": { "model": "titanic:block/helm", "y": 270 },
"facing=east": { "model": "titanic:block/helm", "y": 90 }
}
}
@@ -0,0 +1,8 @@
{
"variants": {
"facing=north": { "model": "titanic:block/helm_socket" },
"facing=south": { "model": "titanic:block/helm_socket", "y": 180 },
"facing=west": { "model": "titanic:block/helm_socket", "y": 270 },
"facing=east": { "model": "titanic:block/helm_socket", "y": 90 }
}
}
@@ -0,0 +1,9 @@
{
"variants": {
"cables=0": { "model": "titanic:block/lifting_frame" },
"cables=1": { "model": "titanic:block/lifting_frame" },
"cables=2": { "model": "titanic:block/lifting_frame" },
"cables=3": { "model": "titanic:block/lifting_frame" },
"cables=4": { "model": "titanic:block/lifting_frame" }
}
}
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "titanic:block/repair_panel" }
}
}
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "titanic:block/ship_hull" }
}
}
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "titanic:block/winch" }
}
}
@@ -0,0 +1,50 @@
{
"itemGroup.titanic": "Titanic",
"item.titanic.steel_ingot": "Steel Ingot",
"item.titanic.steel_cable": "Steel Cable",
"item.titanic.ships_wheel": "Ship's Wheel (Part)",
"item.titanic.ship_hull": "Ship Hull Plating",
"item.titanic.lifting_frame": "Lifting Frame",
"item.titanic.winch": "Winch",
"item.titanic.repair_panel": "Repair Panel",
"item.titanic.boiler": "Boiler",
"item.titanic.crankshaft": "Crankshaft",
"item.titanic.chair": "Chair",
"item.titanic.helm": "Ship's Helm",
"block.titanic.damaged_hull": "Damaged Hull Plating",
"block.titanic.ship_hull": "Ship Hull Plating",
"block.titanic.broken_porthole": "Broken Porthole",
"block.titanic.helm_socket": "Helm Socket",
"block.titanic.helm": "Ship's Helm",
"block.titanic.lifting_frame": "Lifting Frame",
"block.titanic.winch": "Winch",
"block.titanic.repair_panel": "Repair Panel",
"block.titanic.boiler": "Boiler",
"block.titanic.crankshaft": "Crankshaft",
"block.titanic.chair": "Chair",
"message.titanic.frame_threaded": "Cable threaded: %s/%s",
"message.titanic.frame_rigged": "The lifting frame is fully rigged! Link it to a winch on the surface.",
"message.titanic.frame_already_linked": "This frame is already linked to a winch.",
"message.titanic.frame_needs_winch": "Fully rigged. Now link a winch above with a Steel Cable.",
"message.titanic.frame_needs_cable": "This frame still needs %s more cable(s).",
"message.titanic.winch_needs_cable": "You need a Steel Cable to link this winch.",
"message.titanic.frame_not_rigged": "The lifting frame below isn't fully rigged yet.",
"message.titanic.raise_started": "The cable is taut - the wreck is being raised!",
"message.titanic.no_frame_found": "No lifting frame found directly below this winch.",
"message.titanic.boiler_fed": "You feed the boiler.",
"message.titanic.boiler_burning": "The boiler is already burning.",
"message.titanic.boiler_needs_fuel": "The boiler needs fuel.",
"message.titanic.helm_not_seaworthy": "She isn't seaworthy yet - finish the dry dock repairs first.",
"message.titanic.repair_wrong_item": "The repair panel doesn't need that.",
"message.titanic.repair_material_done": "That material has already been fully delivered.",
"message.titanic.repair_delivered": "Delivered: %s/%s",
"message.titanic.repair_needs_materials_first": "Deliver all other materials before installing the ship's wheel.",
"message.titanic.repair_already_done": "The ship's wheel has already been installed.",
"message.titanic.repair_complete": "Repairs complete - the Titanic sails again!"
}
@@ -0,0 +1,29 @@
{
"textures": {
"side": "titanic:block/boiler_side",
"top": "titanic:block/boiler_top",
"door": "titanic:block/boiler_door"
},
"elements": [
{
"name": "tank",
"from": [1, 0, 1],
"to": [15, 14, 15],
"faces": {
"down": {"texture": "#top"}, "up": {"texture": "#top"},
"north": {"texture": "#door"}, "south": {"texture": "#side"},
"west": {"texture": "#side"}, "east": {"texture": "#side"}
}
},
{
"name": "cap",
"from": [0, 14, 0],
"to": [16, 16, 16],
"faces": {
"down": {"texture": "#top"}, "up": {"texture": "#top"},
"north": {"texture": "#top"}, "south": {"texture": "#top"},
"west": {"texture": "#top"}, "east": {"texture": "#top"}
}
}
]
}
@@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "titanic:block/broken_porthole"
}
}
@@ -0,0 +1,14 @@
{
"textures": {
"wood": "titanic:block/chair_wood",
"cushion": "titanic:block/chair_cushion"
},
"elements": [
{ "name": "leg_nw", "from": [2, 0, 2], "to": [4, 7, 4], "faces": {"down":{"texture":"#wood"},"up":{"texture":"#wood"},"north":{"texture":"#wood"},"south":{"texture":"#wood"},"west":{"texture":"#wood"},"east":{"texture":"#wood"}} },
{ "name": "leg_ne", "from": [12, 0, 2], "to": [14, 7, 4], "faces": {"down":{"texture":"#wood"},"up":{"texture":"#wood"},"north":{"texture":"#wood"},"south":{"texture":"#wood"},"west":{"texture":"#wood"},"east":{"texture":"#wood"}} },
{ "name": "leg_sw", "from": [2, 0, 12], "to": [4, 7, 14], "faces": {"down":{"texture":"#wood"},"up":{"texture":"#wood"},"north":{"texture":"#wood"},"south":{"texture":"#wood"},"west":{"texture":"#wood"},"east":{"texture":"#wood"}} },
{ "name": "leg_se", "from": [12, 0, 12], "to": [14, 7, 14], "faces": {"down":{"texture":"#wood"},"up":{"texture":"#wood"},"north":{"texture":"#wood"},"south":{"texture":"#wood"},"west":{"texture":"#wood"},"east":{"texture":"#wood"}} },
{ "name": "seat", "from": [2, 7, 2], "to": [14, 9, 14], "faces": {"down":{"texture":"#wood"},"up":{"texture":"#cushion"},"north":{"texture":"#wood"},"south":{"texture":"#wood"},"west":{"texture":"#wood"},"east":{"texture":"#wood"}} },
{ "name": "backrest", "from": [2, 9, 2], "to": [14, 16, 4], "faces": {"down":{"texture":"#wood"},"up":{"texture":"#wood"},"north":{"texture":"#wood"},"south":{"texture":"#cushion"},"west":{"texture":"#wood"},"east":{"texture":"#wood"}} }
]
}
@@ -0,0 +1,10 @@
{
"textures": {
"metal": "titanic:block/crankshaft_metal"
},
"elements": [
{ "name": "flywheel_left", "from": [2, 3, 5], "to": [6, 13, 11], "faces": {"down":{"texture":"#metal"},"up":{"texture":"#metal"},"north":{"texture":"#metal"},"south":{"texture":"#metal"},"west":{"texture":"#metal"},"east":{"texture":"#metal"}} },
{ "name": "shaft", "from": [4, 6, 6], "to": [12, 10, 10], "faces": {"down":{"texture":"#metal"},"up":{"texture":"#metal"},"north":{"texture":"#metal"},"south":{"texture":"#metal"},"west":{"texture":"#metal"},"east":{"texture":"#metal"}} },
{ "name": "flywheel_right", "from": [10, 3, 5], "to": [14, 13, 11], "faces": {"down":{"texture":"#metal"},"up":{"texture":"#metal"},"north":{"texture":"#metal"},"south":{"texture":"#metal"},"west":{"texture":"#metal"},"east":{"texture":"#metal"}} }
]
}
@@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "titanic:block/damaged_hull"
}
}
@@ -0,0 +1,78 @@
{
"textures": {
"wood": "titanic:block/helm_wood",
"rim": "titanic:block/helm_wheel_rim"
},
"elements": [
{
"name": "base",
"from": [2, 0, 2],
"to": [14, 3, 14],
"faces": {
"down": {"texture": "#wood"}, "up": {"texture": "#wood"},
"north": {"texture": "#wood"}, "south": {"texture": "#wood"},
"west": {"texture": "#wood"}, "east": {"texture": "#wood"}
}
},
{
"name": "pole",
"from": [6, 3, 6],
"to": [10, 12, 10],
"faces": {
"down": {"texture": "#wood"}, "up": {"texture": "#wood"},
"north": {"texture": "#wood"}, "south": {"texture": "#wood"},
"west": {"texture": "#wood"}, "east": {"texture": "#wood"}
}
},
{
"name": "wheel_hub",
"from": [6, 9, 6],
"to": [10, 13, 10],
"faces": {
"down": {"texture": "#rim"}, "up": {"texture": "#rim"},
"north": {"texture": "#rim"}, "south": {"texture": "#rim"},
"west": {"texture": "#rim"}, "east": {"texture": "#rim"}
}
},
{
"name": "wheel_top",
"from": [5, 14, 7],
"to": [11, 16, 9],
"faces": {
"down": {"texture": "#rim"}, "up": {"texture": "#rim"},
"north": {"texture": "#rim"}, "south": {"texture": "#rim"},
"west": {"texture": "#rim"}, "east": {"texture": "#rim"}
}
},
{
"name": "wheel_bottom",
"from": [5, 6, 7],
"to": [11, 8, 9],
"faces": {
"down": {"texture": "#rim"}, "up": {"texture": "#rim"},
"north": {"texture": "#rim"}, "south": {"texture": "#rim"},
"west": {"texture": "#rim"}, "east": {"texture": "#rim"}
}
},
{
"name": "wheel_left",
"from": [5, 8, 7],
"to": [7, 14, 9],
"faces": {
"down": {"texture": "#rim"}, "up": {"texture": "#rim"},
"north": {"texture": "#rim"}, "south": {"texture": "#rim"},
"west": {"texture": "#rim"}, "east": {"texture": "#rim"}
}
},
{
"name": "wheel_right",
"from": [9, 8, 7],
"to": [11, 14, 9],
"faces": {
"down": {"texture": "#rim"}, "up": {"texture": "#rim"},
"north": {"texture": "#rim"}, "south": {"texture": "#rim"},
"west": {"texture": "#rim"}, "east": {"texture": "#rim"}
}
}
]
}
@@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "titanic:block/helm_socket"
}
}
@@ -0,0 +1,19 @@
{
"textures": {
"beam": "titanic:block/lifting_frame_beam"
},
"elements": [
{ "name": "post_nw", "from": [1, 0, 1], "to": [3, 16, 3], "faces": {"down":{"texture":"#beam"},"up":{"texture":"#beam"},"north":{"texture":"#beam"},"south":{"texture":"#beam"},"west":{"texture":"#beam"},"east":{"texture":"#beam"}} },
{ "name": "post_ne", "from": [13, 0, 1], "to": [15, 16, 3], "faces": {"down":{"texture":"#beam"},"up":{"texture":"#beam"},"north":{"texture":"#beam"},"south":{"texture":"#beam"},"west":{"texture":"#beam"},"east":{"texture":"#beam"}} },
{ "name": "post_sw", "from": [1, 0, 13], "to": [3, 16, 15], "faces": {"down":{"texture":"#beam"},"up":{"texture":"#beam"},"north":{"texture":"#beam"},"south":{"texture":"#beam"},"west":{"texture":"#beam"},"east":{"texture":"#beam"}} },
{ "name": "post_se", "from": [13, 0, 13], "to": [15, 16, 15], "faces": {"down":{"texture":"#beam"},"up":{"texture":"#beam"},"north":{"texture":"#beam"},"south":{"texture":"#beam"},"west":{"texture":"#beam"},"east":{"texture":"#beam"}} },
{ "name": "top_north", "from": [1, 13, 1], "to": [15, 16, 3], "faces": {"down":{"texture":"#beam"},"up":{"texture":"#beam"},"north":{"texture":"#beam"},"south":{"texture":"#beam"},"west":{"texture":"#beam"},"east":{"texture":"#beam"}} },
{ "name": "top_south", "from": [1, 13, 13], "to": [15, 16, 15], "faces": {"down":{"texture":"#beam"},"up":{"texture":"#beam"},"north":{"texture":"#beam"},"south":{"texture":"#beam"},"west":{"texture":"#beam"},"east":{"texture":"#beam"}} },
{ "name": "top_west", "from": [1, 13, 1], "to": [3, 16, 15], "faces": {"down":{"texture":"#beam"},"up":{"texture":"#beam"},"north":{"texture":"#beam"},"south":{"texture":"#beam"},"west":{"texture":"#beam"},"east":{"texture":"#beam"}} },
{ "name": "top_east", "from": [13, 13, 1], "to": [15, 16, 15], "faces": {"down":{"texture":"#beam"},"up":{"texture":"#beam"},"north":{"texture":"#beam"},"south":{"texture":"#beam"},"west":{"texture":"#beam"},"east":{"texture":"#beam"}} },
{ "name": "bottom_north", "from": [1, 0, 1], "to": [15, 3, 3], "faces": {"down":{"texture":"#beam"},"up":{"texture":"#beam"},"north":{"texture":"#beam"},"south":{"texture":"#beam"},"west":{"texture":"#beam"},"east":{"texture":"#beam"}} },
{ "name": "bottom_south", "from": [1, 0, 13], "to": [15, 3, 15], "faces": {"down":{"texture":"#beam"},"up":{"texture":"#beam"},"north":{"texture":"#beam"},"south":{"texture":"#beam"},"west":{"texture":"#beam"},"east":{"texture":"#beam"}} },
{ "name": "bottom_west", "from": [1, 0, 1], "to": [3, 3, 15], "faces": {"down":{"texture":"#beam"},"up":{"texture":"#beam"},"north":{"texture":"#beam"},"south":{"texture":"#beam"},"west":{"texture":"#beam"},"east":{"texture":"#beam"}} },
{ "name": "bottom_east", "from": [13, 0, 1], "to": [15, 3, 15], "faces": {"down":{"texture":"#beam"},"up":{"texture":"#beam"},"north":{"texture":"#beam"},"south":{"texture":"#beam"},"west":{"texture":"#beam"},"east":{"texture":"#beam"}} }
]
}
@@ -0,0 +1,28 @@
{
"textures": {
"side": "titanic:block/repair_panel_side",
"front": "titanic:block/repair_panel_front"
},
"elements": [
{
"name": "back_plate",
"from": [1, 1, 12],
"to": [15, 15, 16],
"faces": {
"down": {"texture": "#side"}, "up": {"texture": "#side"},
"north": {"texture": "#side"}, "south": {"texture": "#side"},
"west": {"texture": "#side"}, "east": {"texture": "#side"}
}
},
{
"name": "screen",
"from": [3, 3, 9],
"to": [13, 13, 12],
"faces": {
"down": {"texture": "#side"}, "up": {"texture": "#side"},
"north": {"texture": "#front"}, "south": {"texture": "#side"},
"west": {"texture": "#side"}, "east": {"texture": "#side"}
}
}
]
}
@@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "titanic:block/ship_hull"
}
}
@@ -0,0 +1,12 @@
{
"textures": {
"frame": "titanic:block/winch_frame",
"drum": "titanic:block/winch_drum"
},
"elements": [
{ "name": "stand_left", "from": [1, 0, 6], "to": [3, 10, 10], "faces": {"down":{"texture":"#frame"},"up":{"texture":"#frame"},"north":{"texture":"#frame"},"south":{"texture":"#frame"},"west":{"texture":"#frame"},"east":{"texture":"#frame"}} },
{ "name": "stand_right", "from": [13, 0, 6], "to": [15, 10, 10], "faces": {"down":{"texture":"#frame"},"up":{"texture":"#frame"},"north":{"texture":"#frame"},"south":{"texture":"#frame"},"west":{"texture":"#frame"},"east":{"texture":"#frame"}} },
{ "name": "drum", "from": [3, 6, 6], "to": [13, 10, 10], "faces": {"down":{"texture":"#drum"},"up":{"texture":"#drum"},"north":{"texture":"#drum"},"south":{"texture":"#drum"},"west":{"texture":"#drum"},"east":{"texture":"#drum"}} },
{ "name": "handle", "from": [13, 9, 9], "to": [16, 11, 11], "faces": {"down":{"texture":"#frame"},"up":{"texture":"#frame"},"north":{"texture":"#frame"},"south":{"texture":"#frame"},"west":{"texture":"#frame"},"east":{"texture":"#frame"}} }
]
}
@@ -0,0 +1 @@
{ "parent": "titanic:block/boiler" }
@@ -0,0 +1 @@
{ "parent": "titanic:block/chair" }
@@ -0,0 +1 @@
{ "parent": "titanic:block/crankshaft" }
@@ -0,0 +1 @@
{ "parent": "titanic:block/helm" }
@@ -0,0 +1 @@
{ "parent": "titanic:block/lifting_frame" }
@@ -0,0 +1 @@
{ "parent": "titanic:block/repair_panel" }
@@ -0,0 +1 @@
{ "parent": "titanic:block/ship_hull" }
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "titanic:item/ships_wheel"
}
}
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "titanic:item/steel_cable"
}
}
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "titanic:item/steel_ingot"
}
}
@@ -0,0 +1 @@
{ "parent": "titanic:block/winch" }
Binary file not shown.

After

Width:  |  Height:  |  Size: 377 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 559 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 424 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 652 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 576 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 571 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 339 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 393 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 314 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

@@ -0,0 +1,6 @@
{
"type": "forge:add_features",
"biomes": "#minecraft:is_ocean",
"features": "titanic:wreck",
"step": "underground_structures"
}
@@ -0,0 +1,12 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{ "type": "minecraft:item", "name": "titanic:boiler" }
],
"conditions": [ { "condition": "minecraft:survives_explosion" } ]
}
]
}

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