started 1.18 rewrite

This commit is contained in:
ticticboooom
2021-12-02 12:24:10 +00:00
parent 6bbac07caf
commit 609e6e24a6
250 changed files with 385 additions and 13050 deletions

View File

@@ -1,40 +0,0 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG]"
labels: bug
assignees: ticticboooom, MasterSloth1
---
<!--
# Notice
Please do not use github issues to post ideas. Ideas should be posted in the #mm-suggestions on Discord (https://discord.gg/NCSRkkPbmF).
Please delete everything above the version information, including this notice before submitting your issue.
Tip: Use two spaces at the end of lines to force a new line.
-->
# Version Information
Forge version:
Masterful Machinery version:
ADD ON'S
if not installed just put "null"
Optifine version:
Botania version:
Create version:
Mekanism version:
Pneumaticcraft version:
Astral Sorcery version:
# Further Information
Link to latest.log: (please use a paste site such as [gist](https://gist.github.com/), do not attach the .txt or paste the log inline)\
Steps to reproduce:
1.
2.
3.
etc...
What I expected to happen:
What happened instead:

View File

@@ -1,27 +0,0 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Java CI with Gradle
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build

View File

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

View File

@@ -1,13 +0,0 @@
![masterful_machinery_cover](https://user-images.githubusercontent.com/55724525/117580477-1955d200-b0c6-11eb-9d40-52b62bbb9881.png)
# Masterful Machinery
### Masterful Machinery is a mod about creating customisable and complex multiblocks machines. Everything in the mod is customisable with Datapacks and configuration files.
Visit [the wiki](https://github.com/TicTicBoooom-Mods/MasterfulMachinery/wiki) to have more informations on how to use the mod.
# Download
You can download the mod on the [curseforge page](https://www.curseforge.com/minecraft/mc-mods/masterful-machinery).
Additional Resources:
=========================
Mod Discord: https://discord.gg/NCSRkkPbmF

View File

@@ -1,39 +1,28 @@
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
maven { url = 'https://files.minecraftforge.net/maven' }
// These repositories are only for Gradle plugins, put any other repositories in the repository block further below
maven { url = 'https://maven.minecraftforge.net' }
mavenCentral()
maven { url "https://repo.spongepowered.org/maven/" }
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '4.1.+', changing: true
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
}
}
plugins {
id 'com.github.johnrengelman.shadow' version '4.0.4'
}
apply plugin: 'net.minecraftforge.gradle'
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'org.spongepowered.mixin'
version = '1.16.5-0.1.57-B' + getVersionNumber()
group = 'com.ticticboooom.mods.mm' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'MasterfulMachinery'
java.toolchain.languageVersion = JavaLanguageVersion.of(8) // Mojang ships Java 8 to end users, so your mod should target Java 8.
version = '0.1.0-1.18'
group = 'live.ticticboooom.mods' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'masterfulmachinery'
configurations {
shade
compile.extendsFrom shade
}
// 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.
// The mappings can be changed at any time and must be in the following format.
// Channel: Version:
// snapshot YYYYMMDD Snapshot are built nightly.
// stable # Stables are built at the discretion of the MCP team.
@@ -42,22 +31,20 @@ minecraft {
// You must be aware of the Mojang license when using the 'official' mappings.
// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
//
// Use non-default mappings at your own risk. they may not always work.
// Use non-default mappings at your own risk. They may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: 'snapshot', version: '20210309-1.16.5'
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
mappings channel: 'official', version: '1.18'
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.
// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
client {
workingDirectory project.file('run')
arg '-mixin.config=masterfulmachinery.mixins.json'
// Recommended logging data for a userdev environment
// The markers can be changed as needed.
// 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.
@@ -67,13 +54,12 @@ minecraft {
// 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'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
mods {
masterfulmachinery {
source sourceSets.main
}
mmtest {
masterfulmachinery_test {
source sourceSets.test
}
}
@@ -81,9 +67,9 @@ minecraft {
server {
workingDirectory project.file('run')
arg '-mixin.config=masterfulmachinery.mixins.json'
// Recommended logging data for a userdev environment
// The markers can be changed as needed.
// 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.
@@ -93,13 +79,12 @@ minecraft {
// 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'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
mods {
masterfulmachinery {
source sourceSets.main
}
mmtest {
masterfulmachinery_test {
source sourceSets.test
}
}
@@ -109,148 +94,84 @@ minecraft {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
// The markers can be changed as needed.
// 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'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${buildDir}/createSrgToMcp/output.srg"
// 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'
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
args '--mod', 'masterfulmachinery', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
mods {
masterfulmachinery {
source sourceSets.main
}
masterfulmachinery_test {
source sourceSets.test
}
}
}
}
}
shadowJar {
configurations = [project.configurations.shade]
}
// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }
repositories {
maven { url 'https://modmaven.dev/' }
maven {
name = "Cursemaven"
url = "https://www.cursemaven.com/"
}
maven {
url 'https://repo.spongepowered.org/maven/'
}
maven {
name 'HellFirePvP'
url 'https://maven.hellfiredev.net/'
}
// Put repositories for dependencies here
// ForgeGradle automatically adds the Forge maven and Maven Central for you
maven {
name 'Curios'
url "https://maven.theillusivec4.top/"
}
maven { url 'https://maven.blamejared.com' }
maven {
url = "https://maven.saps.dev/minecraft"
content {
includeGroup "dev.latvian.mods"
}
}
maven {
// Shedaniel's maven (Architectury API)
url = "https://maven.architectury.dev"
content {
includeGroup "me.shedaniel"
}
}
// If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
// flatDir {
// dir 'libs'
// }
}
dependencies {
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
// Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed
// that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied.
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
compileOnly 'org.projectlombok:lombok:1.18.18'
annotationProcessor 'org.projectlombok:lombok:1.18.18'
minecraft 'net.minecraftforge:forge:1.16.5-36.1.23'
minecraft 'net.minecraftforge:forge:1.18-38.0.5'
compileOnly 'com.google.code.gson:gson:2.8.7'
implementation 'org.spongepowered:mixin:0.8-SNAPSHOT'
annotationProcessor 'org.spongepowered:mixin:0.8.2:processor'
// Real mod deobf dependency examples - these get remapped to your current mappings
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
// runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency
// implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency
implementation fg.deobf("mekanism:Mekanism:${mekanism_version}")// core
runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}:additions")// Mekanism: Additions
runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}:generators")// Mekanism: Generators
runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}:tools")// Mekanism: Tools
compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api")
// at runtime, use the full JEI jar
runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}")
implementation fg.deobf('me.desht.pneumaticcraft:pneumaticcraft-repressurized:1.16.5-2.12.2-186')
implementation fg.deobf("curse.maven:hwyla-253449:3033593")
implementation fg.deobf("curse.maven:create-328085:3384222")
implementation fg.deobf("curse.maven:flywheel-486392:3384004")
implementation fg.deobf("curse.maven:astral-sorcery-241721:3156477")
implementation fg.deobf("curse.maven:observerlib-316833:3162044")
// runtime deps
runtimeOnly fg.deobf("curse.maven:curios-309927:3231111")
compileOnly fg.deobf("vazkii.botania:Botania:1.16.5-416:api")
runtimeOnly fg.deobf("vazkii.botania:Botania:1.16.5-416")
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.16.4-51")
implementation "dev.latvian.mods:rhino:1605.1.0-build.4"
implementation fg.deobf("me.shedaniel:architectury-forge:v1.15.13")
implementation fg.deobf("dev.latvian.mods:kubejs-forge:1605.3.10-build.8")
// You may put jars on which you depend on in ./libs or you may define them like so..
// compile "some.group:artifact:version:classifier"
// compile "some.group:artifact:version"
// Real examples
// compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
// compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
// The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
// provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
// These dependencies get remapped to your current MCP mappings
// deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev'
// Examples using mod jars from ./libs
// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
// For more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
}
// Example for how to get properties into the manifest for reading by the runtime..
// Example for how to get properties into the manifest for reading at runtime.
jar {
manifest {
attributes([
"MixinConfigs" : "masterfulmachinery.mixins.json",
"Specification-Title" : "masterfulmachinery",
"Specification-Vendor" : "ticticboooom",
"Specification-Vendor" : "masterfulmachinerysareus",
"Specification-Version" : "1", // We are version 1 of ourselves
"Implementation-Title" : project.name,
"Implementation-Version" : "${version}",
"Implementation-Vendor" : "TicTicBoooom",
"Implementation-Version" : project.jar.archiveVersion,
"Implementation-Vendor" : "masterfulmachinerysareus",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
// Example configuration to allow publishing using the maven-publish task
// Example configuration to allow publishing using the maven-publish plugin
// This is the preferred method to reobfuscate your jar file
jar.finalizedBy('reobfShadowJar')
jar.finalizedBy('reobfJar')
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
//publish.dependsOn('reobfJar')
// publish.dependsOn('reobfJar')
publishing {
publications {
@@ -260,47 +181,7 @@ publishing {
}
repositories {
maven {
url "file:///${project.projectDir}/mcmodsrepo"
url "file://${project.projectDir}/mcmodsrepo"
}
}
}
reobf {
shadowJar {
dependsOn createMcpToSrg
mappings = createMcpToSrg.outputs.files.singleFile
}
}
def getVersionNumber() {
def vFile = file('version.properties')
def Integer buildNumber = 0
if (vFile.canRead()) {
def Properties versionProps = new Properties();
versionProps.load(new FileInputStream(vFile))
def code = versionProps.getProperty("VERSION_CODE").toInteger() + 1
buildNumber = code
versionProps.setProperty("VERSION_CODE", code.toString())
versionProps.store(vFile.newWriter(), null)
}
return buildNumber.toString()
}
mixin {
add sourceSets.main, "masterfulmachinery.refmap.json"
}
artifacts {
archives shadowJar
shadow shadowJar
}
reobf {
shadowJar {
dependsOn createMcpToSrg
mappings = createMcpToSrg.outputs.files.singleFile
}
}

View File

@@ -1,96 +0,0 @@
{
"controllerId": "basic",
"name": "Basic",
"ports": [
{
"type": "masterfulmachinery:items",
"textureOverride": "minecraft:block/white_terracotta",
"name": "Item",
"id": "simple",
"data": {
"rows": 1,
"columns": 1
}
},
{
"type": "masterfulmachinery:energy",
"name": "Energy",
"id": "simple",
"data": {
"capacity": 1000000
}
},
{
"type": "masterfulmachinery:fluids",
"name": "Fluid",
"id": "simple",
"data": {
"capacity": 5000
}
},
{
"type": "masterfulmachinery:pncr_pressure",
"name": "Pressure",
"id": "simple",
"data": {
"criticalPressure": 7,
"dangerPressure": 5,
"volume": 7000
}
},
{
"type": "masterfulmachinery:botania_mana",
"name": "Mana",
"id": "simple",
"data": {
"capacity": 50000
}
},
{
"type": "masterfulmachinery:astral_starlight",
"name": "Starlight",
"id": "simple",
"data": {
"capacity": 500
}
},
{
"type": "masterfulmachinery:create_rotation",
"name": "Rotation",
"id": "simple",
"data": {
"stress": 32
}
},
{
"type": "masterfulmachinery:mekanism_gas",
"name": "Gas",
"id": "simple",
"data": {
"capacity": 100000
}
},
{
"type": "masterfulmachinery:mekanism_slurry",
"name": "Slurry",
"id": "simple",
"data": {
"capacity": 100000
}
},
{
"type": "masterfulmachinery:mekanism_infuse",
"name": "Infuse",
"id": "simple",
"data": {
"capacity": 100000
}
},
{
"type": "masterfulmachinery:weather",
"name": "Weather",
"id": "simple",
"data": {}
}
]
}

View File

@@ -1,106 +0,0 @@
{
"controllerId": "mid",
"name": "Mid",
"ports": [
{
"type": "masterfulmachinery:items",
"textureOverride": "minecraft:block/red_terracotta",
"name": "Item",
"id": "intermediate",
"data": {
"rows": 3,
"columns": 3
}
},
{
"type": "masterfulmachinery:energy",
"textureOverride": "minecraft:block/red_terracotta",
"name": "Energy",
"id": "intermediate",
"data": {
"capacity": 1000000000
}
},
{
"type": "masterfulmachinery:fluids",
"textureOverride": "minecraft:block/red_terracotta",
"name": "Fluid",
"id": "intermediate",
"data": {
"capacity": 10000
}
},
{
"type": "masterfulmachinery:pncr_pressure",
"textureOverride": "minecraft:block/red_terracotta",
"name": "Pressure",
"id": "intermediate",
"data": {
"criticalPressure": 7,
"dangerPressure": 5,
"volume": 10000
}
},
{
"type": "masterfulmachinery:botania_mana",
"textureOverride": "minecraft:block/red_terracotta",
"name": "Mana",
"id": "intermediate",
"data": {
"capacity": 100000
}
},
{
"type": "masterfulmachinery:astral_starlight",
"textureOverride": "minecraft:block/red_terracotta",
"name": "Starlight",
"id": "intermediate",
"data": {
"capacity": 1000
}
},
{
"type": "masterfulmachinery:create_rotation",
"textureOverride": "minecraft:block/red_terracotta",
"name": "Rotation",
"id": "intermediate",
"data": {
"stress": 128
}
},
{
"type": "masterfulmachinery:mekanism_gas",
"textureOverride": "minecraft:block/red_terracotta",
"name": "Gas",
"id": "intermediate",
"data": {
"capacity": 100000000
}
},
{
"type": "masterfulmachinery:mekanism_slurry",
"textureOverride": "minecraft:block/red_terracotta",
"name": "Slurry",
"id": "intermediate",
"data": {
"capacity": 100000000
}
},
{
"type": "masterfulmachinery:mekanism_infuse",
"textureOverride": "minecraft:block/red_terracotta",
"name": "Infuse",
"id": "intermediate",
"data": {
"capacity": 100000000
}
},
{
"type": "masterfulmachinery:weather",
"textureOverride": "minecraft:block/red_terracotta",
"name": "Weather",
"id": "intermediate",
"data": {}
}
]
}

View File

@@ -1,7 +1,4 @@
# 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
mekanism_version=1.16.5-10.0.20.447
mc_version=1.16.5
jei_version=7.+
org.gradle.daemon=false

Binary file not shown.

View File

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

269
gradlew vendored
View File

@@ -1,7 +1,7 @@
#!/usr/bin/env sh
#!/bin/sh
#
# Copyright 2015 the original author or authors.
# 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.
@@ -17,67 +17,101 @@
#
##############################################################################
##
## Gradle start up script for UN*X
##
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
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
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
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
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
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
@@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
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"
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD="$JAVA_HOME/bin/java"
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
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
@@ -106,80 +140,95 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# 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.
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

View File

@@ -1 +0,0 @@
rootProject.name = "masterfulmachinery"

View File

@@ -1,155 +0,0 @@
package com.ticticboooom.mods.mm;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.gson.Gson;
import com.ticticboooom.mods.mm.block.ControllerBlock;
import com.ticticboooom.mods.mm.block.MachinePortBlock;
import com.ticticboooom.mods.mm.block.container.ControllerBlockContainer;
import com.ticticboooom.mods.mm.block.container.PortBlockContainer;
import com.ticticboooom.mods.mm.client.screen.ControllerBlockContainerScreen;
import com.ticticboooom.mods.mm.client.screen.PortBlockContainerScreen;
import com.ticticboooom.mods.mm.client.screen.StructureGenBlockContainerScreen;
import com.ticticboooom.mods.mm.client.ter.StructureGenTileEntityRenderer;
import com.ticticboooom.mods.mm.datagen.MMPackFinder;
import com.ticticboooom.mods.mm.datagen.DataGeneratorFactory;
import com.ticticboooom.mods.mm.datagen.PackType;
import com.ticticboooom.mods.mm.datagen.gen.runtime.MMBlockStateProvider;
import com.ticticboooom.mods.mm.datagen.gen.runtime.MMItemModelProvider;
import com.ticticboooom.mods.mm.datagen.gen.runtime.MMLangProvider;
import com.ticticboooom.mods.mm.datagen.gen.runtime.MMLootTableProvider;
import com.ticticboooom.mods.mm.network.PacketHandler;
import com.ticticboooom.mods.mm.registration.MMLoader;
import com.ticticboooom.mods.mm.registration.MMPorts;
import com.ticticboooom.mods.mm.registration.MMSetup;
import com.ticticboooom.mods.mm.registration.RecipeTypes;
import lombok.SneakyThrows;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScreenManager;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.RenderTypeLookup;
import net.minecraft.data.DataGenerator;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.resources.ResourcePackList;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModLoader;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.loading.FMLEnvironment;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
@Mod(MM.ID)
public class MM {
public static final String ID = "masterfulmachinery";
public static final Logger LOG = LogManager.getLogger("Masterful Machinery");
public static final Gson GSON = new Gson();
private DataGenerator generator;
private static boolean hasGenerated = false;
private static MM instance;
@SneakyThrows
public MM() {
instance = this;
MMPorts.init();
DataGeneratorFactory.init();
PacketHandler.init();
registerDataGen();
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
MMSetup.BLOCKS_REG.register(bus);
MMSetup.ITEMS_REG.register(bus);
MMSetup.TILES_REG.register(bus);
MMSetup.CONTAINER_REG.register(bus);
RecipeTypes.RECIPE_SERIALIZERS.register(bus);
bus.addListener(this::clientEvents);
try {
if (FMLEnvironment.dist == Dist.CLIENT) {
Minecraft.getInstance().getResourcePackList().addPackFinder(new MMPackFinder(PackType.RESOURCE));
}
} catch (Exception ignored) {
}
MinecraftForge.EVENT_BUS.addListener(this::onServerStart);
}
private void registerDataGen() {
generator = DataGeneratorFactory.createMemoryDataGenerator();
ExistingFileHelper existingFileHelper = new ExistingFileHelper(ImmutableList.of(), ImmutableSet.of(), false);
generator.addProvider(new MMLootTableProvider(generator));
if (FMLEnvironment.dist != Dist.DEDICATED_SERVER) {
generator.addProvider(new MMBlockStateProvider(generator, existingFileHelper));
generator.addProvider(new MMItemModelProvider(generator, existingFileHelper));
generator.addProvider(new MMLangProvider(generator));
}
}
public static void generate() {
if (!hasGenerated) {
try {
if (!ModLoader.isLoadingStateValid()){
return;
}
instance.generator.run();
} catch (IOException e) {
e.printStackTrace();
}
hasGenerated = true;
}
}
public void onServerStart(final FMLServerAboutToStartEvent event) {
event.getServer().getResourcePacks().addPackFinder(new MMPackFinder(PackType.DATA));
}
private void clientEvents(final FMLClientSetupEvent event) {
for (RegistryObject<ContainerType<ControllerBlockContainer>> container : MMLoader.CONTAINERS) {
ScreenManager.registerFactory(container.get(), ControllerBlockContainerScreen::new);
}
for (RegistryObject<ContainerType<?>> container : MMLoader.PORT_CONTAINERS) {
ScreenManager.registerFactory((ContainerType<PortBlockContainer>) container.get(), PortBlockContainerScreen::new);
}
for (RegistryObject<ControllerBlock> block : MMLoader.BLOCKS) {
RenderTypeLookup.setRenderLayer(block.get(), layer -> layer == RenderType.getSolid() || layer == RenderType.getTranslucent());
}
for (RegistryObject<MachinePortBlock> block : MMLoader.IPORT_BLOCKS) {
RenderTypeLookup.setRenderLayer(block.get(), layer -> layer == RenderType.getSolid() || layer == RenderType.getTranslucent());
}
for (RegistryObject<MachinePortBlock> block : MMLoader.OPORT_BLOCKS) {
RenderTypeLookup.setRenderLayer(block.get(), layer -> layer == RenderType.getSolid() || layer == RenderType.getTranslucent());
}
RenderTypeLookup.setRenderLayer(MMSetup.PROJECTOR_BLOCK.get(), RenderType.getTranslucent());
ScreenManager.registerFactory(MMSetup.STRUCTURE_CONTAINER.get(), StructureGenBlockContainerScreen::new);
ClientRegistry.bindTileEntityRenderer(MMSetup.STRUCTURE_TILE.get(), StructureGenTileEntityRenderer::new);
}
public static void injectDatapackFinder(ResourcePackList resourcePacks) {
if (DistExecutor.unsafeRunForDist(() -> () -> resourcePacks != Minecraft.getInstance().getResourcePackList(), () -> () -> true)) {
resourcePacks.addPackFinder(new MMPackFinder(PackType.RESOURCE));
MM.LOG.info("Injecting data pack finder.");
}
}
}

View File

@@ -1,86 +0,0 @@
package com.ticticboooom.mods.mm.block;
import com.ticticboooom.mods.mm.block.tile.ControllerBlockEntity;
import com.ticticboooom.mods.mm.model.ModelOverrideModel;
import lombok.Getter;
import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.shapes.IBooleanFunction;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.network.NetworkHooks;
import javax.annotation.Nullable;
import java.util.stream.Stream;
public class ControllerBlock extends DirectionalBlock {
private RegistryObject<TileEntityType<?>> type;
@Getter
private String controllerName;
@Getter
private String controllerId;
@Getter
private String texOverride;
public ControllerBlock(RegistryObject<TileEntityType<?>> type, String name, String id, String texOverride) {
super(AbstractBlock.Properties.create(Material.IRON).setRequiresTool().hardnessAndResistance(5.0F, 6.0F).sound(SoundType.METAL).harvestLevel(0)
.harvestTool(ToolType.PICKAXE));
this.type = type;
this.controllerName = name;
this.controllerId = id;
this.texOverride = texOverride;
this.setDefaultState(this.getDefaultState().with(FACING, Direction.NORTH));
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder.add(FACING));
}
@Nullable
@Override
public BlockState getStateForPlacement(BlockItemUseContext ctx) {
return this.getDefaultState().with(FACING, ctx.getPlacementHorizontalFacing().getOpposite());
}
@Override
public boolean hasTileEntity(BlockState state) {
return true;
}
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return type.get().create();
}
@Override
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
if (!worldIn.isRemote()) {
TileEntity blockEntity = worldIn.getTileEntity(pos);
if (blockEntity instanceof ControllerBlockEntity) {
NetworkHooks.openGui(((ServerPlayerEntity) player), (ControllerBlockEntity)blockEntity, pos);
}
}
return ActionResultType.SUCCESS;
}
}

View File

@@ -1,110 +0,0 @@
package com.ticticboooom.mods.mm.block;
import com.ticticboooom.mods.mm.block.tile.IMachinePortTile;
import com.ticticboooom.mods.mm.block.tile.MachinePortBlockEntity;
import com.ticticboooom.mods.mm.inventory.ItemStackInventory;
import lombok.Getter;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.network.NetworkHooks;
import net.minecraftforge.items.ItemStackHandler;
import javax.annotation.Nullable;
public class MachinePortBlock extends Block {
private RegistryObject<TileEntityType<?>> type;
@Getter
private String langName;
@Getter
private String controllerId;
@Getter
private String textureOverride;
@Getter
private ResourceLocation overlay;
@Getter
private ResourceLocation portTypeId;
public MachinePortBlock(RegistryObject<TileEntityType<?>> type, String name, String controllerId, String textureOverride, ResourceLocation overlay, ResourceLocation portTypeId) {
super(AbstractBlock.Properties.create(Material.IRON).setRequiresTool().hardnessAndResistance(5.0F, 6.0F).sound(SoundType.METAL).harvestLevel(0)
.harvestTool(ToolType.PICKAXE));
this.type = type;
this.langName = name;
this.controllerId = controllerId;
this.textureOverride = textureOverride;
this.overlay = overlay;
this.portTypeId = portTypeId;
}
@Override
public boolean hasTileEntity(BlockState state) {
return true;
}
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return type.get().create();
}
@Override
public ActionResultType onBlockActivated(BlockState state, World level, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult traceResult) {
if (!level.isRemote()) {
TileEntity blockEntity = level.getTileEntity(pos);
if (blockEntity instanceof IMachinePortTile) {
IMachinePortTile port = (IMachinePortTile) blockEntity;
if (!port.getStorage().onPortActivated(state, level, pos, player, hand ,traceResult)) {
NetworkHooks.openGui(((ServerPlayerEntity) player), port, pos);
}
}
}
return ActionResultType.SUCCESS;
}
@Override
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
TileEntity tile = worldIn.getTileEntity(pos);
super.onReplaced(state, worldIn, pos, newState, isMoving);
if (tile instanceof MachinePortBlockEntity){
LazyOptional<Object> lo = ((MachinePortBlockEntity) tile).getStorage().getLO();
if (lo == null){
return;
}
Object o = lo.orElse(null);
if (o instanceof ItemStackHandler) {
InventoryHelper.dropInventoryItems(worldIn, pos, new ItemStackInventory((ItemStackHandler) o));
}
}
tile.remove();
}
@Override
public void neighborChanged(BlockState p_220069_1_, World world, BlockPos pos, Block p_220069_4_, BlockPos changedPos, boolean p_220069_6_) {
super.neighborChanged(p_220069_1_, world, pos, p_220069_4_, changedPos, p_220069_6_);
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof IMachinePortTile){
((IMachinePortTile) tile).getStorage().neighborChanged();
}
}
}

View File

@@ -1,164 +0,0 @@
package com.ticticboooom.mods.mm.block;
import com.ticticboooom.mods.mm.registration.MMSetup;
import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.IBooleanFunction;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraftforge.common.ToolType;
import javax.annotation.Nullable;
import java.util.stream.Stream;
public class ProjectorBlock extends Block {
public ProjectorBlock() {
super(AbstractBlock.Properties.create(Material.IRON).setRequiresTool().hardnessAndResistance(5.0F, 6.0F).sound(SoundType.METAL).harvestLevel(0)
.harvestTool(ToolType.PICKAXE));
this.setDefaultState(this.getDefaultState().with(FACING, Direction.NORTH));
}
private static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
private static final VoxelShape SHAPE_N = Stream.of(
Block.makeCuboidShape(4, 2, 4, 12, 3, 12),
Block.makeCuboidShape(4, 0, 4, 12, 1, 12),
Block.makeCuboidShape(6, 2.5, 6, 10, 3.5, 10),
Block.makeCuboidShape(5, 1, 5, 11, 2, 11),
Block.makeCuboidShape(5, 6, 5, 11, 12, 11),
Block.makeCuboidShape(0.75, 2.5, 6.75, 2.25, 4.75, 9.25),
Block.makeCuboidShape(13.75, 2.5, 6.75, 15.25, 4.75, 9.25),
Block.makeCuboidShape(6, 3.5, 14, 7, 12.75, 15),
Block.makeCuboidShape(5.75, 11.25, 13.75, 7.25, 13.5, 15.25),
Block.makeCuboidShape(5.75, 2.5, 13.75, 7.25, 4.75, 15.25),
Block.makeCuboidShape(8.75, 11.25, 13.75, 10.25, 13.5, 15.25),
Block.makeCuboidShape(8.75, 2.5, 13.75, 10.25, 4.75, 15.25),
Block.makeCuboidShape(9, 3.5, 14, 10, 12.75, 15),
Block.makeCuboidShape(1.25, 6.25, 7.5, 2.25, 7.25, 8.5),
Block.makeCuboidShape(13.75, 6.25, 7.5, 14.75, 7.25, 8.5),
Block.makeCuboidShape(14, 3.5, 7, 15, 7.75, 9),
Block.makeCuboidShape(1, 3.5, 7, 2, 7.75, 9),
Block.makeCuboidShape(11, 2, 6, 15, 4, 10),
Block.makeCuboidShape(1, 2, 6, 5, 4, 10),
Block.makeCuboidShape(6, 2, 11, 10, 4, 15),
Block.makeCuboidShape(6, 12, 9, 10, 15, 15)
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
private static final VoxelShape SHAPE_E = Stream.of(
Block.makeCuboidShape(4, 2, 4, 12, 3, 12),
Block.makeCuboidShape(4, 0, 4, 12, 1, 12),
Block.makeCuboidShape(6, 2.5, 6, 10, 3.5, 10),
Block.makeCuboidShape(5, 1, 5, 11, 2, 11),
Block.makeCuboidShape(5, 6, 5, 11, 12, 11),
Block.makeCuboidShape(6.75, 2.5, 0.75, 9.25, 4.75, 2.25),
Block.makeCuboidShape(6.75, 2.5, 13.75, 9.25, 4.75, 15.25),
Block.makeCuboidShape(1, 3.5, 6, 2, 12.75, 7),
Block.makeCuboidShape(0.75, 11.25, 5.75, 2.25, 13.5, 7.25),
Block.makeCuboidShape(0.75, 2.5, 5.75, 2.25, 4.75, 7.25),
Block.makeCuboidShape(0.75, 11.25, 8.75, 2.25, 13.5, 10.25),
Block.makeCuboidShape(0.75, 2.5, 8.75, 2.25, 4.75, 10.25),
Block.makeCuboidShape(1, 3.5, 9, 2, 12.75, 10),
Block.makeCuboidShape(7.5, 6.25, 1.25, 8.5, 7.25, 2.25),
Block.makeCuboidShape(7.5, 6.25, 13.75, 8.5, 7.25, 14.75),
Block.makeCuboidShape(7, 3.5, 14, 9, 7.75, 15),
Block.makeCuboidShape(7, 3.5, 1, 9, 7.75, 2),
Block.makeCuboidShape(6, 2, 11, 10, 4, 15),
Block.makeCuboidShape(6, 2, 1, 10, 4, 5),
Block.makeCuboidShape(1, 2, 6, 5, 4, 10),
Block.makeCuboidShape(1, 12, 6, 7, 15, 10)
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
private static final VoxelShape SHAPE_S = Stream.of(
Block.makeCuboidShape(4, 2, 4, 12, 3, 12),
Block.makeCuboidShape(4, 0, 4, 12, 1, 12),
Block.makeCuboidShape(6, 2.5, 6, 10, 3.5, 10),
Block.makeCuboidShape(5, 1, 5, 11, 2, 11),
Block.makeCuboidShape(5, 6, 5, 11, 12, 11),
Block.makeCuboidShape(13.75, 2.5, 6.75, 15.25, 4.75, 9.25),
Block.makeCuboidShape(0.75, 2.5, 6.75, 2.25, 4.75, 9.25),
Block.makeCuboidShape(9, 3.5, 1, 10, 12.75, 2),
Block.makeCuboidShape(8.75, 11.25, 0.75, 10.25, 13.5, 2.25),
Block.makeCuboidShape(8.75, 2.5, 0.75, 10.25, 4.75, 2.25),
Block.makeCuboidShape(5.75, 11.25, 0.75, 7.25, 13.5, 2.25),
Block.makeCuboidShape(5.75, 2.5, 0.75, 7.25, 4.75, 2.25),
Block.makeCuboidShape(6, 3.5, 1, 7, 12.75, 2),
Block.makeCuboidShape(13.75, 6.25, 7.5, 14.75, 7.25, 8.5),
Block.makeCuboidShape(1.25, 6.25, 7.5, 2.25, 7.25, 8.5),
Block.makeCuboidShape(1, 3.5, 7, 2, 7.75, 9),
Block.makeCuboidShape(14, 3.5, 7, 15, 7.75, 9),
Block.makeCuboidShape(1, 2, 6, 5, 4, 10),
Block.makeCuboidShape(11, 2, 6, 15, 4, 10),
Block.makeCuboidShape(6, 2, 1, 10, 4, 5),
Block.makeCuboidShape(6, 12, 1, 10, 15, 7)
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
private static final VoxelShape SHAPE_W = Stream.of(
Block.makeCuboidShape(4, 2, 4, 12, 3, 12),
Block.makeCuboidShape(4, 0, 4, 12, 1, 12),
Block.makeCuboidShape(6, 2.5, 6, 10, 3.5, 10),
Block.makeCuboidShape(5, 1, 5, 11, 2, 11),
Block.makeCuboidShape(5, 6, 5, 11, 12, 11),
Block.makeCuboidShape(6.75, 2.5, 13.75, 9.25, 4.75, 15.25),
Block.makeCuboidShape(6.75, 2.5, 0.75, 9.25, 4.75, 2.25),
Block.makeCuboidShape(14, 3.5, 9, 15, 12.75, 10),
Block.makeCuboidShape(13.75, 11.25, 8.75, 15.25, 13.5, 10.25),
Block.makeCuboidShape(13.75, 2.5, 8.75, 15.25, 4.75, 10.25),
Block.makeCuboidShape(13.75, 11.25, 5.75, 15.25, 13.5, 7.25),
Block.makeCuboidShape(13.75, 2.5, 5.75, 15.25, 4.75, 7.25),
Block.makeCuboidShape(14, 3.5, 6, 15, 12.75, 7),
Block.makeCuboidShape(7.5, 6.25, 13.75, 8.5, 7.25, 14.75),
Block.makeCuboidShape(7.5, 6.25, 1.25, 8.5, 7.25, 2.25),
Block.makeCuboidShape(7, 3.5, 1, 9, 7.75, 2),
Block.makeCuboidShape(7, 3.5, 14, 9, 7.75, 15),
Block.makeCuboidShape(6, 2, 1, 10, 4, 5),
Block.makeCuboidShape(6, 2, 11, 10, 4, 15),
Block.makeCuboidShape(11, 2, 6, 15, 4, 10),
Block.makeCuboidShape(9, 12, 6, 15, 15, 10)
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder.add(FACING));
}
@Nullable
@Override
public BlockState getStateForPlacement(BlockItemUseContext ctx) {
return this.getDefaultState().with(FACING, ctx.getPlacementHorizontalFacing().getOpposite());
}
@Override
public boolean hasTileEntity(BlockState state) {
return true;
}
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return MMSetup.PROJECTOR_TILE.get().create();
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader p_220053_2_, BlockPos p_220053_3_, ISelectionContext p_220053_4_) {
switch (state.get(FACING)) {
case NORTH:
return SHAPE_N;
case EAST:
return SHAPE_E;
case SOUTH:
return SHAPE_S;
case WEST:
return SHAPE_W;
default:
throw new IllegalStateException("Invalid State");
}
}
}

View File

@@ -1,36 +0,0 @@
package com.ticticboooom.mods.mm.block;
import com.simibubi.create.content.contraptions.base.IRotate;
import com.ticticboooom.mods.mm.block.tile.MachinePortBlockEntity;
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
import com.ticticboooom.mods.mm.ports.storage.StarlightPortStorage;
import hellfirepvp.astralsorcery.common.block.base.BlockStarlightRecipient;
import hellfirepvp.astralsorcery.common.constellation.IWeakConstellation;
import net.minecraft.block.BlockState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraftforge.fml.RegistryObject;
import java.util.Random;
public class RotationMachinePortBlock extends MachinePortBlock implements IRotate {
public RotationMachinePortBlock(RegistryObject<TileEntityType<?>> type, String name, String controllerId, String textureOverride, ResourceLocation overlay, ResourceLocation portTypeId) {
super(type, name, controllerId, textureOverride, overlay, portTypeId);
}
@Override
public boolean hasShaftTowards(IWorldReader iWorldReader, BlockPos blockPos, BlockState blockState, Direction direction) {
return true;
}
@Override
public Direction.Axis getRotationAxis(BlockState blockState) {
return Direction.Axis.X;
}
}

View File

@@ -1,175 +0,0 @@
package com.ticticboooom.mods.mm.block;
import com.ticticboooom.mods.mm.block.tile.ControllerBlockEntity;
import com.ticticboooom.mods.mm.block.tile.StructureGenBlockEntity;
import com.ticticboooom.mods.mm.registration.MMSetup;
import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.shapes.IBooleanFunction;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.fml.network.NetworkHooks;
import javax.annotation.Nullable;
import java.util.stream.Stream;
public class StructureGenBlock extends Block {
private static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
private static final VoxelShape SHAPE_N = Stream.of(
Block.makeCuboidShape(1, 2, 1, 15, 5, 6),
Block.makeCuboidShape(0, 0, 0, 16, 2, 16),
Block.makeCuboidShape(0.5, 2, 6.5, 15.5, 5, 15.5),
Block.makeCuboidShape(0, 5, 6, 16, 6, 16),
Block.makeCuboidShape(4, 6, 7, 15, 14, 13),
Block.makeCuboidShape(1, 5.5, 7, 3, 6.5, 9),
Block.makeCuboidShape(1.25, 11, 7.25, 2.75, 11.25, 8.75),
Block.makeCuboidShape(1, 6, 11, 3, 12.25, 14),
Block.makeCuboidShape(1, 11.25, 6.75, 3, 12.25, 11.25),
Block.makeCuboidShape(0, 2, 0, 1, 3, 6),
Block.makeCuboidShape(15, 2, 0, 16, 3, 6),
Block.makeCuboidShape(0, 2, 6, 1, 5, 7),
Block.makeCuboidShape(15, 2, 6, 16, 5, 7),
Block.makeCuboidShape(15, 2, 15, 16, 5, 16),
Block.makeCuboidShape(0, 2, 15, 1, 5, 16)
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
private static final VoxelShape SHAPE_E = Stream.of(
Block.makeCuboidShape(10, 2, 1, 15, 5, 15),
Block.makeCuboidShape(0, 0, 0, 16, 2, 16),
Block.makeCuboidShape(0.5, 2, 0.5, 9.5, 5, 15.5),
Block.makeCuboidShape(0, 5, 0, 10, 6, 16),
Block.makeCuboidShape(3, 6, 4, 9, 14, 15),
Block.makeCuboidShape(7, 5.5, 1, 9, 6.5, 3),
Block.makeCuboidShape(7.25, 11, 1.25, 8.75, 11.25, 2.75),
Block.makeCuboidShape(2, 6, 1, 5, 12.25, 3),
Block.makeCuboidShape(4.75, 11.25, 1, 9.25, 12.25, 3),
Block.makeCuboidShape(10, 2, 0, 16, 3, 1),
Block.makeCuboidShape(10, 2, 15, 16, 3, 16),
Block.makeCuboidShape(9, 2, 0, 10, 5, 1),
Block.makeCuboidShape(9, 2, 15, 10, 5, 16),
Block.makeCuboidShape(0, 2, 15, 1, 5, 16),
Block.makeCuboidShape(0, 2, 0, 1, 5, 1)
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
private static final VoxelShape SHAPE_S = Stream.of(
Block.makeCuboidShape(1, 2, 10, 15, 5, 15),
Block.makeCuboidShape(0, 0, 0, 16, 2, 16),
Block.makeCuboidShape(0.5, 2, 0.5, 15.5, 5, 9.5),
Block.makeCuboidShape(0, 5, 0, 16, 6, 10),
Block.makeCuboidShape(1, 6, 3, 12, 14, 9),
Block.makeCuboidShape(13, 5.5, 7, 15, 6.5, 9),
Block.makeCuboidShape(13.25, 11, 7.25, 14.75, 11.25, 8.75),
Block.makeCuboidShape(13, 6, 2, 15, 12.25, 5),
Block.makeCuboidShape(13, 11.25, 4.75, 15, 12.25, 9.25),
Block.makeCuboidShape(15, 2, 10, 16, 3, 16),
Block.makeCuboidShape(0, 2, 10, 1, 3, 16),
Block.makeCuboidShape(15, 2, 9, 16, 5, 10),
Block.makeCuboidShape(0, 2, 9, 1, 5, 10),
Block.makeCuboidShape(0, 2, 0, 1, 5, 1),
Block.makeCuboidShape(15, 2, 0, 16, 5, 1)
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
private static final VoxelShape SHAPE_W = Stream.of(
Block.makeCuboidShape(1, 2, 1, 6, 5, 15),
Block.makeCuboidShape(0, 0, 0, 16, 2, 16),
Block.makeCuboidShape(6.5, 2, 0.5, 15.5, 5, 15.5),
Block.makeCuboidShape(6, 5, 0, 16, 6, 16),
Block.makeCuboidShape(7, 6, 1, 13, 14, 12),
Block.makeCuboidShape(7, 5.5, 13, 9, 6.5, 15),
Block.makeCuboidShape(7.25, 11, 13.25, 8.75, 11.25, 14.75),
Block.makeCuboidShape(11, 6, 13, 14, 12.25, 15),
Block.makeCuboidShape(6.75, 11.25, 13, 11.25, 12.25, 15),
Block.makeCuboidShape(0, 2, 15, 6, 3, 16),
Block.makeCuboidShape(0, 2, 0, 6, 3, 1),
Block.makeCuboidShape(6, 2, 15, 7, 5, 16),
Block.makeCuboidShape(6, 2, 0, 7, 5, 1),
Block.makeCuboidShape(15, 2, 0, 16, 5, 1),
Block.makeCuboidShape(15, 2, 15, 16, 5, 16)
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
public StructureGenBlock() {
super(AbstractBlock.Properties.create(Material.IRON).setRequiresTool().hardnessAndResistance(5.0F, 6.0F).sound(SoundType.METAL).harvestLevel(0)
.harvestTool(ToolType.PICKAXE));
this.setDefaultState(this.getDefaultState().with(FACING, Direction.NORTH));
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder.add(FACING));
}
@Override
public ActionResultType onBlockActivated(BlockState state, World level, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult traceResult) {
if (!level.isRemote()) {
TileEntity blockEntity = level.getTileEntity(pos);
if (blockEntity instanceof StructureGenBlockEntity) {
NetworkHooks.openGui(((ServerPlayerEntity) player), (StructureGenBlockEntity)blockEntity, pos);
}
}
return ActionResultType.SUCCESS;
}
@Override
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
if (!state.matchesBlock(newState.getBlock())) {
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof StructureGenBlockEntity) {
InventoryHelper.dropInventoryItems(worldIn, pos, ((StructureGenBlockEntity) tileentity).getInv());
worldIn.updateComparatorOutputLevel(pos, this);
}
super.onReplaced(state, worldIn, pos, newState, isMoving);
}
}
@Nullable
@Override
public BlockState getStateForPlacement(BlockItemUseContext ctx) {
return this.getDefaultState().with(FACING, ctx.getPlacementHorizontalFacing().getOpposite());
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader p_220053_2_, BlockPos p_220053_3_, ISelectionContext p_220053_4_) {
switch (state.get(FACING)) {
case NORTH:
return SHAPE_N;
case EAST:
return SHAPE_E;
case SOUTH:
return SHAPE_S;
case WEST:
return SHAPE_W;
default:
throw new IllegalStateException("Invalid State");
}
}
@Override
public boolean hasTileEntity(BlockState state) {
return true;
}
@Nullable
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return MMSetup.STRUCTURE_TILE.get().create();
}
}

View File

@@ -1,53 +0,0 @@
package com.ticticboooom.mods.mm.block.container;
import com.ticticboooom.mods.mm.block.tile.ControllerBlockEntity;
import lombok.Getter;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import javax.annotation.Nullable;
public class ControllerBlockContainer extends Container {
@Getter
private ControllerBlockEntity tile;
public ControllerBlockContainer(@Nullable ContainerType<?> p_i50105_1_, int windowId, PlayerInventory inv, ControllerBlockEntity tile) {
super(p_i50105_1_, windowId);
this.tile = tile;
int playerOffsetX = 8;
int playerOffsetY = 121;
for (int j = 0; j < 3; j++) {
for (int i = 0; i < 9; i++) {
this.addSlot(new Slot(inv, 9 + (j * 9 + i), i* 18 + playerOffsetX, j* 18 + playerOffsetY));
}
}
for (int i = 0; i < 9; i++) {
this.addSlot(new Slot(inv, i,8 + (i * 18), 179));
}
}
public ControllerBlockContainer(ContainerType<?> container, int windowId, PlayerInventory player, PacketBuffer buf) {
this(container, windowId, player, (ControllerBlockEntity) player.player.world.getTileEntity(buf.readBlockPos()));
}
@Override
public boolean canInteractWith(PlayerEntity p_75145_1_) {
return true;
}
@Override
public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) {
return ItemStack.EMPTY;
}
}

View File

@@ -1,70 +0,0 @@
package com.ticticboooom.mods.mm.block.container;
import com.ticticboooom.mods.mm.block.tile.IMachinePortTile;
import lombok.Getter;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.items.ItemStackHandler;
import javax.annotation.Nullable;
public class PortBlockContainer extends Container {
private final PlayerInventory inv;
@Getter
private IMachinePortTile tile;
public PortBlockContainer(@Nullable ContainerType<?> p_i50105_1_, int windowId, PlayerInventory inv, IMachinePortTile tile) {
super(p_i50105_1_, windowId);
this.inv = inv;
tile.getStorage().setupContainer(this, inv, tile);
this.tile = tile;
}
public PortBlockContainer(ContainerType<?> container, int windowId, PlayerInventory player, PacketBuffer buf) {
this(container, windowId, player, (IMachinePortTile) player.player.world.getTileEntity(buf.readBlockPos()));
}
@Override
public boolean canInteractWith(PlayerEntity p_75145_1_) {
return true;
}
@Override
public Slot addSlot(Slot p_75146_1_) {
return super.addSlot(p_75146_1_);
}
@Override
public ItemStack transferStackInSlot(PlayerEntity p_82846_1_, int index) {
ItemStack itemStack = ItemStack.EMPTY;
Object o = tile.getStorage().getLO().orElse(null);
if (o instanceof ItemStackHandler) {
ItemStackHandler handler = ((ItemStackHandler) o);
Slot slot = this.getSlot(index);
if (slot.getHasStack()) {
ItemStack itemStack1 = slot.getStack();
itemStack = itemStack1.copy();
if (index < handler.getSlots()) {
if (!this.mergeItemStack(itemStack1, handler.getSlots(), this.inventorySlots.size(), true)) {
return ItemStack.EMPTY;
}
} else if (!this.mergeItemStack(itemStack1, 0, handler.getSlots(), false)) {
return ItemStack.EMPTY;
}
if (itemStack1.isEmpty()) {
slot.putStack(ItemStack.EMPTY);
} else {
slot.onSlotChanged();
}
}
}
return itemStack;
}
}

View File

@@ -1,26 +0,0 @@
package com.ticticboooom.mods.mm.block.container;
import com.ticticboooom.mods.mm.block.tile.ProjectorBlockEntity;
import com.ticticboooom.mods.mm.registration.MMSetup;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.network.PacketBuffer;
public class ProjectorBlockContainer extends Container {
private ProjectorBlockEntity tile;
public ProjectorBlockContainer(int windowId, ProjectorBlockEntity tile) {
super(MMSetup.PROJECTOR_CONTAINER.get(), windowId);
this.tile = tile;
}
@Override
public boolean canInteractWith(PlayerEntity p_75145_1_) {
return true;
}
public ProjectorBlockContainer(int w, PlayerInventory inv, PacketBuffer buf) {
this(w, (ProjectorBlockEntity) inv.player.world.getTileEntity(buf.readBlockPos()));
}
}

View File

@@ -1,72 +0,0 @@
package com.ticticboooom.mods.mm.block.container;
import com.ticticboooom.mods.mm.block.container.slot.StructureDeviceSlot;
import com.ticticboooom.mods.mm.block.tile.ProjectorBlockEntity;
import com.ticticboooom.mods.mm.block.tile.StructureGenBlockEntity;
import com.ticticboooom.mods.mm.registration.MMSetup;
import lombok.Getter;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.items.ItemStackHandler;
public class StructureGenBlockContainer extends Container {
@Getter
private StructureGenBlockEntity tile;
public StructureGenBlockContainer(int windowId, PlayerInventory inv, StructureGenBlockEntity tile) {
super(MMSetup.STRUCTURE_CONTAINER.get(), windowId);
this.tile = tile;
this.addSlot(new StructureDeviceSlot(tile.getInv(), 0, 151, -14));
this.tile = tile;
int playerOffsetX = 8;
int playerOffsetY = 121;
for (int j = 0; j < 3; j++) {
for (int i = 0; i < 9; i++) {
this.addSlot(new Slot(inv, 9 + (j * 9 + i), i * 18 + playerOffsetX, j * 18 + playerOffsetY));
}
}
for (int i = 0; i < 9; i++) {
this.addSlot(new Slot(inv, i, 8 + (i * 18), 179));
}
}
@Override
public boolean canInteractWith(PlayerEntity p_75145_1_) {
return true;
}
public StructureGenBlockContainer(int w, PlayerInventory inv, PacketBuffer buf) {
this(w, inv, (StructureGenBlockEntity) inv.player.world.getTileEntity(buf.readBlockPos()));
}
@Override
public ItemStack transferStackInSlot(PlayerEntity p_82846_1_, int index) {
ItemStack itemStack = ItemStack.EMPTY;
Slot slot = this.getSlot(index);
if (slot.getHasStack()) {
ItemStack itemStack1 = slot.getStack();
itemStack = itemStack1.copy();
if (index < 1) {
if (!this.mergeItemStack(itemStack1, 1, this.inventorySlots.size(), true)) {
return ItemStack.EMPTY;
}
} else if (!this.mergeItemStack(itemStack1, 0, 1, false)) {
return ItemStack.EMPTY;
}
if (itemStack1.isEmpty()) {
slot.putStack(ItemStack.EMPTY);
} else {
slot.onSlotChanged();
}
}
return itemStack;
}
}

View File

@@ -1,17 +0,0 @@
package com.ticticboooom.mods.mm.block.container.slot;
import com.ticticboooom.mods.mm.registration.MMSetup;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack;
public class StructureDeviceSlot extends Slot {
public StructureDeviceSlot(IInventory inventoryIn, int index, int xPosition, int yPosition) {
super(inventoryIn, index, xPosition, yPosition);
}
@Override
public boolean isItemValid(ItemStack stack) {
return stack.getItem() == MMSetup.STRUCTURE_DEVICE.get();
}
}

View File

@@ -1,94 +0,0 @@
package com.ticticboooom.mods.mm.block.tile;
import com.ticticboooom.mods.mm.block.container.PortBlockContainer;
import com.ticticboooom.mods.mm.inventory.as.MMSimpleTransmissionReceiver;
import com.ticticboooom.mods.mm.network.PacketHandler;
import com.ticticboooom.mods.mm.network.packets.TileClientUpdatePacket;
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
import hellfirepvp.astralsorcery.common.constellation.ConstellationTile;
import hellfirepvp.astralsorcery.common.constellation.IMinorConstellation;
import hellfirepvp.astralsorcery.common.constellation.IWeakConstellation;
import hellfirepvp.astralsorcery.common.tile.base.network.TileReceiverBase;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.fml.network.PacketDistributor;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class AstralMachineInputPortBlockEntity extends TileReceiverBase<MMSimpleTransmissionReceiver> implements IMachinePortTile {
public AstralMachineInputPortBlockEntity(TileEntityType<?> tileEntityTypeIn, ContainerType<?> cont, PortStorage storage) {
super(tileEntityTypeIn);
this.cont = cont;
this.storage = storage;
markForUpdate();
}
@Override
public void tick() {
super.tick();
if (!world.isRemote()) {
PacketHandler.INSTANCE.send(PacketDistributor.ALL.noArg(), new TileClientUpdatePacket.Data(pos, write(new CompoundNBT())));
}
}
private ContainerType<?> cont;
PortStorage storage;
@Override
public void writeCustomNBT(CompoundNBT nbt) {
nbt.put("inv", storage.save(new CompoundNBT()));
super.writeCustomNBT(nbt);
}
@Override
public void read(BlockState state, CompoundNBT nbt) {
super.read(state, nbt);
storage.load(nbt.getCompound("inv"));
}
@Override
public PortStorage getStorage() {
return this.storage;
}
@Override
public boolean isInput() {
return true;
}
@Override
public ITextComponent getDisplayName() {
return new StringTextComponent("Port");
}
@Nullable
@Override
public Container createMenu(int p_createMenu_1_, PlayerInventory p_createMenu_2_, PlayerEntity p_createMenu_3_) {
return new PortBlockContainer(cont, p_createMenu_1_, p_createMenu_2_, this);
}
@Override
public void onBreak() {
super.onBreak();
}
@Override
protected void invalidateCaps() {
this.onBreak();
}
@Nonnull
@Override
public MMSimpleTransmissionReceiver provideEndpoint(BlockPos blockPos) {
return new MMSimpleTransmissionReceiver(blockPos);
}
}

View File

@@ -1,140 +0,0 @@
package com.ticticboooom.mods.mm.block.tile;
import com.ticticboooom.mods.mm.block.container.PortBlockContainer;
import com.ticticboooom.mods.mm.inventory.as.MMIndependentStarlightSource;
import com.ticticboooom.mods.mm.network.PacketHandler;
import com.ticticboooom.mods.mm.network.packets.TileClientUpdatePacket;
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
import hellfirepvp.astralsorcery.common.constellation.ConstellationTile;
import hellfirepvp.astralsorcery.common.constellation.IMinorConstellation;
import hellfirepvp.astralsorcery.common.constellation.IWeakConstellation;
import hellfirepvp.astralsorcery.common.starlight.IIndependentStarlightSource;
import hellfirepvp.astralsorcery.common.starlight.transmission.base.SimpleTransmissionSourceNode;
import hellfirepvp.astralsorcery.common.tile.base.network.TileSourceBase;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.fml.network.PacketDistributor;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class AstralMachinePortBlockEntity extends TileSourceBase<SimpleTransmissionSourceNode> implements IMachinePortTile, ConstellationTile {
public AstralMachinePortBlockEntity(TileEntityType<?> tileEntityTypeIn, ContainerType<?> cont, PortStorage storage) {
super(tileEntityTypeIn);
this.cont = cont;
this.storage = storage;
}
@Override
public void tick() {
super.tick();
if (!world.isRemote()) {
PacketHandler.INSTANCE.send(PacketDistributor.ALL.noArg(), new TileClientUpdatePacket.Data(pos, write(new CompoundNBT())));
}
}
private ContainerType<?> cont;
PortStorage storage;
IWeakConstellation constellationType = null;
IMinorConstellation traitConstellationType = null;
@Nonnull
@Override
public IIndependentStarlightSource provideNewSourceNode() {
return new MMIndependentStarlightSource();
}
@Nonnull
@Override
public SimpleTransmissionSourceNode provideSourceNode(BlockPos blockPos) {
return new SimpleTransmissionSourceNode(blockPos);
}
@Override
public void writeCustomNBT(CompoundNBT nbt) {
nbt.put("inv", storage.save(new CompoundNBT()));
super.writeCustomNBT(nbt);
}
@Override
public void read(BlockState state, CompoundNBT nbt) {
super.read(state, nbt);
storage.load(nbt.getCompound("inv"));
}
@Override
public PortStorage getStorage() {
return this.storage;
}
@Override
public boolean isInput() {
return false;
}
@Override
public ITextComponent getDisplayName() {
return new StringTextComponent("Port");
}
@Nullable
@Override
public Container createMenu(int p_createMenu_1_, PlayerInventory p_createMenu_2_, PlayerEntity p_createMenu_3_) {
return new PortBlockContainer(cont, p_createMenu_1_, p_createMenu_2_, this);
}
@Override
public IWeakConstellation getAttunedConstellation() {
return constellationType;
}
@Override
public boolean setAttunedConstellation(IWeakConstellation cst) {
if (cst != this.constellationType) {
markForUpdate();
}
constellationType = cst;
return true;
}
@Override
public IMinorConstellation getTraitConstellation() {
return traitConstellationType;
}
@Override
public boolean setTraitConstellation(IMinorConstellation tst) {
if (tst != this.traitConstellationType) {
markForUpdate();
}
traitConstellationType = tst;
return true;
}
@Override
public boolean tryUnlink(PlayerEntity player, BlockPos other) {
boolean i = super.tryUnlink(player, other);
markForUpdate();
return i;
}
@Override
public void onBreak() {
super.onBreak();
}
@Override
protected void invalidateCaps() {
this.onBreak();
}
}

View File

@@ -1,130 +0,0 @@
package com.ticticboooom.mods.mm.block.tile;
import com.ticticboooom.mods.mm.block.container.ControllerBlockContainer;
import com.ticticboooom.mods.mm.data.MachineProcessRecipe;
import com.ticticboooom.mods.mm.data.MachineStructureRecipe;
import com.ticticboooom.mods.mm.model.ProcessUpdate;
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
import com.ticticboooom.mods.mm.registration.RecipeTypes;
import lombok.Getter;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.fml.RegistryObject;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
public class ControllerBlockEntity extends UpdatableTile implements ITickableTileEntity, INamedContainerProvider {
private RegistryObject<ContainerType<ControllerBlockContainer>> container;
private String controllerId;
@Getter
private ProcessUpdate update = new ProcessUpdate(0, "", "", "", new ArrayList<>());
public ControllerBlockEntity(RegistryObject<TileEntityType<?>> type, RegistryObject<ContainerType<ControllerBlockContainer>> container, String controllerId) {
super(type.get());
this.container = container;
this.controllerId = controllerId;
}
@Override
public void tick() {
if (world.isRemote()){
return;
}
update.setMsg("Failed to construct \nthe machine");
List<MachineStructureRecipe> recipes = world.getRecipeManager().getRecipesForType(RecipeTypes.MACHINE_STRUCTURE);
for (MachineStructureRecipe recipe : recipes) {
int index = recipe.matches(this.pos, world, controllerId);
if (index != -1) {
if (!update.getSid().equals(recipe.getId().toString())){
update.setTicksTaken(0);
}
update.setSid(recipe.getId().toString());
update.setMsg("Found structure");
onStructureFound(recipe, index);
break;
}
}
update();
}
private void onStructureFound(MachineStructureRecipe structure, int index) {
ArrayList<BlockPos> ports = structure.getPorts(pos, world, index);
List<PortStorage> inputPorts = new ArrayList<>();
List<PortStorage> outputPorts = new ArrayList<>();
for (BlockPos port : ports) {
TileEntity blockEntity = world.getTileEntity(port);
if (blockEntity instanceof IMachinePortTile) {
IMachinePortTile portBE = (IMachinePortTile) blockEntity;
if (portBE.isInput()) {
inputPorts.add(portBE.getStorage());
} else {
outputPorts.add(portBE.getStorage());
}
}
}
onPortsEstablished(inputPorts, outputPorts, structure);
}
private void onPortsEstablished(List<PortStorage> inputPorts, List<PortStorage> outputPorts, MachineStructureRecipe structure) {
List<MachineProcessRecipe> processRecipes = world.getRecipeManager().getRecipesForType(RecipeTypes.MACHINE_PROCESS);
boolean processed = false;
for (MachineProcessRecipe recipe : processRecipes) {
if (recipe.matches(inputPorts, structure.getStructureId(), update)) {
if (!update.getId().equals(recipe.getId().toString())){
update.setTicksTaken(0);
}
this.update.setId(recipe.getId().toString());
this.update = recipe.process(inputPorts, outputPorts, this.update);
processed = true;
break;
}
}
if (!processed) {
this.update.setTicksTaken(0);
}
}
@Override
public ITextComponent getDisplayName() {
return new TranslationTextComponent("container.masterfulmachinery." + this.controllerId + "_controller.name");
}
@Nullable
@Override
public Container createMenu(int p_createMenu_1_, PlayerInventory p_createMenu_2_, PlayerEntity p_createMenu_3_) {
return new ControllerBlockContainer(container.get(), p_createMenu_1_, p_createMenu_2_, this);
}
@Override
public CompoundNBT write(CompoundNBT nbt) {
nbt.putInt("ticks", update.getTicksTaken());
nbt.putString("msg", update.getMsg());
return super.write(nbt);
}
@Override
public void read(BlockState p_230337_1_, CompoundNBT nbt) {
super.read(p_230337_1_, nbt);
update.setTicksTaken(nbt.getInt("ticks"));
update.setMsg(nbt.getString("msg"));
}
}

View File

@@ -1,9 +0,0 @@
package com.ticticboooom.mods.mm.block.tile;
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
import net.minecraft.inventory.container.INamedContainerProvider;
public interface IMachinePortTile extends INamedContainerProvider {
PortStorage getStorage();
boolean isInput();
}

View File

@@ -1,84 +0,0 @@
package com.ticticboooom.mods.mm.block.tile;
import com.ticticboooom.mods.mm.block.container.PortBlockContainer;
import com.ticticboooom.mods.mm.ports.storage.ManaPortStorage;
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
import lombok.Getter;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.Direction;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import vazkii.botania.api.mana.IManaBlock;
import vazkii.botania.api.mana.IManaPool;
import vazkii.botania.api.mana.IManaReceiver;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class MachinePortBlockEntity extends UpdatableTile implements ITickableTileEntity, IMachinePortTile {
protected ContainerType<?> container;
@Getter
protected PortStorage storage;
@Getter
protected boolean input;
public MachinePortBlockEntity(TileEntityType<?> p_i48289_1_, ContainerType<?> container, PortStorage storage, boolean input) {
super(p_i48289_1_);
this.container = container;
this.storage = storage;
this.input = input;
}
@Nonnull
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
if (storage.validate(cap)){
return storage.getLO();
}
return super.getCapability(cap, side);
}
@Override
public CompoundNBT write(CompoundNBT nbt) {
nbt.put("inv", storage.save(new CompoundNBT()));
return super.write(nbt);
}
@Override
public void read(BlockState state, CompoundNBT nbt) {
super.read(state, nbt);
storage.load(nbt.getCompound("inv"));
}
@Override
public ITextComponent getDisplayName() {
return new StringTextComponent("Port");
}
@Nullable
@Override
public Container createMenu(int windowsId, PlayerInventory inv, PlayerEntity player) {
return new PortBlockContainer(container, windowsId, inv,this);
}
@Override
public void tick() {
if (world.isRemote()){
return;
}
this.getStorage().tick(this);
update();
}
}

View File

@@ -1,101 +0,0 @@
package com.ticticboooom.mods.mm.block.tile;
import com.ticticboooom.mods.mm.ports.storage.ManaPortStorage;
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.DyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityType;
import vazkii.botania.api.mana.IManaBlock;
import vazkii.botania.api.mana.IManaPool;
import vazkii.botania.api.mana.IManaSpreader;
import vazkii.botania.api.mana.spark.ISparkAttachable;
import vazkii.botania.api.mana.spark.ISparkEntity;
public class ManaMachinePortBlockEntity extends MachinePortBlockEntity implements IManaPool, ISparkAttachable {
private ISparkEntity spark;
public ManaMachinePortBlockEntity(TileEntityType<?> p_i48289_1_, ContainerType<?> container, PortStorage storage, boolean input) {
super(p_i48289_1_, container, storage, input);
}
@Override
public boolean isFull() {
if (storage instanceof ManaPortStorage) {
ManaPortStorage s = (ManaPortStorage) storage;
return s.getInv().getManaStored() >= s.getInv().getMaxManaStored();
}
return true;
}
@Override
public void receiveMana(int mana) {
if (storage instanceof ManaPortStorage) {
ManaPortStorage s = (ManaPortStorage) storage;
if (mana > 0) {
s.getInv().receiveMana(mana, false);
} else {
s.getInv().extractMana(-mana, false);
}
}
}
@Override
public boolean canReceiveManaFromBursts() {
return this.isInput();
}
@Override
public int getCurrentMana() {
if (storage instanceof ManaPortStorage) {
ManaPortStorage s = (ManaPortStorage) storage;
return s.getInv().getManaStored();
}
return 0;
}
@Override
public boolean isOutputtingPower() {
return !this.input;
}
@Override
public DyeColor getColor() {
return DyeColor.GRAY;
}
@Override
public void setColor(DyeColor color) {
}
@Override
public boolean canAttachSpark(ItemStack stack) {
return true;
}
@Override
public void attachSpark(ISparkEntity entity) {
spark = entity;
}
@Override
public int getAvailableSpaceForMana() {
if (storage instanceof ManaPortStorage) {
ManaPortStorage s = (ManaPortStorage) storage;
return s.getInv().getMaxManaStored() - s.getInv().getManaStored();
}
return 0;
}
@Override
public ISparkEntity getAttachedSpark() {
return spark;
}
@Override
public boolean areIncomingTranfersDone() {
return false;
}
}

View File

@@ -1,10 +0,0 @@
package com.ticticboooom.mods.mm.block.tile;
import com.ticticboooom.mods.mm.registration.MMSetup;
import net.minecraft.tileentity.TileEntity;
public class ProjectorBlockEntity extends TileEntity {
public ProjectorBlockEntity() {
super(MMSetup.PROJECTOR_TILE.get());
}
}

View File

@@ -1,106 +0,0 @@
package com.ticticboooom.mods.mm.block.tile;
import com.simibubi.create.content.contraptions.KineticNetwork;
import com.simibubi.create.content.contraptions.base.GeneratingKineticTileEntity;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.ticticboooom.mods.mm.block.container.PortBlockContainer;
import com.ticticboooom.mods.mm.network.PacketHandler;
import com.ticticboooom.mods.mm.network.packets.TileClientUpdatePacket;
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
import com.ticticboooom.mods.mm.ports.storage.RotationPortStorage;
import lombok.Getter;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.fml.network.PacketDistributor;
import javax.annotation.Nullable;
public class RotationGenMachinePortBlockEntity extends GeneratingKineticTileEntity implements IMachinePortTile, ITickableTileEntity {
private final ContainerType<?> container;
@Getter
private final PortStorage storage;
@Getter
private boolean input;
public RotationGenMachinePortBlockEntity(TileEntityType<?> typeIn, ContainerType<?> container, PortStorage storage, boolean input) {
super(typeIn);
this.container = container;
this.storage = storage;
this.input = input;
if (input) {
this.stress = ((RotationPortStorage) storage).getStress();
}
}
@Override
public ITextComponent getDisplayName() {
return new TranslationTextComponent("container.masterfulmachinery.create_rotation");
}
@Nullable
@Override
public Container createMenu(int p_createMenu_1_, PlayerInventory p_createMenu_2_, PlayerEntity p_createMenu_3_) {
return new PortBlockContainer(container, p_createMenu_1_, p_createMenu_2_, this);
}
@Override
public void tick() {
this.reActivateSource = true;
super.tick();
this.storage.tick(this);
// if (storage instanceof RotationPortStorage) {
// RotationPortStorage stor = (RotationPortStorage) this.storage;
// float prev = this.speed;
// float speed = stor.getSpeed();
// if (speed != prev) {
// if (!hasSource()) {
// effects.queueRotationIndicators();
// }
// applyNewSpeed(prev, speed);
// }
// if (hasNetwork() && speed != 0) {
// KineticNetwork network = getOrCreateNetwork();
// notifyStressCapacityChange(calculateAddedStressCapacity());
// getOrCreateNetwork().updateCapacityFor(this, calculateStressApplied());
// network.updateStress();
// }
//
// onSpeedChanged(prev);
// sendData();
// }
if (!world.isRemote()) {
PacketHandler.INSTANCE.send(PacketDistributor.ALL.noArg(), new TileClientUpdatePacket.Data(pos, write(new CompoundNBT())));
}
}
@Override
protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) {
this.storage.load(compound.getCompound("inv"));
}
@Override
protected void write(CompoundNBT compound, boolean clientPacket) {
compound.put("inv", this.storage.save(new CompoundNBT()));
super.write(compound, clientPacket);
}
@Override
public float getGeneratedSpeed() {
if (storage instanceof RotationPortStorage) {
RotationPortStorage stor = (RotationPortStorage) this.storage;
return stor.getSpeed();
}
return 0;
}
}

View File

@@ -1,83 +0,0 @@
package com.ticticboooom.mods.mm.block.tile;
import com.simibubi.create.Create;
import com.simibubi.create.content.contraptions.KineticNetwork;
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
import com.ticticboooom.mods.mm.block.container.PortBlockContainer;
import com.ticticboooom.mods.mm.network.PacketHandler;
import com.ticticboooom.mods.mm.network.packets.TileClientUpdatePacket;
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
import com.ticticboooom.mods.mm.ports.storage.RotationPortStorage;
import lombok.Getter;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.fml.network.PacketDistributor;
import javax.annotation.Nullable;
public class RotationMachinePortBlockEntity extends KineticTileEntity implements IMachinePortTile, ITickableTileEntity {
private final ContainerType<?> container;
@Getter
private final PortStorage storage;
@Getter
private boolean input;
public RotationMachinePortBlockEntity(TileEntityType<?> typeIn, ContainerType<?> container, PortStorage storage, boolean input) {
super(typeIn);
this.container = container;
this.storage = storage;
this.input = input;
if (input) {
this.stress = ((RotationPortStorage) storage).getStress();
}
}
@Override
public ITextComponent getDisplayName() {
return new TranslationTextComponent("container.masterfulmachinery.create_rotation");
}
@Nullable
@Override
public Container createMenu(int p_createMenu_1_, PlayerInventory p_createMenu_2_, PlayerEntity p_createMenu_3_) {
return new PortBlockContainer(container, p_createMenu_1_, p_createMenu_2_, this);
}
@Override
public void tick() {
super.tick();
if (this.world.isRemote) {
return;
}
if (storage instanceof RotationPortStorage) {
RotationPortStorage storage = (RotationPortStorage) this.storage;
if (input) {
storage.setSpeed(Math.abs(getSpeed()));
}
}
if (!world.isRemote()) {
PacketHandler.INSTANCE.send(PacketDistributor.ALL.noArg(), new TileClientUpdatePacket.Data(pos, write(new CompoundNBT())));
}
}
@Override
protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) {
this.storage.load(compound.getCompound("inv"));
}
@Override
protected void write(CompoundNBT compound, boolean clientPacket) {
compound.put("inv", this.storage.save(new CompoundNBT()));
super.write(compound, clientPacket);
}
}

View File

@@ -1,64 +0,0 @@
package com.ticticboooom.mods.mm.block.tile;
import com.ticticboooom.mods.mm.block.container.StructureGenBlockContainer;
import com.ticticboooom.mods.mm.inventory.ItemStackInventory;
import com.ticticboooom.mods.mm.model.ProcessUpdate;
import com.ticticboooom.mods.mm.registration.MMSetup;
import lombok.Getter;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.ItemStackHelper;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.NonNullList;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.items.ItemStackHandler;
import javax.annotation.Nullable;
public class StructureGenBlockEntity extends UpdatableTile implements ITickableTileEntity, INamedContainerProvider {
public StructureGenBlockEntity() {
super(MMSetup.STRUCTURE_TILE.get());
}
@Getter
private ItemStackHandler handler = new ItemStackHandler(1);
@Getter
private ItemStackInventory inv = new ItemStackInventory(handler);
@Override
public CompoundNBT write(CompoundNBT nbt) {
nbt.put("inv", handler.serializeNBT());
return super.write(nbt);
}
@Override
public void read(BlockState p_230337_1_, CompoundNBT nbt) {
CompoundNBT inv = nbt.getCompound("inv");
this.handler.deserializeNBT(inv);
super.read(p_230337_1_, nbt);
}
@Override
public void tick() {
update();
}
@Override
public ITextComponent getDisplayName() {
return new StringTextComponent("Structure Generator");
}
@Nullable
@Override
public Container createMenu(int p_createMenu_1_, PlayerInventory p_createMenu_2_, PlayerEntity p_createMenu_3_) {
return new StructureGenBlockContainer(p_createMenu_1_, p_createMenu_2_, this);
}
}

View File

@@ -1,21 +0,0 @@
package com.ticticboooom.mods.mm.block.tile;
import com.ticticboooom.mods.mm.network.PacketHandler;
import com.ticticboooom.mods.mm.network.packets.TileClientUpdatePacket;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraftforge.fml.network.PacketDistributor;
public class UpdatableTile extends TileEntity{
public UpdatableTile(TileEntityType<?> p_i48289_1_) {
super(p_i48289_1_);
}
public void update() {
if (!world.isRemote()){
PacketHandler.INSTANCE.send(PacketDistributor.ALL.noArg(), new TileClientUpdatePacket.Data(pos, write(new CompoundNBT())));
}
}
}

View File

@@ -1,31 +0,0 @@
package com.ticticboooom.mods.mm.client;
import net.minecraft.client.renderer.RenderState;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.renderer.vertex.VertexFormat;
import org.lwjgl.opengl.GL11;
import java.util.OptionalDouble;
public class MMRenderTypes extends RenderType {
private static final RenderState.LineState THICK_LINES = new RenderState.LineState(OptionalDouble.of(3.0D));
public static final RenderType OUTLINE = makeType("MMOutline",
DefaultVertexFormats.POSITION_COLOR, GL11.GL_QUADS, 256,
RenderType.State.getBuilder()
.line(THICK_LINES)
.layer(RenderState.NO_LAYERING)
.transparency(RenderState.TRANSLUCENT_TRANSPARENCY)
.texture(NO_TEXTURE)
.depthTest(DEPTH_LEQUAL)
.cull(CULL_DISABLED)
.lightmap(LIGHTMAP_DISABLED)
.writeMask(COLOR_WRITE)
.build(false));
public MMRenderTypes(String nameIn, VertexFormat formatIn, int drawModeIn, int bufferSizeIn, boolean useDelegateIn, boolean needsSortingIn, Runnable setupTaskIn, Runnable clearTaskIn) {
super(nameIn, formatIn, drawModeIn, bufferSizeIn, useDelegateIn, needsSortingIn, setupTaskIn, clearTaskIn);
}
}

View File

@@ -1,105 +0,0 @@
package com.ticticboooom.mods.mm.client.jei;
import com.google.common.collect.ImmutableList;
import com.ticticboooom.mods.mm.MM;
import com.ticticboooom.mods.mm.block.ControllerBlock;
import com.ticticboooom.mods.mm.client.jei.category.MachineProcessRecipeCategory;
import com.ticticboooom.mods.mm.client.jei.category.MachineStructureRecipeCategory;
import com.ticticboooom.mods.mm.client.jei.ingredients.as.StarlightIngredientHelper;
import com.ticticboooom.mods.mm.client.jei.ingredients.as.StarlightIngredientRenderer;
import com.ticticboooom.mods.mm.client.jei.ingredients.as.StarlightIngredientType;
import com.ticticboooom.mods.mm.client.jei.ingredients.energy.EnergyIngredientHelper;
import com.ticticboooom.mods.mm.client.jei.ingredients.energy.EnergyIngredientRenderer;
import com.ticticboooom.mods.mm.client.jei.ingredients.energy.EnergyIngredientType;
import com.ticticboooom.mods.mm.client.jei.ingredients.mana.ManaIngredientHelper;
import com.ticticboooom.mods.mm.client.jei.ingredients.mana.ManaIngredientRenderer;
import com.ticticboooom.mods.mm.client.jei.ingredients.mana.ManaIngredientType;
import com.ticticboooom.mods.mm.client.jei.ingredients.pressure.PNCPressureIngredientHelper;
import com.ticticboooom.mods.mm.client.jei.ingredients.pressure.PNCPressureIngredientRenderer;
import com.ticticboooom.mods.mm.client.jei.ingredients.pressure.PNCPressureIngredientType;
import com.ticticboooom.mods.mm.client.jei.ingredients.rotation.RotationIngredientHelper;
import com.ticticboooom.mods.mm.client.jei.ingredients.rotation.RotationIngredientRenderer;
import com.ticticboooom.mods.mm.client.jei.ingredients.rotation.RotationIngredientType;
import com.ticticboooom.mods.mm.data.MachineProcessRecipe;
import com.ticticboooom.mods.mm.data.MachineStructureRecipe;
import com.ticticboooom.mods.mm.registration.MMLoader;
import com.ticticboooom.mods.mm.registration.RecipeTypes;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.JeiPlugin;
import mezz.jei.api.registration.IModIngredientRegistration;
import mezz.jei.api.registration.IRecipeCategoryRegistration;
import mezz.jei.api.registration.IRecipeRegistration;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.RegistryObject;
import java.util.List;
import java.util.stream.Collectors;
@JeiPlugin
public class MMJeiPlugin implements IModPlugin {
public static final EnergyIngredientType ENERGY_TYPE = new EnergyIngredientType();
public static final EnergyIngredientRenderer ENERGY_TYPE_RENDERER = new EnergyIngredientRenderer();
public static final EnergyIngredientHelper ENERGY_TYPE_HELPER = new EnergyIngredientHelper();
public static final PNCPressureIngredientType PRESSURE_TYPE = new PNCPressureIngredientType();
public static final PNCPressureIngredientRenderer PRESSURE_TYPE_RENDERER = new PNCPressureIngredientRenderer();
public static final PNCPressureIngredientHelper PRESSURE_TYPE_HELPER = new PNCPressureIngredientHelper();
public static final ManaIngredientType MANA_TYPE = new ManaIngredientType();
public static final ManaIngredientRenderer MANA_TYPE_RENDERER = new ManaIngredientRenderer();
public static final ManaIngredientHelper MANA_TYPE_HELPER = new ManaIngredientHelper();
public static final StarlightIngredientType STAR_TYPE = new StarlightIngredientType();
public static final StarlightIngredientRenderer STAR_TYPE_RENDERER = new StarlightIngredientRenderer();
public static final StarlightIngredientHelper STAR_TYPE_HELPER = new StarlightIngredientHelper();
public static final RotationIngredientType ROT_TYPE = new RotationIngredientType();
public static final RotationIngredientRenderer ROT_RENDERER = new RotationIngredientRenderer();
public static final RotationIngredientHelper ROT_HELPER = new RotationIngredientHelper();
@Override
public ResourceLocation getPluginUid() {
return new ResourceLocation(MM.ID, "jei_main");
}
@Override
public void registerIngredients(IModIngredientRegistration registration) {
registration.register(MMJeiPlugin.ENERGY_TYPE, ImmutableList.of(), ENERGY_TYPE_HELPER, ENERGY_TYPE_RENDERER);
registration.register(MMJeiPlugin.PRESSURE_TYPE, ImmutableList.of(), PRESSURE_TYPE_HELPER, PRESSURE_TYPE_RENDERER);
registration.register(MMJeiPlugin.MANA_TYPE, ImmutableList.of(), MANA_TYPE_HELPER, MANA_TYPE_RENDERER);
registration.register(MMJeiPlugin.STAR_TYPE, ImmutableList.of(), STAR_TYPE_HELPER, STAR_TYPE_RENDERER);
registration.register(MMJeiPlugin.ROT_TYPE, ImmutableList.of(), ROT_HELPER, ROT_RENDERER);
}
@Override
public void registerRecipes(IRecipeRegistration registration) {
ENERGY_TYPE_RENDERER.setHelpers(registration.getJeiHelpers());
PRESSURE_TYPE_RENDERER.setHelpers(registration.getJeiHelpers());
MANA_TYPE_RENDERER.setHelpers(registration.getJeiHelpers());
STAR_TYPE_RENDERER.setHelpers(registration.getJeiHelpers());
ROT_RENDERER.setHelpers(registration.getJeiHelpers());
List<MachineStructureRecipe> structureRecipes = Minecraft.getInstance().world.getRecipeManager().getRecipesForType(RecipeTypes.MACHINE_STRUCTURE);
for (RegistryObject<ControllerBlock> block : MMLoader.BLOCKS) {
registration.addRecipes(structureRecipes.stream().filter(x -> x.getControllerId().contains(block.get().getControllerId())).collect(Collectors.toList()), new ResourceLocation(MM.ID, "machine_structure_" + block.get().getControllerId()));
}
List<MachineProcessRecipe> processRecipes = Minecraft.getInstance().world.getRecipeManager().getRecipesForType(RecipeTypes.MACHINE_PROCESS);
for (MachineStructureRecipe structureRecipe : structureRecipes) {
List<MachineProcessRecipe> recipes = processRecipes.stream().filter(x -> x.getStructureId().equals(structureRecipe.getStructureId())).collect(Collectors.toList());
registration.addRecipes(recipes, new ResourceLocation(MM.ID, "machine_process_" + structureRecipe.getStructureId()));
}
}
@Override
public void registerCategories(IRecipeCategoryRegistration registration) {
ENERGY_TYPE_RENDERER.setHelpers(registration.getJeiHelpers());
for (RegistryObject<ControllerBlock> block : MMLoader.BLOCKS) {
registration.addRecipeCategories(new MachineStructureRecipeCategory(registration.getJeiHelpers(), block.get()));
}
List<MachineStructureRecipe> structureRecipes = Minecraft.getInstance().world.getRecipeManager().getRecipesForType(RecipeTypes.MACHINE_STRUCTURE);
for (MachineStructureRecipe structureRecipe : structureRecipes) {
registration.addRecipeCategories(new MachineProcessRecipeCategory(registration.getJeiHelpers(), structureRecipe.getStructureId(), structureRecipe.getName()));
}
}
}

View File

@@ -1,153 +0,0 @@
package com.ticticboooom.mods.mm.client.jei.category;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.ticticboooom.mods.mm.MM;
import com.ticticboooom.mods.mm.data.MachineProcessRecipe;
import com.ticticboooom.mods.mm.ports.MasterfulPortType;
import com.ticticboooom.mods.mm.ports.state.PortState;
import com.ticticboooom.mods.mm.registration.MMPorts;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.gui.drawable.IDrawableStatic;
import mezz.jei.api.helpers.IJeiHelpers;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.util.ResourceLocation;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MachineProcessRecipeCategory implements IRecipeCategory<MachineProcessRecipe> {
private static final ResourceLocation overlayRl = new ResourceLocation(MM.ID, "textures/gui/gui_large_jei.png");
private IJeiHelpers helpers;
private String structureId;
private String structureName;
public MachineProcessRecipeCategory(IJeiHelpers helpers, String structureId, String structureName) {
this.helpers = helpers;
this.structureId = structureId;
this.structureName = structureName;
}
@Override
public ResourceLocation getUid() {
return new ResourceLocation(MM.ID, "machine_process_" + structureId);
}
@Override
public Class<? extends MachineProcessRecipe> getRecipeClass() {
return MachineProcessRecipe.class;
}
@Override
public String getTitle() {
return structureName + " Recipes";
}
public IDrawable getBackground() {
return helpers.getGuiHelper().createBlankDrawable(162, 150);
}
@Override
public IDrawable getIcon() {
return null;
}
@Override
public void setIngredients(MachineProcessRecipe recipe, IIngredients ingredients) {
Map<ResourceLocation, List<?>> inputStacks = new HashMap<>();
Map<ResourceLocation, List<?>> outputStacks = new HashMap<>();
for (PortState input : recipe.getInputs()) {
inputStacks.putIfAbsent(input.getName(), new ArrayList<MasterfulPortType>());
List<?> stacks = inputStacks.getOrDefault(input.getName(), new ArrayList<>());
stacks.addAll(input.getIngredient(true));
inputStacks.put(input.getName(), stacks);
}
for (PortState output : recipe.getOutputs()) {
outputStacks.putIfAbsent(output.getName(), new ArrayList<MasterfulPortType>());
List<?> stacks = outputStacks.getOrDefault(output.getName(), new ArrayList<>());
stacks.addAll(output.getIngredient(true));
outputStacks.put(output.getName(), stacks);
}
for (Map.Entry<ResourceLocation, List<?>> entry : inputStacks.entrySet()) {
MasterfulPortType masterfulPortType = MMPorts.PORTS.get(entry.getKey());
masterfulPortType.getParser().setIngredients(ingredients, entry.getValue(), true);
}
for (Map.Entry<ResourceLocation, List<?>> entry : outputStacks.entrySet()) {
MasterfulPortType masterfulPortType = MMPorts.PORTS.get(entry.getKey());
masterfulPortType.getParser().setIngredients(ingredients, entry.getValue(), false);
}
}
@Override
public void setRecipe(IRecipeLayout recipeLayout, MachineProcessRecipe recipe, IIngredients ingredients) {
final int inputWidth = 60;
Map<String, Integer> indexMap = new HashMap<>();
int currentX = 0;
int currentY = 0;
for (PortState input : recipe.getInputs()) {
Integer index = indexMap.getOrDefault(input.getClass().toString(), 0);
input.setupRecipe(recipeLayout, index, currentX, currentY, true);
indexMap.put(input.getClass().toString(), ++index);
currentX += 20;
if (currentX >= inputWidth) {
currentX = 0;
currentY += 20;
}
}
final int offsetX = 95;
currentX = offsetX;
currentY = 0;
for (PortState output : recipe.getOutputs()) {
Integer index = indexMap.getOrDefault(output.getClass().toString(), 0);
output.setupRecipe(recipeLayout, index, currentX, currentY, false);
indexMap.put(output.getClass().toString(), ++index);
currentX += 20;
if (currentX >= inputWidth + offsetX) {
currentX = offsetX;
currentY += 20;
}
}
}
@Override
public void draw(MachineProcessRecipe recipe, MatrixStack matrixStack, double mouseX, double mouseY) {
final int inputWidth = 60;
int currentX = 0;
int currentY = 0;
for (PortState input : recipe.getInputs()) {
input.render(matrixStack, currentX, currentY, (int) mouseX, (int) mouseY, helpers);
currentX += 20;
if (currentX >= inputWidth) {
currentX = 0;
currentY += 20;
}
}
final int offsetX = 95;
currentX = offsetX;
currentY = 0;
for (PortState output : recipe.getOutputs()) {
output.render(matrixStack, currentX, currentY, (int) mouseX, (int) mouseY, helpers);
currentX += 20;
if (currentX >= inputWidth + offsetX) {
currentX = offsetX;
currentY += 20;
}
}
IDrawableStatic drawable = helpers.getGuiHelper().createDrawable(new ResourceLocation(MM.ID, "textures/gui/slot_parts.png"), 26, 0, 24, 17);
drawable.draw(matrixStack, 66, 5);
}
}

View File

@@ -1,339 +0,0 @@
package com.ticticboooom.mods.mm.client.jei.category;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.ticticboooom.mods.mm.MM;
import com.ticticboooom.mods.mm.block.ControllerBlock;
import com.ticticboooom.mods.mm.block.MachinePortBlock;
import com.ticticboooom.mods.mm.client.util.GuiBlockRenderBuilder;
import com.ticticboooom.mods.mm.data.MachineStructureRecipe;
import com.ticticboooom.mods.mm.data.model.structure.MachineStructureBlockPos;
import com.ticticboooom.mods.mm.data.model.structure.MachineStructurePort;
import com.ticticboooom.mods.mm.data.model.structure.MachineStructureRecipeKeyModel;
import com.ticticboooom.mods.mm.helper.GLScissor;
import com.ticticboooom.mods.mm.helper.RLUtils;
import com.ticticboooom.mods.mm.registration.MMLoader;
import com.ticticboooom.mods.mm.registration.MMSetup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.helpers.IJeiHelpers;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.DirectionalBlock;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.state.Property;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ITag;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Quaternion;
import net.minecraft.util.math.vector.Vector3f;
import net.minecraft.util.math.vector.Vector4f;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.ForgeRegistries;
import org.lwjgl.glfw.GLFW;
import java.util.*;
import java.util.stream.Collectors;
public class MachineStructureRecipeCategory implements IRecipeCategory<MachineStructureRecipe> {
private static final ResourceLocation overlayRl = new ResourceLocation(MM.ID, "textures/gui/gui_large_jei.png");
private static final ResourceLocation iconRl = new ResourceLocation(MM.ID, "textures/items/blueprint.png");
private static final ResourceLocation slotRl = new ResourceLocation(MM.ID, "textures/gui/slot_parts.png");
private IJeiHelpers helpers;
private ControllerBlock controller;
private MachineStructureRecipe recipe;
private float xRotation = 0;
private double xLastMousePosition = 0;
private float yRotation = 0;
private double yLastMousePosition = 0;
private int scrollLastPos = 0;
private Vector3f prePos;
private int sliceY = 0;
private boolean slicingActive = false;
private float scaleFactor = 1F;
private int tickTimer = 0;
private Map<MachineStructureBlockPos, Integer> variantIndices = new HashMap<>();
public MachineStructureRecipeCategory(IJeiHelpers helpers, ControllerBlock controller) {
this.helpers = helpers;
this.controller = controller;
}
@Override
public ResourceLocation getUid() {
return new ResourceLocation(MM.ID, "machine_structure_" + controller.getControllerId());
}
@Override
public Class<? extends MachineStructureRecipe> getRecipeClass() {
return MachineStructureRecipe.class;
}
@Override
public String getTitle() {
return controller.getControllerName();
}
@Override
public IDrawable getBackground() {
return helpers.getGuiHelper().createDrawable(overlayRl, 0, 0, 162, 150);
}
@Override
public IDrawable getIcon() {
return helpers.getGuiHelper().createDrawableIngredient(new ItemStack(MMSetup.BLUEPRINT.get(), 1));
}
private IDrawable getButton() {
return helpers.getGuiHelper().createDrawable(slotRl, 0, 44, 18, 18);
}
@Override
public void setIngredients(MachineStructureRecipe machineStructureRecipe, IIngredients iIngredients) {
Ingredient ingredient = Ingredient.fromStacks(new ItemStack(MMSetup.BLUEPRINT.get()));
ArrayList<Ingredient> objects = new ArrayList<>();
objects.add(ingredient);
objects.add(Ingredient.fromStacks(new ItemStack(ForgeRegistries.ITEMS.getValue(controller.getRegistryName()))));
iIngredients.setInputIngredients(objects);
}
@Override
public void setRecipe(IRecipeLayout iRecipeLayout, MachineStructureRecipe recipe, IIngredients iIngredients) {
this.xRotation = 0;
this.yRotation = 0;
this.yLastMousePosition = 0;
this.xLastMousePosition = 0;
this.scaleFactor = 1.2f;
this.recipe = recipe;
this.sliceY = 0;
this.slicingActive = false;
this.variantIndices.clear();
this.tickTimer = 0;
float tx = 6.75f, ty = -5, tz = 10;
prePos = new Vector3f(tx, ty, tz);
}
@Override
public void draw(MachineStructureRecipe recipe, MatrixStack matrixStack, double mouseX, double mouseY) {
Minecraft mc = Minecraft.getInstance();
if (xLastMousePosition == 0) {
xLastMousePosition = mouseX;
}
if (yLastMousePosition == 0) {
yLastMousePosition = mouseY;
}
// Do mouse rotations
if (GLFW.glfwGetMouseButton(mc.getMainWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_1) != 0 && GLFW.glfwGetKey(mc.getMainWindow().getHandle(), GLFW.GLFW_KEY_LEFT_SHIFT) == 0) {
double relMoveX = mouseX - xLastMousePosition;
double relMoveY = mouseY - yLastMousePosition;
xRotation += relMoveX;
yRotation += relMoveY;
}
// Calculate distances
int minX = Integer.MAX_VALUE;
int maxX = Integer.MIN_VALUE;
int minZ = Integer.MAX_VALUE;
int maxZ = Integer.MIN_VALUE;
int minY = Integer.MAX_VALUE;
int maxY = Integer.MIN_VALUE;
for (MachineStructureRecipeKeyModel part : recipe.getModels().get(0)) {
minX = Math.min(part.getPos().getX(), minX);
maxX = Math.max(part.getPos().getX(), maxX);
minZ = Math.min(part.getPos().getZ(), minZ);
maxZ = Math.max(part.getPos().getZ(), maxZ);
minY = Math.min(part.getPos().getY(), minY);
maxY = Math.max(part.getPos().getY(), maxY);
}
// Do mouse scroll zoom
if (GLFW.glfwGetMouseButton(mc.getMainWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) != 0 && GLFW.glfwGetKey(mc.getMainWindow().getHandle(), GLFW.GLFW_KEY_LEFT_SHIFT) == 0) {
if (scrollLastPos == 0) {
scrollLastPos = (int) mouseY;
}
scaleFactor += (mouseY - yLastMousePosition) * 0.05;
scaleFactor = Math.max(0.003f, scaleFactor);
}
float centreX = ((float) maxX - minX) / 2f;
float centerY = ((float) maxY - minY) / 2f;
float centreZ = ((float) maxZ - minZ) / 2f;
mc.fontRenderer.drawString(matrixStack, recipe.getName(), 2, 2, 0xFFFFFFFF);
// Get the block parts for the layer
List<MachineStructureRecipeKeyModel> parts = recipe.getModels().get(0);
if (slicingActive) {
parts = parts.stream().filter(x -> x.getPos().getY() == sliceY).collect(Collectors.toList());
}
//float tx = 6.5f, ty = -5, tz = 10;
if (GLFW.glfwGetMouseButton(mc.getMainWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_LEFT) != 0 && GLFW.glfwGetKey(mc.getMainWindow().getHandle(), GLFW.GLFW_KEY_LEFT_SHIFT) != 0){
double relMoveX = mouseX - xLastMousePosition;
double relMoveY = mouseY - yLastMousePosition;
prePos.add((float)relMoveX * 0.08f, (float)-relMoveY * 0.08f, 0);
}
Vector3f offset = new Vector3f(-minX - 0.5f - centreX, -minY - 0.5f - centerY, -minZ - 0.5f + centreZ);
Vector4f zero = new Vector4f(0, 0, 0, 1);
zero.transform(matrixStack.getLast().getMatrix().copy());
GLScissor.enable((int)zero.getX(), (int)zero.getY(), 160, 120);
// Render the block parts
for (MachineStructureRecipeKeyModel part : parts) {
this.variantIndices.putIfAbsent(part.getPos(), 0);
if (part.getBlock().isEmpty() && part.getTag().isEmpty() && part.getPort() == null) {
continue;
}
BlockPos bp = new BlockPos(-part.getPos().getX(), part.getPos().getY(), -part.getPos().getZ());
if (!part.getBlock().equals("")) {
ResourceLocation resourceLocation = new ResourceLocation(part.getBlock());
Block block = ForgeRegistries.BLOCKS.getValue(resourceLocation);
if (block != null) {
BlockState defaultState = block.getDefaultState();
defaultState = with(defaultState, part.getProperties());
renderBlock(defaultState, bp, prePos, offset, matrixStack);
}
} else if (!part.getTag().equals("")) {
ResourceLocation resourceLocation = new ResourceLocation(part.getTag());
ITag<Block> tag = BlockTags.getCollection().getTagByID(resourceLocation);
Integer index = this.variantIndices.get(part.getPos());
Block block = tag.getAllElements().get(index);
if (this.tickTimer == 0) {
this.variantIndices.put(part.getPos(), (index + 1) % tag.getAllElements().size());
}
if (block != null) {
BlockState defaultState = block.getDefaultState();
defaultState = with(defaultState, part.getProperties());
renderBlock(defaultState, bp, prePos, offset, matrixStack);
}
} else if (part.getPort() != null) {
MachineStructurePort port = part.getPort();
ArrayList<RegistryObject<MachinePortBlock>> ports = port.isInput() ? MMLoader.IPORT_BLOCKS : MMLoader.OPORT_BLOCKS;
Integer index = this.variantIndices.get(part.getPos());
String controllerId = port.getControllerId().get(index);
if (this.tickTimer == 0) {
this.variantIndices.put(part.getPos(), (index + 1) % port.getControllerId().size());
}
String type = port.getType();
MachinePortBlock block = null;
for (RegistryObject<MachinePortBlock> regPortBlock : ports) {
MachinePortBlock portBlock = regPortBlock.get();
if (portBlock.getPortTypeId().equals(RLUtils.toRL(type)) && portBlock.getControllerId().equals(controllerId)) {
block = portBlock;
break;
}
}
if (block != null) {
BlockState defaultState = block.getDefaultState();
defaultState = with(defaultState, part.getProperties());
renderBlock(defaultState, bp, prePos, offset, matrixStack);
}
}
}
// Render the controller block
if (sliceY == 0) {
ControllerBlock block = null;
MachineStructureBlockPos controllerPos = new MachineStructureBlockPos(0, 0, 0);
this.variantIndices.putIfAbsent(controllerPos, 0);
Integer index = this.variantIndices.get(controllerPos);
String controller = recipe.getControllerId().get(index);
if (this.tickTimer == 0) {
this.variantIndices.put(controllerPos, (index + 1) % recipe.getControllerId().size());
}
for (RegistryObject<ControllerBlock> reg : MMLoader.BLOCKS) {
if (reg.get().getControllerId().equals(controller)) {
block = reg.get();
}
}
if (block != null) {
BlockState defaultState = block.getDefaultState().with(DirectionalBlock.FACING, Direction.NORTH);
renderBlock(defaultState, new BlockPos(0, 0, 0), prePos, offset, matrixStack);
}
}
GLScissor.disable();
// End tick
xLastMousePosition = mouseX;
yLastMousePosition = mouseY;
getButton().draw(matrixStack, 144, 125);
if (++this.tickTimer % 40 == 0) {
this.tickTimer = 0;
}
}
@Override
public boolean handleClick(MachineStructureRecipe recipe, double mouseX, double mouseY, int mouseButton) {
if (mouseX > 144 && mouseY > 125 && mouseX < 162 && mouseY < 143) {
startIncrementSlice();
}
return false;
}
private void startIncrementSlice() {
int topY = Integer.MIN_VALUE;
int bottomY = Integer.MAX_VALUE;
for (MachineStructureRecipeKeyModel part : recipe.getModels().get(0)) {
topY = Math.max(part.getPos().getY(), topY);
bottomY = Math.min(part.getPos().getY(), bottomY);
}
if (!slicingActive) {
slicingActive = true;
sliceY = bottomY;
} else if (sliceY == topY) {
slicingActive = false;
sliceY = 0;
} else {
sliceY++;
}
}
private BlockState with(BlockState defaultState, Map<String, String> props) {
if (props == null) {
return defaultState;
}
for (Map.Entry<String, String> stringStringEntry : props.entrySet()) {
for (Property<?> property : defaultState.getProperties()) {
Optional<?> o = property.parseValue(stringStringEntry.getValue());
if (!o.isPresent()) {
return defaultState;
}
for (Comparable<?> allowedValue : property.getAllowedValues()) {
defaultState = defaultState.cycleValue(property);
if (defaultState.get(property).equals(o.get())) {
return defaultState;
}
}
}
}
return defaultState;
}
private void renderBlock(BlockState defaultState, BlockPos bp, Vector3f prePos, Vector3f offset, MatrixStack ms) {
new GuiBlockRenderBuilder(defaultState).at(bp)
.withPrePosition(prePos)
.withRotation(new Quaternion(new Vector3f(1, 0, 0), 15 + yRotation, true))
.withRotation(new Quaternion(new Vector3f(0, -1, 0), 225 - xRotation, true))
.withScale(new Vector3f(scaleFactor, -scaleFactor, scaleFactor))
.withOffset(offset)
.finalize(ms);
}
}

View File

@@ -1,38 +0,0 @@
package com.ticticboooom.mods.mm.client.jei.category.render;
import net.minecraft.block.BlockState;
import net.minecraft.fluid.FluidState;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import javax.annotation.Nullable;
public class AirBlockReader implements IBlockReader {
private TileEntity tile;
private BlockState state;
public AirBlockReader(BlockState state) {
this.state = state;
}
public void setTile(TileEntity t){
tile = t;
}
@Nullable
@Override
public TileEntity getTileEntity(BlockPos pos) {
return tile;
}
@Override
public BlockState getBlockState(BlockPos pos) {
return state;
}
@Override
public FluidState getFluidState(BlockPos pos) {
return null;
}
}

View File

@@ -1,46 +0,0 @@
package com.ticticboooom.mods.mm.client.jei.ingredients.as;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.PressureStack;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.StarlightStack;
import mezz.jei.api.ingredients.IIngredientHelper;
import javax.annotation.Nullable;
public class StarlightIngredientHelper implements IIngredientHelper<StarlightStack> {
@Nullable
@Override
public StarlightStack getMatch(Iterable<StarlightStack> ingredients, StarlightStack ingredientToMatch) {
return ingredientToMatch;
}
@Override
public String getDisplayName(StarlightStack ingredient) {
return "Starlight";
}
@Override
public String getUniqueId(StarlightStack ingredient) {
return ingredient.getAmount() + "";
}
@Override
public String getModId(StarlightStack ingredient) {
return "astralsorcery";
}
@Override
public String getResourceId(StarlightStack ingredient) {
return "starlight";
}
@Override
public StarlightStack copyIngredient(StarlightStack ingredient) {
return new StarlightStack(ingredient.getAmount());
}
@Override
public String getErrorInfo(@Nullable StarlightStack ingredient) {
return "Error";
}
}

View File

@@ -1,39 +0,0 @@
package com.ticticboooom.mods.mm.client.jei.ingredients.as;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.ticticboooom.mods.mm.MM;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.PressureStack;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.StarlightStack;
import lombok.Setter;
import mezz.jei.api.gui.drawable.IDrawableStatic;
import mezz.jei.api.helpers.IJeiHelpers;
import mezz.jei.api.ingredients.IIngredientRenderer;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import javax.annotation.Nullable;
import java.util.List;
public class StarlightIngredientRenderer implements IIngredientRenderer<StarlightStack> {
@Setter
private IJeiHelpers helpers;
@Override
public void render(MatrixStack matrixStack, int xPosition, int yPosition, @Nullable StarlightStack ingredient) {
if (ingredient != null) {
IDrawableStatic drawable = helpers.getGuiHelper().createDrawable(new ResourceLocation(MM.ID, "textures/gui/slot_parts.png"), 37, 80, 16, 16);
drawable.draw(matrixStack, xPosition, yPosition);
}
}
@Override
public List<ITextComponent> getTooltip(StarlightStack ingredient, ITooltipFlag tooltipFlag) {
return Lists.newArrayList(
new StringTextComponent("Astral Starlight"),
new StringTextComponent(ingredient.getAmount() + " S")
);
}
}

View File

@@ -1,12 +0,0 @@
package com.ticticboooom.mods.mm.client.jei.ingredients.as;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.PressureStack;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.StarlightStack;
import mezz.jei.api.ingredients.IIngredientType;
public class StarlightIngredientType implements IIngredientType<StarlightStack> {
@Override
public Class<? extends StarlightStack> getIngredientClass() {
return StarlightStack.class;
}
}

View File

@@ -1,44 +0,0 @@
package com.ticticboooom.mods.mm.client.jei.ingredients.energy;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.EnergyStack;
import mezz.jei.api.ingredients.IIngredientHelper;
import javax.annotation.Nullable;
public class EnergyIngredientHelper implements IIngredientHelper<EnergyStack> {
@Nullable
@Override
public EnergyStack getMatch(Iterable<EnergyStack> ingredients, EnergyStack ingredientToMatch) {
return ingredientToMatch;
}
@Override
public String getDisplayName(EnergyStack ingredient) {
return "Forge Energy";
}
@Override
public String getUniqueId(EnergyStack ingredient) {
return "fe_" + ingredient + "_fe";
}
@Override
public String getModId(EnergyStack ingredient) {
return "forge";
}
@Override
public String getResourceId(EnergyStack ingredient) {
return "fe_" + ingredient.getAmount() + "_fe";
}
@Override
public EnergyStack copyIngredient(EnergyStack ingredient) {
return new EnergyStack(ingredient.getAmount());
}
@Override
public String getErrorInfo(@Nullable EnergyStack ingredient) {
return "Error";
}
}

View File

@@ -1,39 +0,0 @@
package com.ticticboooom.mods.mm.client.jei.ingredients.energy;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.ticticboooom.mods.mm.MM;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.EnergyStack;
import lombok.Setter;
import mezz.jei.api.gui.drawable.IDrawableStatic;
import mezz.jei.api.helpers.IJeiHelpers;
import mezz.jei.api.ingredients.IIngredientRenderer;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import javax.annotation.Nullable;
import java.text.NumberFormat;
import java.util.List;
public class EnergyIngredientRenderer implements IIngredientRenderer<EnergyStack> {
@Setter
private IJeiHelpers helpers;
@Override
public void render(MatrixStack matrixStack, int xPosition, int yPosition, @Nullable EnergyStack ingredient) {
if (ingredient != null) {
IDrawableStatic drawable = helpers.getGuiHelper().createDrawable(new ResourceLocation(MM.ID, "textures/gui/slot_parts.png"), 19, 62, 16, 16);
drawable.draw(matrixStack, xPosition, yPosition);
}
}
@Override
public List<ITextComponent> getTooltip(EnergyStack ingredient, ITooltipFlag tooltipFlag) {
return Lists.newArrayList(
new StringTextComponent("Forge Energy"),
new StringTextComponent(NumberFormat.getInstance().format(ingredient.getAmount()) + " FE")
);
}
}

View File

@@ -1,11 +0,0 @@
package com.ticticboooom.mods.mm.client.jei.ingredients.energy;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.EnergyStack;
import mezz.jei.api.ingredients.IIngredientType;
public class EnergyIngredientType implements IIngredientType<EnergyStack> {
@Override
public Class<? extends EnergyStack> getIngredientClass() {
return EnergyStack.class;
}
}

View File

@@ -1,46 +0,0 @@
package com.ticticboooom.mods.mm.client.jei.ingredients.mana;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.PressureStack;
import com.ticticboooom.mods.mm.inventory.botania.PortManaInventory;
import mezz.jei.api.ingredients.IIngredientHelper;
import javax.annotation.Nullable;
public class ManaIngredientHelper implements IIngredientHelper<PortManaInventory> {
@Nullable
@Override
public PortManaInventory getMatch(Iterable<PortManaInventory> ingredients, PortManaInventory ingredientToMatch) {
return ingredientToMatch;
}
@Override
public String getDisplayName(PortManaInventory ingredient) {
return "Mana";
}
@Override
public String getUniqueId(PortManaInventory ingredient) {
return ingredient.getManaStored() + "";
}
@Override
public String getModId(PortManaInventory ingredient) {
return "botania";
}
@Override
public String getResourceId(PortManaInventory ingredient) {
return "mana";
}
@Override
public PortManaInventory copyIngredient(PortManaInventory ingredient) {
return new PortManaInventory(ingredient.getManaStored(), ingredient.getMaxManaStored());
}
@Override
public String getErrorInfo(@Nullable PortManaInventory ingredient) {
return "Error";
}
}

View File

@@ -1,39 +0,0 @@
package com.ticticboooom.mods.mm.client.jei.ingredients.mana;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.ticticboooom.mods.mm.MM;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.PressureStack;
import com.ticticboooom.mods.mm.inventory.botania.PortManaInventory;
import lombok.Setter;
import mezz.jei.api.gui.drawable.IDrawableStatic;
import mezz.jei.api.helpers.IJeiHelpers;
import mezz.jei.api.ingredients.IIngredientRenderer;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import javax.annotation.Nullable;
import java.util.List;
public class ManaIngredientRenderer implements IIngredientRenderer<PortManaInventory> {
@Setter
private IJeiHelpers helpers;
@Override
public void render(MatrixStack matrixStack, int xPosition, int yPosition, @Nullable PortManaInventory ingredient) {
if (ingredient != null) {
IDrawableStatic drawable = helpers.getGuiHelper().createDrawable(new ResourceLocation(MM.ID, "textures/gui/slot_parts.png"), 19, 80, 16, 16);
drawable.draw(matrixStack, xPosition, yPosition);
}
}
@Override
public List<ITextComponent> getTooltip(PortManaInventory ingredient, ITooltipFlag tooltipFlag) {
return Lists.newArrayList(
new StringTextComponent("Botania Mana"),
new StringTextComponent(ingredient.getManaStored() + " Units")
);
}
}

View File

@@ -1,11 +0,0 @@
package com.ticticboooom.mods.mm.client.jei.ingredients.mana;
import com.ticticboooom.mods.mm.inventory.botania.PortManaInventory;
import mezz.jei.api.ingredients.IIngredientType;
public class ManaIngredientType implements IIngredientType<PortManaInventory> {
@Override
public Class<? extends PortManaInventory> getIngredientClass() {
return PortManaInventory.class;
}
}

View File

@@ -1,15 +0,0 @@
package com.ticticboooom.mods.mm.client.jei.ingredients.model;
import lombok.Getter;
import lombok.Setter;
public class EnergyStack {
@Getter
@Setter
private int amount;
public EnergyStack(int amount){
this.amount = amount;
}
}

View File

@@ -1,15 +0,0 @@
package com.ticticboooom.mods.mm.client.jei.ingredients.model;
import lombok.Getter;
import lombok.Setter;
public class PressureStack {
@Getter
@Setter
private float amount;
public PressureStack(float amount){
this.amount = amount;
}
}

View File

@@ -1,15 +0,0 @@
package com.ticticboooom.mods.mm.client.jei.ingredients.model;
import lombok.Getter;
import lombok.Setter;
public class RotationStack {
@Getter
@Setter
private float speed;
public RotationStack(float speed){
this.speed = speed;
}
}

View File

@@ -1,15 +0,0 @@
package com.ticticboooom.mods.mm.client.jei.ingredients.model;
import lombok.Getter;
import lombok.Setter;
public class StarlightStack {
@Getter
@Setter
private int amount;
public StarlightStack(int amount){
this.amount = amount;
}
}

View File

@@ -1,48 +0,0 @@
package com.ticticboooom.mods.mm.client.jei.ingredients.pressure;
import com.ticticboooom.mods.mm.MM;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.PressureStack;
import mezz.jei.api.ingredients.IIngredientHelper;
import mezz.jei.api.ingredients.IIngredientType;
import net.minecraft.util.ResourceLocation;
import javax.annotation.Nullable;
public class PNCPressureIngredientHelper implements IIngredientHelper<PressureStack> {
@Nullable
@Override
public PressureStack getMatch(Iterable<PressureStack> ingredients, PressureStack ingredientToMatch) {
return ingredientToMatch;
}
@Override
public String getDisplayName(PressureStack ingredient) {
return "Pressure";
}
@Override
public String getUniqueId(PressureStack ingredient) {
return ingredient.getAmount() + "";
}
@Override
public String getModId(PressureStack ingredient) {
return "pneumaticcraft";
}
@Override
public String getResourceId(PressureStack ingredient) {
return "pressure";
}
@Override
public PressureStack copyIngredient(PressureStack ingredient) {
return new PressureStack(ingredient.getAmount());
}
@Override
public String getErrorInfo(@Nullable PressureStack ingredient) {
return "Error";
}
}

View File

@@ -1,39 +0,0 @@
package com.ticticboooom.mods.mm.client.jei.ingredients.pressure;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.ticticboooom.mods.mm.MM;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.PressureStack;
import lombok.Setter;
import mezz.jei.api.gui.drawable.IDrawableStatic;
import mezz.jei.api.helpers.IJeiHelpers;
import mezz.jei.api.ingredients.IIngredientRenderer;
import mezz.jei.api.ingredients.IIngredientType;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import javax.annotation.Nullable;
import java.util.List;
public class PNCPressureIngredientRenderer implements IIngredientRenderer<PressureStack> {
@Setter
private IJeiHelpers helpers;
@Override
public void render(MatrixStack matrixStack, int xPosition, int yPosition, @Nullable PressureStack ingredient) {
if (ingredient != null) {
IDrawableStatic drawable = helpers.getGuiHelper().createDrawable(new ResourceLocation(MM.ID, "textures/gui/slot_parts.png"), 1, 62, 16, 16);
drawable.draw(matrixStack, xPosition, yPosition);
}
}
@Override
public List<ITextComponent> getTooltip(PressureStack ingredient, ITooltipFlag tooltipFlag) {
return Lists.newArrayList(
new StringTextComponent("PNC Pressure"),
new StringTextComponent(ingredient.getAmount() + " Units")
);
}
}

View File

@@ -1,11 +0,0 @@
package com.ticticboooom.mods.mm.client.jei.ingredients.pressure;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.PressureStack;
import mezz.jei.api.ingredients.IIngredientType;
public class PNCPressureIngredientType implements IIngredientType<PressureStack> {
@Override
public Class<? extends PressureStack> getIngredientClass() {
return PressureStack.class;
}
}

View File

@@ -1,46 +0,0 @@
package com.ticticboooom.mods.mm.client.jei.ingredients.rotation;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.RotationStack;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.StarlightStack;
import mezz.jei.api.ingredients.IIngredientHelper;
import javax.annotation.Nullable;
public class RotationIngredientHelper implements IIngredientHelper<RotationStack> {
@Nullable
@Override
public RotationStack getMatch(Iterable<RotationStack> ingredients, RotationStack ingredientToMatch) {
return ingredientToMatch;
}
@Override
public String getDisplayName(RotationStack ingredient) {
return "SU";
}
@Override
public String getUniqueId(RotationStack ingredient) {
return ingredient.getSpeed() + "";
}
@Override
public String getModId(RotationStack ingredient) {
return "create";
}
@Override
public String getResourceId(RotationStack ingredient) {
return "rotation";
}
@Override
public RotationStack copyIngredient(RotationStack ingredient) {
return new RotationStack(ingredient.getSpeed());
}
@Override
public String getErrorInfo(@Nullable RotationStack ingredient) {
return "Error";
}
}

View File

@@ -1,48 +0,0 @@
package com.ticticboooom.mods.mm.client.jei.ingredients.rotation;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.simibubi.create.AllItems;
import com.ticticboooom.mods.mm.MM;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.RotationStack;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.StarlightStack;
import lombok.Setter;
import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.gui.drawable.IDrawableStatic;
import mezz.jei.api.helpers.IJeiHelpers;
import mezz.jei.api.ingredients.IIngredientRenderer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.common.util.Lazy;
import javax.annotation.Nullable;
import java.util.List;
public class RotationIngredientRenderer implements IIngredientRenderer<RotationStack> {
@Setter
private IJeiHelpers helpers;
@Override
public void render(MatrixStack matrixStack, int xPosition, int yPosition, @Nullable RotationStack ingredient) {
if (ingredient != null) {
IDrawableStatic drawable = helpers.getGuiHelper().createDrawable(new ResourceLocation(MM.ID, "textures/gui/slot_parts.png"), 1, 98, 16, 16);
drawable.draw(matrixStack, xPosition, yPosition);
}
}
@Override
public List<ITextComponent> getTooltip(RotationStack ingredient, ITooltipFlag tooltipFlag) {
return Lists.newArrayList(
new StringTextComponent("Create Rotation"),
new StringTextComponent(ingredient.getSpeed() + " Speed")
);
}
}

View File

@@ -1,12 +0,0 @@
package com.ticticboooom.mods.mm.client.jei.ingredients.rotation;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.RotationStack;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.StarlightStack;
import mezz.jei.api.ingredients.IIngredientType;
public class RotationIngredientType implements IIngredientType<RotationStack> {
@Override
public Class<? extends RotationStack> getIngredientClass() {
return RotationStack.class;
}
}

View File

@@ -1,46 +0,0 @@
package com.ticticboooom.mods.mm.client.screen;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.ticticboooom.mods.mm.MM;
import com.ticticboooom.mods.mm.block.container.ControllerBlockContainer;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
public class ControllerBlockContainerScreen extends ContainerScreen<ControllerBlockContainer> {
private final ControllerBlockContainer container;
public ControllerBlockContainerScreen(ControllerBlockContainer container, PlayerInventory p_i51105_2_, ITextComponent p_i51105_3_) {
super(container, p_i51105_2_, p_i51105_3_);
this.container = container;
}
private static final ResourceLocation GUI = new ResourceLocation(MM.ID, "textures/gui/gui_large.png");
@Override
public void render(MatrixStack stack, int mouseX, int mouseY, float p_230430_4_) {
super.render(stack, mouseX, mouseY, p_230430_4_);
this.renderHoveredTooltip(stack, mouseX, mouseY);
}
@Override
protected void drawGuiContainerForegroundLayer(MatrixStack stack, int x0, int y0) {
this.minecraft.fontRenderer.func_238418_a_(container.getTile().getDisplayName(), 10, -10, 176, 0xfefefe);
drawString(stack, this.minecraft.fontRenderer, "Inventory", 7, 110, 0xfefefe);
int y = 50;
for (String s : container.getTile().getUpdate().getMsg().split("\n")) {
drawString(stack, this.minecraft.fontRenderer, s, 12, y, 0xfefefe);
y += 12;
}
}
@Override
protected void drawGuiContainerBackgroundLayer(MatrixStack stack, float partialTicks, int x, int y) {
this.renderBackground(stack);
this.minecraft.textureManager.bindTexture(GUI);
this.blit(stack, this.guiLeft, this.guiTop - 20, 0, 0, 256, 256);
}
}

View File

@@ -1,40 +0,0 @@
package com.ticticboooom.mods.mm.client.screen;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.ticticboooom.mods.mm.MM;
import com.ticticboooom.mods.mm.block.container.ControllerBlockContainer;
import com.ticticboooom.mods.mm.block.container.PortBlockContainer;
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
public class PortBlockContainerScreen extends ContainerScreen<PortBlockContainer> {
private static final ResourceLocation GUI = new ResourceLocation(MM.ID, "textures/gui/port_gui.png");
private final PortBlockContainer container;
public PortBlockContainerScreen(PortBlockContainer container, PlayerInventory p_i51105_2_, ITextComponent p_i51105_3_) {
super(container, p_i51105_2_, p_i51105_3_);
this.container = container;
}
@Override
public void render(MatrixStack ms, int mouseX, int mouseY, float partialTicks) {
super.render(ms, mouseX, mouseY, partialTicks);
this.renderHoveredTooltip(ms, mouseX, mouseY);
}
@Override
protected void drawGuiContainerBackgroundLayer(MatrixStack stack, float partialTicks, int x, int y) {
this.renderBackground(stack);
container.getTile().getStorage().render(stack, x, y, this.guiLeft, this.guiTop, this);
}
@Override
protected void drawGuiContainerForegroundLayer(MatrixStack stack, int x, int y) {
drawString(stack, this.minecraft.fontRenderer, container.getTile().getDisplayName(), 7, 5, 0xfefefe);
drawString(stack, this.minecraft.fontRenderer, "Inventory", 7, 130, 0xfefefe);
}
}

View File

@@ -1,58 +0,0 @@
package com.ticticboooom.mods.mm.client.screen;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.ticticboooom.mods.mm.MM;
import com.ticticboooom.mods.mm.block.container.StructureGenBlockContainer;
import com.ticticboooom.mods.mm.helper.StructureHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
public class StructureGenBlockContainerScreen extends ContainerScreen<StructureGenBlockContainer> {
private final StructureGenBlockContainer cont;
public StructureGenBlockContainerScreen(StructureGenBlockContainer cont, PlayerInventory p_i51105_2_, ITextComponent p_i51105_3_) {
super(cont, p_i51105_2_, p_i51105_3_);
this.cont = cont;
}
@Override
public void render(MatrixStack ms, int p_230430_2_, int p_230430_3_, float p_230430_4_) {
super.render(ms, p_230430_2_, p_230430_3_, p_230430_4_);
this.renderHoveredTooltip(ms, p_230430_2_, p_230430_3_);
}
@Override
protected void drawGuiContainerForegroundLayer(MatrixStack ms, int x, int y) {
this.minecraft.fontRenderer.func_238418_a_(new StringTextComponent("Structure Generator"), 10, -10, 176, 0xfefefe);
drawString(ms, this.minecraft.fontRenderer, "Inventory", 7, 107, 0xfefefe);
drawCenteredString(ms, this.minecraft.fontRenderer, "COPY TO CLIPBOARD", 80, 50, 0xfefefe);
}
@Override
protected void drawGuiContainerBackgroundLayer(MatrixStack ms, float partialTicks, int x, int y) {
this.renderBackground(ms);
Minecraft.getInstance().textureManager.bindTexture(new ResourceLocation(MM.ID, "textures/gui/port_gui.png"));
blit(ms, guiLeft, guiTop - 20, 0, 0, 175, 256);
Minecraft.getInstance().textureManager.bindTexture(new ResourceLocation(MM.ID, "textures/gui/slot_parts.png"));
blit(ms, guiLeft + 150, guiTop - 15, 0, 26, 18, 18);
}
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
int x = (int)mouseX - guiLeft;
int y = (int)mouseY - guiTop;
if (x > 0 && x < 176 && y > 40 && y < 60){
StructureHelper.copyToClickBoard(cont.getTile().getInv().getStackInSlot(0).getTag(), cont.getTile().getWorld());
}
return super.mouseClicked(mouseX, mouseY, button);
}
}

View File

@@ -1,112 +0,0 @@
package com.ticticboooom.mods.mm.client.ter;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.ticticboooom.mods.mm.block.tile.StructureGenBlockEntity;
import com.ticticboooom.mods.mm.client.MMRenderTypes;
import com.ticticboooom.mods.mm.helper.NBTHelper;
import com.ticticboooom.mods.mm.registration.MMSetup;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Matrix4f;
import net.minecraft.util.math.vector.Quaternion;
public class StructureGenTileEntityRenderer extends TileEntityRenderer<StructureGenBlockEntity> {
public StructureGenTileEntityRenderer(TileEntityRendererDispatcher rendererDispatcherIn) {
super(rendererDispatcherIn);
}
@Override
public void render(StructureGenBlockEntity tileEntityIn, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) {
ItemStack stackInSlot = tileEntityIn.getHandler().getStackInSlot(0);
if (stackInSlot.isEmpty()) {
return;
}
if (stackInSlot.getItem() != MMSetup.STRUCTURE_DEVICE.get()) {
return;
}
if (stackInSlot.getTag() == null){
return;
}
if (stackInSlot.getTag().contains("pos1") && stackInSlot.getTag().contains("pos2")) {
CompoundNBT pos1c = stackInSlot.getTag().getCompound("pos1");
CompoundNBT pos2c = stackInSlot.getTag().getCompound("pos2");
BlockPos pos1 = NBTHelper.fromCompound(pos1c);
BlockPos pos2 = NBTHelper.fromCompound(pos2c);
BlockPos tilePos = tileEntityIn.getPos();
pos1 = pos1.subtract(tilePos);
pos2 = pos2.subtract(tilePos);
IVertexBuilder builder = bufferIn.getBuffer(MMRenderTypes.OUTLINE);
matrixStackIn.push();
Matrix4f mat = matrixStackIn.getLast().getMatrix();
float x = Math.min(pos1.getX(), pos2.getX());
float y = Math.min(pos1.getY(), pos2.getY());
float z = Math.min(pos1.getZ(), pos2.getZ());
float dx = Math.max(pos1.getX(), pos2.getX()) + 1;
float dy = Math.max(pos1.getY(), pos2.getY()) + 1;
float dz = Math.max(pos1.getZ(), pos2.getZ()) + 1;
float xAdjust = addWiggleRoom(x,dx);
x = x+xAdjust;
dx = dx+(xAdjust*-1);
float yAdjust = addWiggleRoom(y,dy);
y = y+yAdjust;
dy = dy+(yAdjust*-1);
float zAdjust = addWiggleRoom(z,dz);
z = z+zAdjust;
dz = dz+(zAdjust*-1);
int R = 255, G = 255, B = 255, A = 70;
builder.pos(mat, x , y, z).color(R, G, B, A).endVertex();
builder.pos(mat, dx, y, z).color(R, G, B, A).endVertex();
builder.pos(mat, dx, y, dz).color(R, G, B, A).endVertex();
builder.pos(mat, x, y, dz).color(R, G, B, A).endVertex();
builder.pos(mat, x , dy, z).color(R, G, B, A).endVertex();
builder.pos(mat, x, dy, dz).color(R, G, B, A).endVertex();
builder.pos(mat, dx, dy, dz).color(R, G, B, A).endVertex();
builder.pos(mat, dx, dy, z).color(R, G, B, A).endVertex();
builder.pos(mat, x , y, z).color(R, G, B, A).endVertex();
builder.pos(mat, x, dy, z).color(R, G, B, A).endVertex();
builder.pos(mat, dx, dy, z).color(R, G, B, A).endVertex();
builder.pos(mat, dx, y, z).color(R, G, B, A).endVertex();
builder.pos(mat, x , y, dz).color(R, G, B, A).endVertex();
builder.pos(mat, dx, y, dz).color(R, G, B, A).endVertex();
builder.pos(mat, dx, dy, dz).color(R, G, B, A).endVertex();
builder.pos(mat, x, dy, dz).color(R, G, B, A).endVertex();
builder.pos(mat, dx , y, z).color(R, G, B, A).endVertex();
builder.pos(mat, dx, y, dz).color(R, G, B, A).endVertex();
builder.pos(mat, dx, dy, dz).color(R, G, B, A).endVertex();
builder.pos(mat, dx, dy, z).color(R, G, B, A).endVertex();
builder.pos(mat, x , y, z).color(R, G, B, A).endVertex();
builder.pos(mat, x, y, dz).color(R, G, B, A).endVertex();
builder.pos(mat, x, dy, dz).color(R, G, B, A).endVertex();
builder.pos(mat, x, dy, z).color(R, G, B, A).endVertex();
matrixStackIn.pop();
}
}
private float addWiggleRoom(float coordOne, float coordTwo) {
if(coordOne > coordTwo) {
return 0.05f;
}
return -0.05f;
}
}

View File

@@ -1,129 +0,0 @@
package com.ticticboooom.mods.mm.client.util;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.fluid.Fluid;
import net.minecraft.inventory.container.PlayerContainer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.vector.Matrix4f;
import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fluids.FluidStack;
public class FluidRenderer {
public static final FluidRenderer INSTANCE = new FluidRenderer(1000, 16, 16, 16);
private static final int TEX_WIDTH = 16;
private static final int TEX_HEIGHT = 16;
private int capacity;
private final int width;
private final int height;
private final int minHeight;
public FluidRenderer(int capacity, int width, int height, int minHeight) {
this.capacity = capacity;
this.width = width;
this.height = height;
this.minHeight = minHeight;
}
public void render(MatrixStack matrixStack, final int xPosition, final int yPosition, FluidStack stack, final int height) {
RenderSystem.enableBlend();
RenderSystem.enableAlphaTest();
drawFluid(matrixStack, xPosition, yPosition, stack, height);
RenderSystem.color4f(1, 1, 1, 1);
RenderSystem.disableAlphaTest();
RenderSystem.disableBlend();
}
private void drawFluid(MatrixStack matrixStack, int xPosition, int yPosition, FluidStack stack, final int height) {
if (stack == null) {
return;
}
Fluid fluid = stack.getFluid();
if (fluid == null) {
return;
}
TextureAtlasSprite fluidStillSprite = getStillFluidSprite(stack);
FluidAttributes attributes = fluid.getAttributes();
int fluidColor = attributes.getColor(stack);
int amount = stack.getAmount();
drawTiledSprite(matrixStack, xPosition, yPosition, width, height, fluidColor, height, fluidStillSprite);
}
private void drawTiledSprite(MatrixStack matrixStack, int xPosition, int yPosition, int width, int height, int color, int scaledAmount, TextureAtlasSprite sprite) {
Minecraft minecraft = Minecraft.getInstance();
minecraft.getTextureManager().bindTexture(PlayerContainer.LOCATION_BLOCKS_TEXTURE);
Matrix4f matrix = matrixStack.getLast().getMatrix();
setGLColorFromInt(color);
final int xTileCount = width / TEX_WIDTH;
final int xRemainder = height - (xTileCount * TEX_WIDTH);
final int yTileCount = scaledAmount / TEX_HEIGHT;
final int yRemainder = scaledAmount - (yTileCount * TEX_HEIGHT);
final int yStart = yPosition + height;
for (int xTile = 0; xTile <= xTileCount; xTile++) {
for (int yTile = 0; yTile <= yTileCount; yTile++) {
int w = (xTile == xTileCount) ? xRemainder : TEX_WIDTH;
int h = (yTile == yTileCount) ? yRemainder : TEX_HEIGHT;
int x = xPosition + (xTile * TEX_WIDTH);
int y = yStart - ((yTile + 1) * TEX_HEIGHT);
if (w > 0 && h > 0) {
int maskTop = TEX_HEIGHT - h;
int maskRight = TEX_WIDTH - w;
drawTextureWithMasking(matrix, x, y, sprite, maskTop, maskRight, 100);
}
}
}
}
private void drawTextureWithMasking(Matrix4f matrix, int x, int y, TextureAtlasSprite sprite, int maskTop, int maskRight, int z) {
float uMin = sprite.getMinU();
float uMax = sprite.getMaxU();
float vMin = sprite.getMinV();
float vMax = sprite.getMaxV();
uMax = uMax - (maskRight / 16F * (uMax - uMin));
vMax = vMax - (maskTop / 16F * (vMax - vMin));
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
bufferBuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
bufferBuilder.pos(matrix, x, y + 16, z).tex(uMin, vMax).endVertex();
bufferBuilder.pos(matrix, x + 16 - maskRight, y + 16, z).tex(uMax, vMax).endVertex();
bufferBuilder.pos(matrix, x + 16 - maskRight, y + maskTop, z).tex(uMax, vMin).endVertex();
bufferBuilder.pos(matrix, x, y + maskTop, z).tex(uMin, vMin).endVertex();
tessellator.draw();
}
private static void setGLColorFromInt(int color) {
float red = (color >> 16 & 0xFF) / 255.0F;
float green = (color >> 8 & 0xFF) / 255.0F;
float blue = (color & 0xFF) / 255.0F;
float alpha = ((color >> 24) & 0xFF) / 255F;
RenderSystem.color4f(red, green, blue, alpha);
}
private TextureAtlasSprite getStillFluidSprite(FluidStack stack) {
Minecraft minecraft = Minecraft.getInstance();
Fluid fluid = stack.getFluid();
FluidAttributes attributes = fluid.getAttributes();
ResourceLocation fluidStill = attributes.getStillTexture(stack);
return minecraft.getAtlasSpriteGetter(PlayerContainer.LOCATION_BLOCKS_TEXTURE).apply(fluidStill);
}
}

View File

@@ -1,146 +0,0 @@
package com.ticticboooom.mods.mm.client.util;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import com.ticticboooom.mods.mm.client.jei.category.render.AirBlockReader;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BlockRendererDispatcher;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.RenderTypeLookup;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Matrix4f;
import net.minecraft.util.math.vector.Quaternion;
import net.minecraft.util.math.vector.Vector3f;
import net.minecraftforge.client.model.data.EmptyModelData;
import java.util.ArrayList;
import java.util.List;
public class GuiBlockRenderBuilder {
private final BlockState blockState;
private BlockPos position;
private List<Quaternion> orderedRotation = new ArrayList<>();
private Minecraft mc = Minecraft.getInstance();
private Vector3f scale;
private Vector3f prePosition = new Vector3f();
private Vector3f positionOffset = new Vector3f();
private TileEntityRenderer<TileEntity> ter = null;
private TileEntity tile;
public GuiBlockRenderBuilder(BlockState blockState) {
this.blockState = blockState;
position = new BlockPos(0, 0, 0);
try {
AirBlockReader airBlockReader = new AirBlockReader(blockState);
tile = blockState.createTileEntity(airBlockReader);
airBlockReader.setTile(tile);
if (tile != null) {
ter = TileEntityRendererDispatcher.instance.getRenderer(tile);
}
} catch (Exception ignored) {
}
}
public GuiBlockRenderBuilder at(BlockPos position) {
if (tile != null) {
tile.setWorldAndPos(Minecraft.getInstance().world, Minecraft.getInstance().player.getPosition());
}
this.position = position;
return this;
}
public GuiBlockRenderBuilder withRotation(Quaternion rotation) {
orderedRotation.add(rotation);
return this;
}
public GuiBlockRenderBuilder withScale(Vector3f scale) {
this.scale = scale;
return this;
}
public GuiBlockRenderBuilder withPrePosition(Vector3f position) {
this.prePosition = position;
return this;
}
public GuiBlockRenderBuilder withOffset(Vector3f offset) {
this.positionOffset = offset;
return this;
}
private void prepareRender() {
// RenderSystem.enableBlend();
// RenderSystem.enableRescaleNormal();
// RenderSystem.enableAlphaTest();
// RenderHelper.setupGui3DDiffuseLighting();
// RenderSystem.alphaFunc(516, 0.1F);
// RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
// RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
}
private void cleanupRender() {
// RenderSystem.disableAlphaTest();
// RenderSystem.disableRescaleNormal();
}
public void finalize(MatrixStack ms) {
prepareRender();
IRenderTypeBuffer.Impl buf = mc.getRenderTypeBuffers().getBufferSource();
BlockRendererDispatcher brd = Minecraft.getInstance().getBlockRendererDispatcher();
ms.push();
transformMatrix(ms);
//brd.renderBlock(blockState, ms, buf, 0xF000F0, OverlayTexture.NO_OVERLAY, EmptyModelData.INSTANCE);
// Copied the code to render block using a model from BlockRenderDispatcher#renderBlock for the case of model.
// Some blocks use ENTITYBLOCK_ANIMATED which is weird and I dont know how it works coz it only ever works on vanilla items,
// and I just dont know what to think about this honestly but this seems to work so I'm not touching it anymore unless something
// else decides to break in which case I will indeed come back to this and figure out a work around then.
IBakedModel model = brd.getModelForState(blockState);
int color = Minecraft.getInstance().getBlockColors().getColor(blockState, null, null, 0);
float r = (float) (color >> 16 & 255) / 255.0F;
float g = (float) (color >> 8 & 255) / 255.0F;
float b = (float) (color & 255) / 255.0F;
brd.getBlockModelRenderer().renderModel(ms.getLast(), buf.getBuffer(RenderTypeLookup.func_239220_a_(blockState, false)), blockState, model, r, g, b, 0xF000F0, OverlayTexture.NO_OVERLAY, EmptyModelData.INSTANCE);
ms.push();
try {
if (ter != null) {
MatrixStack isolatedStack = new MatrixStack();
isolatedStack.push();
isolatedStack.getLast().getMatrix().set(ms.getLast().getMatrix().copy());
isolatedStack.getLast().getNormal().set(ms.getLast().getNormal().copy());
ter.render(tile, 1.f, isolatedStack, buf, 0xF000F0, OverlayTexture.NO_OVERLAY);
}
} catch (Exception ignored) {
}
buf.finish();
ms.pop();
ms.pop();
cleanupRender();
}
private void transformMatrix(MatrixStack ms) {
ms.scale(12, -12, 12);
ms.translate(prePosition.getX(), prePosition.getY(), prePosition.getZ());
for (Quaternion quaternion : orderedRotation) {
ms.rotate(quaternion);
}
ms.scale(scale.getX(), -scale.getY(), scale.getZ());
ms.translate(position.getX() + positionOffset.getX(), position.getY() + positionOffset.getY(), position.getZ() + positionOffset.getZ());
if (tile != null) {
//tile.setPos(new BlockPos(0, 0, 0));
}
}
}

View File

@@ -1,50 +0,0 @@
/*
* MIT License
*
* Copyright (c) 2020 Ridanisaurus
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.ticticboooom.mods.mm.core.mixin;
import com.ticticboooom.mods.mm.MM;
import net.minecraft.resources.ResourcePackInfo;
import net.minecraft.resources.ResourcePackList;
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
import net.minecraftforge.fml.packs.ModFileResourcePack;
import net.minecraftforge.fml.packs.ResourcePackLoader;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
@Mixin(ResourcePackLoader.class)
public class ResourceLoaderMixin {
@Inject(method = "loadResourcePacks(Lnet/minecraft/resources/ResourcePackList;Ljava/util/function/BiFunction;)V", at = @At("RETURN"), remap = false)
private static <T extends ResourcePackInfo> void injectPacks(ResourcePackList resourcePacks, BiFunction<Map<ModFile, ? extends ModFileResourcePack>,
BiConsumer<? super ModFileResourcePack, T>, ResourcePackLoader.IPackInfoFinder> packFinder, CallbackInfo callback) {
MM.injectDatapackFinder(resourcePacks);
}
}

View File

@@ -1,382 +0,0 @@
package com.ticticboooom.mods.mm.data;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.ticticboooom.mods.mm.MM;
import com.ticticboooom.mods.mm.exception.InvalidProcessDefinitionException;
import com.ticticboooom.mods.mm.helper.RLUtils;
import com.ticticboooom.mods.mm.model.ProcessUpdate;
import com.ticticboooom.mods.mm.ports.MasterfulPortType;
import com.ticticboooom.mods.mm.ports.state.PortState;
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
import com.ticticboooom.mods.mm.registration.MMPorts;
import com.ticticboooom.mods.mm.registration.RecipeTypes;
import lombok.Getter;
import lombok.SneakyThrows;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class MachineProcessRecipe implements IRecipe<IInventory> {
@Getter
private final List<PortState> inputs;
@Getter
private final List<PortState> outputs;
@Getter
private int ticks;
@Getter
private String structureId;
private ResourceLocation rl;
private List<Double> inputRolls = new ArrayList<>();
private List<Double> outputRolls = new ArrayList<>();
private Random rand = new Random();
public MachineProcessRecipe(List<PortState> inputs, List<PortState> outputs, int ticks, String structureId, ResourceLocation rl) {
this.inputs = inputs;
this.outputs = outputs;
this.ticks = ticks;
this.structureId = structureId;
this.rl = rl;
}
public boolean matches(List<PortStorage> inputPorts, String structureId, ProcessUpdate update) {
return structureId.equals(this.structureId) && canTake(inputPorts, update.getTakenIndices());
}
private boolean canTake(List<PortStorage> inputPorts, List<Integer> takenIndices) {
int i = -1;
for (PortState input : inputs) {
i++;
if (takenIndices.contains(i)) {
continue;
}
if (!input.isConsumePerTick()) {
if (!input.validateRequirement(inputPorts)) {
return false;
}
}
}
return true;
}
private boolean canPut(List<PortStorage> outputPorts) {
for (PortState output : outputs) {
if (!output.validateResult(outputPorts)) {
return false;
}
}
return true;
}
private void resetChances() {
inputRolls.clear();
outputRolls.clear();
for (PortState input : inputs) {
if (input.supportsPerTick()) {
inputRolls.add(rand.nextDouble());
} else {
inputRolls.add(1.0);
}
}
for (PortState output : outputs) {
if (output.supportsPerTick()) {
outputRolls.add(rand.nextDouble());
} else {
outputRolls.add(1.0);
}
}
}
public ProcessUpdate process(List<PortStorage> inputPorts, List<PortStorage> outputPorts, ProcessUpdate update) {
resetChances();
boolean canTake = canTake(inputPorts, update.getTakenIndices());
boolean canPut = canPut(outputPorts);
if (!canTake || !canPut) {
update.setMsg("Found Structure");
return update;
}
int takenIndex = 0;
if (update.getTicksTaken() <= 0) {
for (PortState input : inputs) {
if (input.isInstantConsume() && input.validateRequirement(inputPorts)) {
update.getTakenIndices().add(takenIndex);
input.processRequirement(inputPorts);
}
takenIndex++;
}
}
int index = 0;
if (update.getTicksTaken() >= ticks) {
update.getTakenIndices().clear();
for (PortState input : inputs) {
if (input.isConsumePerTick() || input.isInstantConsume()) {
continue;
}
if (inputRolls.get(index) < input.getChance()) {
input.processRequirement(inputPorts);
index++;
}
}
index = 0;
for (PortState output : outputs) {
if (output.isConsumePerTick()) {
continue;
}
if (outputRolls.get(index) < output.getChance()) {
output.processResult(outputPorts);
}
}
update.setMsg("");
update.setTicksTaken(0);
update.setTakenIndices(new ArrayList<>());
return update;
}
boolean canTick = true;
index = 0;
for (PortState input : inputs) {
if (input.isConsumePerTick()) {
if (inputRolls.get(index) < input.getChance()) {
if (!input.validateRequirement(inputPorts)) {
canTick = false;
}
}
}
}
index = 0;
for (PortState output : outputs) {
if (outputRolls.get(index) < output.getChance()) {
if (output.isConsumePerTick()) {
if (!output.validateResult(outputPorts)) {
canTick = false;
}
}
}
}
if (canTick) {
for (PortState input : inputs) {
if (inputRolls.get(index) < input.getChance()) {
if (input.isConsumePerTick()) {
input.processRequirement(inputPorts);
}
}
}
for (PortState output : outputs) {
if (outputRolls.get(index) < output.getChance()) {
if (output.isConsumePerTick()) {
output.processResult(outputPorts);
}
}
}
update.setTicksTaken(update.getTicksTaken() + 1);
}
update.setMsg((int) (((float) update.getTicksTaken() / (float) ticks) * 100) + "%");
return update;
}
@Override
public boolean matches(IInventory p_77569_1_, World p_77569_2_) {
return false;
}
@Override
public ItemStack getCraftingResult(IInventory inv) {
return null;
}
@Override
public boolean canFit(int p_194133_1_, int p_194133_2_) {
return false;
}
@Override
public ItemStack getRecipeOutput() {
return ItemStack.EMPTY;
}
@Override
public ResourceLocation getId() {
return rl;
}
@Override
public IRecipeSerializer<?> getSerializer() {
return RecipeTypes.PROCESS.get();
}
@Override
public IRecipeType<?> getType() {
return RecipeTypes.MACHINE_PROCESS;
}
public static final class Serializer implements IRecipeSerializer<MachineProcessRecipe> {
@Override
public MachineProcessRecipe read(ResourceLocation rl, JsonObject obj) {
try {
int ticks = obj.get("ticks").getAsInt();
String structureId = obj.get("structureId").getAsString();
JsonArray inputs = obj.get("inputs").getAsJsonArray();
JsonArray outputs = obj.get("outputs").getAsJsonArray();
List<PortState> inputStates = getStates(inputs);
List<PortState> outputStates = getStates(outputs);
validateProcess(inputStates, outputStates, ticks, structureId, rl);
MM.LOG.debug("Added process '{}' for structure '{}'", rl, structureId);
return new MachineProcessRecipe(inputStates, outputStates, ticks, structureId, rl);
} catch (InvalidProcessDefinitionException e) {
MM.LOG.error("InvalidProcessDefinition: " + e.getMessage());
}
return null;
}
@SneakyThrows
private List<PortState> getStates(JsonArray io) {
List<PortState> ioStates = new ArrayList<>();
for (JsonElement elem : io) {
JsonObject out = elem.getAsJsonObject();
String type = out.get("type").getAsString();
boolean perTick = false;
if (out.has("perTick")) {
perTick = out.get("perTick").getAsBoolean();
} else if (out.has("consumePerTick")) {
perTick = out.get("consumePerTick").getAsBoolean();
}
ResourceLocation typeRl = RLUtils.toRL(type);
if (!MMPorts.PORTS.containsKey(typeRl)) {
throw new Exception(type + " is not a valid input type");
}
double chance = 1;
if (out.has("chance")) {
chance = out.get("chance").getAsDouble();
}
boolean consumeInstantly = false;
if (out.has("consumeInstantly")) {
consumeInstantly = out.get("consumeInstantly").getAsBoolean();
}
MasterfulPortType value = MMPorts.PORTS.get(typeRl);
PortState data = value.getParser().createState(out.get("data").getAsJsonObject());
data.setConsumePerTick(perTick);
data.setChance(chance);
data.setInstantConsume(consumeInstantly);
ioStates.add(data);
}
return ioStates;
}
@Nullable
@Override
public MachineProcessRecipe read(ResourceLocation rl, PacketBuffer buf) {
int inputCount = buf.readInt();
int outputCount = buf.readInt();
int ticks = buf.readInt();
String structureId = buf.readString();
List<PortState> inputs = getStates(buf, inputCount);
List<PortState> outputs = getStates(buf, outputCount);
return new MachineProcessRecipe(inputs, outputs, ticks, structureId, rl);
}
private List<PortState> getStates(PacketBuffer buf, int count) {
List<PortState> result = new ArrayList<>();
for (int i = 0; i < count; i++) {
String inpType = buf.readString();
boolean perTick = buf.readBoolean();
double chance = buf.readDouble();
MasterfulPortType value = MMPorts.PORTS.get(RLUtils.toRL(inpType));
PortState state = value.getParser().createState(buf);
state.setConsumePerTick(perTick);
state.setChance(chance);
result.add(state);
}
return result;
}
@Override
public void write(PacketBuffer buf, MachineProcessRecipe recipe) {
buf.writeInt(recipe.inputs.size());
buf.writeInt(recipe.outputs.size());
buf.writeInt(recipe.ticks);
buf.writeString(recipe.structureId);
writeStates(buf, recipe.inputs);
writeStates(buf, recipe.outputs);
}
private void writeStates(PacketBuffer buf, List<PortState> states) {
for (PortState state : states) {
MasterfulPortType value = MMPorts.PORTS.get(state.getName());
buf.writeString(value.getRegistryName().toString());
buf.writeBoolean(state.isConsumePerTick());
buf.writeDouble(state.getChance());
value.getParser().write(buf, state);
}
}
@Override
public IRecipeSerializer<?> setRegistryName(ResourceLocation name) {
return this;
}
@Override
public ResourceLocation getRegistryName() {
return new ResourceLocation(MM.ID, "machine_process");
}
@Override
public Class<IRecipeSerializer<?>> getRegistryType() {
return RecipeTypes.PROCESS.get().getRegistryType();
}
private void validateProcess(List<PortState> inputs, List<PortState> outputs, int ticks, String structureId, ResourceLocation rl) throws InvalidProcessDefinitionException {
for (PortState input : inputs) {
input.validateDefinition();
commonValidate(input);
}
for (PortState output : outputs) {
output.validateDefinition();
commonValidate(output);
}
}
private void commonValidate(PortState state) throws InvalidProcessDefinitionException {
if (!state.supportsChances() && state.getChance() != 1) {
throw new InvalidProcessDefinitionException("Port Type: " + state.getName() + " does not support chanced operations (chance)");
}
if (state.getChance() < 0 || state.getChance() > 1) {
throw new InvalidProcessDefinitionException("Ingredient chance must be between 0 and 1");
}
if (!state.supportsPerTick() && state.isConsumePerTick()) {
throw new InvalidProcessDefinitionException("Port Type: " + state.getName() + " does not support per tick operations (perTick)");
}
}
}
}

View File

@@ -1,384 +0,0 @@
package com.ticticboooom.mods.mm.data;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.mojang.datafixers.util.Pair;
import com.mojang.serialization.Codec;
import com.mojang.serialization.DataResult;
import com.mojang.serialization.JsonOps;
import com.ticticboooom.mods.mm.MM;
import com.ticticboooom.mods.mm.block.ControllerBlock;
import com.ticticboooom.mods.mm.block.MachinePortBlock;
import com.ticticboooom.mods.mm.block.tile.IMachinePortTile;
import com.ticticboooom.mods.mm.data.model.structure.*;
import com.ticticboooom.mods.mm.exception.InvalidStructureDefinitionException;
import com.ticticboooom.mods.mm.helper.RLUtils;
import com.ticticboooom.mods.mm.registration.MMLoader;
import com.ticticboooom.mods.mm.registration.MMPorts;
import com.ticticboooom.mods.mm.registration.RecipeTypes;
import lombok.Getter;
import lombok.SneakyThrows;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.network.PacketBuffer;
import net.minecraft.state.Property;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ITag;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3i;
import net.minecraft.world.World;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.ForgeRegistries;
import javax.annotation.Nullable;
import java.util.*;
public class MachineStructureRecipe implements IRecipe<IInventory> {
private final ResourceLocation rl;
@Getter
private String name;
@Getter
private List<List<MachineStructureRecipeKeyModel>> models;
@Getter
private final List<String> controllerId;
private String id;
public MachineStructureRecipe(List<MachineStructureRecipeKeyModel> models, List<String> controllerId, String id, ResourceLocation rl, String name) {
this.rl = rl;
this.name = name;
List<MachineStructureRecipeKeyModel> rotated = new ArrayList<>();
List<MachineStructureRecipeKeyModel> rotated1 = new ArrayList<>();
List<MachineStructureRecipeKeyModel> rotated2 = new ArrayList<>();
for (MachineStructureRecipeKeyModel model : models) {
BlockPos rotatedPos = new BlockPos(model.getPos().getX(), model.getPos().getY(), model.getPos().getZ()).rotate(Rotation.CLOCKWISE_90);
BlockPos rotatedPos1 = new BlockPos(model.getPos().getX(), model.getPos().getY(), model.getPos().getZ()).rotate(Rotation.CLOCKWISE_180);
BlockPos rotatedPos2 = new BlockPos(model.getPos().getX(), model.getPos().getY(), model.getPos().getZ()).rotate(Rotation.COUNTERCLOCKWISE_90);
rotated.add(new MachineStructureRecipeKeyModel(new MachineStructureBlockPos(rotatedPos.getX(), rotatedPos.getY(), rotatedPos.getZ()), model.getTag(), model.getBlock(), model.getProperties(), model.getPort()));
rotated1.add(new MachineStructureRecipeKeyModel(new MachineStructureBlockPos(rotatedPos1.getX(), rotatedPos1.getY(), rotatedPos1.getZ()), model.getTag(), model.getBlock(), model.getProperties(), model.getPort()));
rotated2.add(new MachineStructureRecipeKeyModel(new MachineStructureBlockPos(rotatedPos2.getX(), rotatedPos2.getY(), rotatedPos2.getZ()), model.getTag(), model.getBlock(), model.getProperties(), model.getPort()));
}
this.models = new ArrayList<>();
this.models.add(models);
this.models.add(rotated);
this.models.add(rotated1);
this.models.add(rotated2);
this.controllerId = controllerId;
this.id = id;
}
@Override
public boolean matches(IInventory p_77569_1_, World p_77569_2_) {
return false;
}
@Override
public ItemStack getCraftingResult(IInventory p_77572_1_) {
return null;
}
@Override
public boolean canFit(int p_194133_1_, int p_194133_2_) {
return false;
}
public int matches(BlockPos controllerPos, World world, String controllerId) {
if (!this.controllerId.contains(controllerId)) {
return -1;
}
int index = 0;
for (List<MachineStructureRecipeKeyModel> model : models) {
if (matchesWithRotation(controllerPos, world, model)) {
return index;
}
index++;
}
return -1;
}
public boolean matchesWithRotation(BlockPos controllerPos, World world, List<MachineStructureRecipeKeyModel> items) {
for (MachineStructureRecipeKeyModel model : items) {
if (!innerBlockMatch(controllerPos, world, model)) {
return false;
}
}
return true;
}
public boolean innerBlockMatch(BlockPos controllerPos, World world, MachineStructureRecipeKeyModel model) {
BlockPos pos = controllerPos.add(model.getPos().getX(), model.getPos().getY(), model.getPos().getZ());
BlockState blockState = world.getBlockState(pos);
boolean valid = false;
if (!model.getTag().equals("")) {
String[] split = model.getTag().split(":");
if (split.length != 2) {
MM.LOG.fatal("too many : (colons) in structure tag: {}", model.getTag());
return false;
}
ITag<Block> tag = BlockTags.getCollection().get(new ResourceLocation(split[0], split[1]));
if (tag == null) {
MM.LOG.fatal("no existing block tag for structure tag: {}", model.getTag());
return false;
}
valid = tag.contains(blockState.getBlock());
} else if (!model.getBlock().equals("")) {
valid = blockState.getBlock().getRegistryName().toString().equals(model.getBlock());
} else if (model.getPort() != null) {
MachineStructurePort structurePort = model.getPort();
TileEntity portBlockEntity = world.getTileEntity(pos);
if (portBlockEntity instanceof IMachinePortTile && blockState.getBlock() instanceof MachinePortBlock) {
IMachinePortTile portTile = (IMachinePortTile) portBlockEntity;
MachinePortBlock portBlock = ((MachinePortBlock) blockState.getBlock());
if (portTile.isInput() == structurePort.isInput() &&
portBlock.getPortTypeId().equals(RLUtils.toRL(structurePort.getType()))) {
List<String> controllerIds = structurePort.getControllerId() != null ? structurePort.getControllerId() : this.controllerId;
valid = controllerIds.contains(portBlock.getControllerId());
}
}
}
if (!valid) {
return false;
}
if (model.getProperties() == null) {
return true;
}
for (Map.Entry<String, String> stringStringEntry : model.getProperties().entrySet()) {
for (Map.Entry<Property<?>, Comparable<?>> propertyEntry : blockState.getValues().entrySet()) {
if (propertyEntry.getKey().getName().equals(stringStringEntry.getKey())) {
Optional<?> o = propertyEntry.getKey().parseValue(stringStringEntry.getValue());
return propertyEntry.getValue().equals(o.get());
}
}
}
return false;
}
public ArrayList<BlockPos> getPorts(BlockPos controllerPos, World world, int index) {
ArrayList<BlockPos> result = new ArrayList<>();
for (MachineStructureRecipeKeyModel model : models.get(index)) {
BlockPos pos = controllerPos.add(model.getPos().toVector());
BlockState state = world.getBlockState(pos);
if (state.getBlock() instanceof MachinePortBlock) {
result.add(pos);
}
}
return result;
}
public String getStructureId() {
return id;
}
@Override
public ItemStack getRecipeOutput() {
return ItemStack.EMPTY;
}
@Override
public ResourceLocation getId() {
return rl;
}
@Override
public IRecipeSerializer<?> getSerializer() {
return RecipeTypes.STRUCTURE.get();
}
@Override
public IRecipeType<?> getType() {
return RecipeTypes.MACHINE_STRUCTURE;
}
public static final class Serializer implements IRecipeSerializer<MachineStructureRecipe> {
@Override
public MachineStructureRecipe read(ResourceLocation rl, JsonObject obj) {
try {
JsonElement controllerIdJson = obj.get("controllerId");
List<String> ids = new ArrayList<>();
if (controllerIdJson.isJsonPrimitive()) {
ids.add(controllerIdJson.getAsString());
} else {
for (JsonElement jsonElement : controllerIdJson.getAsJsonArray()) {
ids.add(jsonElement.getAsString());
}
}
String id = obj.get("id").getAsString();
String name = "";
if (obj.has("name")) {
name = obj.get("name").getAsString();
} else {
name = id;
}
DataResult<Pair<List<List<String>>, JsonElement>> apply = JsonOps.INSTANCE.withDecoder(Codec.list(Codec.list(Codec.STRING))).apply(obj.getAsJsonArray("layout"));
List<List<String>> layout = apply.result().get().getFirst();
List<MachineStructureRecipeKeyModel> result = getResult(obj.getAsJsonObject("legend"), layout);
validateStructure(result, ids, id, rl);
MM.LOG.debug("Added structure '{}' with id '{}'", rl, id);
return new MachineStructureRecipe(result, ids, id, rl, name);
} catch (InvalidStructureDefinitionException e) {
MM.LOG.error("InvalidStructureDefinition: " + e.getMessage());
}
return null;
}
private List<MachineStructureRecipeKeyModel> getResult(JsonObject legend, List<List<String>> layout) throws InvalidStructureDefinitionException {
HashMap<Character, MachineStructureRecipeLegendModel> model = new HashMap<>();
for (Map.Entry<String, JsonElement> entry : legend.entrySet()) {
DataResult<Pair<MachineStructureRecipeLegendModel, JsonElement>> apply = JsonOps.INSTANCE.withDecoder(MachineStructureRecipeLegendModel.CODEC).apply(entry.getValue());
MachineStructureRecipeLegendModel first = apply.result().get().getFirst();
model.put(entry.getKey().charAt(0), first);
}
ArrayList<MachineStructureRecipeKeyModel> result = new ArrayList<>();
Vector3i controllerPos = getControllerPos(layout);
int y = 0;
int z = 0;
for (List<String> layer : layout) {
for (String row : layer) {
for (int x = 0; x < row.length(); x++) {
char c = row.charAt(x);
if (c == 'C') {
continue;
}
if (c == ' ') {
continue;
}
MachineStructureRecipeLegendModel machineStructureRecipeLegendModel = model.get(c);
BlockPos pos = new BlockPos(x, y, z).subtract(new BlockPos(controllerPos));
result.add(new MachineStructureRecipeKeyModel(new MachineStructureBlockPos(pos.getX(), pos.getY(), pos.getZ()), machineStructureRecipeLegendModel.getTag(), machineStructureRecipeLegendModel.getBlock(), machineStructureRecipeLegendModel.getProperties(), machineStructureRecipeLegendModel.getPort()));
}
z++;
}
y++;
z = 0;
}
return result;
}
private Vector3i getControllerPos(List<List<String>> layout) throws InvalidStructureDefinitionException {
int y = 0;
int z = 0;
for (List<String> layer : layout) {
for (String row : layer) {
for (int x = 0; x < row.length(); x++) {
if (row.charAt(x) == 'C') {
return new Vector3i(x, y, z);
}
}
z++;
}
y++;
z = 0;
}
throw new InvalidStructureDefinitionException("'C' AKA controller not found in layout section");
}
@SneakyThrows
@Nullable
@Override
public MachineStructureRecipe read(ResourceLocation rl, PacketBuffer buf) {
List<String> controllerId = new ArrayList<>();
int idCount = buf.readInt();
for (int i = 0; i < idCount; i++) {
controllerId.add(buf.readString());
}
String id = buf.readString();
String name = buf.readString();
try {
MachineStructureObject machineStructureObject = buf.func_240628_a_(MachineStructureObject.CODEC);
List<MachineStructureRecipeKeyModel> models = machineStructureObject.getInner();
return new MachineStructureRecipe(models, controllerId, id, rl, name);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
public void write(PacketBuffer buf, MachineStructureRecipe recipe) {
buf.writeInt(recipe.controllerId.size());
for (String s : recipe.controllerId) {
buf.writeString(s);
}
buf.writeString(recipe.id);
buf.writeString(recipe.name);
try {
buf.func_240629_a_(MachineStructureObject.CODEC, new MachineStructureObject(recipe.getModels().get(0)));
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public IRecipeSerializer<?> setRegistryName(ResourceLocation name) {
return this;
}
@Override
public ResourceLocation getRegistryName() {
return new ResourceLocation(MM.ID, "machine_structure");
}
@Override
public Class<IRecipeSerializer<?>> getRegistryType() {
return RecipeTypes.STRUCTURE.get().getRegistryType();
}
private void validateStructure(List<MachineStructureRecipeKeyModel> models, List<String> controllerId, String id, ResourceLocation rl) throws InvalidStructureDefinitionException {
for (MachineStructureRecipeKeyModel model : models) {
if (!model.getBlock().equals("")) {
if (RLUtils.isRL(model.getBlock())) {
if (!ForgeRegistries.BLOCKS.containsKey(RLUtils.toRL(model.getBlock()))) {
throw new InvalidStructureDefinitionException("Block: " + model.getBlock() + " is not an existing block in the game");
}
} else {
throw new InvalidStructureDefinitionException("Block: " + model.getBlock() + " is defined but not a valid block id (ResourceLocation)");
}
} else if (!model.getTag().equals("")) {
if (!RLUtils.isRL(model.getTag())) {
throw new InvalidStructureDefinitionException("Block Tag: " + model.getBlock() + " is defined but not a valid block tag id (ResourceLocation)");
}
} else if (model.getPort() != null) {
if (!MMPorts.PORTS.containsKey(RLUtils.toRL(model.getPort().getType()))) {
throw new InvalidStructureDefinitionException("Port: " + model.getPort() + " is defined but not a valid port type id (ResourceLocation)");
} else if (!controllerId.containsAll(model.getPort().getControllerId())) {
throw new InvalidStructureDefinitionException("Port: " + model.getPort() + " is defined but not a valid port controller id specified (ResourceLocation)");
}
} else {
throw new InvalidStructureDefinitionException("You must define at least 1 'block' or 'tag' per port within the 'data' object");
}
}
for (String s : controllerId) {
boolean controllerIdFound = false;
for (RegistryObject<ControllerBlock> block : MMLoader.BLOCKS) {
controllerIdFound = block.get().getControllerId().equals(s) || controllerIdFound;
}
if (!controllerIdFound) {
throw new InvalidStructureDefinitionException("controllerId: " + s + " does not exist");
}
}
}
}
}

View File

@@ -1,49 +0,0 @@
package com.ticticboooom.mods.mm.data.model.structure;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import net.minecraft.util.math.vector.Vector3i;
import java.util.Objects;
@Getter
@AllArgsConstructor
public class MachineStructureBlockPos implements Comparable<MachineStructureBlockPos> {
public static final Codec<MachineStructureBlockPos> CODEC = RecordCodecBuilder.create(x -> x.group(
Codec.INT.fieldOf("x").forGetter(z -> z.x),
Codec.INT.fieldOf("y").forGetter(z -> z.y),
Codec.INT.fieldOf("z").forGetter(z -> z.z)
).apply(x, MachineStructureBlockPos::new));
private final int x;
private final int y;
private final int z;
@Override
public int compareTo(MachineStructureBlockPos other) {
return toVector().compareTo(other.toVector());
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
MachineStructureBlockPos that = (MachineStructureBlockPos) o;
return toVector().equals(that.toVector());
}
@Override
public int hashCode() {
return toVector().hashCode();
}
public Vector3i toVector(){
return new Vector3i(this.x, this.y, this.z);
}
}

View File

@@ -1,18 +0,0 @@
package com.ticticboooom.mods.mm.data.model.structure;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.List;
@Getter
@AllArgsConstructor
public class MachineStructureObject {
public static final Codec<MachineStructureObject> CODEC = RecordCodecBuilder.create(x -> x.group(
Codec.list(MachineStructureRecipeKeyModel.CODEC).fieldOf("object").forGetter(z -> z.inner)
).apply(x, MachineStructureObject::new));
private final List<MachineStructureRecipeKeyModel> inner;
}

View File

@@ -1,31 +0,0 @@
package com.ticticboooom.mods.mm.data.model.structure;
import com.mojang.datafixers.util.Either;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
@ToString
@Getter
@AllArgsConstructor
public class MachineStructurePort {
public static final Codec<MachineStructurePort> CODEC = RecordCodecBuilder.create(x -> x.group(
Codec.STRING.fieldOf("type").forGetter(z -> z.type),
Codec.BOOL.fieldOf("input").forGetter(z -> z.input),
Codec.either(Codec.STRING, Codec.list(Codec.STRING)).xmap(
either -> either.map(Collections::singletonList, Function.identity()),
ids -> ids.size() == 1 ? Either.left(ids.get(0)) : Either.right(ids)
).optionalFieldOf("controllerId").forGetter(z -> Optional.ofNullable(z.controllerId))
).apply(x, (w, y, z) -> new MachineStructurePort(w, y, z.orElse(null))));
private final String type;
private final boolean input;
private final List<String> controllerId;
}

View File

@@ -1,27 +0,0 @@
package com.ticticboooom.mods.mm.data.model.structure;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Map;
import java.util.Optional;
@Getter
@AllArgsConstructor
public class MachineStructureRecipeKeyModel {
public static final Codec<MachineStructureRecipeKeyModel> CODEC = RecordCodecBuilder.create(x -> x.group(
MachineStructureBlockPos.CODEC.fieldOf("pos").forGetter(z -> z.pos),
Codec.STRING.optionalFieldOf("tag").forGetter(z -> Optional.of(z.tag)),
Codec.STRING.optionalFieldOf("block").forGetter(z -> Optional.of(z.block)),
Codec.unboundedMap(Codec.STRING, Codec.STRING).optionalFieldOf("nbt").forGetter(z -> Optional.ofNullable(z.properties)),
MachineStructurePort.CODEC.optionalFieldOf("port").forGetter(z -> Optional.ofNullable(z.port))
).apply(x, (w0, w, y, z, z0) -> new MachineStructureRecipeKeyModel(w0, w.orElse(""), y.orElse(""), z.orElse(null), z0.orElse(null))));
private MachineStructureBlockPos pos;
private final String tag;
private final String block;
private final Map<String, String> properties;
private final MachineStructurePort port;
}

View File

@@ -1,26 +0,0 @@
package com.ticticboooom.mods.mm.data.model.structure;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import java.util.Map;
import java.util.Optional;
@Getter
@AllArgsConstructor
public class MachineStructureRecipeLegendModel {
public static final Codec<MachineStructureRecipeLegendModel> CODEC = RecordCodecBuilder.create(x -> x.group(
Codec.STRING.optionalFieldOf("tag").forGetter(z -> Optional.of(z.tag)),
Codec.STRING.optionalFieldOf("block").forGetter(z -> Optional.of(z.block)),
Codec.unboundedMap(Codec.STRING, Codec.STRING).optionalFieldOf("props").forGetter(z -> Optional.ofNullable(z.properties)),
MachineStructurePort.CODEC.optionalFieldOf("port").forGetter(z -> Optional.ofNullable(z.port))
).apply(x, (w, y, z, z0) -> new MachineStructureRecipeLegendModel(w.orElse(""), y.orElse(""), z.orElse(null), z0.orElse(null))));
private final String tag;
private final String block;
@Setter
private Map<String, String> properties;
private final MachineStructurePort port;
}

View File

@@ -1,36 +0,0 @@
package com.ticticboooom.mods.mm.data.model.structure;
import net.minecraft.tags.ITag;
import net.minecraft.util.ResourceLocation;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class MockedNamedTag<T> implements ITag.INamedTag<T> {
private final ResourceLocation name;
public MockedNamedTag(ResourceLocation name) {
this.name = name;
}
@Override
public ResourceLocation getName() {
return name;
}
@Override
public boolean contains(T element) {
return false;
}
@Override
public List<T> getAllElements() {
return new ArrayList<>();
}
@Override
public T getRandomElement(Random random) {
return INamedTag.super.getRandomElement(random);
}
}

View File

@@ -1,44 +0,0 @@
/*
* MIT License
*
* Copyright (c) 2020 Ridanisaurus
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.ticticboooom.mods.mm.datagen;
import com.google.common.collect.ImmutableList;
import net.minecraft.data.DataGenerator;
import net.minecraftforge.fml.loading.FMLPaths;
import java.nio.file.Path;
public class DataGeneratorFactory {
public static Path ROOT_PATH;
public static void init() {
ROOT_PATH = FMLPaths.CONFIGDIR.get().resolve("masterful_machinery/packs");
}
public static DataGenerator createMemoryDataGenerator() {
return new DataGenerator(ROOT_PATH, ImmutableList.of());
}
}

View File

@@ -1,126 +0,0 @@
package com.ticticboooom.mods.mm.datagen;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.ticticboooom.mods.mm.MM;
import net.minecraft.resources.IResourcePack;
import net.minecraft.resources.ResourcePackType;
import net.minecraft.resources.data.IMetadataSectionSerializer;
import net.minecraft.util.JSONUtils;
import net.minecraft.util.ResourceLocation;
import javax.annotation.Nullable;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class InMemoryPack implements IResourcePack {
private final Path path;
public InMemoryPack(Path path) {
MM.generate();
this.path = path;
}
private static String getFullPath(ResourcePackType type, ResourceLocation location) {
return String.format("%s/%s/%s", type.getDirectoryName(), location.getNamespace(), location.getPath());
}
@Override
public InputStream getRootResourceStream(String fileName) throws IOException {
Path resolved = path.resolve(fileName);
return Files.newInputStream(resolved);
}
@Override
public InputStream getResourceStream(ResourcePackType type, ResourceLocation location) throws IOException {
Path resolved = path.resolve(getFullPath(type, location));
if (!Files.exists(resolved)){
throw new IOException("Resource does not exist");
}
return Files.newInputStream(resolved);
}
@Override
public Collection<ResourceLocation> getAllResourceLocations(ResourcePackType type, String namespaceIn, String pathIn, int maxDepthIn, Predicate<String> filterIn) {
List<ResourceLocation> result = new ArrayList<>();
getChildResourceLocations(result, 0, maxDepthIn, filterIn, path.resolve(type.getDirectoryName() + "/" + namespaceIn + "/" + pathIn), namespaceIn, pathIn);
return result;
}
private void getChildResourceLocations(List<ResourceLocation> result, int depth, int maxDepth, Predicate<String> filter, Path current, String currentRLNS, String currentRLPath) {
if (depth >= maxDepth) {
return;
}
try {
if (!Files.exists(current) || !Files.isDirectory(current)){
return;
}
Stream<Path> list = Files.list(current);
for (Path child : list.collect(Collectors.toList())) {
if (!Files.isDirectory(child)) {
result.add(new ResourceLocation(currentRLNS, currentRLPath + "/" + child.getFileName()));
continue;
}
getChildResourceLocations(result, depth + 1, maxDepth, filter, child, currentRLNS, currentRLPath + "/" + child.getFileName());
}
} catch (IOException ignored) {
ignored.printStackTrace();
}
}
@Override
public boolean resourceExists(ResourcePackType type, ResourceLocation location) {
Path finalPath = path.resolve(type.getDirectoryName() + "/" + location.getNamespace() + "/" + location.getPath());
return Files.exists(finalPath);
}
@Override
public Set<String> getResourceNamespaces(ResourcePackType type) {
Set<String> result = new HashSet<>();
try {
Stream<Path> list = Files.list(path.resolve(type.getDirectoryName()));
for (Path resultingPath : list.collect(Collectors.toList())) {
result.add(resultingPath.getFileName().toString());
}
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
public <T> T getMetadata(IMetadataSectionSerializer<T> deserializer) throws IOException {
JsonObject jsonobject = new JsonObject();
JsonObject packObject = new JsonObject();
packObject.addProperty("pack_format", 6);
packObject.addProperty("description", "masterfulmachinery");
jsonobject.add("pack", packObject);
if (!jsonobject.has(deserializer.getSectionName())) {
return null;
} else {
try {
return deserializer.deserialize(JSONUtils.getJsonObject(jsonobject, deserializer.getSectionName()));
} catch (JsonParseException jsonparseexception) {
return null;
}
}
}
@Override
public String getName() {
return "MM Memory Pack";
}
@Override
public void close() {
}
}

View File

@@ -1,55 +0,0 @@
/*
* MIT License
*
* Copyright (c) 2020 Ridanisaurus
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.ticticboooom.mods.mm.datagen;
import net.minecraft.resources.IPackFinder;
import net.minecraft.resources.IPackNameDecorator;
import net.minecraft.resources.ResourcePackInfo;
import java.nio.file.Path;
import java.util.function.Consumer;
public class MMPackFinder implements IPackFinder {
private final PackType type;
public MMPackFinder(PackType type) {
this.type = type;
}
@Override
public void findPacks(Consumer<ResourcePackInfo> infoConsumer, ResourcePackInfo.IFactory infoFactory) {
Path rootPath = DataGeneratorFactory.ROOT_PATH;
ResourcePackInfo pack = ResourcePackInfo.createResourcePack("mm_" + type.getSuffix(), true,
() -> new InMemoryPack(rootPath), infoFactory, ResourcePackInfo.Priority.BOTTOM, IPackNameDecorator.PLAIN);
if (pack != null) {
infoConsumer.accept(pack);
}
}
}

View File

@@ -1,30 +0,0 @@
package com.ticticboooom.mods.mm.datagen;
import net.minecraft.tags.ITag;
import net.minecraft.util.ResourceLocation;
import java.util.ArrayList;
import java.util.List;
public class MockedNamedTag<T> implements ITag.INamedTag<T> {
private final ResourceLocation name;
public MockedNamedTag(ResourceLocation name) {
this.name = name;
}
@Override
public ResourceLocation getName() {
return name;
}
@Override
public boolean contains(T element) {
return false;
}
@Override
public List<T> getAllElements() {
return new ArrayList<>();
}
}

View File

@@ -1,17 +0,0 @@
package com.ticticboooom.mods.mm.datagen;
public enum PackType {
DATA("data"),
RESOURCE("resource")
;
private final String suffix;
PackType(String suffix) {
this.suffix = suffix;
}
public String getSuffix() {
return suffix;
}
}

View File

@@ -1,141 +0,0 @@
/*
* MIT License
*
* Copyright (c) 2020 Ridanisaurus
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.ticticboooom.mods.mm.datagen.gen.runtime;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.ticticboooom.mods.mm.MM;
import net.minecraft.advancements.criterion.EnchantmentPredicate;
import net.minecraft.advancements.criterion.ItemPredicate;
import net.minecraft.advancements.criterion.MinMaxBounds;
import net.minecraft.block.Block;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.DirectoryCache;
import net.minecraft.data.IDataProvider;
import net.minecraft.data.LootTableProvider;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.item.Item;
import net.minecraft.loot.*;
import net.minecraft.loot.conditions.MatchTool;
import net.minecraft.loot.conditions.SurvivesExplosion;
import net.minecraft.loot.functions.ApplyBonus;
import net.minecraft.loot.functions.ExplosionDecay;
import net.minecraft.loot.functions.SetCount;
import net.minecraft.util.IItemProvider;
import net.minecraft.util.ResourceLocation;
import java.io.IOException;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
public abstract class BaseLootTableProvider extends LootTableProvider {
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
// Filled by subclasses
protected final Map<Block, LootTable.Builder> blockLootTable = new HashMap<>();
protected final Map<Item, LootTable.Builder> itemLootTable = new HashMap<>();
private final DataGenerator generator;
public BaseLootTableProvider(DataGenerator dataGeneratorIn) {
super(dataGeneratorIn);
this.generator = dataGeneratorIn;
}
@Override
// Entry point
public void act(DirectoryCache cache) {
this.addTables();
Map<ResourceLocation, LootTable> tables = new HashMap<>();
for (Map.Entry<Block, LootTable.Builder> entry : this.blockLootTable.entrySet()) {
tables.put(entry.getKey().getLootTable(),
entry.getValue().setParameterSet(LootParameterSets.BLOCK).build());
}
this.writeTables(cache, tables);
}
@Override
public String getName() {
return "MM LootTables";
}
// Subclasses can override this to fill the 'lootTables' map.
protected abstract void addTables();
protected LootTable.Builder createBlockLootTable(Block block) {
LootPool.Builder builder = LootPool.builder()
.rolls(ConstantRange.of(1))
.addEntry(ItemLootEntry.builder(block))
.acceptCondition(SurvivesExplosion.builder());
return LootTable.builder().addLootPool(builder);
}
protected LootTable.Builder createItemLootTable(Item item) {
LootPool.Builder builder = LootPool.builder()
.rolls(ConstantRange.of(1))
.addEntry(ItemLootEntry.builder(item))
.acceptCondition(SurvivesExplosion.builder());
return LootTable.builder().addLootPool(builder);
}
protected LootTable.Builder createSpecialTable(Item item, IItemProvider itemProvider) {
LootPool.Builder builder = LootPool.builder()
.rolls(ConstantRange.of(1))
.addEntry(ItemLootEntry.builder(item)
.acceptCondition(MatchTool.builder(ItemPredicate.Builder.create().enchantment(new EnchantmentPredicate(Enchantments.SILK_TOUCH, MinMaxBounds.IntBound.atLeast(1)))))
.alternatively(ItemLootEntry.builder(itemProvider)
.acceptFunction(ApplyBonus.oreDrops(Enchantments.FORTUNE))
.acceptFunction(ExplosionDecay.builder())));
return LootTable.builder().addLootPool(builder);
}
protected LootTable.Builder createCountTable(Item item, IItemProvider itemProvider, float minCount, float maxCount) {
LootPool.Builder builder = LootPool.builder()
.rolls(ConstantRange.of(1))
.addEntry(ItemLootEntry.builder(item)
.acceptCondition(MatchTool.builder(ItemPredicate.Builder.create().enchantment(new EnchantmentPredicate(Enchantments.SILK_TOUCH, MinMaxBounds.IntBound.atLeast(1)))))
.alternatively(ItemLootEntry.builder(itemProvider)
.acceptFunction(SetCount.builder(RandomValueRange.of(minCount, maxCount)))
.acceptFunction(ApplyBonus.oreDrops(Enchantments.FORTUNE))
.acceptFunction(ExplosionDecay.builder())));
return LootTable.builder().addLootPool(builder);
}
// Actually write out the tables in the output folder
private void writeTables(DirectoryCache cache, Map<ResourceLocation, LootTable> tables) {
Path outputFolder = this.generator.getOutputFolder();
tables.forEach((key, lootTable) -> {
Path path = outputFolder.resolve("data/" + key.getNamespace() + "/loot_tables/" + key.getPath() + ".json");
try {
IDataProvider.save(GSON, cache, LootTableManager.toJson(lootTable), path);
} catch (IOException e) {
MM.LOG.error("Couldn't write loot table {}", path, e);
}
});
}
}

View File

@@ -1,149 +0,0 @@
package com.ticticboooom.mods.mm.datagen.gen.runtime;
import com.ticticboooom.mods.mm.MM;
import com.ticticboooom.mods.mm.block.ControllerBlock;
import com.ticticboooom.mods.mm.block.MachinePortBlock;
import com.ticticboooom.mods.mm.helper.RLUtils;
import com.ticticboooom.mods.mm.ports.MasterfulPortType;
import com.ticticboooom.mods.mm.registration.MMLoader;
import com.ticticboooom.mods.mm.registration.MMPorts;
import com.ticticboooom.mods.mm.registration.MMSetup;
import net.minecraft.block.Block;
import net.minecraft.block.DirectionalBlock;
import net.minecraft.block.HorizontalBlock;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.data.DataGenerator;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.generators.BlockStateProvider;
import net.minecraftforge.client.model.generators.ModelBuilder;
import net.minecraftforge.client.model.generators.ModelFile;
import net.minecraftforge.client.model.generators.VariantBlockStateBuilder;
import net.minecraftforge.client.model.generators.loaders.MultiLayerModelBuilder;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.fml.RegistryObject;
public class MMBlockStateProvider extends BlockStateProvider {
public MMBlockStateProvider(DataGenerator gen, ExistingFileHelper exFileHelper) {
super(gen, MM.ID, exFileHelper);
}
public static final ResourceLocation BASE_TEXTURE = new ResourceLocation(MM.ID, "block/base_block");
private static final ResourceLocation CONTROLLER_TEXTURE = new ResourceLocation(MM.ID, "block/controller_cutout");
@Override
protected void registerStatesAndModels() {
for (RegistryObject<ControllerBlock> controller : MMLoader.BLOCKS) {
if (!controller.isPresent()) {
return;
}
dynamicBlockNorthOverlay(controller.getId(), controller.get().getTexOverride() != null ? RLUtils.toRL(controller.get().getTexOverride()) : BASE_TEXTURE, CONTROLLER_TEXTURE);
VariantBlockStateBuilder variantBuilder = getVariantBuilder(controller.get());
variantBuilder.partialState().with(DirectionalBlock.FACING, Direction.NORTH).modelForState().modelFile(new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/" + controller.getId().getPath()))).rotationY(0).addModel();
variantBuilder.partialState().with(DirectionalBlock.FACING, Direction.SOUTH).modelForState().modelFile(new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/" + controller.getId().getPath()))).rotationY(180).addModel();
variantBuilder.partialState().with(DirectionalBlock.FACING, Direction.EAST).modelForState().modelFile(new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/" + controller.getId().getPath()))).rotationY(90).addModel();
variantBuilder.partialState().with(DirectionalBlock.FACING, Direction.WEST).modelForState().modelFile(new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/" + controller.getId().getPath()))).rotationY(270).addModel();
variantBuilder.partialState().with(DirectionalBlock.FACING, Direction.UP).modelForState().modelFile(new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/" + controller.getId().getPath()))).rotationY(0).addModel();
variantBuilder.partialState().with(DirectionalBlock.FACING, Direction.DOWN).modelForState().modelFile(new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/" + controller.getId().getPath()))).rotationY(0).addModel();
}
for (RegistryObject<MachinePortBlock> port : MMLoader.IPORT_BLOCKS) {
MasterfulPortType masterfulPortType = MMPorts.PORTS.get(port.get().getPortTypeId());
masterfulPortType.getParser().generateBlockStates(this, true, port);
}
for (RegistryObject<MachinePortBlock> port : MMLoader.OPORT_BLOCKS) {
MasterfulPortType masterfulPortType = MMPorts.PORTS.get(port.get().getPortTypeId());
masterfulPortType.getParser().generateBlockStates(this, false, port);
}
directionalState(MMSetup.PROJECTOR_BLOCK.get());
directionalState(MMSetup.STRUCTURE_BLOCK.get());
}
public void dynamicBlockNorthOverlay(ResourceLocation loc, ResourceLocation baseTexture, ResourceLocation overlayTexture) {
models().getBuilder(loc.toString()).parent(new ModelFile.UncheckedModelFile(mcLoc("block/block")))
.texture("particle", overlayTexture)
.transforms()
.transform(ModelBuilder.Perspective.THIRDPERSON_LEFT)
.rotation(75F, 45F, 0F)
.translation(0F, 2.5F, 0)
.scale(0.375F, 0.375F, 0.375F)
.end()
.transform(ModelBuilder.Perspective.THIRDPERSON_RIGHT)
.rotation(75F, 45F, 0F)
.translation(0F, 2.5F, 0)
.scale(0.375F, 0.375F, 0.375F)
.end()
.end()
.customLoader(MultiLayerModelBuilder::begin)
.submodel(RenderType.getSolid(), this.models().nested().parent(new ModelFile.UncheckedModelFile(mcLoc("block/block")))
.texture("base", baseTexture)
.element()
.from(0, 0, 0)
.to(16, 16, 16)
.cube("#base")
//.allFaces((dir, uv) -> uv.uvs(0F,0.0F, 16F,16F))
.end()
)
.submodel(RenderType.getTranslucent(), this.models().nested().parent(new ModelFile.UncheckedModelFile(mcLoc("block/block")))
.texture("overlay", overlayTexture)
.element()
.from(0, 0, 0)
.to(16, 16, 16)
.face(Direction.NORTH)
.texture("#overlay")
//.allFaces((dir, uv) -> uv.uvs(0F,0F, 16F,16F))
.end()
.end()
)
.end();
}
public void dynamicBlock(ResourceLocation loc, ResourceLocation baseTexture, ResourceLocation overlayTexture) {
models().getBuilder(loc.toString()).parent(new ModelFile.UncheckedModelFile(mcLoc("block/block")))
.texture("particle", overlayTexture)
.transforms()
.transform(ModelBuilder.Perspective.THIRDPERSON_LEFT)
.rotation(75F, 45F, 0F)
.translation(0F, 2.5F, 0)
.scale(0.375F, 0.375F, 0.375F)
.end()
.transform(ModelBuilder.Perspective.THIRDPERSON_RIGHT)
.rotation(75F, 45F, 0F)
.translation(0F, 2.5F, 0)
.scale(0.375F, 0.375F, 0.375F)
.end()
.end()
.customLoader(MultiLayerModelBuilder::begin)
.submodel(RenderType.getSolid(), this.models().nested().parent(new ModelFile.UncheckedModelFile(mcLoc("block/block")))
.texture("base", baseTexture)
.element()
.from(0, 0, 0)
.to(16, 16, 16)
.cube("#base")
//.allFaces((dir, uv) -> uv.uvs(0F,0.0F, 16F,16F))
.end()
)
.submodel(RenderType.getTranslucent(), this.models().nested().parent(new ModelFile.UncheckedModelFile(mcLoc("block/block")))
.texture("overlay", overlayTexture)
.element()
.from(0, 0, 0)
.to(16, 16, 16)
.allFaces((dir, uv) -> uv.texture("#overlay"))
.end()
)
.end();
}
private void directionalState(Block block) {
VariantBlockStateBuilder variantBuilder = getVariantBuilder(block);
variantBuilder.partialState().with(HorizontalBlock.HORIZONTAL_FACING, Direction.NORTH).modelForState().modelFile(new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/" + block.getRegistryName().getPath()))).rotationY(0).addModel();
variantBuilder.partialState().with(HorizontalBlock.HORIZONTAL_FACING, Direction.SOUTH).modelForState().modelFile(new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/" + block.getRegistryName().getPath()))).rotationY(180).addModel();
variantBuilder.partialState().with(HorizontalBlock.HORIZONTAL_FACING, Direction.EAST).modelForState().modelFile(new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/" + block.getRegistryName().getPath()))).rotationY(90).addModel();
variantBuilder.partialState().with(HorizontalBlock.HORIZONTAL_FACING, Direction.WEST).modelForState().modelFile(new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/" + block.getRegistryName().getPath()))).rotationY(270).addModel();
}
}

View File

@@ -1,43 +0,0 @@
package com.ticticboooom.mods.mm.datagen.gen.runtime;
import com.ticticboooom.mods.mm.MM;
import com.ticticboooom.mods.mm.block.ControllerBlock;
import com.ticticboooom.mods.mm.block.MachinePortBlock;
import com.ticticboooom.mods.mm.helper.RLUtils;
import com.ticticboooom.mods.mm.registration.MMLoader;
import com.ticticboooom.mods.mm.registration.MMSetup;
import net.minecraft.data.DataGenerator;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.generators.ItemModelProvider;
import net.minecraftforge.client.model.generators.ModelFile;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.fml.RegistryObject;
public class MMItemModelProvider extends ItemModelProvider {
public MMItemModelProvider(DataGenerator gen, ExistingFileHelper exFileHelper) {
super(gen, MM.ID, exFileHelper);
}
@Override
protected void registerModels() {
for (RegistryObject<ControllerBlock> controller : MMLoader.BLOCKS) {
if (!controller.isPresent()){
return;
}
this.getBuilder(controller.getId().toString()).parent(new ModelFile.UncheckedModelFile(new ResourceLocation(controller.getId().getNamespace(), "block/" + controller.getId().getPath())));
}
for (RegistryObject<MachinePortBlock> port : MMLoader.OPORT_BLOCKS) {
this.getBuilder(port.getId().toString()).parent(new ModelFile.UncheckedModelFile(new ResourceLocation(port.getId().getNamespace(), "block/" + port.getId().getPath())));
}
for (RegistryObject<MachinePortBlock> port : MMLoader.IPORT_BLOCKS) {
this.getBuilder(port.getId().toString()).parent(new ModelFile.UncheckedModelFile(new ResourceLocation(port.getId().getNamespace(), "block/" + port.getId().getPath())));
}
this.getBuilder(MMSetup.BLUEPRINT.getId().getPath()).parent(new ModelFile.UncheckedModelFile("item/generated")).texture("layer0", "item/blueprint");
this.getBuilder(MMSetup.STRUCTURE_DEVICE.getId().getPath()).parent(new ModelFile.UncheckedModelFile("item/generated")).texture("layer0", "item/scanning_tool");
this.getBuilder(MMSetup.STRUCTURE_ITEM.getId().getPath()).parent(new ModelFile.UncheckedModelFile(RLUtils.toRL(MM.ID + ":block/structure_generator")));
this.getBuilder(MMSetup.PROJECTOR_ITEM.getId().getPath()).parent(new ModelFile.UncheckedModelFile(RLUtils.toRL(MM.ID + ":block/" + MMSetup.PROJECTOR_BLOCK.getId().getPath())));
}
}

View File

@@ -1,48 +0,0 @@
package com.ticticboooom.mods.mm.datagen.gen.runtime;
import com.ticticboooom.mods.mm.MM;
import com.ticticboooom.mods.mm.block.ControllerBlock;
import com.ticticboooom.mods.mm.block.MachinePortBlock;
import com.ticticboooom.mods.mm.registration.MMLoader;
import com.ticticboooom.mods.mm.registration.MMSetup;
import net.minecraft.data.DataGenerator;
import net.minecraftforge.common.data.LanguageProvider;
import net.minecraftforge.fml.RegistryObject;
public class MMLangProvider extends LanguageProvider {
public MMLangProvider(DataGenerator gen) {
super(gen, MM.ID, "en_us");
}
@Override
protected void addTranslations() {
for (RegistryObject<ControllerBlock> block : MMLoader.BLOCKS) {
if (!block.isPresent()){
return;
}
this.add(block.get(), block.get().getControllerName() + " Controller");
this.add("container.masterfulmachinery." + block.get().getControllerId() + "_controller.name", block.get().getControllerName() + " Controller");
for (RegistryObject<MachinePortBlock> port : MMLoader.IPORT_BLOCKS) {
if (port.get().getControllerId().equals(block.get().getControllerId())){
this.add(port.get(), block.get().getControllerName() + " - " + port.get().getLangName() + " Input Port");
}
}
for (RegistryObject<MachinePortBlock> port : MMLoader.OPORT_BLOCKS) {
if (port.get().getControllerId().equals(block.get().getControllerId())) {
this.add(port.get(), block.get().getControllerName() + " - " + port.get().getLangName() + " Output Port");
}
}
}
if (!MMSetup.BLUEPRINT.isPresent()){
return;
}
this.add(MMSetup.BLUEPRINT.get(), "Blueprint");
this.add(MMSetup.STRUCTURE_DEVICE.get(), "Structure Selector");
this.add(MMSetup.PROJECTOR_BLOCK.get(), "Structure Projector");
this.add(MMSetup.STRUCTURE_BLOCK.get(), "Structure Generator");
this.add("container.masterfulmachinery.create_rotation", "Rotation Port");
this.add("itemGroup.masterfulmachinery", "Masterful Machinery");
}
}

View File

@@ -1,36 +0,0 @@
package com.ticticboooom.mods.mm.datagen.gen.runtime;
import com.ticticboooom.mods.mm.block.ControllerBlock;
import com.ticticboooom.mods.mm.block.MachinePortBlock;
import com.ticticboooom.mods.mm.registration.MMLoader;
import com.ticticboooom.mods.mm.registration.MMSetup;
import net.minecraft.data.DataGenerator;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.ForgeRegistries;
public class MMLootTableProvider extends BaseLootTableProvider {
public MMLootTableProvider(DataGenerator dataGeneratorIn) {
super(dataGeneratorIn);
}
@Override
protected void addTables() {
for (RegistryObject<ControllerBlock> controller : MMLoader.BLOCKS) {
if (!controller.isPresent()){
return;
}
blockLootTable.put(controller.get(), createItemLootTable(ForgeRegistries.ITEMS.getValue(controller.getId())));
}
for (RegistryObject<MachinePortBlock> port : MMLoader.IPORT_BLOCKS) {
blockLootTable.put(port.get(), createItemLootTable(ForgeRegistries.ITEMS.getValue(port.getId())));
}
for (RegistryObject<MachinePortBlock> port : MMLoader.OPORT_BLOCKS) {
blockLootTable.put(port.get(), createItemLootTable(ForgeRegistries.ITEMS.getValue(port.getId())));
}
blockLootTable.put(MMSetup.PROJECTOR_BLOCK.get(), createCountTable(MMSetup.PROJECTOR_ITEM.get(), MMSetup.PROJECTOR_ITEM.get(), 1, 1));
blockLootTable.put(MMSetup.STRUCTURE_BLOCK.get(), createBlockLootTable(MMSetup.STRUCTURE_BLOCK.get()));
}
}

View File

@@ -1,14 +0,0 @@
package com.ticticboooom.mods.mm.event;
import com.ticticboooom.mods.mm.registration.MMLoader;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLConstructModEvent;
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public class ConstructEventHandler {
@SubscribeEvent
public static void onConstruct(FMLConstructModEvent event) {
MMLoader.load();
}
}

View File

@@ -1,7 +0,0 @@
package com.ticticboooom.mods.mm.exception;
public class InvalidProcessDefinitionException extends Exception {
public InvalidProcessDefinitionException(String message) {
super(message);
}
}

View File

@@ -1,7 +0,0 @@
package com.ticticboooom.mods.mm.exception;
public class InvalidStructureDefinitionException extends Exception {
public InvalidStructureDefinitionException(String message) {
super(message);
}
}

View File

@@ -1,39 +0,0 @@
package com.ticticboooom.mods.mm.helper;
//once again robbed kindly from https://github.com/vincentmetevelis/CustomQuests2/blob/1.16.5-2.1.0/src/main/java/com/vincentmet/customquests/helpers/rendering/GLScissor.java Thanks Vince ;)
import net.minecraft.client.*;
import net.minecraftforge.api.distmarker.*;
import org.lwjgl.opengl.GL11;
import static org.lwjgl.opengl.GL11.*;
@OnlyIn(Dist.CLIENT)
public class GLScissor{
public static void enable(int x, int y, int width, int height){
MainWindow mw = Minecraft.getInstance().getMainWindow();
double s = mw.getGuiScaleFactor();
if(width<0)width=0;
if(height<0)height=0;
if(x<0)x=0;
if(y<0)y=0;
GL11.glPushMatrix();
glEnable(GL_SCISSOR_TEST);
glScissor(
(int)(x * s),
(int)(mw.getFramebufferHeight() - ((double)(y + height) * s)),
(int)(width * s),
(int)(height * s)
);
}
public static void disable(){
glDisable(GL_SCISSOR_TEST);
GL11.glPopMatrix();
}
public static boolean isEnabled(){
return glIsEnabled(GL_SCISSOR_TEST);
}
}

View File

@@ -1,13 +0,0 @@
package com.ticticboooom.mods.mm.helper;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.gui.screen.Screen;
public class GuiHelper {
public static void renderVerticallyFilledBar(MatrixStack ms, Screen screen, int x, int y, int u, int v, int width, int height, float pct) {
float invPct = 1 - pct;
screen.blit(ms, x, y + (int) (height * invPct), u, v + (int) (height * invPct), width, (int) (height * pct));
}
}

View File

@@ -1,22 +0,0 @@
package com.ticticboooom.mods.mm.helper;
import com.ticticboooom.mods.mm.MM;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
public class IOHelper {
public static File getFileAndCreate(Path path) {
if (!Files.exists(path)) {
try {
Files.createDirectories(path);
} catch (IOException e) {
e.printStackTrace();
MM.LOG.fatal("failed to create path: {}", path.toAbsolutePath());
}
}
return path.toFile();
}
}

View File

@@ -1,11 +0,0 @@
package com.ticticboooom.mods.mm.helper;
import com.ticticboooom.mods.mm.inventory.ItemStackInventory;
import net.minecraft.inventory.Inventory;
import net.minecraftforge.items.ItemStackHandler;
public class InvHelper {
public static ItemStackInventory getItems(ItemStackHandler handler){
return new ItemStackInventory(handler);
}
}

View File

@@ -1,22 +0,0 @@
package com.ticticboooom.mods.mm.helper;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.math.BlockPos;
import org.lwjgl.system.CallbackI;
public class NBTHelper {
public static CompoundNBT toCompound(BlockPos pos) {
CompoundNBT result = new CompoundNBT();
result.putInt("x", pos.getX());
result.putInt("y", pos.getY());
result.putInt("z", pos.getZ());
return result;
}
public static BlockPos fromCompound(CompoundNBT nbt) {
int x = nbt.getInt("x");
int y = nbt.getInt("y");
int z = nbt.getInt("z");
return new BlockPos(x, y, z);
}
}

View File

@@ -1,13 +0,0 @@
package com.ticticboooom.mods.mm.helper;
import net.minecraft.util.ResourceLocation;
public class RLUtils {
public static ResourceLocation toRL(String str) {
return ResourceLocation.tryCreate(str);
}
public static boolean isRL(String str) {
return ResourceLocation.tryCreate(str) != null;
}
}

View File

@@ -1,128 +0,0 @@
package com.ticticboooom.mods.mm.helper;
import com.google.gson.*;
import com.mojang.datafixers.util.Pair;
import com.mojang.serialization.Codec;
import com.mojang.serialization.DataResult;
import com.mojang.serialization.JsonOps;
import com.ticticboooom.mods.mm.block.ControllerBlock;
import com.ticticboooom.mods.mm.registration.MMLoader;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3i;
import net.minecraft.world.World;
import net.minecraftforge.fml.RegistryObject;
import java.util.*;
public class StructureHelper {
static String allChars;
static {
int[] codePoints = new int[0x110000];
for (int i = 0; i < codePoints.length; i++) {
codePoints[i] = i;
}
allChars = new String(codePoints, 0, codePoints.length);
}
private static Gson GSON = null;
public static void copyToClickBoard(CompoundNBT tag, World world) {
if (tag == null) {
return;
}
if (!tag.contains("pos1") || !tag.contains("pos2")) {
return;
}
BlockPos pos1 = NBTHelper.fromCompound(tag.getCompound("pos1"));
BlockPos pos2 = NBTHelper.fromCompound(tag.getCompound("pos2"));
int x = Math.min(pos1.getX(), pos2.getX());
int y = Math.min(pos1.getY(), pos2.getY());
int z = Math.min(pos1.getZ(), pos2.getZ());
int dx = Math.max(pos1.getX(), pos2.getX());
int dy = Math.max(pos1.getY(), pos2.getY());
int dz = Math.max(pos1.getZ(), pos2.getZ());
BlockPos minPos = new BlockPos(x, y, z);
BlockPos maxPos = new BlockPos(dx, dy, dz);
List<List<String>> layout = new ArrayList<>();
Map<Character, ResourceLocation> legend = new HashMap<>();
Map<ResourceLocation, Character> legendLookup = new HashMap<>();
char index = 41;
for (int yi = minPos.getY(); yi <= maxPos.getY(); yi++) {
ArrayList<String> strings = new ArrayList<>();
for (int zi = minPos.getZ(); zi <= maxPos.getZ(); zi++) {
StringBuilder row = new StringBuilder();
for (int xi = minPos.getX(); xi <= maxPos.getX(); xi++) {
BlockState state = world.getBlockState(new BlockPos(xi, yi, zi));
ResourceLocation registryName = state.getBlock().getRegistryName();
if (index == 'C'){
index++;
}
if (state.isAir()) {
row.append(" ");
continue;
}
if (state.getBlock() instanceof ControllerBlock) {
row.append('C');
continue;
}
if (!legendLookup.containsKey(registryName)) {
legend.put(index, registryName);
legendLookup.put(registryName, index);
index++;
}
row.append(legendLookup.get(registryName));
}
strings.add(row.toString());
}
layout.add(strings);
}
JsonObject jsonObject = toJson(legend, layout);
String s = new GsonBuilder()
.setPrettyPrinting()
.disableHtmlEscaping()
.create().toJson(jsonObject);
Minecraft.getInstance().keyboardListener.setClipboardString(s);
}
private static JsonObject toJson(Map<Character, ResourceLocation> legend, List<List<String>> layout) {
JsonObject result = new JsonObject();
result.addProperty("type", "masterfulmachinery:machine_structure");
result.addProperty("id", "change_this");
result.addProperty("controllerId", "change_this");
result.addProperty("name", "Change This");
DataResult<JsonElement> apply = JsonOps.INSTANCE.withEncoder(Codec.list(Codec.list(Codec.STRING))).apply(layout);
JsonArray layoutJson = apply.result().get().getAsJsonArray();
result.add("layout", layoutJson);
JsonObject legendJson = new JsonObject();
for (Map.Entry<Character, ResourceLocation> entry : legend.entrySet()) {
JsonObject inner = new JsonObject();
inner.addProperty("block", entry.getValue().toString());
legendJson.add(entry.getKey().toString(), inner);
}
result.add("legend", legendJson);
return result;
}
}

View File

@@ -1,63 +0,0 @@
package com.ticticboooom.mods.mm.inventory;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.ItemStackHandler;
public class ItemStackInventory implements IInventory {
private ItemStackHandler handler;
public ItemStackInventory(ItemStackHandler handler) {
this.handler = handler;
}
@Override
public int getSizeInventory() {
return handler.getSlots();
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public ItemStack getStackInSlot(int p_70301_1_) {
return handler.getStackInSlot(p_70301_1_);
}
@Override
public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) {
ItemStack stackInSlot = handler.getStackInSlot(p_70298_1_);
handler.setStackInSlot(p_70298_1_, ItemStack.EMPTY);
return stackInSlot;
}
@Override
public ItemStack removeStackFromSlot(int p_70304_1_) {
return handler.getStackInSlot(p_70304_1_);
}
@Override
public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) {
handler.setStackInSlot(p_70299_1_, p_70299_2_);
}
@Override
public void markDirty() {
}
@Override
public boolean isUsableByPlayer(PlayerEntity player) {
return true;
}
@Override
public void clear() {
}
}

View File

@@ -1,77 +0,0 @@
package com.ticticboooom.mods.mm.inventory;
import net.minecraft.nbt.CompoundNBT;
import net.minecraftforge.energy.IEnergyStorage;
public class PortEnergyInventory implements IEnergyStorage {
private int stored;
private int capacity;
public PortEnergyInventory(int stored, int capacity) {
this.stored = stored;
this.capacity = capacity;
}
@Override
public int receiveEnergy(int maxReceive, boolean simulate) {
if (simulate) {
if ((long)maxReceive + stored > capacity) {
return (stored + maxReceive - capacity);
} else {
return maxReceive;
}
}
if ((long)maxReceive + stored > capacity) {
int result = (stored + maxReceive - capacity);
stored = capacity;
return result;
} else {
stored += maxReceive;
return maxReceive;
}
}
@Override
public int extractEnergy(int maxExtract, boolean simulate) {
if (simulate) {
if (stored - maxExtract < 0) {
return stored;
} else {
return maxExtract;
}
}
if (stored - maxExtract < 0) {
int result = stored;
stored = 0;
return result;
} else {
stored -= maxExtract;
return maxExtract;
}
}
@Override
public int getEnergyStored() {
return stored;
}
@Override
public int getMaxEnergyStored() {
return capacity;
}
@Override
public boolean canExtract() {
return stored > 0;
}
@Override
public boolean canReceive() {
return stored < capacity;
}
public void setStored(int amount) {
this.stored = amount;
}
}

View File

@@ -1,105 +0,0 @@
package com.ticticboooom.mods.mm.inventory;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.IFluidHandler;
import javax.annotation.Nonnull;
public class PortFluidInventory implements IFluidHandler {
private FluidStack stack = FluidStack.EMPTY;
private final int capacity;
public PortFluidInventory(int capacity) {
this.capacity = capacity;
}
@Override
public int getTanks() {
return 1;
}
@Nonnull
@Override
public FluidStack getFluidInTank(int tank) {
return tank != 0 ? FluidStack.EMPTY : stack.copy();
}
@Override
public int getTankCapacity(int tank) {
return tank != 0 ? 0 : capacity;
}
@Override
public boolean isFluidValid(int tank, @Nonnull FluidStack stack) {
return tank == 0 && (this.stack.isEmpty() || stack.isFluidEqual(this.stack));
}
@Override
public int fill(FluidStack resource, FluidAction action) {
if (!stack.isEmpty() && !resource.isFluidEqual(stack)) {
return 0;
}
if (action == FluidAction.SIMULATE) {
if ((long)resource.getAmount() + stack.getAmount() > capacity) {
return resource.getAmount() - (stack.getAmount() + resource.getAmount() - capacity);
} else {
return resource.getAmount();
}
}
if ((long)resource.getAmount() + stack.getAmount() > capacity) {
int preAmount = stack.getAmount();
if (stack.isEmpty()) {
stack = new FluidStack(resource.getFluid(), capacity);
} else {
stack.setAmount(capacity);
}
return resource.getAmount() - (preAmount + resource.getAmount() - capacity);
} else {
if (stack.isEmpty()) {
stack = new FluidStack(resource.getFluid(), resource.getAmount());
} else {
stack.setAmount(stack.getAmount() + resource.getAmount());
}
return resource.getAmount();
}
}
@Nonnull
@Override
public FluidStack drain(FluidStack resource, FluidAction action) {
if (!stack.isEmpty() && !resource.isFluidEqual(stack)) {
return FluidStack.EMPTY;
}
return innerDrain(resource.getAmount(), action == FluidAction.SIMULATE);
}
@Nonnull
@Override
public FluidStack drain(int maxDrain, FluidAction action) {
return innerDrain(maxDrain, action == FluidAction.SIMULATE);
}
private FluidStack innerDrain(int amount, boolean simulate) {
if (simulate) {
if (stack.getAmount() - amount <= 0) {
return stack.copy();
} else {
return new FluidStack(stack.getFluid(), amount);
}
}
if (stack.getAmount() - amount <= 0) {
FluidStack preStack = stack.copy();
stack.setAmount(0);
return preStack;
} else {
stack.setAmount(stack.getAmount() - amount);
return new FluidStack(stack.getFluid(), amount);
}
}
public void setStack(FluidStack stack) {
this.stack = stack;
}
}

View File

@@ -1,47 +0,0 @@
package com.ticticboooom.mods.mm.inventory.as;
public interface IStarlightStorage {
/**
* Adds starlight to the storage. Returns quantity of starlight that was accepted.
*
* @param maxReceive
* Maximum amount of starlight to be inserted.
* @param simulate
* If TRUE, the insertion will only be simulated.
* @return Amount of starlight that was (or would have been, if simulated) accepted by the storage.
*/
int receiveStarlight(int maxReceive, boolean simulate);
/**
* Removes starlight from the storage. Returns quantity of starlight that was removed.
*
* @param maxExtract
* Maximum amount of starlight to be extracted.
* @param simulate
* If TRUE, the extraction will only be simulated.
* @return Amount of starlight that was (or would have been, if simulated) extracted from the storage.
*/
int extractStarlight(int maxExtract, boolean simulate);
/**
* Returns the amount of starlight currently stored.
*/
int getStarlightStored();
/**
* Returns the maximum amount of starlight that can be stored.
*/
int getMaxStarlightStored();
/**
* Returns if this storage can have starlight extracted.
* If this is false, then any calls to extractStarlight will return 0.
*/
boolean canExtract();
/**
* Used to determine if this storage can receive starlight.
* If this is false, then any calls to receivestarlight will return 0.
*/
boolean canReceive();
}

View File

@@ -1,96 +0,0 @@
package com.ticticboooom.mods.mm.inventory.as;
import com.ticticboooom.mods.mm.block.tile.AstralMachinePortBlockEntity;
import com.ticticboooom.mods.mm.ports.storage.StarlightPortStorage;
import hellfirepvp.astralsorcery.AstralSorcery;
import hellfirepvp.astralsorcery.common.block.base.BlockStarlightRecipient;
import hellfirepvp.astralsorcery.common.constellation.Constellation;
import hellfirepvp.astralsorcery.common.constellation.IConstellation;
import hellfirepvp.astralsorcery.common.constellation.IWeakConstellation;
import hellfirepvp.astralsorcery.common.lib.ConstellationsAS;
import hellfirepvp.astralsorcery.common.starlight.IIndependentStarlightSource;
import hellfirepvp.astralsorcery.common.starlight.transmission.registry.SourceClassRegistry;
import hellfirepvp.astralsorcery.common.util.nbt.NBTHelper;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.server.ServerWorld;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Map;
public class MMIndependentStarlightSource implements IIndependentStarlightSource {
private StarlightPortStorage storage;
IWeakConstellation attunedConstellation = null;
@Override
public float produceStarlightTick(ServerWorld serverWorld, BlockPos blockPos) {
if (storage == null){
return 0;
}
return storage.getInv().extractStarlight(Integer.MAX_VALUE, false);
}
@Nullable
@Override
public IWeakConstellation getStarlightType() {
return ConstellationsAS.aevitas;
}
@Override
public void threadedUpdateProximity(BlockPos blockPos, Map<BlockPos, IIndependentStarlightSource> map) {
}
@Override
public SourceClassRegistry.SourceProvider getProvider() {
return new Provider();
}
@Override
public void readFromNBT(CompoundNBT compound) {
this.attunedConstellation = NBTHelper.readOptional(compound, "constellation", (nbt) -> {
IConstellation cst = IConstellation.readFromNBT(nbt);
if (cst instanceof IWeakConstellation) {
return (IWeakConstellation) cst;
}
return null;
});
}
@Override
public void writeToNBT(CompoundNBT compound) {
NBTHelper.writeOptional(compound, "constellation", this.attunedConstellation, (nbt, cst) -> cst.writeToNBT(nbt));
}
@Override
public <T extends TileEntity> boolean updateFromTileEntity(T tile) {
if (tile instanceof AstralMachinePortBlockEntity) {
AstralMachinePortBlockEntity astralTile = (AstralMachinePortBlockEntity) tile;
attunedConstellation = astralTile.getAttunedConstellation();
storage = (StarlightPortStorage) astralTile.getStorage();
}
return true;
}
public static class Provider implements SourceClassRegistry.SourceProvider {
@Override
public IIndependentStarlightSource provideEmptySource() {
return new MMIndependentStarlightSource();
}
@Override
@Nonnull
public ResourceLocation getIdentifier() {
return AstralSorcery.key("mm_independent_source");
}
}
}

View File

@@ -1,57 +0,0 @@
package com.ticticboooom.mods.mm.inventory.as;
import com.ticticboooom.mods.mm.block.tile.AstralMachineInputPortBlockEntity;
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
import com.ticticboooom.mods.mm.ports.storage.StarlightPortStorage;
import hellfirepvp.astralsorcery.common.constellation.IWeakConstellation;
import hellfirepvp.astralsorcery.common.starlight.transmission.IPrismTransmissionNode;
import hellfirepvp.astralsorcery.common.starlight.transmission.base.SimpleTransmissionReceiver;
import hellfirepvp.astralsorcery.common.starlight.transmission.registry.TransmissionProvider;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class MMSimpleTransmissionReceiver extends SimpleTransmissionReceiver<AstralMachineInputPortBlockEntity> {
private AstralMachineInputPortBlockEntity astralMachineInputPortBlockEntity;
public MMSimpleTransmissionReceiver(BlockPos thisPos) {
super(thisPos);
}
@Override
public boolean syncTileData(World world, AstralMachineInputPortBlockEntity astralMachineInputPortBlockEntity) {
this.astralMachineInputPortBlockEntity = astralMachineInputPortBlockEntity;
return true;
}
@Override
public Class<AstralMachineInputPortBlockEntity> getTileClass() {
return AstralMachineInputPortBlockEntity.class;
}
@Override
public void onStarlightReceive(World world, IWeakConstellation iWeakConstellation, double v) {
AstralMachineInputPortBlockEntity tileAtPos = this.getTileAtPos(world);
if (tileAtPos == null){
return;
}
PortStorage storage = tileAtPos.getStorage();
if (storage instanceof StarlightPortStorage) {
((StarlightPortStorage) storage).getInv().receiveStarlight((int)v, false);
}
}
@Override
public TransmissionProvider getProvider() {
return new Provider();
}
public static final class Provider extends TransmissionProvider {
@Override
public IPrismTransmissionNode get() {
return new MMSimpleTransmissionReceiver(null);
}
}
}

View File

@@ -1,74 +0,0 @@
package com.ticticboooom.mods.mm.inventory.as;
public class PortStarlightInventory implements IStarlightStorage {
private int stored;
private int capacity;
public PortStarlightInventory(int stored, int capacity) {
this.stored = stored;
this.capacity = capacity;
}
@Override
public int receiveStarlight(int maxReceive, boolean simulate) {
if (simulate) {
if ((long)maxReceive + stored > capacity) {
return (stored + maxReceive - capacity);
} else {
return maxReceive;
}
}
if ((long)maxReceive + stored > capacity) {
int result = (stored + maxReceive - capacity);
stored = capacity;
return result;
} else {
stored += maxReceive;
return maxReceive;
}
}
@Override
public int extractStarlight(int maxExtract, boolean simulate) {
if (simulate) {
if ((long)stored - maxExtract < 0) {
return stored;
} else {
return maxExtract;
}
}
if ((long)stored - maxExtract < 0) {
int result = stored;
stored = 0;
return result;
} else {
stored -= maxExtract;
return maxExtract;
}
}
@Override
public int getStarlightStored() {
return stored;
}
@Override
public int getMaxStarlightStored() {
return capacity;
}
@Override
public boolean canExtract() {
return stored > 0;
}
@Override
public boolean canReceive() {
return stored < capacity;
}
public void setStored(int amount) {
this.stored = amount;
}
}

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